summaryrefslogtreecommitdiffstats
path: root/awxkit
diff options
context:
space:
mode:
authorAvi Layani <alayani@redhat.com>2023-12-13 17:28:31 +0100
committerGitHub <noreply@github.com>2023-12-13 17:28:31 +0100
commitdf24cb692b16103842d00fc4c52806c5e8197db8 (patch)
treeed3b1b7e6dcccacc48672e14ebc51130b1accb36 /awxkit
parentUpdate setuptools-scm (#14716) (diff)
downloadawx-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.py20
-rw-r--r--awxkit/awxkit/cli/options.py4
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