mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-24 13:50:22 -07:00
parent
261b0af15a
commit
2a984bbc98
1 changed files with 14 additions and 4 deletions
|
@ -33,6 +33,7 @@ import ansible.constants as C
|
||||||
from ansible.errors import AnsibleError
|
from ansible.errors import AnsibleError
|
||||||
from ansible.module_utils.urls import open_url
|
from ansible.module_utils.urls import open_url
|
||||||
from ansible.galaxy.token import GalaxyToken
|
from ansible.galaxy.token import GalaxyToken
|
||||||
|
from ansible.utils.unicode import to_str
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from __main__ import display
|
from __main__ import display
|
||||||
|
@ -109,12 +110,21 @@ class GalaxyAPI(object):
|
||||||
Fetches the Galaxy API current version to ensure
|
Fetches the Galaxy API current version to ensure
|
||||||
the API server is up and reachable.
|
the API server is up and reachable.
|
||||||
"""
|
"""
|
||||||
|
url = '%s/api/' % self._api_server
|
||||||
try:
|
try:
|
||||||
url = '%s/api/' % self._api_server
|
return_data =open_url(url, validate_certs=self._validate_certs)
|
||||||
data = json.load(open_url(url, validate_certs=self._validate_certs))
|
|
||||||
return data['current_version']
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise AnsibleError("The API server (%s) is not responding, please try again later" % url)
|
raise AnsibleError("Failed to get data from the API server (%s): %s " % (url, to_str(e)))
|
||||||
|
|
||||||
|
try:
|
||||||
|
data = json.load(return_data)
|
||||||
|
except Exception as e:
|
||||||
|
raise AnsibleError("Could not process data from the API server (%s): %s " % (url, to_str(e)))
|
||||||
|
|
||||||
|
if not 'current_version' in data:
|
||||||
|
raise AnsibleError("missing required 'current_version' from server response (%s)" % url)
|
||||||
|
|
||||||
|
return data['current_version']
|
||||||
|
|
||||||
@g_connect
|
@g_connect
|
||||||
def authenticate(self, github_token):
|
def authenticate(self, github_token):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue