Added workflows for ccp_demo

master
dcore94 4 years ago
parent 1580912117
commit 4f168491d0

@ -0,0 +1,89 @@
{
"ownerApp" : "Cloud Computation Platform",
"name" : "ccp_build_runtime",
"createBy" : "Marco Lettere",
"description": "Build a runtime to be used in the gCube Cloud Computation Platform",
"version" : 10,
"ownerEmail" : "m.lettere@gmail.com",
"inputParameters" : ["runtime", "runtime-descriptor-endpoint", "runtime-status-endpoint"],
"tasks" : [
{
"name": "LAMBDA_TASK",
"taskReferenceName": "init",
"type": "LAMBDA",
"inputParameters": {
"descriptor_url" : "${workflow.input.runtime-descriptor-endpoint}",
"scriptExpression": "1"
}
},
{
"name" : "pyrest",
"taskReferenceName" : "update_status_building",
"type" : "SIMPLE",
"inputParameters" : {
"url" : "${workflow.input.runtime-status-endpoint}",
"method" : "put",
"body" : { "status" : "BUILDING"}
}
},
{
"name" : "pyexec",
"taskReferenceName" : "fetch_descriptor_and_build",
"type" : "SIMPLE",
"inputParameters" : {
"operation" : "Shell",
"commands" : [
{ "line" : "curl ${init.input.descriptor_url} -o /tmp/runtime${workflow.input.runtime}.json"},
{ "line" : "sudo packer build /tmp/runtime${workflow.input.runtime}.json"}
]
}
},
{
"name": "decide_task",
"taskReferenceName": "decide1",
"inputParameters": {
"case_value_param": "${fetch_descriptor_and_build.output.status}"
},
"type": "DECISION",
"caseValueParam": "case_value_param",
"defaultCase" : [
{
"name" : "pyrest",
"taskReferenceName" : "update_status_ready",
"type" : "SIMPLE",
"inputParameters" : {
"url" : "${workflow.input.runtime-status-endpoint}",
"method" : "put",
"body" : { "status" : "NONE"}
}
}
],
"decisionCases": {
"COMPLETED": [
{
"name" : "pyrest",
"taskReferenceName" : "update_status_ready",
"type" : "SIMPLE",
"inputParameters" : {
"url" : "${workflow.input.runtime-status-endpoint}",
"method" : "put",
"body" : { "status" : "READY"}
}
}
],
"FAILED": [
{
"name" : "pyrest",
"taskReferenceName" : "update_status_failed",
"type" : "SIMPLE",
"inputParameters" : {
"url" : "${workflow.input.runtime-status-endpoint}",
"method" : "put",
"body" : { "status" : "FAILED"}
}
}
]
}
}
]
}

@ -0,0 +1,87 @@
{
"ownerApp" : "Cloud Computation Platform",
"name" : "ccp-clean-instance",
"createBy" : "Marco Lettere",
"description": "Common workflow for cleaning an instance",
"version" : 1,
"ownerEmail" : "m.lettere@gmail.com",
"inputParameters" : ["runtime-endpoint", "instance", "instance-endpoint"],
"tasks" : [
{
"name" : "pyrest",
"taskReferenceName" : "fetch-instance",
"type" : "SIMPLE",
"accept" : "application/json",
"inputParameters" : {
"url" : "${workflow.input.instance-endpoint}/${workflow.input.instance}",
"method" : "GET",
"headers" : {
"Accept" : "application/json"
}
}
},
{
"name": "LAMBDA_TASK",
"taskReferenceName": "init",
"type": "LAMBDA",
"inputParameters": {
"runtime" : "${workflow.input.runtime}",
"instancename" : "${fetch-instance.output.body.name}",
"scriptExpression": " return { 'instancename' : $.instancename}"
}
},
{
"name" : "pyrest",
"taskReferenceName" : "fetch-runtime",
"type" : "SIMPLE",
"inputParameters" : {
"url" : "${workflow.input.runtime-endpoint}/${fetch-instance.output.body.runtime}",
"accept" : "application/json",
"method" : "GET",
"headers" : {
"Accept" : "application/json"
}
}
},
{
"name" : "pyexec",
"taskReferenceName" : "extract-destroy-playbook",
"type" : "SIMPLE",
"inputParameters" : {
"operation" : "Write",
"path" : "/tmp/destroy-playbook.yml",
"content" : "${fetch-runtime.output.body.provisioning.cleanscript}"
}
},
{
"name" : "pyrest",
"taskReferenceName" : "update-instance-status-cleaning",
"type" : "SIMPLE",
"inputParameters" : {
"url" : "${workflow.input.instance-endpoint}/${fetch-instance.output.body.id}/status",
"method" : "PUT",
"body" : { "status" : "CLEANING"}
}
},
{
"name" : "pyexec",
"taskReferenceName" : "destroy-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}/${fetch-instance.output.body.id}/status",
"method" : "PUT",
"body" : { "status" : "COMPLETED"}
}
}
]
}

