mirror of
https://github.com/ansible/awx.git
synced 2026-03-16 16:37:30 -02:30
Renamed LaunchJob to JobTemplate, LaunchJobStatus to Job, LaunchJobHostSummary to JobHostSummary, and LaunchJobStatusEvent to JobEvent. Updated admin, celery task, management commands accordingly.
This commit is contained in:
@@ -30,10 +30,10 @@ class Command(NoArgsCommand):
|
||||
help = 'Ansible Commander Callback Event Capture'
|
||||
|
||||
option_list = NoArgsCommand.option_list + (
|
||||
make_option('-i', '--launch-job-status', dest='launch_job_status_id',
|
||||
make_option('-j', '--job', dest='job_id',
|
||||
type='int', default=0,
|
||||
help='Launch job status ID (can also be specified using '
|
||||
'ACOM_LAUNCH_JOB_STATUS_ID environment variable)'),
|
||||
help='Job ID (can also be specified using ACOM_JOB_ID '
|
||||
'environment variable)'),
|
||||
make_option('-e', '--event', dest='event_type', default=None,
|
||||
help='Event type'),
|
||||
make_option('-f', '--file', dest='event_data_file', default=None,
|
||||
@@ -44,29 +44,28 @@ class Command(NoArgsCommand):
|
||||
)
|
||||
|
||||
def handle_noargs(self, **options):
|
||||
from lib.main.models import LaunchJobStatus, LaunchJobStatusEvent
|
||||
from lib.main.models import Job, JobEvent
|
||||
event_type = options.get('event_type', None)
|
||||
if not event_type:
|
||||
raise CommandError('No event specified')
|
||||
if event_type not in [x[0] for x in LaunchJobStatusEvent.EVENT_TYPES]:
|
||||
if event_type not in [x[0] for x in JobEvent.EVENT_TYPES]:
|
||||
raise CommandError('Unsupported event')
|
||||
event_data_file = options.get('event_data_file', None)
|
||||
event_data_json = options.get('event_data_json', None)
|
||||
if event_data_file is None and event_data_json is None:
|
||||
raise CommandError('Either --file or --data must be specified')
|
||||
try:
|
||||
launch_job_status_id = int(os.getenv('ACOM_LAUNCH_JOB_STATUS_ID',
|
||||
options.get('launch_job_status_id', 0)))
|
||||
job_id = int(os.getenv('ACOM_JOB_ID', options.get('job_id', 0)))
|
||||
except ValueError:
|
||||
raise CommandError('Launch job status ID must be an integer')
|
||||
if not launch_job_status_id:
|
||||
raise CommandError('No launch job status ID specified')
|
||||
raise CommandError('Job ID must be an integer')
|
||||
if not job_id:
|
||||
raise CommandError('No Job ID specified')
|
||||
try:
|
||||
launch_job_status = LaunchJobStatus.objects.get(id=launch_job_status_id)
|
||||
except LaunchJobStatus.DoesNotExist:
|
||||
raise CommandError('Launch job status with ID %d not found' % launch_job_status_id)
|
||||
if launch_job_status.status != 'running':
|
||||
raise CommandError('Unable to add event except when launch job is running')
|
||||
job = Job.objects.get(id=job_id)
|
||||
except Job.DoesNotExist:
|
||||
raise CommandError('Job with ID %d not found' % job_id)
|
||||
if job.status != 'running':
|
||||
raise CommandError('Unable to add event except when job is running')
|
||||
try:
|
||||
if event_data_json is None:
|
||||
try:
|
||||
@@ -81,8 +80,7 @@ class Command(NoArgsCommand):
|
||||
event_data = json.loads(event_data_json)
|
||||
except ValueError:
|
||||
raise CommandError('Error parsing JSON data')
|
||||
launch_job_status.launch_job_status_events.create(event=event_type,
|
||||
event_data=event_data)
|
||||
job.job_events.create(event=event_type, event_data=event_data)
|
||||
|
||||
if __name__ == '__main__':
|
||||
from __init__ import run_command_as_script
|
||||
|
||||
@@ -27,9 +27,9 @@ class Command(NoArgsCommand):
|
||||
help = 'Ansible Commander Inventory script'
|
||||
|
||||
option_list = NoArgsCommand.option_list + (
|
||||
make_option('-i', '--inventory', dest='inventory', type='int', default=0,
|
||||
help='Inventory ID (can also be specified using '
|
||||
'ACOM_INVENTORY_ID environment variable)'),
|
||||
make_option('-i', '--inventory', dest='inventory_id', type='int',
|
||||
default=0, help='Inventory ID (can also be specified using'
|
||||
' ACOM_INVENTORY_ID environment variable)'),
|
||||
make_option('--list', action='store_true', dest='list', default=False,
|
||||
help='Return JSON hash of host groups.'),
|
||||
make_option('--host', dest='host', default='',
|
||||
@@ -75,7 +75,7 @@ class Command(NoArgsCommand):
|
||||
try:
|
||||
# Command line argument takes precedence over environment
|
||||
# variable.
|
||||
inventory_id = int(options.get('inventory', 0) or \
|
||||
inventory_id = int(options.get('inventory_id', 0) or \
|
||||
os.getenv('ACOM_INVENTORY_ID', 0))
|
||||
except ValueError:
|
||||
raise CommandError('Inventory ID must be an integer')
|
||||
|
||||
Reference in New Issue
Block a user