orchestrator-setup/resources/workflows/ccp_demo/test-methods.json

191 lines
5.9 KiB
JSON

{
"ownerApp" : "Cloud Computation Platform",
"name" : "ccp-test-method",
"createBy" : "Marco Lettere",
"description": "Common workflow for testing a method",
"version" : 2,
"ownerEmail" : "m.lettere@gmail.com",
"inputParameters" : ["runtime", "method", "runtime-endpoint", "instance-endpoint", "method-endpoint", "parameters"],
"tasks" : [
{
"name": "LAMBDA_TASK",
"taskReferenceName": "init",
"type": "LAMBDA",
"inputParameters": {
"resource-endpoint" : "http://localhost:8984/resources/methods",
"runtime" : "${workflow.input.runtime}",
"parameters" : "${workflow.input.parameters}",
"scriptExpression": "var instn = 'test-' + $.runtime + '-' + (Math.abs((Math.random() * 10e11)|0)); var p = $.parameters; p[\"instancename\"] = instn; return p"
}
},
{
"name" : "pyrest",
"taskReferenceName" : "create-instance",
"type" : "SIMPLE",
"inputParameters" : {
"url" : "${workflow.input.instance-endpoint}",
"method" : "POST",
"body" : { "name" : "${init.output.result.instancename}", "status" : "NONE", "runtime" : "${workflow.input.runtime}", "method" : "${workflow.input.method}"}
}
},
{
"name" : "fork-join",
"taskReferenceName" : "fetch-resources",
"type" : "FORK_JOIN",
"forkTasks" : [
[
{
"name" : "pyrest",
"taskReferenceName" : "fetch-runtime",
"type" : "SIMPLE",
"inputParameters" : {
"url" : "${workflow.input.runtime-endpoint}/${workflow.input.runtime}",
"accept" : "application/json",
"method" : "GET",
"headers" : {
"Accept" : "application/json"
}
}
}
],
[
{
"name" : "pyrest",
"taskReferenceName" : "fetch-method",
"type" : "SIMPLE",
"accept" : "application/json",
"inputParameters" : {
"url" : "${workflow.input.method-endpoint}/${workflow.input.method}",
"method" : "GET",
"headers" : {
"Accept" : "application/json"
}
}
}
]
]
},
{
"name" : "join",
"taskReferenceName" : "fetch-resources-join",
"type": "JOIN",
"joinOn" : ["fetch-runtime", "fetch-method"]
},
{
"name" : "pyrest",
"taskReferenceName" : "update-instance-status-deploying",
"type" : "SIMPLE",
"inputParameters" : {
"url" : "${workflow.input.instance-endpoint}/${create-instance.output.body.id}/status",
"method" : "PUT",
"body" : { "status" : "DEPLOYING"}
}
},
{
"name" : "pyexec",
"taskReferenceName" : "start-method-instance",
"type" : "SIMPLE",
"inputParameters" : {
"operation" : "Sequence",
"tasks" : [
{
"operation" : "Ansible",
"playbook" : "${fetch-runtime.output.body.provisioning.startscript}",
"extra_vars" : "${init.output.result}"
}
]
}
},
{
"name" : "pyexec",
"taskReferenceName" : "deploy-method-instance",
"type" : "SIMPLE",
"inputParameters" : {
"operation" : "Sequence",
"tasks" : [
{
"operation" : "Ansible",
"playbook" : "${fetch-method.output.body.deployscript}",
"extra_vars" : "${init.output.result}",
"gather_facts" : "no"
}
]
}
},
{
"name" : "pyrest",
"taskReferenceName" : "update-instance-status-executing",
"type" : "SIMPLE",
"inputParameters" : {
"url" : "${workflow.input.instance-endpoint}/${create-instance.output.body.id}/status",
"method" : "PUT",
"body" : { "status" : "EXECUTING"}
}
},
{
"name" : "pyexec",
"taskReferenceName" : "execute-method-instance",
"type" : "SIMPLE",
"inputParameters" : {
"operation" : "Ansible",
"playbook" : "${fetch-method.output.body.executescript}",
"extra_vars" : "${init.output.result}",
"gather_facts" : "no"
}
},
{
"name" : "pyrest",
"taskReferenceName" : "update-instance-status-executed",
"type" : "SIMPLE",
"inputParameters" : {
"url" : "${workflow.input.instance-endpoint}/${create-instance.output.body.id}/status",
"method" : "PUT",
"body" : { "status" : "EXECUTED"}
}
},
{
"name": "pyrest",
"type": "SIMPLE",
"taskReferenceName": "send-execution-output",
"inputParameters": {
"url": "${workflow.input.method-endpoint}/${workflow.input.method}/test-output",
"method": "POST",
"headers": {
"Content-Type": "text/plain"
},
"body": "OK: ${execute-method-instance.output.ok[*].result.stdout} ERRORS: ${execute-method-instance.output.failed[0].result.msg} + EXCP: ${execute-method-instance.output.failed[*].result.exception}"
}
},
{
"name" : "pyrest",
"taskReferenceName" : "update-instance-status-cleaning",
"type" : "SIMPLE",
"inputParameters" : {
"url" : "${workflow.input.instance-endpoint}/${create-instance.output.body.id}/status",
"method" : "PUT",
"body" : { "status" : "CLEANING"}
}
},
{
"name" : "pyexec",
"taskReferenceName" : "destroy-method-instance",
"type" : "SIMPLE",
"inputParameters" : {
"operation" : "Ansible",
"playbook" : "${fetch-runtime.output.body.provisioning.cleanscript}",
"extra_vars" : "${init.output.result}"
}
},
{
"name" : "pyrest",
"taskReferenceName" : "update-instance-status-completed",
"type" : "SIMPLE",
"inputParameters" : {
"url" : "${workflow.input.instance-endpoint}/${create-instance.output.body.id}/status",
"method" : "PUT",
"body" : { "status" : "COMPLETED"}
}
}
]
}