Merge "QNAP: Fix login on Python3"
This commit is contained in:
commit
ff5ce3e9b9
File diff suppressed because it is too large
Load Diff
@ -1231,23 +1231,16 @@ class QnapAPIExecutor(object):
|
|||||||
|
|
||||||
def execute_login(self):
|
def execute_login(self):
|
||||||
"""Login and return sid."""
|
"""Login and return sid."""
|
||||||
params = OrderedDict()
|
params = OrderedDict(
|
||||||
params['pwd'] = base64.b64encode(self.password.encode("utf-8"))
|
pwd=base64.b64encode(self.password.encode('utf-8')).decode(),
|
||||||
params['serviceKey'] = '1'
|
serviceKey='1',
|
||||||
params['user'] = self.username
|
user=self.username,
|
||||||
|
)
|
||||||
sanitized_params = OrderedDict()
|
encoded_params = urllib.parse.urlencode(params)
|
||||||
|
|
||||||
for key in params:
|
|
||||||
value = params[key]
|
|
||||||
if value is not None:
|
|
||||||
sanitized_params[key] = six.text_type(value)
|
|
||||||
|
|
||||||
sanitized_params = urllib.parse.urlencode(sanitized_params)
|
|
||||||
url = ('/cgi-bin/authLogin.cgi?')
|
url = ('/cgi-bin/authLogin.cgi?')
|
||||||
|
|
||||||
res_details = self._execute_and_get_response_details(
|
res_details = self._execute_and_get_response_details(
|
||||||
self.ip, url, sanitized_params)
|
self.ip, url, encoded_params)
|
||||||
root = ET.fromstring(res_details['data'])
|
root = ET.fromstring(res_details['data'])
|
||||||
LOG.debug('execute_login data: %s', res_details['data'])
|
LOG.debug('execute_login data: %s', res_details['data'])
|
||||||
session_id = root.find('authSid').text
|
session_id = root.find('authSid').text
|
||||||
|
Loading…
x
Reference in New Issue
Block a user