1 .. This work is licensed under a Creative Commons Attribution 4.0 International License.
2 .. http://creativecommons.org/licenses/by/4.0
3 .. Copyright (C) 2019 IBM.
5 .. _hello_world_script_executor_cba:
7 How to create a “Hello World” Package with CDS Designer UI? The Script Executor Type
8 ====================================================================================
14 **How to Get Started with CDS Designer UI**
16 If you’re new to CDS Designer UI and need to get set up, the following guides may be helpful:
18 - :ref:`running_cds_ui_locally`
19 - :ref:`designer_guide`
24 In order to see the latest version described below in the tutorial, we will need to use the latest cds-ui-server docker image:
25 nexus3.onap.org:10001/onap/ccsdk-cds-ui-server:1.1.0-STAGING-latest
28 Create New CBA Package
29 ~~~~~~~~~~~~~~~~~~~~~~
31 In the Package List, click on the **Create Package** button.
35 Define Package MetaData
36 ~~~~~~~~~~~~~~~~~~~~~~~
40 1. Package name (Required), type **"Hello-world-package-kotlin"**
41 2. Package version (Required), type **"1.0.0"**
42 3. Package description (Required), type **"just description"**
43 4. Package Tags (Required), type **"kotlin"** then use the **Enter** key on the keyboard
44 5. In the Custom Key section, add Key name **"template_type"** and
45 6. For Key Value **"DEFAULT"**
49 Once you enter all fields you will be able to save your package. Click on the **Save** button and continue to define your package.
58 1. Click on the **Create Script** button
62 In the **Create Script File** modal:
66 1. Enter script file name **"Test"**
67 2. Choose the script type **"Kotlin"**
68 3. Type or copy and paste the below script in the code editor
70 .. code-block:: kotlin
73 \* Copyright © 2020, Orange
75 \* Licensed under the Apache License, Version 2.0 (the "License");
76 \* you may not use this file except in compliance with the License.
77 \* You may obtain a copy of the License at
79 \* http://www.apache.org/licenses/LICENSE-2.0
81 \* Unless required by applicable law or agreed to in writing, software
82 \* distributed under the License is distributed on an "AS IS" BASIS,
83 \* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
84 \* See the License for the specific language governing permissions and
85 \* limitations under the License.
88 package org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts
90 import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
91 import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractScriptComponentFunction
92 import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.ComponentRemoteScriptExecutor
93 import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
94 import org.slf4j.LoggerFactory
96 open class HelloWorld : AbstractScriptComponentFunction() {
97 private val log = LoggerFactory.getLogger(HelloWorld::class.java)!!
99 override fun getName(): String {
103 override suspend fun processNB(executionRequest: ExecutionServiceInput) {
104 log.info("executing hello world script ")
105 val username = getDynamicProperties("username").asText()
106 log.info("username : $username")
107 //executionRequest.payload.put("Action1-response","hello from $username")
108 setAttribute("response-data", "Hello, $username".asJsonPrimitive())
111 override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
112 log.info("Executing Recovery")
113 bluePrintRuntimeService.getBluePrintError().addError("${runtimeException.message}")
117 4. Click on the **Create Script** button to save the script file
121 Now, you can view and edit your script file.
125 After the new script is added to the **scripts list**, click on the **Save** button to save the package updates.
129 Define DSL Properties
130 ~~~~~~~~~~~~~~~~~~~~~
132 In the DSL PROPERTIES Tab:
134 1. Copy and paste the below DSL definition
139 "Action1-properties": {
141 "get_input": "username"
148 Then click on the **Save** button to update the package.
155 From the Package information box on top, click on the **Designer Mode** button.
159 Click on the **Skip to Designer Canvas** button to go directly to Designer Mode.
163 Now the designer has zero action added. Let's start adding the first Action.
167 Go to the left side of the designer screen and in the **ACTIONS tab**, click on the **+ New Action** button.
171 Now, the first Action **Action1** is added to the **Actions list** and in the **Workflow canvas**.
175 Add Script Executor Function To The Action
176 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
178 On the left side of the designer screen, Click on the **FUNCTIONS tab** to view all the **Functions List.**
182 **Drag** the function type **"component-script-executor"**
186 **Drop** the function to the **"Action1"** Action container.
190 Define Action Attributes
191 ~~~~~~~~~~~~~~~~~~~~~~~~
193 Click on **Action1** from the ACTIONS tab to open **the ACTION ATTRIBUTES** section on designer screens’ right side.
197 Let's customize the first action's attribute by click on the **+ Create Custom** button to open **Add Custom Attributes** modal window.
201 In the **Add Custom Attributes** **Window**, and the **INPUTS tab** starts to add the first input attribute for **Action1**.
202 **INPUTS Tab:** Enter the required properties for the inputs’ attribute:
204 1. Name: **"username"**
206 3. Attribute type name: **"dt-resource-assignment-properties"**
207 4. Required: **"True"**
211 After you add the **username** input's attribute, click on In the OUTPUT Tab to create the output attribute too.
215 **OUTPUTS Tab:** Enter the required properties for the output’ attribute:
217 1. Name: **"hello-world-output"**
218 2. Required: **"True"**
220 4. Type name: **"json"**
221 5. Value (get_attribute): From the **Functions list**, select **"component-script-executor"** that will show all attributes included in this function
222 6. Select parameter name **"response-data"**
223 7. Click on the **Submit Attributes** button to add input and output attributes to **Actions' Attributes list**
224 8. Click on the **Close** button to close the modal window and go back to the designer screen.
228 Now, you can see all the added attributes listed in the **ACTION ATTRIBUTES** area.
232 Define Function Attributes
233 ~~~~~~~~~~~~~~~~~~~~~~~~~~
235 From **ACTIONS** List, Click on the function nam **"component-script-executor"**.
239 When you click on the **component-script-executor** function, the **FUNCTION ATTRIBUTES** section will be open on the right side of the designers' screen.
240 Now, you need to add the values of **Inputs** required attributes in **the Interfaces** **section**.
244 1. **script-type:** **"kotlin"**
245 2. **script-class-reference: "org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts.HelloWorld"**
246 3. Add optional attribute by click on **Add Optional Attributes** button, add **"dynamic-properties"** then enter the value **"*Action1-properties"**
250 From the page header and inside **the Save** **menu**, click on the **Save** button to save all the changes.
254 Enrich And Deploy The CBA Package
255 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
257 From the page header and inside the **Save menu**, click on the **Enrich & Deploy** button.
261 Once the process is done, a confirmation message will appear.
265 Test The CBA package With CDS REST API
266 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
268 To test the CDS hello_world package we created, we can use the REST API shown below to run the **script executor** workflow in the **Hello-world-package-kotlin** package, which will resolve the value of the "username" resource from the REST Call input, and will send it back to the user in the form of "Hello, $username!".
270 **CURL Request to RUN CBA Package**
274 curl --location --request POST 'http://10.1.1.9:8080/api/v1/execution-service/process' \
275 --header 'Content-Type: application/json;charset=UTF-8' \
276 --header 'Accept: application/json;charset=UTF-8,application/json' \
277 --header 'Authorization: Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==' \
278 --header 'Host: cds-blueprints-processor-http:8080' \
279 --header 'Cookie: JSESSIONID=7E69BC3F752FD5A3D7D1663FE583ED71' \
281 "actionIdentifiers": {
283 "blueprintName": "Hello-world-package-kotlin",
284 "blueprintVersion": "1.0.0",
285 "actionName": "Action1"
289 "username":"Orange Egypt"
293 "subRequestId": "143748f9-3cd5-4910-81c9-a4601ff2ea58",
294 "requestId": "e5eb1f1e-3386-435d-b290-d49d8af8db4c",
295 "originatorId": "SDNC_DG"
300 **CDS Response showing result of running package**
306 "correlationUUID": null,
308 "timestamp": "2021-01-12T13:22:26.518Z",
309 "originatorId": "SDNC_DG",
310 "requestId": "e5eb1f1e-3386-435d-b290-d49d8af8db4c",
311 "subRequestId": "143748f9-3cd5-4910-81c9-a4601ff2ea58",
314 "actionIdentifiers": {
315 "blueprintName": "Hello-world-package-kotlin",
316 "blueprintVersion": "1.0.0",
317 "actionName": "Action1",
322 "eventType": "EVENT_COMPONENT_EXECUTED",
323 "timestamp": "2021-01-12T13:22:56.144Z",
324 "errorMessage": null,
328 "Action1-response": {
329 "hello-world-output": {
330 "hello_world_template": "Hello, Orange Egypt"
336 Screenshot from POSTMAN showing how to run the **Hello_world-package-kotlin** package, and the CDS Response:
340 .. |image1| image:: https://wiki.onap.org/download/attachments/93006316/1.png?version=1&modificationDate=1610364491000&api=v2
342 .. |image2| image:: https://wiki.onap.org/download/attachments/93006316/02.png?version=1&modificationDate=1610390913000&api=v2
344 .. |image3| image:: https://wiki.onap.org/download/attachments/93006316/03.png?version=1&modificationDate=1610390934000&api=v2
346 .. |image4| image:: https://wiki.onap.org/download/attachments/93006316/04.png?version=1&modificationDate=1610391083000&api=v2
348 .. |image5| image:: https://wiki.onap.org/download/attachments/93006316/05.png?version=1&modificationDate=1610391137000&api=v2
350 .. |image6| image:: https://wiki.onap.org/download/attachments/93006316/06.png?version=1&modificationDate=1610391364000&api=v2
352 .. |image7| image:: https://wiki.onap.org/download/attachments/93006316/07.png?version=1&modificationDate=1610391427000&api=v2
354 .. |image8| image:: https://wiki.onap.org/download/attachments/93006316/08.png?version=1&modificationDate=1610391642000&api=v2
356 .. |image9| image:: https://wiki.onap.org/download/attachments/93006316/09.png?version=1&modificationDate=1610391749000&api=v2
358 .. |image10| image:: https://wiki.onap.org/download/attachments/93006316/10.png?version=2&modificationDate=1610391971000&api=v2
360 .. |image11| image:: https://wiki.onap.org/download/attachments/84650426/Create%20Package.jpg?version=1&modificationDate=1591034193000&api=v2
362 .. |image12| image:: https://wiki.onap.org/download/attachments/93006316/11.png?version=1&modificationDate=1610364492000&api=v2
364 .. |image13| image:: https://wiki.onap.org/download/attachments/93006316/12.png?version=2&modificationDate=1610392150000&api=v2
366 .. |image14| image:: https://wiki.onap.org/download/attachments/93006316/13.png?version=2&modificationDate=1610392171000&api=v2
368 .. |image15| image:: https://wiki.onap.org/download/attachments/93006316/14.png?version=2&modificationDate=1610392192000&api=v2
370 .. |image16| image:: https://wiki.onap.org/download/attachments/93006316/15.png?version=2&modificationDate=1610392224000&api=v2
372 .. |image17| image:: https://wiki.onap.org/download/attachments/93006316/16.png?version=2&modificationDate=1610392392000&api=v2
374 .. |image18| image:: https://wiki.onap.org/download/attachments/93006316/17.png?version=3&modificationDate=1610392589000&api=v2
376 .. |image19| image:: https://wiki.onap.org/download/attachments/93006316/18.png?version=2&modificationDate=1610392609000&api=v2
378 .. |image20| image:: https://wiki.onap.org/download/attachments/93006316/19.png?version=1&modificationDate=1610364492000&api=v2
380 .. |image21| image:: https://wiki.onap.org/download/attachments/93006316/20.png?version=2&modificationDate=1610392718000&api=v2
382 .. |image22| image:: https://wiki.onap.org/download/attachments/93006316/21.png?version=2&modificationDate=1610392773000&api=v2
384 .. |image23| image:: https://wiki.onap.org/download/attachments/93006316/22.png?version=2&modificationDate=1610392886000&api=v2
386 .. |image24| image:: https://wiki.onap.org/download/attachments/93006316/23.png?version=2&modificationDate=1610392915000&api=v2
388 .. |image25| image:: https://wiki.onap.org/download/attachments/93006316/24.png?version=2&modificationDate=1610392939000&api=v2
390 .. |image26| image:: https://wiki.onap.org/download/attachments/93006316/25.png?version=4&modificationDate=1612796837000&api=v2
392 .. |image27| image:: https://wiki.onap.org/download/attachments/93006316/26.png?version=5&modificationDate=1612796934000&api=v2
394 .. |image28| image:: https://wiki.onap.org/download/attachments/93006316/26.png?version=4&modificationDate=1610393629000&api=v2
396 .. |image29| image:: https://wiki.onap.org/download/attachments/93006316/28.png?version=5&modificationDate=1612797010000&api=v2
398 .. |image30| image:: https://wiki.onap.org/download/attachments/93006316/29.png?version=5&modificationDate=1612797073000&api=v2
400 .. |image31| image:: https://wiki.onap.org/download/attachments/93006316/30.png?version=2&modificationDate=1612797108000&api=v2
402 .. |image32| image:: https://wiki.onap.org/download/attachments/93006316/31.png?version=1&modificationDate=1610459101000&api=v2