mirror of
https://github.com/ansible/awx.git
synced 2026-01-15 03:40:42 -03:30
pycharm refactor rename files and class, linux rename tower_ controller_
This commit is contained in:
parent
2ad84b60b3
commit
44fed1d7c1
@ -1,46 +1,131 @@
|
||||
---
|
||||
action_groups:
|
||||
tower:
|
||||
- tower_credential_input_source
|
||||
- tower_credential
|
||||
- tower_credential_type
|
||||
- tower_group
|
||||
- tower_host
|
||||
- tower_inventory
|
||||
- tower_inventory_source
|
||||
- tower_job_cancel
|
||||
- tower_job_launch
|
||||
- tower_job_list
|
||||
- tower_job_template
|
||||
- tower_job_wait
|
||||
- tower_label
|
||||
- tower_license
|
||||
- tower_notification
|
||||
- tower_organization
|
||||
- tower_project
|
||||
- tower_role
|
||||
- tower_schedule
|
||||
- tower_settings
|
||||
- tower_team
|
||||
- tower_token
|
||||
- tower_user
|
||||
- tower_workflow_job_template_node
|
||||
- tower_workflow_job_template
|
||||
- tower_workflow_launch
|
||||
controller:
|
||||
- credential_input_source
|
||||
- credential
|
||||
- credential_type
|
||||
- group
|
||||
- host
|
||||
- inventory
|
||||
- inventory_source
|
||||
- job_cancel
|
||||
- job_launch
|
||||
- job_list
|
||||
- job_template
|
||||
- job_wait
|
||||
- label
|
||||
- license
|
||||
- notification
|
||||
- organization
|
||||
- project
|
||||
- role
|
||||
- schedule
|
||||
- settings
|
||||
- team
|
||||
- token
|
||||
- user
|
||||
- workflow_job_template_node
|
||||
- workflow_job_template
|
||||
- workflow_launch
|
||||
|
||||
plugin_routing:
|
||||
inventory:
|
||||
tower:
|
||||
redirect: awx.awx.controller
|
||||
lookup:
|
||||
tower_api:
|
||||
redirect: awx.awx.controller_api
|
||||
tower_schedule_rrule:
|
||||
redirect: awx.awx.schedule_rrule
|
||||
modules:
|
||||
tower_job_list:
|
||||
redirect: job_list
|
||||
tower_job_launch:
|
||||
redirect: job_launch
|
||||
tower_workflow_job_template:
|
||||
redirect: workflow_job_template
|
||||
tower_team:
|
||||
redirect: team
|
||||
tower_job_wait:
|
||||
redirect: job_wait
|
||||
tower_application:
|
||||
redirect: application
|
||||
tower_ad_hoc_command_wait:
|
||||
redirect: ad_hoc_command_wait
|
||||
tower_credential:
|
||||
redirect: credential
|
||||
tower_label:
|
||||
redirect: label
|
||||
tower_group:
|
||||
redirect: group
|
||||
tower_host:
|
||||
redirect: host
|
||||
tower_schedule:
|
||||
redirect: schedule
|
||||
tower_role:
|
||||
redirect: role
|
||||
tower_ad_hoc_command:
|
||||
redirect: ad_hoc_command
|
||||
tower_execution_environment:
|
||||
redirect: execution_environment
|
||||
tower_inventory_source_update:
|
||||
redirect: inventory_source_update
|
||||
tower_instance_group:
|
||||
redirect: instance_group
|
||||
tower_settings:
|
||||
redirect: settings
|
||||
tower_meta:
|
||||
redirect: meta
|
||||
tower_export:
|
||||
redirect: export
|
||||
tower_ad_hoc_command_cancel:
|
||||
redirect: ad_hoc_command_cancel
|
||||
tower_inventory_source:
|
||||
redirect: inventory_source
|
||||
tower_user:
|
||||
redirect: user
|
||||
tower_workflow_launch:
|
||||
redirect: workflow_launch
|
||||
tower_project:
|
||||
redirect: project
|
||||
tower_token:
|
||||
redirect: token
|
||||
tower_credential_type:
|
||||
redirect: credential_type
|
||||
tower_license:
|
||||
redirect: license
|
||||
tower_project_update:
|
||||
redirect: project_update
|
||||
tower_notification_template:
|
||||
redirect: notification_template
|
||||
tower_organization:
|
||||
redirect: organization
|
||||
tower_job_template:
|
||||
redirect: job_template
|
||||
tower_workflow_job_template_node:
|
||||
redirect: workflow_job_template_node
|
||||
tower_job_cancel:
|
||||
redirect: job_cancel
|
||||
tower_import:
|
||||
redirect: import
|
||||
tower_credential_input_source:
|
||||
redirect: credential_input_source
|
||||
tower_inventory:
|
||||
redirect: inventory
|
||||
tower_receive:
|
||||
redirect: receive
|
||||
deprecation:
|
||||
removal_date: TBD
|
||||
warning_text: see plugin documentation for details
|
||||
tower_send:
|
||||
redirect: send
|
||||
deprecation:
|
||||
removal_date: TBD
|
||||
warning_text: see plugin documentation for details
|
||||
tower_workflow_template:
|
||||
redirect: workflow_template
|
||||
deprecation:
|
||||
removal_date: TBD
|
||||
warning_text: see plugin documentation for details
|
||||
tower_notification:
|
||||
redirect: tower_notification_template
|
||||
redirect: notification_template
|
||||
|
||||
@ -72,7 +72,7 @@ from ansible.errors import AnsibleParserError, AnsibleOptionsError
|
||||
from ansible.plugins.inventory import BaseInventoryPlugin
|
||||
from ansible.config.manager import ensure_type
|
||||
|
||||
from ..module_utils.tower_api import TowerAPIModule
|
||||
from ..module_utils.controller_api import ControllerAPIModule
|
||||
|
||||
|
||||
def handle_error(**kwargs):
|
||||
@ -104,12 +104,12 @@ class InventoryModule(BaseInventoryPlugin):
|
||||
|
||||
# Defer processing of params to logic shared with the modules
|
||||
module_params = {}
|
||||
for plugin_param, module_param in TowerAPIModule.short_params.items():
|
||||
for plugin_param, module_param in ControllerAPIModule.short_params.items():
|
||||
opt_val = self.get_option(plugin_param)
|
||||
if opt_val is not None:
|
||||
module_params[module_param] = opt_val
|
||||
|
||||
module = TowerAPIModule(argument_spec={}, direct_params=module_params, error_callback=handle_error, warn_callback=self.warn_callback)
|
||||
module = ControllerAPIModule(argument_spec={}, direct_params=module_params, error_callback=handle_error, warn_callback=self.warn_callback)
|
||||
|
||||
# validate type of inventory_id because we allow two types as special case
|
||||
inventory_id = self.get_option('inventory_id')
|
||||
@ -120,7 +120,7 @@ from ansible.plugins.lookup import LookupBase
|
||||
from ansible.errors import AnsibleError
|
||||
from ansible.module_utils._text import to_native
|
||||
from ansible.utils.display import Display
|
||||
from ..module_utils.tower_api import TowerAPIModule
|
||||
from ..module_utils.controller_api import ControllerAPIModule
|
||||
|
||||
|
||||
class LookupModule(LookupBase):
|
||||
@ -140,13 +140,13 @@ class LookupModule(LookupBase):
|
||||
|
||||
# Defer processing of params to logic shared with the modules
|
||||
module_params = {}
|
||||
for plugin_param, module_param in TowerAPIModule.short_params.items():
|
||||
for plugin_param, module_param in ControllerAPIModule.short_params.items():
|
||||
opt_val = self.get_option(plugin_param)
|
||||
if opt_val is not None:
|
||||
module_params[module_param] = opt_val
|
||||
|
||||
# Create our module
|
||||
module = TowerAPIModule(argument_spec={}, direct_params=module_params, error_callback=self.handle_error, warn_callback=self.warn_callback)
|
||||
module = ControllerAPIModule(argument_spec={}, direct_params=module_params, error_callback=self.handle_error, warn_callback=self.warn_callback)
|
||||
|
||||
response = module.get_endpoint(terms[0], data=self.get_option('query_params', {}))
|
||||
|
||||
@ -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:
|
||||
@ -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)
|
||||
|
||||
@ -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)
|
||||
@ -111,7 +111,7 @@ status:
|
||||
sample: pending
|
||||
'''
|
||||
|
||||
from ..module_utils.tower_api import TowerAPIModule
|
||||
from ..module_utils.controller_api import ControllerAPIModule
|
||||
|
||||
|
||||
def main():
|
||||
@ -135,7 +135,7 @@ def main():
|
||||
)
|
||||
|
||||
# Create a module for ourselves
|
||||
module = TowerAPIModule(argument_spec=argument_spec)
|
||||
module = ControllerAPIModule(argument_spec=argument_spec)
|
||||
|
||||
# Extract our parameters
|
||||
inventory = module.params.get('inventory')
|
||||
@ -62,7 +62,7 @@ id:
|
||||
|
||||
import time
|
||||
|
||||
from ..module_utils.tower_api import TowerAPIModule
|
||||
from ..module_utils.controller_api import ControllerAPIModule
|
||||
|
||||
|
||||
def main():
|
||||
@ -75,7 +75,7 @@ def main():
|
||||
)
|
||||
|
||||
# Create a module for ourselves
|
||||
module = TowerAPIModule(argument_spec=argument_spec)
|
||||
module = ControllerAPIModule(argument_spec=argument_spec)
|
||||
|
||||
# Extract our parameters
|
||||
command_id = module.params.get('command_id')
|
||||
@ -82,7 +82,7 @@ status:
|
||||
'''
|
||||
|
||||
|
||||
from ..module_utils.tower_api import TowerAPIModule
|
||||
from ..module_utils.controller_api import ControllerAPIModule
|
||||
|
||||
|
||||
def main():
|
||||
@ -94,7 +94,7 @@ def main():
|
||||
)
|
||||
|
||||
# Create a module for ourselves
|
||||
module = TowerAPIModule(argument_spec=argument_spec)
|
||||
module = ControllerAPIModule(argument_spec=argument_spec)
|
||||
|
||||
# Extract our parameters
|
||||
command_id = module.params.get('command_id')
|
||||
@ -91,7 +91,7 @@ EXAMPLES = '''
|
||||
|
||||
import time
|
||||
|
||||
from ..module_utils.tower_api import TowerAPIModule
|
||||
from ..module_utils.controller_api import ControllerAPIModule
|
||||
|
||||
|
||||
def main():
|
||||
@ -108,7 +108,7 @@ def main():
|
||||
)
|
||||
|
||||
# Create a module for ourselves
|
||||
module = TowerAPIModule(argument_spec=argument_spec)
|
||||
module = ControllerAPIModule(argument_spec=argument_spec)
|
||||
|
||||
# Extract our parameters
|
||||
name = module.params.get('name')
|
||||
@ -289,7 +289,7 @@ EXAMPLES = '''
|
||||
organization: Foo
|
||||
'''
|
||||
|
||||
from ..module_utils.tower_api import TowerAPIModule
|
||||
from ..module_utils.controller_api import ControllerAPIModule
|
||||
|
||||
KIND_CHOICES = {
|
||||
'aws': 'Amazon Web Services',
|
||||
@ -378,7 +378,7 @@ def main():
|
||||
)
|
||||
|
||||
# Create a module for ourselves
|
||||
module = TowerAPIModule(argument_spec=argument_spec, required_one_of=[['kind', 'credential_type']])
|
||||
module = ControllerAPIModule(argument_spec=argument_spec, required_one_of=[['kind', 'credential_type']])
|
||||
|
||||
# Extract our parameters
|
||||
name = module.params.get('name')
|
||||
@ -69,7 +69,7 @@ EXAMPLES = '''
|
||||
|
||||
'''
|
||||
|
||||
from ..module_utils.tower_api import TowerAPIModule
|
||||
from ..module_utils.controller_api import ControllerAPIModule
|
||||
|
||||
|
||||
def main():
|
||||
@ -84,7 +84,7 @@ def main():
|
||||
)
|
||||
|
||||
# Create a module for ourselves
|
||||
module = TowerAPIModule(argument_spec=argument_spec)
|
||||
module = ControllerAPIModule(argument_spec=argument_spec)
|
||||
|
||||
# Extract our parameters
|
||||
description = module.params.get('description')
|
||||
@ -80,7 +80,7 @@ EXAMPLES = '''
|
||||
RETURN = ''' # '''
|
||||
|
||||
|
||||
from ..module_utils.tower_api import TowerAPIModule
|
||||
from ..module_utils.controller_api import ControllerAPIModule
|
||||
|
||||
KIND_CHOICES = {'ssh': 'Machine', 'vault': 'Ansible Vault', 'net': 'Network', 'scm': 'Source Control', 'cloud': 'Lots of others', 'insights': 'Insights'}
|
||||
|
||||
@ -97,7 +97,7 @@ def main():
|
||||
)
|
||||
|
||||
# Create a module for ourselves
|
||||
module = TowerAPIModule(argument_spec=argument_spec)
|
||||
module = ControllerAPIModule(argument_spec=argument_spec)
|
||||
|
||||
# Extract our parameters
|
||||
name = module.params.get('name')
|
||||
@ -67,7 +67,7 @@ EXAMPLES = '''
|
||||
'''
|
||||
|
||||
|
||||
from ..module_utils.tower_api import TowerAPIModule
|
||||
from ..module_utils.controller_api import ControllerAPIModule
|
||||
import json
|
||||
|
||||
|
||||
@ -84,7 +84,7 @@ def main():
|
||||
)
|
||||
|
||||
# Create a module for ourselves
|
||||
module = TowerAPIModule(argument_spec=argument_spec)
|
||||
module = ControllerAPIModule(argument_spec=argument_spec)
|
||||
|
||||
# Extract our parameters
|
||||
name = module.params.get('name')
|
||||
@ -99,7 +99,7 @@ EXAMPLES = '''
|
||||
from os import environ
|
||||
import logging
|
||||
from ansible.module_utils.six.moves import StringIO
|
||||
from ..module_utils.tower_awxkit import TowerAWXKitModule
|
||||
from ..module_utils.awxkit import ControllerAWXKitModule
|
||||
|
||||
try:
|
||||
from awxkit.api.pages.api import EXPORTABLE_RESOURCES
|
||||
@ -114,12 +114,12 @@ def main():
|
||||
all=dict(type='bool', default=False),
|
||||
)
|
||||
|
||||
# We are not going to raise an error here because the __init__ method of TowerAWXKitModule will do that for us
|
||||
# We are not going to raise an error here because the __init__ method of ControllerAWXKitModule will do that for us
|
||||
if HAS_EXPORTABLE_RESOURCES:
|
||||
for resource in EXPORTABLE_RESOURCES:
|
||||
argument_spec[resource] = dict(type='str')
|
||||
|
||||
module = TowerAWXKitModule(argument_spec=argument_spec)
|
||||
module = ControllerAWXKitModule(argument_spec=argument_spec)
|
||||
|
||||
if not HAS_EXPORTABLE_RESOURCES:
|
||||
module.fail_json(msg="Your version of awxkit does not have import/export")
|
||||
@ -99,7 +99,7 @@ EXAMPLES = '''
|
||||
preserve_existing_children: True
|
||||
'''
|
||||
|
||||
from ..module_utils.tower_api import TowerAPIModule
|
||||
from ..module_utils.controller_api import ControllerAPIModule
|
||||
import json
|
||||
|
||||
|
||||
@ -119,7 +119,7 @@ def main():
|
||||
)
|
||||
|
||||
# Create a module for ourselves
|
||||
module = TowerAPIModule(argument_spec=argument_spec)
|
||||
module = ControllerAPIModule(argument_spec=argument_spec)
|
||||
|
||||
# Extract our parameters
|
||||
name = module.params.get('name')
|
||||
@ -71,7 +71,7 @@ EXAMPLES = '''
|
||||
'''
|
||||
|
||||
|
||||
from ..module_utils.tower_api import TowerAPIModule
|
||||
from ..module_utils.controller_api import ControllerAPIModule
|
||||
import json
|
||||
|
||||
|
||||
@ -88,7 +88,7 @@ def main():
|
||||
)
|
||||
|
||||
# Create a module for ourselves
|
||||
module = TowerAPIModule(argument_spec=argument_spec)
|
||||
module = ControllerAPIModule(argument_spec=argument_spec)
|
||||
|
||||
# Extract our parameters
|
||||
name = module.params.get('name')
|
||||
@ -48,7 +48,7 @@ EXAMPLES = '''
|
||||
assets: "{{ lookup('file', 'org.json') | from_json() }}"
|
||||
'''
|
||||
|
||||
from ..module_utils.tower_awxkit import TowerAWXKitModule
|
||||
from ..module_utils.awxkit import ControllerAWXKitModule
|
||||
|
||||
# These two lines are not needed if awxkit changes to do programatic notifications on issues
|
||||
from ansible.module_utils.six.moves import StringIO
|
||||
@ -66,7 +66,7 @@ except ImportError:
|
||||
def main():
|
||||
argument_spec = dict(assets=dict(type='dict', required=True))
|
||||
|
||||
module = TowerAWXKitModule(argument_spec=argument_spec, supports_check_mode=False)
|
||||
module = ControllerAWXKitModule(argument_spec=argument_spec, supports_check_mode=False)
|
||||
|
||||
assets = module.params.get('assets')
|
||||
|
||||
@ -80,7 +80,7 @@ extends_documentation_fragment: awx.awx.auth
|
||||
EXAMPLES = '''
|
||||
'''
|
||||
|
||||
from ..module_utils.tower_api import TowerAPIModule
|
||||
from ..module_utils.controller_api import ControllerAPIModule
|
||||
|
||||
|
||||
def main():
|
||||
@ -99,7 +99,7 @@ def main():
|
||||
)
|
||||
|
||||
# Create a module for ourselves
|
||||
module = TowerAPIModule(argument_spec=argument_spec)
|
||||
module = ControllerAPIModule(argument_spec=argument_spec)
|
||||
|
||||
# Extract our parameters
|
||||
name = module.params.get('name')
|
||||
@ -95,7 +95,7 @@ EXAMPLES = '''
|
||||
'''
|
||||
|
||||
|
||||
from ..module_utils.tower_api import TowerAPIModule
|
||||
from ..module_utils.controller_api import ControllerAPIModule
|
||||
import json
|
||||
|
||||
|
||||
@ -115,7 +115,7 @@ def main():
|
||||
)
|
||||
|
||||
# Create a module for ourselves
|
||||
module = TowerAPIModule(argument_spec=argument_spec)
|
||||
module = ControllerAPIModule(argument_spec=argument_spec)
|
||||
|
||||
# Extract our parameters
|
||||
name = module.params.get('name')
|
||||
@ -150,7 +150,7 @@ EXAMPLES = '''
|
||||
private: false
|
||||
'''
|
||||
|
||||
from ..module_utils.tower_api import TowerAPIModule
|
||||
from ..module_utils.controller_api import ControllerAPIModule
|
||||
from json import dumps
|
||||
|
||||
|
||||
@ -189,7 +189,7 @@ def main():
|
||||
)
|
||||
|
||||
# Create a module for ourselves
|
||||
module = TowerAPIModule(argument_spec=argument_spec)
|
||||
module = ControllerAPIModule(argument_spec=argument_spec)
|
||||
|
||||
# Extract our parameters
|
||||
name = module.params.get('name')
|
||||
@ -83,7 +83,7 @@ status:
|
||||
sample: pending
|
||||
'''
|
||||
|
||||
from ..module_utils.tower_api import TowerAPIModule
|
||||
from ..module_utils.controller_api import ControllerAPIModule
|
||||
|
||||
|
||||
def main():
|
||||
@ -98,7 +98,7 @@ def main():
|
||||
)
|
||||
|
||||
# Create a module for ourselves
|
||||
module = TowerAPIModule(argument_spec=argument_spec)
|
||||
module = ControllerAPIModule(argument_spec=argument_spec)
|
||||
|
||||
# Extract our parameters
|
||||
name = module.params.get('name')
|
||||
@ -49,7 +49,7 @@ id:
|
||||
'''
|
||||
|
||||
|
||||
from ..module_utils.tower_api import TowerAPIModule
|
||||
from ..module_utils.controller_api import ControllerAPIModule
|
||||
|
||||
|
||||
def main():
|
||||
@ -60,7 +60,7 @@ def main():
|
||||
)
|
||||
|
||||
# Create a module for ourselves
|
||||
module = TowerAPIModule(argument_spec=argument_spec)
|
||||
module = ControllerAPIModule(argument_spec=argument_spec)
|
||||
|
||||
# Extract our parameters
|
||||
job_id = module.params.get('job_id')
|
||||
@ -145,7 +145,7 @@ status:
|
||||
sample: pending
|
||||
'''
|
||||
|
||||
from ..module_utils.tower_api import TowerAPIModule
|
||||
from ..module_utils.controller_api import ControllerAPIModule
|
||||
|
||||
|
||||
def main():
|
||||
@ -171,7 +171,7 @@ def main():
|
||||
)
|
||||
|
||||
# Create a module for ourselves
|
||||
module = TowerAPIModule(argument_spec=argument_spec)
|
||||
module = ControllerAPIModule(argument_spec=argument_spec)
|
||||
|
||||
optional_args = {}
|
||||
# Extract our parameters
|
||||
@ -79,7 +79,7 @@ results:
|
||||
'''
|
||||
|
||||
|
||||
from ..module_utils.tower_api import TowerAPIModule
|
||||
from ..module_utils.controller_api import ControllerAPIModule
|
||||
|
||||
|
||||
def main():
|
||||
@ -92,7 +92,7 @@ def main():
|
||||
)
|
||||
|
||||
# Create a module for ourselves
|
||||
module = TowerAPIModule(
|
||||
module = ControllerAPIModule(
|
||||
argument_spec=argument_spec,
|
||||
mutually_exclusive=[
|
||||
('page', 'all_pages'),
|
||||
@ -343,7 +343,7 @@ EXAMPLES = '''
|
||||
state: "present"
|
||||
'''
|
||||
|
||||
from ..module_utils.tower_api import TowerAPIModule
|
||||
from ..module_utils.controller_api import ControllerAPIModule
|
||||
import json
|
||||
|
||||
|
||||
@ -417,7 +417,7 @@ def main():
|
||||
)
|
||||
|
||||
# Create a module for ourselves
|
||||
module = TowerAPIModule(argument_spec=argument_spec)
|
||||
module = ControllerAPIModule(argument_spec=argument_spec)
|
||||
|
||||
# Extract our parameters
|
||||
name = module.params.get('name')
|
||||
@ -97,7 +97,7 @@ status:
|
||||
'''
|
||||
|
||||
|
||||
from ..module_utils.tower_api import TowerAPIModule
|
||||
from ..module_utils.controller_api import ControllerAPIModule
|
||||
|
||||
|
||||
def main():
|
||||
@ -112,7 +112,7 @@ def main():
|
||||
)
|
||||
|
||||
# Create a module for ourselves
|
||||
module = TowerAPIModule(argument_spec=argument_spec)
|
||||
module = ControllerAPIModule(argument_spec=argument_spec)
|
||||
|
||||
# Extract our parameters
|
||||
job_id = module.params.get('job_id')
|
||||
@ -53,7 +53,7 @@ EXAMPLES = '''
|
||||
organization: My Organization
|
||||
'''
|
||||
|
||||
from ..module_utils.tower_api import TowerAPIModule
|
||||
from ..module_utils.controller_api import ControllerAPIModule
|
||||
|
||||
|
||||
def main():
|
||||
@ -66,7 +66,7 @@ def main():
|
||||
)
|
||||
|
||||
# Create a module for ourselves
|
||||
module = TowerAPIModule(argument_spec=argument_spec)
|
||||
module = ControllerAPIModule(argument_spec=argument_spec)
|
||||
|
||||
# Extract our parameters
|
||||
name = module.params.get('name')
|
||||
@ -44,12 +44,12 @@ EXAMPLES = '''
|
||||
'''
|
||||
|
||||
import base64
|
||||
from ..module_utils.tower_api import TowerAPIModule
|
||||
from ..module_utils.controller_api import ControllerAPIModule
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
module = TowerAPIModule(
|
||||
module = ControllerAPIModule(
|
||||
argument_spec=dict(
|
||||
manifest=dict(type='str', required=True),
|
||||
force=dict(type='bool', required=False),
|
||||
@ -61,11 +61,11 @@ EXAMPLES = '''
|
||||
'''
|
||||
|
||||
|
||||
from ..module_utils.tower_api import TowerAPIModule
|
||||
from ..module_utils.controller_api import ControllerAPIModule
|
||||
|
||||
|
||||
def main():
|
||||
module = TowerAPIModule(argument_spec={})
|
||||
module = ControllerAPIModule(argument_spec={})
|
||||
namespace = {'awx': 'awx', 'tower': 'ansible'}.get(module._COLLECTION_TYPE, 'unknown')
|
||||
namespace_name = '{0}.{1}'.format(namespace, module._COLLECTION_TYPE)
|
||||
module.exit_json(prefix=namespace_name, name=module._COLLECTION_TYPE, namespace=namespace, version=module._COLLECTION_VERSION)
|
||||
@ -313,7 +313,7 @@ EXAMPLES = '''
|
||||
RETURN = ''' # '''
|
||||
|
||||
|
||||
from ..module_utils.tower_api import TowerAPIModule
|
||||
from ..module_utils.controller_api import ControllerAPIModule
|
||||
|
||||
OLD_INPUT_NAMES = (
|
||||
'username',
|
||||
@ -384,7 +384,7 @@ def main():
|
||||
)
|
||||
|
||||
# Create a module for ourselves
|
||||
module = TowerAPIModule(argument_spec=argument_spec)
|
||||
module = ControllerAPIModule(argument_spec=argument_spec)
|
||||
|
||||
# Extract our parameters
|
||||
name = module.params.get('name')
|
||||
@ -109,7 +109,7 @@ EXAMPLES = '''
|
||||
tower_config_file: "~/tower_cli.cfg"
|
||||
'''
|
||||
|
||||
from ..module_utils.tower_api import TowerAPIModule
|
||||
from ..module_utils.controller_api import ControllerAPIModule
|
||||
|
||||
|
||||
def main():
|
||||
@ -130,7 +130,7 @@ def main():
|
||||
)
|
||||
|
||||
# Create a module for ourselves
|
||||
module = TowerAPIModule(argument_spec=argument_spec)
|
||||
module = ControllerAPIModule(argument_spec=argument_spec)
|
||||
|
||||
# Extract our parameters
|
||||
name = module.params.get('name')
|
||||
@ -199,7 +199,7 @@ EXAMPLES = '''
|
||||
|
||||
import time
|
||||
|
||||
from ..module_utils.tower_api import TowerAPIModule
|
||||
from ..module_utils.controller_api import ControllerAPIModule
|
||||
|
||||
|
||||
def wait_for_project_update(module, last_request):
|
||||
@ -280,7 +280,7 @@ def main():
|
||||
)
|
||||
|
||||
# Create a module for ourselves
|
||||
module = TowerAPIModule(argument_spec=argument_spec)
|
||||
module = ControllerAPIModule(argument_spec=argument_spec)
|
||||
|
||||
# Extract our parameters
|
||||
name = module.params.get('name')
|
||||
@ -77,7 +77,7 @@ EXAMPLES = '''
|
||||
wait: False
|
||||
'''
|
||||
|
||||
from ..module_utils.tower_api import TowerAPIModule
|
||||
from ..module_utils.controller_api import ControllerAPIModule
|
||||
import json
|
||||
import time
|
||||
|
||||
@ -93,7 +93,7 @@ def main():
|
||||
)
|
||||
|
||||
# Create a module for ourselves
|
||||
module = TowerAPIModule(argument_spec=argument_spec)
|
||||
module = ControllerAPIModule(argument_spec=argument_spec)
|
||||
|
||||
# Extract our parameters
|
||||
name = module.params.get('name')
|
||||
@ -148,7 +148,7 @@ EXAMPLES = '''
|
||||
state: present
|
||||
'''
|
||||
|
||||
from ..module_utils.tower_api import TowerAPIModule
|
||||
from ..module_utils.controller_api import ControllerAPIModule
|
||||
|
||||
|
||||
def main():
|
||||
@ -194,7 +194,7 @@ def main():
|
||||
state=dict(choices=['present', 'absent'], default='present'),
|
||||
)
|
||||
|
||||
module = TowerAPIModule(argument_spec=argument_spec)
|
||||
module = ControllerAPIModule(argument_spec=argument_spec)
|
||||
|
||||
role_type = module.params.pop('role')
|
||||
role_field = role_type + '_role'
|
||||
@ -135,7 +135,7 @@ EXAMPLES = '''
|
||||
register: result
|
||||
'''
|
||||
|
||||
from ..module_utils.tower_api import TowerAPIModule
|
||||
from ..module_utils.controller_api import ControllerAPIModule
|
||||
|
||||
|
||||
def main():
|
||||
@ -160,7 +160,7 @@ def main():
|
||||
)
|
||||
|
||||
# Create a module for ourselves
|
||||
module = TowerAPIModule(argument_spec=argument_spec)
|
||||
module = ControllerAPIModule(argument_spec=argument_spec)
|
||||
|
||||
# Extract our parameters
|
||||
rrule = module.params.get('rrule')
|
||||
@ -69,7 +69,7 @@ EXAMPLES = '''
|
||||
last_name: "surname"
|
||||
'''
|
||||
|
||||
from ..module_utils.tower_api import TowerAPIModule
|
||||
from ..module_utils.controller_api import ControllerAPIModule
|
||||
|
||||
try:
|
||||
import yaml
|
||||
@ -107,7 +107,7 @@ def main():
|
||||
)
|
||||
|
||||
# Create a module for ourselves
|
||||
module = TowerAPIModule(
|
||||
module = ControllerAPIModule(
|
||||
argument_spec=argument_spec,
|
||||
required_one_of=[['name', 'settings']],
|
||||
mutually_exclusive=[['name', 'settings']],
|
||||
@ -59,7 +59,7 @@ EXAMPLES = '''
|
||||
tower_config_file: "~/tower_cli.cfg"
|
||||
'''
|
||||
|
||||
from ..module_utils.tower_api import TowerAPIModule
|
||||
from ..module_utils.controller_api import ControllerAPIModule
|
||||
|
||||
|
||||
def main():
|
||||
@ -73,7 +73,7 @@ def main():
|
||||
)
|
||||
|
||||
# Create a module for ourselves
|
||||
module = TowerAPIModule(argument_spec=argument_spec)
|
||||
module = ControllerAPIModule(argument_spec=argument_spec)
|
||||
|
||||
# Extract our parameters
|
||||
name = module.params.get('name')
|
||||
@ -116,7 +116,7 @@ tower_token:
|
||||
returned: on successful create
|
||||
'''
|
||||
|
||||
from ..module_utils.tower_api import TowerAPIModule
|
||||
from ..module_utils.controller_api import ControllerAPIModule
|
||||
|
||||
|
||||
def return_token(module, last_response):
|
||||
@ -142,7 +142,7 @@ def main():
|
||||
)
|
||||
|
||||
# Create a module for ourselves
|
||||
module = TowerAPIModule(
|
||||
module = ControllerAPIModule(
|
||||
argument_spec=argument_spec,
|
||||
mutually_exclusive=[
|
||||
('existing_token', 'existing_token_id'),
|
||||
@ -107,7 +107,7 @@ EXAMPLES = '''
|
||||
tower_config_file: "~/tower_cli.cfg"
|
||||
'''
|
||||
|
||||
from ..module_utils.tower_api import TowerAPIModule
|
||||
from ..module_utils.controller_api import ControllerAPIModule
|
||||
|
||||
|
||||
def main():
|
||||
@ -125,7 +125,7 @@ def main():
|
||||
)
|
||||
|
||||
# Create a module for ourselves
|
||||
module = TowerAPIModule(argument_spec=argument_spec)
|
||||
module = ControllerAPIModule(argument_spec=argument_spec)
|
||||
|
||||
# Extract our parameters
|
||||
username = module.params.get('username')
|
||||
@ -77,7 +77,7 @@ RETURN = """
|
||||
"""
|
||||
|
||||
|
||||
from ..module_utils.tower_api import TowerAPIModule
|
||||
from ..module_utils.controller_api import ControllerAPIModule
|
||||
|
||||
|
||||
def main():
|
||||
@ -91,7 +91,7 @@ def main():
|
||||
)
|
||||
|
||||
# Create a module for ourselves
|
||||
module = TowerAPIModule(argument_spec=argument_spec)
|
||||
module = ControllerAPIModule(argument_spec=argument_spec)
|
||||
|
||||
# Extract our parameters
|
||||
workflow_job_id = module.params.get("workflow_job_id")
|
||||
@ -455,7 +455,7 @@ EXAMPLES = '''
|
||||
|
||||
'''
|
||||
|
||||
from ..module_utils.tower_api import TowerAPIModule
|
||||
from ..module_utils.controller_api import ControllerAPIModule
|
||||
|
||||
import json
|
||||
|
||||
@ -689,7 +689,7 @@ def main():
|
||||
)
|
||||
|
||||
# Create a module for ourselves
|
||||
module = TowerAPIModule(argument_spec=argument_spec)
|
||||
module = ControllerAPIModule(argument_spec=argument_spec)
|
||||
|
||||
# Extract our parameters
|
||||
name = module.params.get('name')
|
||||
@ -224,7 +224,7 @@ EXAMPLES = '''
|
||||
- my-third-node
|
||||
'''
|
||||
|
||||
from ..module_utils.tower_api import TowerAPIModule
|
||||
from ..module_utils.controller_api import ControllerAPIModule
|
||||
|
||||
|
||||
def main():
|
||||
@ -259,7 +259,7 @@ def main():
|
||||
]
|
||||
|
||||
# Create a module for ourselves
|
||||
module = TowerAPIModule(
|
||||
module = ControllerAPIModule(
|
||||
argument_spec=argument_spec,
|
||||
mutually_exclusive=mutually_exclusive,
|
||||
required_if=required_if,
|
||||
@ -90,7 +90,7 @@ EXAMPLES = '''
|
||||
wait: False
|
||||
'''
|
||||
|
||||
from ..module_utils.tower_api import TowerAPIModule
|
||||
from ..module_utils.controller_api import ControllerAPIModule
|
||||
import json
|
||||
|
||||
|
||||
@ -109,7 +109,7 @@ def main():
|
||||
)
|
||||
|
||||
# Create a module for ourselves
|
||||
module = TowerAPIModule(argument_spec=argument_spec)
|
||||
module = ControllerAPIModule(argument_spec=argument_spec)
|
||||
|
||||
optional_args = {}
|
||||
# Extract our parameters
|
||||
@ -69,7 +69,7 @@ RETURN = """
|
||||
"""
|
||||
|
||||
|
||||
from ..module_utils.tower_api import TowerAPIModule
|
||||
from ..module_utils.controller_api import ControllerAPIModule
|
||||
import time
|
||||
|
||||
|
||||
@ -83,7 +83,7 @@ def main():
|
||||
)
|
||||
|
||||
# Create a module for ourselves
|
||||
module = TowerAPIModule(argument_spec=argument_spec)
|
||||
module = ControllerAPIModule(argument_spec=argument_spec)
|
||||
|
||||
# Extract our parameters
|
||||
workflow_job_id = module.params.get("workflow_job_id")
|
||||
@ -150,14 +150,14 @@ def run_module(request, collection_import):
|
||||
def mock_load_params(self):
|
||||
self.params = module_params
|
||||
|
||||
if getattr(resource_module, 'TowerAWXKitModule', None):
|
||||
resource_class = resource_module.TowerAWXKitModule
|
||||
elif getattr(resource_module, 'TowerAPIModule', None):
|
||||
resource_class = resource_module.TowerAPIModule
|
||||
if getattr(resource_module, 'ControllerAWXKitModule', None):
|
||||
resource_class = resource_module.ControllerAWXKitModule
|
||||
elif getattr(resource_module, 'ControllerAPIModule', None):
|
||||
resource_class = resource_module.ControllerAPIModule
|
||||
elif getattr(resource_module, 'TowerLegacyModule', None):
|
||||
resource_class = resource_module.TowerLegacyModule
|
||||
else:
|
||||
raise ("The module has neither a TowerLegacyModule, TowerAWXKitModule or a TowerAPIModule")
|
||||
raise ("The module has neither a TowerLegacyModule, ControllerAWXKitModule or a ControllerAPIModule")
|
||||
|
||||
with mock.patch.object(resource_class, '_load_params', new=mock_load_params):
|
||||
# Call the test utility (like a mock server) instead of issuing HTTP requests
|
||||
|
||||
@ -49,7 +49,7 @@ def mock_awx_ping_response(self, method, url, **kwargs):
|
||||
|
||||
|
||||
def test_version_warning(collection_import, silence_warning):
|
||||
TowerAPIModule = collection_import('plugins.module_utils.tower_api').TowerAPIModule
|
||||
TowerAPIModule = collection_import('plugins.module_utils.tower_api').ControllerAPIModule
|
||||
cli_data = {'ANSIBLE_MODULE_ARGS': {}}
|
||||
testargs = ['module_file2.py', json.dumps(cli_data)]
|
||||
with mock.patch.object(sys, 'argv', testargs):
|
||||
@ -64,7 +64,7 @@ def test_version_warning(collection_import, silence_warning):
|
||||
|
||||
|
||||
def test_version_warning_strictness_awx(collection_import, silence_warning):
|
||||
TowerAPIModule = collection_import('plugins.module_utils.tower_api').TowerAPIModule
|
||||
TowerAPIModule = collection_import('plugins.module_utils.tower_api').ControllerAPIModule
|
||||
cli_data = {'ANSIBLE_MODULE_ARGS': {}}
|
||||
testargs = ['module_file2.py', json.dumps(cli_data)]
|
||||
# Compare 1.0.0 to 1.2.3 (major matches)
|
||||
@ -87,7 +87,7 @@ def test_version_warning_strictness_awx(collection_import, silence_warning):
|
||||
|
||||
|
||||
def test_version_warning_strictness_tower(collection_import, silence_warning):
|
||||
TowerAPIModule = collection_import('plugins.module_utils.tower_api').TowerAPIModule
|
||||
TowerAPIModule = collection_import('plugins.module_utils.tower_api').ControllerAPIModule
|
||||
cli_data = {'ANSIBLE_MODULE_ARGS': {}}
|
||||
testargs = ['module_file2.py', json.dumps(cli_data)]
|
||||
# Compare 1.2.0 to 1.2.3 (major/minor matches)
|
||||
@ -112,7 +112,7 @@ def test_version_warning_strictness_tower(collection_import, silence_warning):
|
||||
|
||||
|
||||
def test_type_warning(collection_import, silence_warning):
|
||||
TowerAPIModule = collection_import('plugins.module_utils.tower_api').TowerAPIModule
|
||||
TowerAPIModule = collection_import('plugins.module_utils.tower_api').ControllerAPIModule
|
||||
cli_data = {'ANSIBLE_MODULE_ARGS': {}}
|
||||
testargs = ['module_file2.py', json.dumps(cli_data)]
|
||||
with mock.patch.object(sys, 'argv', testargs):
|
||||
@ -128,7 +128,7 @@ def test_type_warning(collection_import, silence_warning):
|
||||
|
||||
def test_duplicate_config(collection_import, silence_warning):
|
||||
# imports done here because of PATH issues unique to this test suite
|
||||
TowerAPIModule = collection_import('plugins.module_utils.tower_api').TowerAPIModule
|
||||
TowerAPIModule = collection_import('plugins.module_utils.tower_api').ControllerAPIModule
|
||||
data = {'name': 'zigzoom', 'zig': 'zoom', 'tower_username': 'bob', 'tower_config_file': 'my_config'}
|
||||
|
||||
with mock.patch.object(TowerAPIModule, 'load_config') as mock_load:
|
||||
@ -152,7 +152,7 @@ def test_no_templated_values(collection_import):
|
||||
Those replacements should happen at build time, so they should not be
|
||||
checked into source.
|
||||
"""
|
||||
TowerAPIModule = collection_import('plugins.module_utils.tower_api').TowerAPIModule
|
||||
TowerAPIModule = collection_import('plugins.module_utils.tower_api').ControllerAPIModule
|
||||
assert TowerAPIModule._COLLECTION_VERSION == "0.0.1-devel", (
|
||||
'The collection version is templated when the collection is built ' 'and the code should retain the placeholder of "0.0.1-devel".'
|
||||
)
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
---
|
||||
- name: Set the collection version in the tower_api.py file
|
||||
- name: Set the collection version in the controller_api.py file
|
||||
replace:
|
||||
path: "{{ collection_path }}/plugins/module_utils/tower_api.py"
|
||||
path: "{{ collection_path }}/plugins/module_utils/controller_api.py"
|
||||
regexp: '^ _COLLECTION_VERSION = "0.0.1-devel"'
|
||||
replace: ' _COLLECTION_VERSION = "{{ collection_version }}"'
|
||||
when:
|
||||
- "awx_template_version | default(True)"
|
||||
|
||||
- name: Set the collection type in the tower_api.py file
|
||||
- name: Set the collection type in the controller_api.py file
|
||||
replace:
|
||||
path: "{{ collection_path }}/plugins/module_utils/tower_api.py"
|
||||
path: "{{ collection_path }}/plugins/module_utils/controller_api.py"
|
||||
regexp: '^ _COLLECTION_TYPE = "awx"'
|
||||
replace: ' _COLLECTION_TYPE = "{{ collection_package }}"'
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
|
||||
- name: Change inventory file to support desired namespace and package names
|
||||
replace:
|
||||
path: "{{ collection_path }}/plugins/inventory/tower.py"
|
||||
path: "{{ collection_path }}/plugins/inventory/controller.py"
|
||||
regexp: "^ NAME = 'awx.awx.tower' # REPLACE$"
|
||||
replace: " NAME = '{{ collection_namespace }}.{{ collection_package }}.tower' # REPLACE"
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user