Fix doc-rules job and cds-ui build
[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_payload`)
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       "topology_template": {
46         "workflows": {
47           "resource-assignment": {
48             "steps": {
49               "resource-assignment": {
50                 "description": "Resource Assign Workflow",
51                 "target": "resource-assignment"
52               }
53             }
54           },
55           "inputs": {
56             "resource-assignment-properties": {
57               "description": "Dynamic PropertyDefinition for workflow(resource-assignment).",
58               "required": true,
59               "type": "dt-resource-assignment-properties"
60             }
61           },
62           "outputs": {
63             "meshed-template": {
64               "type": "json",
65               "value": {
66                 "get_attribute": [
67                   "resource-assignment",
68                   "assignment-params"
69                 ]
70               }
71             }
72           }
73         },
74         "node_templates": {
75           "resource-assignment": {
76             "type": "component-resource-resolution",
77             "interfaces": {
78               "ResourceResolutionComponent": {
79                 "operations": {
80                   "process": {
81                     "inputs": {
82                       "artifact-prefix-names": [
83                         "vf-module-1"
84                       ]
85                     }
86                   }
87                 }
88               }
89             },
90             "artifacts": {
91               "vf-module-1-template": {
92                 "type": "artifact-template-velocity",
93                 "file": "Templates/vf-module-1-template.vtl"
94               },
95               "vf-module-1-mapping": {
96                 "type": "artifact-mapping-resource",
97                 "file": "Templates/vf-module-1-mapping.json"
98               }
99             }
100           }
101         }
102       }
103
104 .. _workflow_multiple_actions:
105
106 Multiple sub-actions
107 **********************
108
109 The workflow is backed by a Directed Graph engine, dg-generic (see :ref:`node_type` -> DG,
110 and is an **imperative** workflow.
111
112 A DG used as workflow for CDS is composed of multiple execute nodes; each individual
113 execute node refers to an modelled Component (see :ref:`node_type` -> Component) instance.
114
115 In the example above, you can see the target of the workflow's steps execute-script is
116 ``execute-remote-ansible-process``, which is a node_template of type ``dg_generic``
117
118 `Link of example
119 <https://github.com/onap/ccsdk-cds/blob/master/components/model-catalog/blueprint-model/test-blueprint/remote_scripts/Definitions/remote_scripts.json#L184-L204>`_
120
121 .. code-block:: json
122    :caption: **workflow plan example**
123
124     "topology_template": {
125       "workflows": {
126         "execute-remote-ansible": {
127           "steps": {
128             "execute-script": {
129               "description": "Execute Remote Ansible Script",
130               "target": "execute-remote-ansible-process"
131             }
132           }
133         },
134         "inputs": {
135           "ip": {
136             "required": false,
137             "type": "string"
138           },
139           "username": {
140             "required": false,
141             "type": "string"
142           },
143           "password": {
144             "required": false,
145             "type": "string"
146           },
147           "execute-remote-ansible-properties": {
148             "description": "Dynamic PropertyDefinition for workflow(execute-remote-ansible).",
149             "required": true,
150             "type": "dt-execute-remote-ansible-properties"
151           }
152         },
153         "outputs": {
154           "ansible-variable-resolution": {
155             "type": "json",
156             "value": {
157               "get_attribute": [
158                 "resolve-ansible-vars",
159                 "assignment-params"
160               ]
161             }
162           },
163           "prepare-environment-logs": {
164             "type": "string",
165             "value": {
166               "get_attribute": [
167                 "execute-remote-ansible",
168                 "prepare-environment-logs"
169               ]
170             }
171           },
172           "execute-command-logs": {
173             "type": "string",
174             "value": {
175               "get_attribute": [
176                 "execute-remote-ansible",
177                 "execute-command-logs"
178               ]
179             }
180           }
181         },
182         "node_templates": {
183           "execute-remote-ansible-process": {
184             "type": "dg-generic",
185             "properties": {
186               "content": {
187                 "get_artifact": [
188                   "SELF",
189                   "dg-execute-remote-ansible-process"
190                 ]
191               },
192               "dependency-node-templates": [
193                 "resolve-ansible-vars",
194                 "execute-remote-ansible"
195               ]
196             },
197             "artifacts": {
198               "dg-execute-remote-ansible-process": {
199                 "type": "artifact-directed-graph",
200                 "file": "Plans/CONFIG_ExecAnsiblePlaybook.xml"
201               }
202             }
203           }
204         }
205       }
206     }
207
208 Properties of a workflow
209 **************************
210
211 .. list-table::
212    :widths: 25 75
213    :header-rows: 1
214
215    * - Property
216      - Description
217    * - workflow-name
218      - Defines the name of the action that can be triggered by external system
219    * - inputs
220      - | They are two types of inputs, the dynamic ones, and the static one.
221        |
222
223        .. tabs::
224
225           .. tab:: static
226
227              Specified at workflow level
228
229              * can be inputs for the Component(s), see the inputs section of the component of interest.
230              * represent inputs to derived custom logic within scripting
231
232              These will end up under ``${actionName}-request`` section of the payload (see Dynamic API)
233
234           .. tab:: dynamic
235
236              Represent the resources defined as input (see :ref:`node_type` -> Source -> Input)
237              within mapping definition files (see :ref:`artifact_type` -> Mapping).
238
239              The **enrichment process** will (see :ref:`enrichment`)
240
241              * dynamically gather all of them under a data-type, named ``dt-${actionName}-properties``
242              * will add it as a input of the workflow, as follow using this name: ``${actionName}-properties``
243
244              Example for workflow named `resource-assignment`:
245
246              .. code-block:: json
247                 :caption: **dynamic input**
248
249                 "resource-assignment-properties": {
250                   "required": true,
251                   "type": "dt-resource-assignment-properties"
252                 }
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::
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