@startuml
title Configure and deploy the control loop with TCA in DCAE
actor CLAMP_User
participant CLAMP
participant Policy
box "DCAE controller"
database Inventory
participant "Deployment-handler" as DH
control Cloudify
participant "dcaepolicy\n plugin in\n Cloudify" as dcaepolicyplugin
participant "k8s/docker\n plugin in\n Cloudify" as k8splugin
participant "Policy-handler" as PH
database "Consul-kv" as consul_kv
participant "Config-binding service" as CBS
end box
participant MSB
control "k8s or docker" as k8s
participant TCA_Instance
autonumber
note over CLAMP_User: Closed loop
hnote right CLAMP_User: decided to install TCA
CLAMP_User -> CLAMP : Configure thresholds\n of control loop
CLAMP_User -> CLAMP : Configure actions\n of control loop
activate CLAMP
CLAMP -> Policy : Create Configuration\n and Operational Policies
CLAMP -> Inventory : Get DCAE Service Id\n based on Distributed Parameters
group install TCA_Instance
CLAMP -> DH : **install** instance of TCA with **policy_id** as input\n PUT /dcae-deployments/<**deployment-id**>\n {"**serviceTypeId**":"86615fc1-aed9-4aa2-9e4b-abdaccbe63de",\n "**inputs**":{"dcae_service_location":<loc>,\n "dcae_target_type":<type>,\n "dcae_target_name":<target>,\n "**policy_id**":<policy_id>}}
group get blueprint
activate DH #lightgray
DH -> Inventory : make sure **do not have** the deployment for TCA_Instance\n GET /dcae-services/<**deployment-id**>
activate Inventory #lightgray
Inventory --> DH : 404 - deployment not found as expected
deactivate Inventory
DH -> Inventory : get **blueprint** for TCA by **serviceTypeId**\n GET /dcae-service-types/86615fc1-aed9-4aa2-9e4b-abdaccbe63de
activate Inventory #lightgray
Inventory --> DH : 200 - blueprint for TCA
deactivate Inventory
DH -> Inventory : **register** deployment for TCA_Instance\n PUT /dcae-services/<**deployment-id**>
activate Inventory #lightgray
Inventory --> DH : 200 - deployment registered
deactivate Inventory
end group get blueprint
group start installing TCA_Instance
DH -> Cloudify : upload **blueprint** for TCA\n PUT /api/v2.1/blueprints/<**deployment-id**>
activate Cloudify #lightgray
Cloudify --> DH : 200 - blueprint uploaded
deactivate Cloudify #lightgray
DH -> Cloudify : create deployment for TCA_Instance\n PUT /api/v2.1/deployments/<**deployment-id**>\n {"blueprint_id":<**deployment-id**>,\n "**inputs**":{"dcae_service_location":<loc>,\n "dcae_target_type":<type>,\n "dcae_target_name":<target>,\n "**policy_id**":<policy_id>}}
activate Cloudify #lightgray
Cloudify --> DH : 201 - deployment created
deactivate Cloudify #lightgray
DH -> Cloudify : start installing TCA_Instance\n POST /api/v2.1/executions\n {"deployment_id":<**deployment-id**>,\n "workflow_id":"install"}
activate Cloudify #lightyellow
Cloudify --> DH : 201 - {"status":"**pending**", ...,\n "id": <**execution_id**>}
DH -> Cloudify : check the status of execution\n GET /api/v2.1/executions/<**execution_id**>
activate Cloudify #lightgray
Cloudify --> DH : 200 - {"status":"**started**", ...,\n "id": <**execution_id**>}
deactivate Cloudify
end group start installing TCA_Instance
DH --> CLAMP : 202 - started installation: url to get status\n {"requestId":"fc3603d7-1c93-448e-988b-373a8c5d8b18",\n "links":{"self":"http://<deployment-handler-url>/dcae-deployments/<**deployment-id**>",\n "**status**":"http://<deployment-handler-url>/dcae-deployments/<**deployment-id**>/operation/<**execution_id**>"}}
deactivate DH
CLAMP -> CLAMP : sleep
newpage CLAMP polling for installation status
group CLAMP polling for installation status
CLAMP -> CLAMP : wake up
activate CLAMP #DarkSalmon
CLAMP -> DH : get status of installation\n http://<deployment-handler-url>/dcae-deployments/<**deployment-id**>/operation/<**execution_id**>
activate DH #DarkSalmon
DH -> Cloudify : get execution status\n GET /api/v2.1/executions/<**execution_id**>
activate Cloudify #DarkSalmon
Cloudify --> DH : 200 - {"status":"**started**", ...,\n "id": <**execution_id**>}
deactivate Cloudify
DH --> CLAMP : 200 - installation status: **processing**\n {"operationType":"install","status":"processing",\n "requestId":"c60a00cb-81db-402f-ae81-83791140a369",\n "links":{"self":"http://<deployment-handler-url>/dcae-deployments/<**deployment-id**>",\n "**status**":"http://<deployment-handler-url>/dcae-deployments/<**deployment-id**>/operation/<**execution_id**>"}}
deactivate DH
CLAMP -> CLAMP : sleep
deactivate CLAMP
end group
newpage get and gather policies and install TCA_Instance
group get policy by <policy_id>
create dcaepolicyplugin
Cloudify -> dcaepolicyplugin : on create node of type\n **dcae.nodes.policy**\n with <**policy_id**>\n from input as property value
activate Cloudify #lightblue
activate dcaepolicyplugin #lightblue
dcaepolicyplugin -> PH : get policy from policy-handler by <**policy_id**>\n GET /policy_latest/<**policy_id**>
activate PH #lightblue
PH -> MSB : pass to Policy - POST /getConfig \n {"policyName" = <**policy_id**>}
activate MSB #lightblue
MSB -> Policy : POST /getConfig {"policyName" = <**policy_id**>}
activate Policy #lightblue
Policy --> MSB : 200 - found policy-body [{"policyName": <**policy_id**>+".1.xml", "policyConfigStatus": "CONFIG_RETRIEVED", ..., "policyVersion": "1", "**config**": "{\"hello\":\"world !\"}"}]
deactivate Policy
MSB --> PH : 200 - pass on the found policy body
deactivate MSB
PH --> dcaepolicyplugin : 200 - {"policy_id": <**policy_id**>,\n "**policy_body**": {"policyName": <**policy_id**>+".1.xml",\n "policyConfigStatus": "CONFIG_RETRIEVED", ...,\n "policyVersion": "1", "**config**": {"hello": "world !"}}}
deactivate PH
dcaepolicyplugin --> Cloudify : success
deactivate dcaepolicyplugin
destroy dcaepolicyplugin
deactivate Cloudify
end group get policy
group gather policies and install TCA_Instance
create k8splugin
Cloudify -> k8splugin : on create node for TCA_Instance
activate Cloudify #lightblue
activate k8splugin #lightblue
k8splugin -> k8splugin: gather policies on TCA_Instance\n @Policies.gather_policies_to_node()
k8splugin -> consul_kv: store application_config for TCA_Instance\n under key=<**service_component_name**>
activate consul_kv #lightblue
consul_kv --> k8splugin: 200 OK
deactivate consul_kv
k8splugin -> consul_kv: store policies for TCA_Instance\n in folder=<**service_component_name**>:**policies**/\n @Policies.gather_policies_to_node() - PUT /v1/txn
activate consul_kv #lightblue
consul_kv --> k8splugin: 200 OK
deactivate consul_kv
k8splugin -> k8s: prepare deployment of TCA_Instance\n create_namespaced_deployment / {docker - create container} for TCA_Instance
activate k8s #lightblue
k8s --> k8splugin: 200 OK
deactivate k8s
k8splugin -> k8s: deploy TCA_Instance from <TCA-image>\n create_namespaced_service / {docker run <TCA-image>} - pass <**service_component_name**>
activate k8s #lightblue
create TCA_Instance
k8s -> TCA_Instance: deploys
activate TCA_Instance #lightyellow
k8s --> k8splugin: deployed TCA_Instance
deactivate k8s
k8splugin --> Cloudify : success
deactivate k8splugin
destroy k8splugin
deactivate Cloudify
deactivate Cloudify
end group gather policies and install
newpage starting TCA_Instance
group get config and policies
TCA_Instance -> CBS: get config and policies (**new API**):\n GET /service_component**_all**/<**service_component_name**>
activate TCA_Instance #darkorange
activate CBS #darkorange
CBS -> consul_kv: get all\n for <scn>\n PUT /v1/txn
activate consul_kv #darkorange
consul_kv --> CBS: 200 - config\n and policies
deactivate consul_kv
CBS --> TCA_Instance: 200 - config and policies\n {"**config**" : { … whatever the <CBS>/service_component/<scn> returns …},\n "**policies**" : {"items": [{"policyName": <**policy_id**>+".1.xml",\n "policyConfigStatus": "CONFIG_RETRIEVED", ...,\n "policyVersion": "1", "**config**": {"hello": "world !"}}],\n "event": {"action": "gathered", "policies_count": 1,\n "timestamp": "2018-02-12T10:20:30.777Z",\n "update_id": "0e79edc0-6c64-425e-a618-cc13ef50cd56"}}}
deactivate CBS
deactivate TCA_Instance
end group get config and policies
TCA_Instance -->]: run
group CLAMP polling for installation status
CLAMP -> CLAMP : wake up
activate CLAMP #DarkSalmon
CLAMP -> DH : get status of installation\n http://<deployment-handler-url>/dcae-deployments/<**deployment-id**>/operation/<**execution_id**>
activate DH #DarkSalmon
DH -> Cloudify : get execution status\n GET /api/v2.1/executions/<**execution_id**>
activate Cloudify #DarkSalmon
Cloudify --> DH : 200 - {"status":"**terminated**", ...,\n "id": <**execution_id**>}
deactivate Cloudify
DH --> CLAMP : 200 - installation status: **succeeded**\n {"operationType":"install","status":"**succeeded**",\n "requestId":"58dddc4c-0783-463c-9e23-2ae349e98ea7",\n "links":{"self":"http://<deployment-handler-url>/dcae-deployments/<deployment-id>",\n "status":"http://<deployment-handler-url>/dcae-deployments/<deployment-id>/operation/<execution_id>"}}
deactivate DH
deactivate CLAMP
end group
hnote over CLAMP: installed TCA
deactivate CLAMP
end group
@enduml |