blob: fd1efb93d99ab0ea377a8fce4c163fd96a6d48a9 [file] [log] [blame]
Ralph Knag1fca6ac2017-12-05 12:05:57 -05001.. This work is licensed under a Creative Commons Attribution 4.0 International License.
2.. http://creativecommons.org/licenses/by/4.0
3
4.. _walkthrough:
5
6Walk-through
7============
8
Ralph Knagd2cd31b2018-04-02 16:27:46 -04009This section demonstrates the flow and usage of the dcae_cli tool to
10onboard a typical component to the DCAE platform. The commands are
11explained in more detail in :doc:`dcae_cli Commands <commands>`.
Ralph Knag1fca6ac2017-12-05 12:05:57 -050012
Ralph Knagd2cd31b2018-04-02 16:27:46 -040013- `Add (and validate) a data format <#add-a-data-format>`__
14- `Add (and validate) the component <#add-the-component>`__
15- `View the platform generated
16 configuration <#view-the-platform-generated-configuration>`__
17- `If needed, Create the dmaap file for Dmaap Testing <#create-the-input-file-for-dmaap-testing>`__
18- `If needed, Create the input file for *Sourced at Deployment* Testing <#create-the-input-file-for-sourced-at-deployment-testing>`__
19- `Run the component <#run-the-component>`__
20- :any:`Undeploy the component <dcae_cli_undeploy_the_component>`
21- :any:`Publish the component and data_format <dcae_cli_publish_the_component_and_data_format>` to let others
22 know its ready for reuse
23- `List the Catalog Contents <#list-the-catalog-contents>`__ to see
24 your published resources
Ralph Knag1fca6ac2017-12-05 12:05:57 -050025
Ralph Knag1fca6ac2017-12-05 12:05:57 -050026
Ralph Knagd2cd31b2018-04-02 16:27:46 -040027--------------
Ralph Knag1fca6ac2017-12-05 12:05:57 -050028
Ralph Knagd2cd31b2018-04-02 16:27:46 -040029Add a Data Format
30-----------------
Ralph Knag1fca6ac2017-12-05 12:05:57 -050031
32::
33
Ralph Knagd2cd31b2018-04-02 16:27:46 -040034 $ dcae_cli data_format add $HOME/yourapp/data-formats/health.json
Ralph Knag1fca6ac2017-12-05 12:05:57 -050035
Ralph Knagd2cd31b2018-04-02 16:27:46 -040036Verify that the data_format was added
Ralph Knag1fca6ac2017-12-05 12:05:57 -050037
38::
39
Ralph Knagd2cd31b2018-04-02 16:27:46 -040040 $ dcae_cli data_format list | grep yourapp
41 | sandbox.platform.yourapp.health | 0.1.0 | Data format used for the /health endpoint | staged | 2017-11-07 21:48:47.736518 |
Ralph Knag1fca6ac2017-12-05 12:05:57 -050042
Ralph Knagd2cd31b2018-04-02 16:27:46 -040043(Note: Each of the data formats for your component need to be added,
44unless already existing in the onboarding catalog )
Ralph Knag1fca6ac2017-12-05 12:05:57 -050045
Ralph Knagd2cd31b2018-04-02 16:27:46 -040046--------------
Ralph Knag1fca6ac2017-12-05 12:05:57 -050047
Ralph Knagd2cd31b2018-04-02 16:27:46 -040048Add the Component
49-----------------
Ralph Knag1fca6ac2017-12-05 12:05:57 -050050
51::
52
Ralph Knagd2cd31b2018-04-02 16:27:46 -040053 $ dcae_cli component add $HOME/yourapp/component-spec.json
Ralph Knag1fca6ac2017-12-05 12:05:57 -050054
Ralph Knagd2cd31b2018-04-02 16:27:46 -040055Verify that the component was added
Ralph Knag1fca6ac2017-12-05 12:05:57 -050056
57::
58
Ralph Knagd2cd31b2018-04-02 16:27:46 -040059 $ dcae_cli component list
Ralph Knag1fca6ac2017-12-05 12:05:57 -050060 Active profile: solutioning
61
Ralph Knagd2cd31b2018-04-02 16:27:46 -040062 +-------------------------------+---------+--------+---------------------------------------------------------------+--------+----------------------------+-----------+
63 | Name | Version | Type | Description | Status | Modified | #Deployed |
64 +-------------------------------+---------+--------+---------------------------------------------------------------+--------+----------------------------+-----------+
65 | sandbox.platform.yourapp | 0.7.0 | docker | Web service used as a stand-alone test DCAE service compone.. | staged | 2017-11-08 20:27:34.168854 | 0 |
66 +-------------------------------+---------+--------+---------------------------------------------------------------+--------+----------------------------+-----------+
Ralph Knag1fca6ac2017-12-05 12:05:57 -050067
Ralph Knagd2cd31b2018-04-02 16:27:46 -040068--------------
Ralph Knag1fca6ac2017-12-05 12:05:57 -050069
Ralph Knagd2cd31b2018-04-02 16:27:46 -040070.. _dcae-cli-view-the-platform:
Ralph Knag1fca6ac2017-12-05 12:05:57 -050071
Ralph Knagd2cd31b2018-04-02 16:27:46 -040072View the platform generated configuration
73-----------------------------------------
74
75The ``component dev`` command is useful during onboarding. Running this
76command is part of a multi-step process that sets up a temporary test
77environment, generates your application configuration, makes it
78available in that environment, and allows you to view that configuration
79to help with debugging.
80
81Here is a step-by-step example based on a component specification called
82``component-spec.json``.
83
84Step 1 - Run the component dev command
85~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
86
87(This creates a file called env_$ENV (in the current directory)- where
88$ENV is the name of the active profile. Note: SERVICE_NAME and HOSTNAME
89always resolve to the same value).
Ralph Knag1fca6ac2017-12-05 12:05:57 -050090
91::
92
Ralph Knagd2cd31b2018-04-02 16:27:46 -040093 $ dcae_cli component dev component-spec.json
Ralph Knag1fca6ac2017-12-05 12:05:57 -050094 Ready for component development
95
Ralph Knagd2cd31b2018-04-02 16:27:46 -040096 Setup these environment variables. Run "source env_solutioning":
Ralph Knag1fca6ac2017-12-05 12:05:57 -050097
Ralph Knagd2cd31b2018-04-02 16:27:46 -040098 export DOCKER_HOST=yourdockerhost.com:2376
Ralph Knag1fca6ac2017-12-05 12:05:57 -050099 export SERVICE_CHECK_INTERVAL=15s
100 export CONFIG_BINDING_SERVICE=config_binding_service
Ralph Knagd2cd31b2018-04-02 16:27:46 -0400101 export HOSTNAME=user12.b599cf0e-75e8-484b-b8e2-557576d77036.0-7-0.sandbox-platform-yourapp
102 export CONSUL_HOST=yourconsulhost.com
Ralph Knag1fca6ac2017-12-05 12:05:57 -0500103 export CDAP_BROKER=cdap_broker
Ralph Knagd2cd31b2018-04-02 16:27:46 -0400104 export SERVICE_NAME=user12.b599cf0e-75e8-484b-b8e2-557576d77036.0-7-0.sandbox-platform-yourapp
Ralph Knag1fca6ac2017-12-05 12:05:57 -0500105 export SERVICE_CHECK_TIMEOUT=1s
106 export SERVICE_CHECK_HTTP=/health
107
108 Press any key to stop and to clean up
109
Ralph Knagd2cd31b2018-04-02 16:27:46 -0400110Step 2 - Setup the environment
111~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ralph Knag1fca6ac2017-12-05 12:05:57 -0500112
Ralph Knagd2cd31b2018-04-02 16:27:46 -0400113In another window, setup the temporary testing environment, by executing
114the environment file created above.
Ralph Knag1fca6ac2017-12-05 12:05:57 -0500115
116::
117
Ralph Knagd2cd31b2018-04-02 16:27:46 -0400118 $ source env_solutioning
119
120(The application configuration is now available under the SERVICE_NAME
121shown above -
122``user12.b599cf0e-75e8-484b-b8e2-557576d77036.0-7-0.sandbox-platform-yourapp``).
123
124Step 3 - Query CONSUL
125~~~~~~~~~~~~~~~~~~~~~
126
127Query CONSUL to get the IP/PORT of CONFIG BINDING SERVICE
128
129::
130
131 $ curl http://$CONSUL_HOST:8500/v1/catalog/service/$CONFIG_BINDING_SERVICE
Ralph Knag1fca6ac2017-12-05 12:05:57 -0500132 [
133 {
Ralph Knagd2cd31b2018-04-02 16:27:46 -0400134 "ID": "bfbc220d-4603-7f90-ec2e-611d3c330f20",
135 "Node":"docker00",
VENKATESH KUMARfac34a12019-01-20 20:15:08 -0500136 "Address": "127.0.0.1",
137 "Datacenter":"dcae-central",
Ralph Knag1fca6ac2017-12-05 12:05:57 -0500138 "TaggedAddresses": {
Ralph Knagd2cd31b2018-04-02 16:27:46 -0400139 "lan":"10.226.1.15",
140 "wan":"10.226.1.15"
Ralph Knag1fca6ac2017-12-05 12:05:57 -0500141 },
142 "NodeMeta": {},
Ralph Knagd2cd31b2018-04-02 16:27:46 -0400143 "ServiceID": "472b116f9035:config_binding_service:10000",
Ralph Knag1fca6ac2017-12-05 12:05:57 -0500144 "ServiceName": "config_binding_service",
145 "ServiceTags": [],
VENKATESH KUMARfac34a12019-01-20 20:15:08 -0500146 "ServiceAddress":"127.0.0.1",
Ralph Knagd2cd31b2018-04-02 16:27:46 -0400147 "ServicePort":10000,
Ralph Knag1fca6ac2017-12-05 12:05:57 -0500148 "ServiceEnableTagOverride": false,
Ralph Knagd2cd31b2018-04-02 16:27:46 -0400149 "CreateIndex":1078990,
150 "ModifyIndex":1078990
Ralph Knag1fca6ac2017-12-05 12:05:57 -0500151 }
152 ]
153
Ralph Knagd2cd31b2018-04-02 16:27:46 -0400154Fetch the generated configuration from CONFIG BINDING SERVICE using the
155‘serviceaddress’ and ‘serviceport’ from above along with $SERVICE_NAME
156from earlier.
Ralph Knag1fca6ac2017-12-05 12:05:57 -0500157
158::
159
Ralph Knagd2cd31b2018-04-02 16:27:46 -0400160 $ curl http://135.205.226.126:10000/service_component/user12.b599cf0e-75e8-484b-b8e2-557576d77036.0-7-0.sandbox-platform-yourapp
Ralph Knag1fca6ac2017-12-05 12:05:57 -0500161
Ralph Knagd2cd31b2018-04-02 16:27:46 -0400162 {"streams_subscribes": {}, "services_calls": {}, "multiplier": 3, "streams_publishes": {}}
Ralph Knag1fca6ac2017-12-05 12:05:57 -0500163
Ralph Knagd2cd31b2018-04-02 16:27:46 -0400164--------------
165
166.. _dcae-cli-walkthrough-dmaap-testing:
167
168Create the input file for Dmaap Testing
169---------------------------------------
170
171Currently, the dcae-cli tool does not have the capability to provision
172topics or feeds. Therefore, in order to test with ``message router`` or
173``data router`` feeds, the developer must manually provision the topic
174or feed and then provide the connection details in the form of a DMaap
175JSON file for testing. This file is then passed in on the
176``component run`` or ``component dev`` commands by using the argument
177``--dmaap-file``.
178
179The structure of the DMaaP JSON is an object of config keys with the
180topic or feed connection details. The config keys are the ``config_key``
181values specified in the component specification streams section where
182the streams must be type ``message router`` or ``data router``. This
183file corresponds to the ``Dmaap Connection Object`` which is generated
184by the platform and provided to the component at runtime. The exception
185is that ``delivery_url`` cannot be provided in the dmaap-file because it
186is not created until the component is deployed. Refer to :any:`Dmaap Connection Object <dmaap-connection-objects>`, for details on creating the dmaap-file for testing.
187
188--------------
189
190Create the input file for *Sourced at Deployment* Testing
191---------------------------------------------------------
Ralph Knag1fca6ac2017-12-05 12:05:57 -0500192
193Components may have configuration parameters whose values are to be
Ralph Knagd2cd31b2018-04-02 16:27:46 -0400194sourced at deployment time. This is established in the
195:any:`component specification <common-specification-parameters>`
Ralph Knag1fca6ac2017-12-05 12:05:57 -0500196by setting the property ``sourced_at_deployment`` to ``true`` for each
Ralph Knagd2cd31b2018-04-02 16:27:46 -0400197applicable parameter.
Ralph Knag1fca6ac2017-12-05 12:05:57 -0500198
Ralph Knagd2cd31b2018-04-02 16:27:46 -0400199Then, use the ``--inputs-file`` command-line argument when running the
200component ``dev`` or ``run`` command for your component. This is to
201simulate providing the dynamic, deployment time values for those
202parameters marked as ``sourced_at_deployment``.
Ralph Knag1fca6ac2017-12-05 12:05:57 -0500203
204For example, if your component specification has the following
205configuration parameters:
206
207::
208
209 "parameters": [{
210 "name": "vnf-ip",
211 "value": "",
212 "sourced_at_deployment": true
213 },
214 {
215 "name": "static-param",
216 "value": 5
217 }]
218
Ralph Knagd2cd31b2018-04-02 16:27:46 -0400219Pass in an input file that looks like:
Ralph Knag1fca6ac2017-12-05 12:05:57 -0500220
221::
222
223 {
224 "vnf-ip": "10.100.1.100"
225 }
226
Ralph Knagd2cd31b2018-04-02 16:27:46 -0400227The application configuration would look like:
Ralph Knag1fca6ac2017-12-05 12:05:57 -0500228
229::
230
231 {
232 "vnf-ip": "10.100.1.100",
233 "static-param": 5
234 }
235
Ralph Knag1fca6ac2017-12-05 12:05:57 -0500236--------------
237
Ralph Knagd2cd31b2018-04-02 16:27:46 -0400238Run the component
239-----------------
Ralph Knag1fca6ac2017-12-05 12:05:57 -0500240
Ralph Knagd2cd31b2018-04-02 16:27:46 -0400241The ``run`` operation is to be used for running your application in its
242container remotely on the activated environment. Docker containers have
243the additional option to run locally on your development machine. If the
244component uses Dmaap, you can specify the Dmaap Connection Object as
245well. Refer to :any:`Dmaap Connection Object <dmaap-connection-objects>`.
Ralph Knag1fca6ac2017-12-05 12:05:57 -0500246
Ralph Knagd2cd31b2018-04-02 16:27:46 -0400247In order to run the component, the data formats and component must have
248been added to the onboarding catalog.
Ralph Knag1fca6ac2017-12-05 12:05:57 -0500249
Ralph Knagd2cd31b2018-04-02 16:27:46 -0400250To verify what’s in the catalog:
Ralph Knag1fca6ac2017-12-05 12:05:57 -0500251
252::
253
Ralph Knagd2cd31b2018-04-02 16:27:46 -0400254 $ dcae_cli catalog list --expanded
255 Active profile: solutioning
256 +---------------------------+---------+--------+---------------------------------------------------------------+--------+----------------------------+-----------+
257 | Name | Version | Type | Description | Status | Modified | #Deployed |
258 +---------------------------+---------+--------+---------------------------------------------------------------+--------+----------------------------+-----------+
259 | sandbox.platform.yourapp | 0.7.0 | docker | Web service used as a stand-alone test DCAE service compone.. | staged | 2017-11-08 20:27:34.168854 | 0 |
260 +---------------------------+---------+--------+---------------------------------------------------------------+--------+----------------------------+-----------+
Ralph Knag1fca6ac2017-12-05 12:05:57 -0500261
Ralph Knagd2cd31b2018-04-02 16:27:46 -0400262For Docker
Ralph Knag1fca6ac2017-12-05 12:05:57 -0500263
Ralph Knagd2cd31b2018-04-02 16:27:46 -0400264**NOTE** Make sure the Docker image has been uploaded to the shared
265registry.
Ralph Knag1fca6ac2017-12-05 12:05:57 -0500266
Ralph Knagd2cd31b2018-04-02 16:27:46 -0400267A docker component can be run in either ``attached`` or ``unattached``
268mode. (Default is unattached).
269
Lusheng Jieaac78d2018-06-06 00:20:03 -0400270+------------------+-----------------------------------------------------------+
271| Mode | Description |
272+==================+===========================================================+
273| attached | component is run in the foreground, container |
274| | logs are streamed to stdout. Ctrl-C is used to |
275| | terminate the dcae_cli session. |
276+------------------+-----------------------------------------------------------+
277| unattached | component is run in the background container |
278| | logs are viewed via ``docker logs`` command, |
279| | container runs until undeployed with dcae_cli |
280| | ``undeploy`` command. |
281+------------------+-----------------------------------------------------------+
Ralph Knagd2cd31b2018-04-02 16:27:46 -0400282
283Run a component in attached mode:
Lusheng Jieaac78d2018-06-06 00:20:03 -0400284---------------------------------
Ralph Knagd2cd31b2018-04-02 16:27:46 -0400285
286::
287
288 $ dcae_cli -v component run --attached sandbox.platform.yourapp:0.7.0
289 DCAE.Docker | INFO | Running image 'nexus01.server.com:18443/repository/solutioning01-mte2-docker/dcae-platform/yourapp:0.7.0' as 'user12.dbb13a3c-d870-487e-b584-89929b856b5c.0-7-0.sandbox-platform-yourapp'
290 DCAE.Docker.user12.dbb13a3c-d870-487e-b584-89929b856b5c.0-7-0.sandbox-platform-yourapp | INFO | Consul host: yourconsulhost.com
291
292 DCAE.Docker.user12.dbb13a3c-d870-487e-b584-89929b856b5c.0-7-0.sandbox-platform-yourapp | INFO | service name: user12.dbb13a3c-d870-487e-b584-89929b856b5c.0-7-0.sandbox-platform-yourapp
293
294 DCAE.Docker.user12.dbb13a3c-d870-487e-b584-89929b856b5c.0-7-0.sandbox-platform-yourapp | INFO | get_config returned the following configuration: {"streams_subscribes": {}, "multiplier": 3, "services_calls": {}, "streams_publishes": {}}
295
296 DCAE.Docker.user12.dbb13a3c-d870-487e-b584-89929b856b5c.0-7-0.sandbox-platform-yourapp | INFO | * Running on http://0.0.0.0:8080/ (Press CTRL+C to quit)
297
VENKATESH KUMARfac34a12019-01-20 20:15:08 -0500298 DCAE.Docker.user12.dbb13a3c-d870-487e-b584-89929b856b5c.0-7-0.sandbox-platform-yourapp | INFO | 127.0.0.1 - - [08/Nov/2017 23:27:30] "GET /health HTTP/1.1" 200 -
Ralph Knagd2cd31b2018-04-02 16:27:46 -0400299
300
301 Hit Ctrl-C to terminate session.
302
303 ^C
304 DCAE.Docker | INFO | Stopping container 'user12.dbb13a3c-d870-487e-b584-89929b856b5c.0-7-0.sandbox-platform-yourapp' and cleaning up...
305
306Run a component in unattached mode:
Lusheng Jieaac78d2018-06-06 00:20:03 -0400307-----------------------------------
Ralph Knagd2cd31b2018-04-02 16:27:46 -0400308
309::
310
311 $ dcae_cli -v component run sandbox.platform.yourapp:0.7.0
312 DCAE.Docker | INFO | Running image 'nexus01.server.com:18443/repository/solutioning01-mte2-docker/dcae-platform/yourapp:0.7.0' as 'user12.22629ebd-417e-4e61-a9a0-f0cb16d4cef2.0-7-0.sandbox-platform-yourapp'
313 DCAE.Run | INFO | Deployed user12.22629ebd-417e-4e61-a9a0-f0cb16d4cef2.0-7-0.sandbox-platform-yourapp. Verifying..
314 DCAE.Run | INFO | Container is up and healthy
315
316**NOTE** You must undeploy this component when finished testing. This is
317important to conserve resources in the environment.
318
319Run a component that subscribes to Dmaap Message Router or Data Router
Lusheng Jieaac78d2018-06-06 00:20:03 -0400320----------------------------------------------------------------------
Ralph Knagd2cd31b2018-04-02 16:27:46 -0400321
322::
323
324 $ dcae_cli -v component run $component-that-uses-dmamp --dmaap-file $dmaap-connection-object
325
326Run a component that expects input that is ``sourced at deployment``
Lusheng Jieaac78d2018-06-06 00:20:03 -0400327--------------------------------------------------------------------
Ralph Knagd2cd31b2018-04-02 16:27:46 -0400328
329::
330
331 $ dcae_cli -v component run $component-that-expects-dti --inputs-file $input-file-to-simulate-dti
332
333--------------
334
335
336.. _dcae_cli_undeploy_the_component:
337
338Undeploy the component
339----------------------
340
Lusheng Jieaac78d2018-06-06 00:20:03 -0400341The ``undeploy`` command is used to undeploy any instance of a specified component/version that you have deployed. This includes cleaning up the configuration.
342Undeploy ``sandbox.platform.yourapp:0.7.0`` that was deployed above:
343``$ dcae_cli -v component undeploy sandbox.platform.yourapp:0.7.0 DCAE.Undeploy | WARNING | Undeploying components: 1 DCAE.Undeploy | WARNING | Undeployed components: 1``
Ralph Knagd2cd31b2018-04-02 16:27:46 -0400344
345.. _dcae_cli_publish_the_component_and_data_format:
346
347Publish the component and data_format
348-------------------------------------
349
350Once a component has been tested, it (and the data_format(s)) should be
351published in the onboarding catalog using the ``publish`` sub-command
352for both the ``data_format`` and ``component`` command.
353
354**Note** Before a component can be published, all data_formats that it
355references must be published.
356
357Publishing will change the status of a component or data_format,
358indicating that it has been tested, make accessible for other developers
359to use.
360
361::
362
363 $ dcae_cli data_format publish sandbox.platform.yourapp:0.7.0
364 Data format has been published
365
366 $dcae_cli component publish sandbox.platform.yourapp:0.7.0
367 Component has been published
368
369--------------
370
371List the catalog contents
372-------------------------
373
374::
375
376 $dcae_cli catalog list
377
378 $ dcae_cli data_format list | grep sandbox
379 | sandbox.platform.yourapp | 0.7.0 | docker | Web service used as a stand-alone test DCAE service compone.. | user12 | published | 2017-11-13 |
380 | sandbox.platform.yourapp.health | 0.1.0 | Data format used for the /health endpoint | published | 2017-11-13 17:48:10.121588 |
381 | sandbox.platform.any | 0.1.0 | Data format used when no data format is required. | published | 2017-11-13 17:47:51.622607 |
382 | sandbox.platform.yourapp.identity.response | 0.1.0 | Data format used for the /identity endpoint response which should | published | 2017-11-13 17:47:43.234715 |
383 | sandbox.platform.yourapp.identity.request | 0.1.0 | Data format used for the /identity endpoint request. This is | published | 2017-11-13 17:47:36.693643 |
384 | sandbox.platform.yourapp.rollcall.response | 0.1.0 | Data format used for the /rollcall endpoint respon.. | published | 2017-11-13 17:46:30.026846 |
385