2021-06-30 16:05:48 +02:00
|
|
|
{
|
|
|
|
"ownerApp" : "Orchestrator",
|
|
|
|
"name" : "add_all_system_services_to_vre",
|
|
|
|
"createBy" : "Marco Lettere",
|
|
|
|
"description": "All system services retrieved from the IS through IC Proxy are added as Member to a VRE",
|
|
|
|
"version" : 1,
|
|
|
|
"ownerEmail" : "marco.lettere@nubisware.com",
|
2021-06-30 18:39:36 +02:00
|
|
|
"inputParameters" : ["client_resource_id"],
|
2021-06-30 16:05:48 +02:00
|
|
|
"tasks" : [
|
|
|
|
{
|
2023-10-13 09:58:38 +02:00
|
|
|
"name": "INLINE_TASK",
|
2021-06-30 16:05:48 +02:00
|
|
|
"taskReferenceName": "init",
|
2023-10-13 09:58:38 +02:00
|
|
|
"type": "INLINE",
|
2021-06-30 16:05:48 +02:00
|
|
|
"inputParameters": {
|
|
|
|
"keycloak": "{{ keycloak }}/{{ keycloak_realm }}",
|
|
|
|
"keycloak_admin" : "{{ keycloak_admin }}/{{ keycloak_realm }}",
|
|
|
|
"iC_proxy" : "{{ ic_proxy }}",
|
2023-10-13 09:58:38 +02:00
|
|
|
"evaluatorType" : "javascript",
|
2021-06-30 16:05:48 +02:00
|
|
|
"scriptExpression": "1 == 1"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name" : "pyrest",
|
2021-06-30 16:37:40 +02:00
|
|
|
"taskReferenceName" : "authorize_on_realm",
|
2021-06-30 16:05:48 +02:00
|
|
|
"type" : "SIMPLE",
|
|
|
|
"inputParameters" : {
|
2021-06-30 16:37:40 +02:00
|
|
|
"url" : "{{ keycloak }}/{{ keycloak_realm }}/protocol/openid-connect/token",
|
2021-06-30 16:05:48 +02:00
|
|
|
"method" : "POST",
|
|
|
|
"headers" : {
|
|
|
|
"Accept" : "application/json"
|
|
|
|
},
|
|
|
|
"body" : {
|
|
|
|
"client_id" : "orchestrator",
|
2021-06-30 16:37:40 +02:00
|
|
|
"client_secret" : "{{ keycloak_auth }}",
|
2021-06-30 16:05:48 +02:00
|
|
|
"grant_type" : "client_credentials"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2021-06-30 17:24:51 +02:00
|
|
|
{
|
|
|
|
"name" : "pyrest",
|
|
|
|
"taskReferenceName" : "authorize_with_uma_rpt",
|
|
|
|
"type" : "SIMPLE",
|
|
|
|
"inputParameters" : {
|
|
|
|
"url" : "{{ keycloak }}/{{ keycloak_realm }}/protocol/openid-connect/token",
|
|
|
|
"method" : "POST",
|
|
|
|
"headers" : {
|
2021-06-30 17:26:58 +02:00
|
|
|
"Accept" : "application/json",
|
|
|
|
"Authorization" : "Bearer ${authorize_on_realm.output.body.access_token}"
|
2021-06-30 17:24:51 +02:00
|
|
|
},
|
|
|
|
"body" : {
|
|
|
|
"audience" : "{{ root_vo }}",
|
|
|
|
"grant_type" : "urn:ietf:params:oauth:grant-type:uma-ticket"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2021-06-30 16:05:48 +02:00
|
|
|
{
|
|
|
|
"name" : "pyrest",
|
2021-06-30 18:48:49 +02:00
|
|
|
"taskReferenceName" : "retrieve_system_services",
|
2021-06-30 16:05:48 +02:00
|
|
|
"type" : "SIMPLE",
|
|
|
|
"inputParameters" : {
|
|
|
|
"url" : "{{ ic_proxy }}/icproxy/gcube/service/ServiceEndpoint/SystemService",
|
|
|
|
"method" : "GET",
|
|
|
|
"headers" : {
|
2021-06-30 16:22:22 +02:00
|
|
|
"Accept" : "application/xml",
|
2021-06-30 17:24:51 +02:00
|
|
|
"Authorization" : "Bearer ${authorize_with_uma_rpt.output.body.access_token}"
|
2021-06-30 16:05:48 +02:00
|
|
|
}
|
|
|
|
}
|
2021-06-30 16:37:40 +02:00
|
|
|
},
|
2021-06-30 17:42:22 +02:00
|
|
|
{
|
|
|
|
"name" : "pyeval",
|
2021-06-30 18:45:01 +02:00
|
|
|
"taskReferenceName" : "extract_system_service_names",
|
2021-06-30 17:42:22 +02:00
|
|
|
"type" : "SIMPLE",
|
|
|
|
"inputParameters" : {
|
2021-06-30 18:12:12 +02:00
|
|
|
"code" : "exec('import xml.etree.ElementTree as ET') or list(map(lambda n: n.text, ET.fromstring(data['xmlstring']).findall('Resource/Profile/Name')))",
|
2021-06-30 17:42:22 +02:00
|
|
|
"xmlstring" : "${retrieve_system_services.output.body}"
|
|
|
|
}
|
|
|
|
},
|
2021-06-30 16:37:40 +02:00
|
|
|
{
|
|
|
|
"name" : "pyrest",
|
|
|
|
"taskReferenceName" : "authorize",
|
|
|
|
"type" : "SIMPLE",
|
|
|
|
"inputParameters" : {
|
|
|
|
"url" : "{{ keycloak }}/master/protocol/openid-connect/token",
|
|
|
|
"method" : "POST",
|
|
|
|
"headers" : {
|
|
|
|
"Accept" : "application/json"
|
|
|
|
},
|
|
|
|
"body" : {
|
|
|
|
"client_id" : "orchestrator",
|
|
|
|
"client_secret" : "{{ keycloak_auth_master }}",
|
|
|
|
"grant_type" : "client_credentials"
|
|
|
|
}
|
|
|
|
}
|
2021-06-30 18:39:36 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"name" : "pyrest",
|
|
|
|
"taskReferenceName" : "get_vre",
|
|
|
|
"type" : "SIMPLE",
|
|
|
|
"inputParameters" : {
|
|
|
|
"url" : "${init.input.keycloak_admin}/clients/${workflow.input.client_resource_id}",
|
|
|
|
"method" : "GET",
|
|
|
|
"headers" : {
|
|
|
|
"Authorization" : "Bearer ${authorize.output.body.access_token}",
|
|
|
|
"Accept" : "application/json"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2023-10-13 09:58:38 +02:00
|
|
|
"name": "INLINE_TASK",
|
2021-06-30 18:39:36 +02:00
|
|
|
"taskReferenceName": "build_get_system_services_tasks",
|
2023-10-13 09:58:38 +02:00
|
|
|
"type": "INLINE",
|
2021-06-30 18:39:36 +02:00
|
|
|
"inputParameters": {
|
2021-06-30 19:05:37 +02:00
|
|
|
"url" : "${init.input.keycloak_admin}/clients?search=true&clientId=",
|
2021-06-30 18:45:01 +02:00
|
|
|
"services" : "${extract_system_service_names.output.result}",
|
2023-10-13 09:58:38 +02:00
|
|
|
"evaluatorType" : "javascript",
|
|
|
|
"expression": "inputs = {}, tasks = [];function f(){for (var i = 0; i < $.services.length; i++){s = $.services[i];tasks.push({name: 'pyrest',type: 'SIMPLE',taskReferenceName: 'get_system_service' + i});inputs['get_system_service' + i] = {url: $.url + s,method: 'GET',headers: {Authorization: 'Bearer ${authorize.output.body.access_token}', Accept: 'application/json'}}};return {tasks: Java.to(tasks, 'java.util.Map[]'),inputs: inputs};} f()"
|
2021-06-30 18:39:36 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name" : "fork_dynamic",
|
|
|
|
"type" : "FORK_JOIN_DYNAMIC",
|
|
|
|
"taskReferenceName" : "parallel_get_system_services_tasks",
|
|
|
|
"inputParameters" : {
|
|
|
|
"tasks" : "${build_get_system_services_tasks.output.result.tasks}",
|
|
|
|
"inputs" : "${build_get_system_services_tasks.output.result.inputs}"
|
|
|
|
},
|
|
|
|
"dynamicForkTasksParam": "tasks",
|
|
|
|
"dynamicForkTasksInputParamName": "inputs"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name" : "join",
|
|
|
|
"type" : "JOIN",
|
2021-07-01 11:19:07 +02:00
|
|
|
"taskReferenceName" : "join_parallel_get_system_services_tasks"
|
2021-07-01 10:24:47 +02:00
|
|
|
},
|
|
|
|
{
|
2023-10-13 09:58:38 +02:00
|
|
|
"name": "INLINE_TASK",
|
2021-07-01 10:24:47 +02:00
|
|
|
"taskReferenceName": "build_get_system_services_useraccount_tasks",
|
2023-10-13 09:58:38 +02:00
|
|
|
"type": "INLINE",
|
2021-07-01 10:24:47 +02:00
|
|
|
"inputParameters": {
|
2023-10-13 09:58:38 +02:00
|
|
|
"evaluatorType" : "javascript",
|
2021-07-01 10:41:15 +02:00
|
|
|
"url" : "${init.input.keycloak_admin}/clients",
|
2021-07-01 11:19:07 +02:00
|
|
|
"services" : "${join_parallel_get_system_services_tasks.output..body.*.id}",
|
2023-10-13 09:58:38 +02:00
|
|
|
"scriptExpression": "inputs = {}, tasks = [];function f(){for (var i = 0; i < $.services.length; i++){s = $.services[i];tasks.push({name: 'pyrest',type: 'SIMPLE',taskReferenceName: 'get_system_service_useraccount' + i});inputs['get_system_service_useraccount' + i] = {url: $.url + '/' + s + '/service-account-user',method: 'GET',headers: {Authorization: 'Bearer ${authorize.output.body.access_token}', Accept: 'application/json'}}};return {tasks: Java.to(tasks, 'java.util.Map[]'),inputs: inputs};"
|
2021-07-01 10:24:47 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name" : "fork_dynamic",
|
|
|
|
"type" : "FORK_JOIN_DYNAMIC",
|
|
|
|
"taskReferenceName" : "parallel_get_system_services_useraccount_tasks",
|
|
|
|
"inputParameters" : {
|
|
|
|
"tasks" : "${build_get_system_services_useraccount_tasks.output.result.tasks}",
|
|
|
|
"inputs" : "${build_get_system_services_useraccount_tasks.output.result.inputs}"
|
|
|
|
},
|
|
|
|
"dynamicForkTasksParam": "tasks",
|
|
|
|
"dynamicForkTasksInputParamName": "inputs"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name" : "join",
|
|
|
|
"type" : "JOIN",
|
2021-07-01 10:29:04 +02:00
|
|
|
"taskReferenceName" : "join_parallel_get_system_services_useraccount_tasks"
|
2021-07-01 11:16:55 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "LAMBDA_TASK",
|
|
|
|
"taskReferenceName": "build_member_roles_assignment_tasks",
|
|
|
|
"type": "LAMBDA",
|
|
|
|
"inputParameters": {
|
|
|
|
"context" : "${get_vre.output.body}",
|
2021-07-01 11:25:38 +02:00
|
|
|
"service_ids" : "${join_parallel_get_system_services_useraccount_tasks.output..body.id}",
|
2023-10-13 09:58:38 +02:00
|
|
|
"evaluatorType" : "javascript",
|
|
|
|
"expression": "inputs={},tasks=[];for(var i=0;i<$.service_ids.length;i++)c=$.context,tasks.push({name:'sub_workflow_task',type:'SUB_WORKFLOW',taskReferenceName:'call_add_all_member_roles_'+i, subWorkflowParam:{ name:'add_all_member_roles'}}),inputs['call_add_all_member_roles_'+i]={context:c, client:$.service_ids[i]};return {tasks:Java.to(tasks,'java.util.Map[]'),inputs:inputs};} f()"
|
2021-07-01 11:16:55 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name" : "fork_dynamic",
|
|
|
|
"type" : "FORK_JOIN_DYNAMIC",
|
|
|
|
"taskReferenceName" : "parallel_build_member_roles_assignment_tasks",
|
|
|
|
"inputParameters" : {
|
|
|
|
"tasks" : "${build_member_roles_assignment_tasks.output.result.tasks}",
|
|
|
|
"inputs" : "${build_member_roles_assignment_tasks.output.result.inputs}"
|
|
|
|
},
|
|
|
|
"dynamicForkTasksParam": "tasks",
|
|
|
|
"dynamicForkTasksInputParamName": "inputs"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name" : "join",
|
|
|
|
"type" : "JOIN",
|
|
|
|
"taskReferenceName" : "join_parallel_build_member_roles_assignment_tasks"
|
2021-06-30 16:38:39 +02:00
|
|
|
}
|
2021-06-30 16:05:48 +02:00
|
|
|
]
|
|
|
|
}
|