Numerous model-related updates and supporing changes, including:

- Add variables field on Host/Group models and remove separate VariableData model.
- Add data migrations for existing variable data.
- Update views, serializers and tests to keep roughly the same API interface for variable data.
- Add has_active_failures properties on Group/Host models to provide indication of last job status.
- Add job_tags field on JobTemplate/Job models to specify tags to ansible-playbook.
- Add host_config_key field to JobTemplate model for use by empheral hosts.
- Add job_args, job_cwd and job_env fields to Job model to capture more info from running the job.
- Add failed flag on JobHostSummary model.
- Add play/task fields on JobEvent model to capture new context variables from callback.
- Add parent field on JobEvent model to capture hierarchy of job events.
- Add hosts field on JobEvent model to capture all hosts associated with the event (especially useful for parent events in the hierarchy).
- Removed existing Tag model, replace with django-taggit instead.
- Removed existing AuditLog model, replacement TBD.
This commit is contained in:
Chris Church
2013-06-10 17:21:04 -04:00
parent 7b0bbff376
commit cba55a061a
24 changed files with 1924 additions and 498 deletions

View File

@@ -8,6 +8,7 @@ from optparse import make_option
import os
import sys
from django.core.management.base import NoArgsCommand, CommandError
from django.db import transaction
class Command(NoArgsCommand):
'''
@@ -30,12 +31,13 @@ class Command(NoArgsCommand):
help='JSON-formatted callback event data'),
)
@transaction.commit_on_success
def handle_noargs(self, **options):
from ansibleworks.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 JobEvent.EVENT_TYPES]:
if event_type not in [x[0] for x in JobEvent.EVENT_CHOICES]:
raise CommandError('Unsupported event')
event_data_file = options.get('event_data_file', None)
event_data_json = options.get('event_data_json', None)

View File

@@ -32,8 +32,8 @@ class Command(NoArgsCommand):
'hosts': list(group.hosts.values_list('name', flat=True)),
'children': list(group.children.values_list('name', flat=True)),
}
if group.variable_data is not None:
group_info['vars'] = json.loads(group.variable_data.data)
if group.variables:
group_info['vars'] = group.variables_dict
group_info = dict(filter(lambda x: bool(x[1]), group_info.items()))
if group_info.keys() in ([], ['hosts']):
@@ -51,8 +51,8 @@ class Command(NoArgsCommand):
except Host.DoesNotExist:
raise CommandError('Host %s not found in the given inventory' % hostname)
hostvars = {}
if host.variable_data is not None:
hostvars = json.loads(host.variable_data.data)
if host.variables:
hostvars = host.variables_dict
self.stdout.write(json.dumps(hostvars, indent=indent))
def handle_noargs(self, **options):