@ -0,0 +1,54 @@
{
"ownerApp" : "Cloud Computation Platform",
"name" : "ccp-deploy-method",
"createBy" : "Marco Lettere",
"description": "Common workflow for cleaning an instance",
"version" : 1,
"ownerEmail" : "m.lettere@gmail.com",
"inputParameters" : ["method", "method-endpoint", "instance", "instance-endpoint"],
"tasks" : [
{
"name" : "pyrest",
"taskReferenceName" : "update-instance-status-deploying",
"type" : "SIMPLE",
"inputParameters" : {
"url" : "${workflow.input.instance-endpoint}/${workflow.input.instance}/status",
"method" : "PUT",
"body" : { "status" : "DEPLOYING"}
}
},
{
"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" : "pyexec",
"taskReferenceName" : "deploy-method-instance",
"type" : "SIMPLE",
"inputParameters" : {
"operation" : "Ansible",
"playbook" : "${fetch-method.output.body.deployscript}",
"extra_vars" : "${workflow.input}"
}
},
{
"name" : "pyrest",
"taskReferenceName" : "update-instance-status-deployed",
"type" : "SIMPLE",
"inputParameters" : {
"url" : "${workflow.input.instance-endpoint}/${workflow.input.instance}/status",
"method" : "PUT",
"body" : { "status" : "DEPLOYED"}
}
}
]
}

@ -0,0 +1,74 @@
{
"ownerApp" : "Cloud Computation Platform",
"name" : "ccp-launch-runtime",
"createBy" : "Marco Lettere",
"description": "Common workflow for launching a runtime",
"version" : 1,
"ownerEmail" : "m.lettere@gmail.com",
"inputParameters" : ["runtime", "runtime-endpoint", "instance-name", "instance-endpoint"],
"tasks" : [
{
"name": "LAMBDA_TASK",
"taskReferenceName": "init",
"type": "LAMBDA",
"inputParameters": {
"runtime" : "${workflow.input.runtime}",
"instancename" : "${workflow.input.instance-name}",
"scriptExpression": "var instname = ($.instancename != null ? $.instancename : 'auto-' + $.runtime + '-' + (Math.abs((Math.random() * 10e11)|0))); return { 'instancename' : instname}"
}
},
{
"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" : "none"}
}
},
{
"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" : "pyexec",
"taskReferenceName" : "extract-start-playbook",
"type" : "SIMPLE",
"inputParameters" : {
"operation" : "Write",
"path" : "/tmp/start-playbook.yml",
"content" : "${fetch-runtime.output.body.provisioning.startscript}"
}
},
{
"name" : "pyexec",
"taskReferenceName" : "start-instance",
"type" : "SIMPLE",
"inputParameters" : {
"operation" : "Ansible",
"playbook" : "${fetch-runtime.output.body.provisioning.startscript}",
"extra_vars" : "${init.output.result}"
}
},
{
"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"}
}
}
]
}

@ -0,0 +1,190 @@
{
"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"}
}
}
]
}

@ -9,6 +9,8 @@ done
echo 'Contact ... starting upload'
# IAM
curl -s -o /dev/null -w "%{http_code}\n" -X POST -H 'Content-Type: application/json' -d @/var/resources/tasks/pytasks.json $BASE/metadata/taskdefs
curl -s -o /dev/null -w "%{http_code}\n" -X POST -H 'Content-Type: application/json' -d @/var/resources/workflows/portal/user-group-role_created.json $BASE/metadata/workflow
@ -26,3 +28,14 @@ curl -s -o /dev/null -w "%{http_code}\n" -X POST -H 'Content-Type: application/j
curl -s -o /dev/null -w "%{http_code}\n" -X POST -H 'Content-Type: application/json' -d @/var/resources/workflows/portal/invitation-accepted.json $BASE/metadata/workflow
curl -s -o /dev/null -w "%{http_code}\n" -X POST -H 'Content-Type: application/json' -d @/var/resources/workflows/portal/create-user-add-to-vre.json $BASE/metadata/workflow
# CCP
curl -s -o /dev/null -w "%{http_code}\n" -X POST -H 'Content-Type: application/json' -d @/var/resources/workflows/ccp_demo/build-runtimes.json $BASE/metadata/workflow
curl -s -o /dev/null -w "%{http_code}\n" -X POST -H 'Content-Type: application/json' -d @/var/resources/workflows/ccp_demo/launch-runtimes.json $BASE/metadata/workflow
curl -s -o /dev/null -w "%{http_code}\n" -X POST -H 'Content-Type: application/json' -d @/var/resources/workflows/ccp_demo/clean-instances.json $BASE/metadata/workflow
curl -s -o /dev/null -w "%{http_code}\n" -X POST -H 'Content-Type: application/json' -d @/var/resources/workflows/ccp_demo/deploy-methods.json $BASE/metadata/workflow
curl -s -o /dev/null -w "%{http_code}\n" -X POST -H 'Content-Type: application/json' -d @/var/resources/workflows/ccp_demo/test-methods.json $BASE/metadata/workflow

Loading…
Cancel
Save