|
|
@ -46,7 +46,6 @@ from ansible.module_utils.basic import to_text
|
|
|
|
from ansible.module_utils.six.moves import urllib
|
|
|
|
from ansible.module_utils.six.moves import urllib
|
|
|
|
import json
|
|
|
|
import json
|
|
|
|
import re
|
|
|
|
import re
|
|
|
|
import sys
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class HttpApi(HttpApiBase):
|
|
|
|
class HttpApi(HttpApiBase):
|
|
|
@ -66,11 +65,7 @@ class HttpApi(HttpApiBase):
|
|
|
|
def login(self, username, password):
|
|
|
|
def login(self, username, password):
|
|
|
|
"""Call a defined login endpoint to receive an authentication token."""
|
|
|
|
"""Call a defined login endpoint to receive an authentication token."""
|
|
|
|
|
|
|
|
|
|
|
|
if sys.version_info[0] >= 3:
|
|
|
|
|
|
|
|
data = "username=" + urllib.parse.quote(username) + "&secretkey=" + urllib.parse.quote(password) + "&ajax=1"
|
|
|
|
data = "username=" + urllib.parse.quote(username) + "&secretkey=" + urllib.parse.quote(password) + "&ajax=1"
|
|
|
|
else:
|
|
|
|
|
|
|
|
data = "username=" + urllib.quote(username) + "&secretkey=" + urllib.quote(password) + "&ajax=1"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dummy, result_data = self.send_request(url='/logincheck', data=data, method='POST')
|
|
|
|
dummy, result_data = self.send_request(url='/logincheck', data=data, method='POST')
|
|
|
|
if result_data[0] != '1':
|
|
|
|
if result_data[0] != '1':
|
|
|
|
raise Exception('Wrong credentials. Please check')
|
|
|
|
raise Exception('Wrong credentials. Please check')
|
|
|
|