8216819ac2553f771952131c3d6b970c01294869
[ccsdk/cds.git] / docs / modelingconcepts / workflow.rst
1 .. This work is a derivative of https://wiki.onap.org/display/DW/Modeling+Concepts#Concepts-100023263
2 .. This work is licensed under a Creative Commons Attribution 4.0
3 .. International License. http://creativecommons.org/licenses/by/4.0
4 .. Copyright (C) 2020 Deutsche Telekom AG.
5
6 .. _workflow:
7
8 Workflow
9 ---------
10
11 .. note::
12
13    **Workflow Scope within CDS Framework**
14
15    The workflow is within the scope of the micro provisioning and configuration 
16    management in **controller domain** and does NOT account for the MACRO service orchestration workflow which is covered by the SO Project. 
17
18 A workflow defines an overall action to be taken on the service, hence is an 
19 entry-point for the run-time execution of the :ref:`CBA Package <cba>`.
20
21 A workflow also defines **inputs** and **outputs** that will defined the **payload contract** 
22 of the **request** and **response** (see :ref:`Dynamic API`)
23
24 A workflow can be **composed** of one or multiple **sub-actions** to execute.
25
26 A CBA package can have as **many workflows** as needed.
27
28 .. _workflow_single_action:
29
30 Single action
31 **************
32
33 The workflow is directly backed by a component (see :ref:`node_type` -> Component).
34
35 In the example bellow, the target of the workflow's steps resource-assignment is ``resource-assignment`` 
36 which actually is the name of the ``node_template`` defined after, of type ``component-resource-resolution``.
37
38 `Link to example 
39 <https://github.com/onap/ccsdk-cds/blob/master/components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/golden-blueprint.json#L40-L71>`_
40
41
42 .. code-block:: json
43    :caption: **Example**
44
45       . . .
46    "topology_template": {
47       "workflows": {
48          "resource-assignment": {
49          "steps": {
50             "resource-assignment": {
51                "description": "Resource Assign Workflow",
52                "target": "resource-assignment"
53                ]
54             }
55          },
56          "inputs": {
57             "resource-assignment-properties": {
58                "description": "Dynamic PropertyDefinition for workflow(resource-assignment).",
59                "required": true,
60                "type": "dt-resource-assignment-properties"
61             }
62          },
63          "outputs": {
64             "meshed-template": {
65                "type": "json",
66                "value": {
67                "get_attribute": [
68                   "resource-assignment",
69                   "assignment-params"
70                ]
71                }
72             }
73          }
74          },
75       "node_templates": {
76          "resource-assignment": {
77          "type": "component-resource-resolution",
78          "interfaces": {
79             "ResourceResolutionComponent": {
80                "operations": {
81                "process": {
82                   "inputs": {
83                      "artifact-prefix-names": [
84                      "vf-module-1"
85                      ]
86                   }
87                }
88                }
89             }
90          },
91          "artifacts": {
92             "vf-module-1-template": {
93                "type": "artifact-template-velocity",
94                "file": "Templates/vf-module-1-template.vtl"
95             },
96             "vf-module-1-mapping": {
97                "type": "artifact-mapping-resource",
98                "file": "Templates/vf-module-1-mapping.json"
99             }
100          }
101          }
102       }
103    . . .
104
105 .. _workflow_multiple_actions:
106
107 Multiple sub-actions
108 **********************
109
110 The workflow is backed by a Directed Graph engine, dg-generic (see :ref:`node_type` -> DG, 
111 and is an **imperative** workflow.
112
113 A DG used as workflow for CDS is composed of multiple execute nodes; each individual 
114 execute node refers to an modelled Component (see :ref:`node_type` -> Component) instance.
115
116 In the example above, you can see the target of the workflow's steps execute-script is 
117 ``execute-remote-ansible-process``, which is a node_template of type ``dg_generic``
118
119 `Link of example 
120 <https://github.com/onap/ccsdk-cds/blob/master/components/model-catalog/blueprint-model/test-blueprint/remote_scripts/Definitions/remote_scripts.json#L184-L204>`_ 
121
122 .. code-block:: json
123    :caption: **workflow plan example**
124
125    . . .
126    "topology_template": {
127       "workflows": {
128          "execute-remote-ansible": {
129          "steps": {
130             "execute-script": {
131                "description": "Execute Remote Ansible Script",
132                "target": "execute-remote-ansible-process"
133                ]
134             }
135          },
136          "inputs": {
137             "ip": {
138                "required": false,
139                "type": "string"
140             },
141             "username": {
142                "required": false,
143                "type": "string"
144             },
145             "password": {
146                "required": false,
147                "type": "string"
148             },
149             "execute-remote-ansible-properties": {
150                "description": "Dynamic PropertyDefinition for workflow(execute-remote-ansible).",
151                "required": true,
152                "type": "dt-execute-remote-ansible-properties"
153             }
154          },
155          "outputs": {
156             "ansible-variable-resolution": {
157                "type": "json",
158                "value": {
159                "get_attribute": [
160                   "resolve-ansible-vars",
161                   "assignment-params"
162                ]
163                }
164             },
165             "prepare-environment-logs": {
166                "type": "string",
167                "value": {
168                "get_attribute": [
169                   "execute-remote-ansible",
170                   "prepare-environment-logs"
171                ]
172                }
173             },
174             "execute-command-logs": {
175                "type": "string",
176                "value": {
177                "get_attribute": [
178                   "execute-remote-ansible",
179                   "execute-command-logs"
180                ]
181                }
182             }
183          }
184          }
185       },
186       "node_templates": {
187          "execute-remote-ansible-process": {
188          "type": "dg-generic",
189          "properties": {
190             "content": {
191                "get_artifact": [
192                "SELF",
193                "dg-execute-remote-ansible-process"
194                ]
195             },
196             "dependency-node-templates": [
197                "resolve-ansible-vars",
198                "execute-remote-ansible"
199             ]
200          },
201          "artifacts": {
202             "dg-execute-remote-ansible-process": {
203                "type": "artifact-directed-graph",
204                "file": "Plans/CONFIG_ExecAnsiblePlaybook.xml"
205             }
206          }
207          }
208
209 Properties of a workflow
210 **************************
211
212 .. list-table::
213    :widths: 25 75
214    :header-rows: 1
215
216    * - Property
217      - Description
218    * - workflow-name
219      - Defines the name of the action that can be triggered by external system
220    * - inputs
221      - | They are two types of inputs, the dynamic ones, and the static one.
222        | 
223
224        .. tabs::
225           
226           .. tab:: static
227  
228              Specified at workflow level
229
230              * can be inputs for the Component(s), see the inputs section of the component of interest.
231              * represent inputs to derived custom logic within scripting
232
233              These will end up under ``${actionName}-request`` section of the payload (see Dynamic API)
234
235           .. tab:: dynamic
236  
237              Represent the resources defined as input (see :ref:`node_type` -> Source -> Input) 
238              within mapping definition files (see :ref:`artifact_type` -> Mapping).
239
240              The **enrichment process** will (see :ref:`enrichment`)
241
242              * dynamically gather all of them under a data-type, named ``dt-${actionName}-properties``
243              * will add it as a input of the workflow, as follow using this name: ``${actionName}-properties``
244
245              Example for workflow named `resource-assignment`:
246
247              .. code-block:: json
248                 :caption: **dynamic input**
249
250                 "resource-assignment-properties": {
251                 "required": true,
252                 "type": "dt-resource-assignment-properties"
253                 }
254    * - outputs
255      - | Defines the outputs of the execution; there can be as many output as needed.
256        | Depending on the Component (see :ref:`node_type` -> Component) of use, some attribute might be retrievable.
257
258        .. list-table::
259             :widths: 50 50
260             :header-rows: 1
261
262             * - type
263               - value
264             * - data type (complex / primitive)
265               - value resolvable using :ref:`expression` -> get_attribute
266    * - steps
267      - | Defines the actual step to execute as part of the workflow
268        | 
269        .. list-table::
270           :widths: 25 25 50
271           :header-rows: 1      
272           
273           * - step-name
274             - description
275             - target
276           * - name of the step
277             - step description
278             - | a node_template implementing on of the supported Node Type (see :ref:`node_type` -> DG), 
279                 either a Component or a DG
280               | (see :ref:`workflow_single_action` or :ref:`workflow_multiple_actions`)
281
282 Example:
283
284 .. code-block:: json
285    :caption: **workflow example**
286
287    {
288     "workflow": {
289        "resource-assignment": {                                <- workflow-name
290           "inputs": {
291           "vnf-id": {                                         <- static inputs
292              "required": true,
293              "type": "string"
294           },
295           "resource-assignment-properties": {                    <- dynamic inputs
296              "required": true,
297              "type": "dt-resource-assignment-properties"
298           }
299           },
300           "steps": {
301           "call-resource-assignment": {                       <- step-name
302              "description": "Resource Assignment Workflow",
303              "target": "resource-assignment-process"           <- node_template targeted by the step
304           }
305           },
306           "outputs": {
307           "template-properties": {                            <- output
308              "type": "json",                                   <- complex type
309              "value": {
310                 "get_attribute": [                              <- uses expression to retrieve attribute from context
311                 "resource-assignment",
312                 "assignment-params"
313                 ]
314              }
315           }
316           }
317        }
318     }
319    }
320
321 `TOSCA definition <http://docs.oasis-open.org/tosca/TOSCA-Simple-Profile-YAML/v1.2/csd01/TOSCA-Simple-Profile-YAML-v1.2-csd01.html#_Toc494454203>`_
322