diff options
author | Alan Rominger <arominge@redhat.com> | 2021-04-12 19:57:03 +0200 |
---|---|---|
committer | Alan Rominger <arominge@redhat.com> | 2021-04-22 14:36:46 +0200 |
commit | 38352063e8caadcc0b641d87bd95f350529d51bf (patch) | |
tree | 35bb9e38ec2c3974c971d704ca334ffd25535184 /awxkit | |
parent | Change inventory source factory defaults (diff) | |
download | awx-38352063e8caadcc0b641d87bd95f350529d51bf.tar.xz awx-38352063e8caadcc0b641d87bd95f350529d51bf.zip |
Remove custom inventory script API
Diffstat (limited to 'awxkit')
-rw-r--r-- | awxkit/awxkit/api/pages/inventory.py | 60 | ||||
-rw-r--r-- | awxkit/awxkit/api/resources.py | 3 | ||||
-rw-r--r-- | awxkit/awxkit/awx/utils.py | 1 | ||||
-rw-r--r-- | awxkit/awxkit/cli/custom.py | 1 | ||||
-rw-r--r-- | awxkit/awxkit/cli/resource.py | 1 |
5 files changed, 0 insertions, 66 deletions
diff --git a/awxkit/awxkit/api/pages/inventory.py b/awxkit/awxkit/api/pages/inventory.py index 4378cc47ce..994bc32880 100644 --- a/awxkit/awxkit/api/pages/inventory.py +++ b/awxkit/awxkit/api/pages/inventory.py @@ -125,64 +125,6 @@ class Inventories(page.PageList, Inventory): page.register_page([resources.inventories, resources.related_inventories], Inventories) -class InventoryScript(HasCopy, HasCreate, base.Base): - - dependencies = [Organization] - - def payload(self, organization, **kwargs): - payload = PseudoNamespace( - name=kwargs.get('name') or 'Inventory Script - {}'.format(random_title()), - description=kwargs.get('description') or random_title(10), - organization=organization.id, - script=kwargs.get('script') or self._generate_script(), - ) - return payload - - def create_payload(self, name='', description='', organization=Organization, script='', **kwargs): - self.create_and_update_dependencies(organization) - payload = self.payload(name=name, description=description, organization=self.ds.organization, script=script, **kwargs) - payload.ds = DSAdapter(self.__class__.__name__, self._dependency_store) - return payload - - def create(self, name='', description='', organization=Organization, script='', **kwargs): - payload = self.create_payload(name=name, description=description, organization=organization, script=script, **kwargs) - return self.update_identity(InventoryScripts(self.connection).post(payload)) - - def _generate_script(self): - script = '\n'.join( - [ - '#!/usr/bin/env python', - '# -*- coding: utf-8 -*-', - 'import json', - 'inventory = dict()', - 'inventory["{0}"] = dict()', - 'inventory["{0}"]["hosts"] = list()', - 'inventory["{0}"]["hosts"].append("{1}")', - 'inventory["{0}"]["hosts"].append("{2}")', - 'inventory["{0}"]["hosts"].append("{3}")', - 'inventory["{0}"]["hosts"].append("{4}")', - 'inventory["{0}"]["hosts"].append("{5}")', - 'inventory["{0}"]["vars"] = dict(ansible_host="127.0.0.1", ansible_connection="local")', - 'print(json.dumps(inventory))', - ] - ) - group_name = re.sub(r"[\']", "", "group_{}".format(random_title(non_ascii=False))) - host_names = [re.sub(r"[\':]", "", "host_{}".format(random_utf8())) for _ in range(5)] - - return script.format(group_name, *host_names) - - -page.register_page([resources.inventory_script, (resources.inventory_scripts, 'post'), (resources.inventory_script_copy, 'post')], InventoryScript) - - -class InventoryScripts(page.PageList, InventoryScript): - - pass - - -page.register_page([resources.inventory_scripts], InventoryScripts) - - class Group(HasCreate, HasVariables, base.Base): dependencies = [Inventory] @@ -408,8 +350,6 @@ class InventorySource(HasCreate, HasNotifications, UnifiedJobTemplate): if credential: credential = self.ds.credential - if source_script: - source_script = self.ds.inventory_script if project: project = self.ds.project diff --git a/awxkit/awxkit/api/resources.py b/awxkit/awxkit/api/resources.py index 573c96598f..3d27dbb1df 100644 --- a/awxkit/awxkit/api/resources.py +++ b/awxkit/awxkit/api/resources.py @@ -65,9 +65,6 @@ class Resources(object): _inventory_related_root_groups = r'inventories/\d+/root_groups/' _inventory_related_script = r'inventories/\d+/script/' _inventory_related_update_inventory_sources = r'inventories/\d+/update_inventory_sources/' - _inventory_script = r'inventory_scripts/\d+/' - _inventory_script_copy = r'inventory_scripts/\d+/copy/' - _inventory_scripts = 'inventory_scripts/' _inventory_source = r'inventory_sources/\d+/' _inventory_source_schedule = r'inventory_sources/\d+/schedules/\d+/' _inventory_source_schedules = r'inventory_sources/\d+/schedules/' diff --git a/awxkit/awxkit/awx/utils.py b/awxkit/awxkit/awx/utils.py index 0a96a4cb38..66de4517dc 100644 --- a/awxkit/awxkit/awx/utils.py +++ b/awxkit/awxkit/awx/utils.py @@ -39,7 +39,6 @@ def delete_all(v): v.projects, v.inventory, v.hosts, - v.inventory_scripts, v.labels, v.credentials, v.teams, diff --git a/awxkit/awxkit/cli/custom.py b/awxkit/awxkit/cli/custom.py index d2b9bc6590..e65b20e852 100644 --- a/awxkit/awxkit/cli/custom.py +++ b/awxkit/awxkit/cli/custom.py @@ -349,7 +349,6 @@ class RoleMixin(object): ['organizations', 'organization'], ['projects', 'project'], ['inventories', 'inventory'], - ['inventory_scripts', 'inventory_script'], ['teams', 'team'], ['credentials', 'credential'], ['job_templates', 'job_template'], diff --git a/awxkit/awxkit/cli/resource.py b/awxkit/awxkit/cli/resource.py index 7aa7c32e0a..b4747b6e43 100644 --- a/awxkit/awxkit/cli/resource.py +++ b/awxkit/awxkit/cli/resource.py @@ -23,7 +23,6 @@ DEPRECATED_RESOURCES = { 'instances': 'instance', 'instance_groups': 'instance_group', 'inventory': 'inventories', - 'inventory_scripts': 'inventory_script', 'inventory_sources': 'inventory_source', 'inventory_updates': 'inventory_update', 'jobs': 'job', |