Splitting out AWX and Tower versions

This commit is contained in:
John Westcott IV
2021-03-24 10:16:53 -04:00
committed by beeankha
parent e2b290ff99
commit bb43ecb0b5
2 changed files with 66 additions and 18 deletions

View File

@@ -260,13 +260,21 @@ class TowerAPIModule(TowerModule):
tower_type = response.info().getheader('X-API-Product-Name', None)
tower_version = response.info().getheader('X-API-Product-Version', None)
collection_major = Version(self._COLLECTION_VERSION).version[0]
tower_major = Version(tower_version).version[0]
parsed_collection_version = Version(self._COLLECTION_VERSION).version
parsed_tower_version = Version(tower_version).version
if tower_type != 'AWX':
collection_compare_ver = parsed_collection_version[0]
tower_compare_ver = parsed_tower_version[0]
else:
collection_compare_ver = "{}.{}".format(parsed_collection_version[0], parsed_collection_version[1])
tower_major = '{}.{}'.format(parsed_tower_version[0], parsed_tower_version[1])
if self._COLLECTION_TYPE not in self.collection_to_version or self.collection_to_version[self._COLLECTION_TYPE] != tower_type:
self.warn("You are using the {0} version of this collection but connecting to {1}".format(self._COLLECTION_TYPE, tower_type))
elif collection_major != tower_major:
elif collection_compare_ver != tower_compare_ver:
self.warn("You are running collection version {0} but connecting to tower version {1}".format(self._COLLECTION_VERSION, tower_version))
self.version_checked = True
response_body = ''