pycharm refactor rename files and class, linux rename tower_ controller_

This commit is contained in:
Seth Foster
2021-04-28 18:13:22 -04:00
parent 2ad84b60b3
commit 44fed1d7c1
93 changed files with 234 additions and 149 deletions

View File

@@ -2,7 +2,7 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
from .tower_module import TowerModule
from .controller_module import ControllerModule
from ansible.module_utils.basic import missing_required_lib
try:
@@ -15,14 +15,14 @@ except ImportError:
HAS_AWX_KIT = False
class TowerAWXKitModule(TowerModule):
class ControllerAWXKitModule(ControllerModule):
connection = None
apiV2Ref = None
def __init__(self, argument_spec, **kwargs):
kwargs['supports_check_mode'] = False
super(TowerAWXKitModule, self).__init__(argument_spec=argument_spec, **kwargs)
super(ControllerAWXKitModule, self).__init__(argument_spec=argument_spec, **kwargs)
# Die if we don't have AWX_KIT installed
if not HAS_AWX_KIT:

View File

@@ -2,7 +2,7 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
from .tower_module import TowerModule
from .controller_module import ControllerModule
from ansible.module_utils.urls import Request, SSLValidationError, ConnectionError
from ansible.module_utils.six import PY2
from ansible.module_utils.six.moves.urllib.error import HTTPError
@@ -12,8 +12,8 @@ import time
from json import loads, dumps
class TowerAPIModule(TowerModule):
# TODO: Move the collection version check into tower_module.py
class ControllerAPIModule(ControllerModule):
# TODO: Move the collection version check into controller_module.py
# This gets set by the make process so whatever is in here is irrelevant
_COLLECTION_VERSION = "0.0.1-devel"
_COLLECTION_TYPE = "awx"
@@ -30,7 +30,7 @@ class TowerAPIModule(TowerModule):
def __init__(self, argument_spec, direct_params=None, error_callback=None, warn_callback=None, **kwargs):
kwargs['supports_check_mode'] = True
super(TowerAPIModule, self).__init__(
super(ControllerAPIModule, self).__init__(
argument_spec=argument_spec, direct_params=direct_params, error_callback=error_callback, warn_callback=warn_callback, **kwargs
)
self.session = Request(cookies=CookieJar(), validate_certs=self.verify_ssl)
@@ -47,14 +47,14 @@ class TowerAPIModule(TowerModule):
@staticmethod
def get_name_field_from_endpoint(endpoint):
return TowerAPIModule.IDENTITY_FIELDS.get(endpoint, 'name')
return ControllerAPIModule.IDENTITY_FIELDS.get(endpoint, 'name')
def get_item_name(self, item, allow_unknown=False):
if item:
if 'name' in item:
return item['name']
for field_name in TowerAPIModule.IDENTITY_FIELDS.values():
for field_name in ControllerAPIModule.IDENTITY_FIELDS.values():
if field_name in item:
return item[field_name]
@@ -544,13 +544,13 @@ class TowerAPIModule(TowerModule):
"""
if isinstance(obj, dict):
for val in obj.values():
if TowerAPIModule.has_encrypted_values(val):
if ControllerAPIModule.has_encrypted_values(val):
return True
elif isinstance(obj, list):
for val in obj:
if TowerAPIModule.has_encrypted_values(val):
if ControllerAPIModule.has_encrypted_values(val):
return True
elif obj == TowerAPIModule.ENCRYPTED_STRING:
elif obj == ControllerAPIModule.ENCRYPTED_STRING:
return True
return False
@@ -565,11 +565,11 @@ class TowerAPIModule(TowerModule):
if set(old_field.keys()) != set(new_field.keys()):
return False
for key in new_field.keys():
if not TowerAPIModule.fields_could_be_same(old_field[key], new_field[key]):
if not ControllerAPIModule.fields_could_be_same(old_field[key], new_field[key]):
return False
return True # all sub-fields are either equal or could be equal
else:
if old_field == TowerAPIModule.ENCRYPTED_STRING:
if old_field == ControllerAPIModule.ENCRYPTED_STRING:
return True
return bool(new_field == old_field)

View File

@@ -29,7 +29,7 @@ class ItemNotDefined(Exception):
pass
class TowerModule(AnsibleModule):
class ControllerModule(AnsibleModule):
url = None
AUTH_ARGSPEC = dict(
tower_host=dict(required=False, fallback=(env_fallback, ['TOWER_HOST'])),
@@ -60,7 +60,7 @@ class TowerModule(AnsibleModule):
def __init__(self, argument_spec=None, direct_params=None, error_callback=None, warn_callback=None, **kwargs):
full_argspec = {}
full_argspec.update(TowerModule.AUTH_ARGSPEC)
full_argspec.update(ControllerModule.AUTH_ARGSPEC)
full_argspec.update(argument_spec)
kwargs['supports_check_mode'] = True
@@ -72,7 +72,7 @@ class TowerModule(AnsibleModule):
if direct_params is not None:
self.params = direct_params
else:
super(TowerModule, self).__init__(argument_spec=full_argspec, **kwargs)
super(ControllerModule, self).__init__(argument_spec=full_argspec, **kwargs)
self.load_config_files()
@@ -242,15 +242,15 @@ class TowerModule(AnsibleModule):
if self.error_callback:
self.error_callback(**kwargs)
else:
super(TowerModule, self).fail_json(**kwargs)
super(ControllerModule, self).fail_json(**kwargs)
def exit_json(self, **kwargs):
# Try to log out if we are authenticated
self.logout()
super(TowerModule, self).exit_json(**kwargs)
super(ControllerModule, self).exit_json(**kwargs)
def warn(self, warning):
if self.warn_callback is not None:
self.warn_callback(warning)
else:
super(TowerModule, self).warn(warning)
super(ControllerModule, self).warn(warning)