1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-31 15:21:13 +03:00

Merge pull request #2808 from wwitzel3/release_3.3.0

disable computed for create preload data mgmt cmd
This commit is contained in:
Shane McDonald 2018-08-09 10:14:52 -04:00 committed by GitHub
commit 61c21c5ac0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,6 +4,7 @@
from django.core.management.base import BaseCommand from django.core.management.base import BaseCommand
from crum import impersonate from crum import impersonate
from awx.main.models import User, Organization, Project, Inventory, CredentialType, Credential, Host, JobTemplate from awx.main.models import User, Organization, Project, Inventory, CredentialType, Credential, Host, JobTemplate
from awx.main.signals import disable_computed_fields
class Command(BaseCommand): class Command(BaseCommand):
@ -22,33 +23,34 @@ class Command(BaseCommand):
except IndexError: except IndexError:
superuser = None superuser = None
with impersonate(superuser): with impersonate(superuser):
o = Organization.objects.create(name='Default') with disable_computed_fields():
p = Project(name='Demo Project', o = Organization.objects.create(name='Default')
scm_type='git', p = Project(name='Demo Project',
scm_url='https://github.com/ansible/ansible-tower-samples', scm_type='git',
scm_update_on_launch=True, scm_url='https://github.com/ansible/ansible-tower-samples',
scm_update_cache_timeout=0, scm_update_on_launch=True,
organization=o) scm_update_cache_timeout=0,
p.save(skip_update=True) organization=o)
ssh_type = CredentialType.from_v1_kind('ssh') p.save(skip_update=True)
c = Credential.objects.create(credential_type=ssh_type, ssh_type = CredentialType.from_v1_kind('ssh')
name='Demo Credential', c = Credential.objects.create(credential_type=ssh_type,
inputs={ name='Demo Credential',
'username': superuser.username inputs={
}, 'username': superuser.username
created_by=superuser) },
c.admin_role.members.add(superuser) created_by=superuser)
i = Inventory.objects.create(name='Demo Inventory', c.admin_role.members.add(superuser)
organization=o, i = Inventory.objects.create(name='Demo Inventory',
created_by=superuser) organization=o,
Host.objects.create(name='localhost', created_by=superuser)
inventory=i, Host.objects.create(name='localhost',
variables="ansible_connection: local", inventory=i,
created_by=superuser) variables="ansible_connection: local",
jt = JobTemplate.objects.create(name='Demo Job Template', created_by=superuser)
playbook='hello_world.yml', jt = JobTemplate.objects.create(name='Demo Job Template',
project=p, playbook='hello_world.yml',
inventory=i) project=p,
jt.credentials.add(c) inventory=i)
jt.credentials.add(c)
print('Default organization added.') print('Default organization added.')
print('Demo Credential, Inventory, and Job Template added.') print('Demo Credential, Inventory, and Job Template added.')