diff options
author | Avi Layani <alayani@redhat.com> | 2023-12-13 17:28:31 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-13 17:28:31 +0100 |
commit | df24cb692b16103842d00fc4c52806c5e8197db8 (patch) | |
tree | ed3b1b7e6dcccacc48672e14ebc51130b1accb36 /awxkit | |
parent | Update setuptools-scm (#14716) (diff) | |
download | awx-df24cb692b16103842d00fc4c52806c5e8197db8.tar.xz awx-df24cb692b16103842d00fc4c52806c5e8197db8.zip |
Adding hosts bulk deletion feature (#14462)
* Adding hosts bulk deletion feature
Signed-off-by: Avi Layani <alayani@redhat.com>
* fix the type of the argument
Signed-off-by: Avi Layani <alayani@redhat.com>
* fixing activity_entry tracking
Signed-off-by: Avi Layani <alayani@redhat.com>
* Revert "fixing activity_entry tracking"
This reverts commit c8eab52c2ccc5abe215d56d1704ba1157e5fbbd0.
Since the bulk_delete is not related to an inventory, only hosts which
can be from different inventories.
* get only needed vars to reduce memory consumption
Signed-off-by: Avi Layani <alayani@redhat.com>
* filtering the data to reduce memory increase the number of queries
Signed-off-by: Avi Layani <alayani@redhat.com>
* update the activity stream for inventories
Signed-off-by: Avi Layani <alayani@redhat.com>
* fix the changes dict initialiazation
Signed-off-by: Avi Layani <alayani@redhat.com>
---------
Signed-off-by: Avi Layani <alayani@redhat.com>
Diffstat (limited to 'awxkit')
-rw-r--r-- | awxkit/awxkit/cli/custom.py | 20 | ||||
-rw-r--r-- | awxkit/awxkit/cli/options.py | 4 |
2 files changed, 24 insertions, 0 deletions
diff --git a/awxkit/awxkit/cli/custom.py b/awxkit/awxkit/cli/custom.py index 431fef07e8..6d2be2475c 100644 --- a/awxkit/awxkit/cli/custom.py +++ b/awxkit/awxkit/cli/custom.py @@ -143,6 +143,26 @@ class BulkHostCreate(CustomAction): return response +class BulkHostDelete(CustomAction): + action = 'host_delete' + resource = 'bulk' + + @property + def options_endpoint(self): + return self.page.endpoint + '{}/'.format(self.action) + + def add_arguments(self, parser, resource_options_parser): + options = self.page.connection.options(self.options_endpoint) + if options.ok: + options = options.json()['actions']['POST'] + resource_options_parser.options['HOSTDELETEPOST'] = options + resource_options_parser.build_query_arguments(self.action, 'HOSTDELETEPOST') + + def perform(self, **kwargs): + response = self.page.get().host_delete.post(kwargs) + return response + + class ProjectUpdate(Launchable, CustomAction): action = 'update' resource = 'projects' diff --git a/awxkit/awxkit/cli/options.py b/awxkit/awxkit/cli/options.py index 848e4f6bf7..ecedf3918d 100644 --- a/awxkit/awxkit/cli/options.py +++ b/awxkit/awxkit/cli/options.py @@ -270,6 +270,10 @@ class ResourceOptionsParser(object): if k == 'hosts': kwargs['type'] = list_of_json_or_yaml kwargs['required'] = required = True + if method == "host_delete": + if k == 'hosts': + kwargs['type'] = list_of_json_or_yaml + kwargs['required'] = required = True if method == "job_launch": if k == 'jobs': kwargs['type'] = list_of_json_or_yaml |