Skip to content

Commit

Permalink
Fixed issue where collection exits when detecting Galaxy path prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
bmclaughlin committed Jun 7, 2024
1 parent 548c17e commit b515dd0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
4 changes: 4 additions & 0 deletions changelogs/fragments/bug_galaxy_path_prefix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
bugfixes:
- Fixed issue where collection exits when detecting Galaxy path prefix
...
21 changes: 11 additions & 10 deletions plugins/module_utils/ah_api_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,16 +504,17 @@ def get_galaxy_path_prefix(self):

try:
response = self.make_request("GET", url)
except AHAPIModuleError as e:
self.fail_json(msg="Error while contacting server for Galaxy path prefix: {error} \nurl: {url}".format(error=e, url=url))
if response["status_code"] == 404:
return "/api/{prefix}".format(prefix=self.path_prefix.strip("/"))
else:
try:
rs_prefix = response["json"]["apis"]["galaxy"]
except KeyError as e:
self.fail_json(msg="Error while getting Galaxy api path prefix: {error}".format(error=e))
return rs_prefix.strip("/")
except AHAPIModuleError:
# 404 indicates this is standalone
if response["status_code"] == 404:
return "/api/{prefix}".format(prefix=self.path_prefix.strip("/"))
# indicates this is behind resource_provider
else:
try:
rs_prefix = response["json"]["apis"]["galaxy"]
except KeyError as e:
self.fail_json(msg="Error while getting Galaxy api path prefix: {error}".format(error=e))
return rs_prefix.strip("/")

def get_server_version(self):
"""Return the automation hub/galaxy server version.
Expand Down

0 comments on commit b515dd0

Please sign in to comment.