mirror of
https://github.com/ansible/awx.git
synced 2024-11-01 08:21:15 +03:00
instantiate db with sample workflows
This commit is contained in:
parent
0e68481a85
commit
cae48cfb77
41
awx/main/tests/manual/workflows/linear.py
Normal file
41
awx/main/tests/manual/workflows/linear.py
Normal 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()
|
1
awx/main/tests/manual/workflows/linear.svg
Normal file
1
awx/main/tests/manual/workflows/linear.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 8.2 KiB |
46
awx/main/tests/manual/workflows/parallel.py
Normal file
46
awx/main/tests/manual/workflows/parallel.py
Normal 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()
|
1
awx/main/tests/manual/workflows/parallel.svg
Normal file
1
awx/main/tests/manual/workflows/parallel.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 8.6 KiB |
Loading…
Reference in New Issue
Block a user