1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-31 23:51:09 +03:00

instantiate db with sample workflows

This commit is contained in:
Chris Meyers 2016-09-08 13:04:56 -04:00
parent 0e68481a85
commit cae48cfb77
4 changed files with 89 additions and 0 deletions

View File

@ -0,0 +1,41 @@
# AWX
from awx.main.models import (
WorkflowNode,
WorkflowJobTemplate,
WorkflowJob,
)
from awx.main.models.jobs import JobTemplate
def do_init_workflow(job_template_success, job_template_fail, job_template_never):
wfjt, created = WorkflowJobTemplate.objects.get_or_create(name="linear workflow")
wfjt.delete()
wfjt, created = WorkflowJobTemplate.objects.get_or_create(name="linear workflow")
print(wfjt.id)
WorkflowNode.objects.all().delete()
if created:
nodes_success = []
nodes_fail = []
nodes_never = []
for i in range(0, 2):
nodes_success.append(WorkflowNode.objects.create(workflow_job_template=wfjt, unified_job_template=job_template_success))
nodes_fail.append(WorkflowNode.objects.create(workflow_job_template=wfjt, unified_job_template=job_template_fail))
nodes_never.append(WorkflowNode.objects.create(workflow_job_template=wfjt, unified_job_template=job_template_never))
nodes_never.append(WorkflowNode.objects.create(workflow_job_template=wfjt, unified_job_template=job_template_never))
nodes_fail[1].delete()
nodes_success[0].success_nodes.add(nodes_fail[0])
nodes_success[0].failure_nodes.add(nodes_never[0])
nodes_fail[0].failure_nodes.add(nodes_success[1])
nodes_fail[0].success_nodes.add(nodes_never[1])
nodes_success[1].failure_nodes.add(nodes_never[2])
def do_init():
jt_success = JobTemplate.objects.get(id=5)
jt_fail= JobTemplate.objects.get(id=9)
jt_never= JobTemplate.objects.get(id=11)
do_init_workflow(jt_success, jt_fail, jt_never)
if __name__ == "__main__":
do_init()

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 8.2 KiB

View File

@ -0,0 +1,46 @@
# AWX
from awx.main.models import (
WorkflowNode,
WorkflowJobTemplate,
WorkflowJob,
)
from awx.main.models.jobs import JobTemplate
def do_init_workflow(job_template_success, job_template_fail, job_template_never, jts_parallel):
wfjt, created = WorkflowJobTemplate.objects.get_or_create(name="parallel workflow")
wfjt.delete()
wfjt, created = WorkflowJobTemplate.objects.get_or_create(name="parallel workflow")
print(wfjt.id)
WorkflowNode.objects.all().delete()
if created:
node_success = WorkflowNode.objects.create(workflow_job_template=wfjt, unified_job_template=job_template_success)
nodes_never = []
for x in range(0, 3):
nodes_never.append(WorkflowNode.objects.create(workflow_job_template=wfjt, unified_job_template=job_template_never))
nodes_parallel = []
for jt in jts_parallel:
nodes_parallel.append(WorkflowNode.objects.create(workflow_job_template=wfjt, unified_job_template=jt))
node_success.success_nodes.add(nodes_parallel[0])
node_success.success_nodes.add(nodes_parallel[1])
node_success.success_nodes.add(nodes_parallel[2])
# Add a failure node for each paralell node
for i, n in enumerate(nodes_parallel):
n.failure_nodes.add(nodes_never[i])
def do_init():
jt_success = JobTemplate.objects.get(id=5)
jt_fail= JobTemplate.objects.get(id=9)
jt_never= JobTemplate.objects.get(id=11)
jt_parallel = []
jt_parallel.append(JobTemplate.objects.get(id=16))
jt_parallel.append(JobTemplate.objects.get(id=17))
jt_parallel.append(JobTemplate.objects.get(id=18))
do_init_workflow(jt_success, jt_fail, jt_never, jt_parallel)
if __name__ == "__main__":
do_init()

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 8.6 KiB