mirror of
https://github.com/ansible/awx.git
synced 2026-06-25 08:28:03 -02:30
awxkit cli support
fixes for awx cli
This commit is contained in:
committed by
Elijah DeLee
parent
861ba8a727
commit
34834252ff
@@ -44,6 +44,10 @@ class CustomAction(metaclass=CustomActionRegistryMeta):
|
||||
|
||||
|
||||
class Launchable(object):
|
||||
@property
|
||||
def options_endpoint(self):
|
||||
return self.page.endpoint + '1/{}/'.format(self.action)
|
||||
|
||||
def add_arguments(self, parser, resource_options_parser, with_pk=True):
|
||||
from .options import pk_or_name
|
||||
|
||||
@@ -53,7 +57,7 @@ class Launchable(object):
|
||||
parser.choices[self.action].add_argument('--action-timeout', type=int, help='If set with --monitor or --wait, time out waiting on job completion.')
|
||||
parser.choices[self.action].add_argument('--wait', action='store_true', help='If set, waits until the launched job finishes.')
|
||||
|
||||
launch_time_options = self.page.connection.options(self.page.endpoint + '1/{}/'.format(self.action))
|
||||
launch_time_options = self.page.connection.options(self.options_endpoint)
|
||||
if launch_time_options.ok:
|
||||
launch_time_options = launch_time_options.json()['actions']['POST']
|
||||
resource_options_parser.options['LAUNCH'] = launch_time_options
|
||||
@@ -90,6 +94,48 @@ class JobTemplateLaunch(Launchable, CustomAction):
|
||||
resource = 'job_templates'
|
||||
|
||||
|
||||
class BulkJobLaunch(Launchable, CustomAction):
|
||||
action = 'job_launch'
|
||||
resource = 'bulk'
|
||||
|
||||
@property
|
||||
def options_endpoint(self):
|
||||
return self.page.endpoint + '{}/'.format(self.action)
|
||||
|
||||
def add_arguments(self, parser, resource_options_parser):
|
||||
Launchable.add_arguments(self, parser, resource_options_parser, with_pk=False)
|
||||
|
||||
def perform(self, **kwargs):
|
||||
monitor_kwargs = {
|
||||
'monitor': kwargs.pop('monitor', False),
|
||||
'wait': kwargs.pop('wait', False),
|
||||
'action_timeout': kwargs.pop('action_timeout', False),
|
||||
}
|
||||
response = self.page.get().job_launch.post(kwargs)
|
||||
self.monitor(response, **monitor_kwargs)
|
||||
return response
|
||||
|
||||
|
||||
class BulkHostCreate(CustomAction):
|
||||
action = 'host_create'
|
||||
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['HOSTCREATEPOST'] = options
|
||||
resource_options_parser.build_query_arguments(self.action, 'HOSTCREATEPOST')
|
||||
|
||||
def perform(self, **kwargs):
|
||||
response = self.page.get().host_create.post(kwargs)
|
||||
return response
|
||||
|
||||
|
||||
class ProjectUpdate(Launchable, CustomAction):
|
||||
action = 'update'
|
||||
resource = 'projects'
|
||||
|
||||
Reference in New Issue
Block a user