blob: 4be95113a8653affcbd3ce5f46bf38e4d7e6c51b [file] [log] [blame]
JakobKrieg0f29c1c2020-10-01 14:00:40 +02001.. This work is a derivative of https://wiki.onap.org/display/DW/PNF+Simulator+Day-N+config-assign+and+config-deploy+use+case
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
6PNF Simulator Day-N config-assign/deploy
7========================================
8
JakobKrieg0f29c1c2020-10-01 14:00:40 +02009Overview
10~~~~~~~~~~
11
JakobKriegfac42cc2020-11-06 19:17:56 +010012This use case shows in a very simple how the day-n configuration is assigned and deployed to a PNF through CDS.
13A Netconf server (docker image `sysrepo/sysrepo-netopeer2`) is used for simulating the PNF.
JakobKrieg0f29c1c2020-10-01 14:00:40 +020014
15This use case (POC) solely requires a running CDS and the PNF Simulator running on a VM (Ubuntu is used by the author).
16No other module of ONAP is needed.
17
JakobKriegfac42cc2020-11-06 19:17:56 +010018There are different ways to run CDS and the PNF simulator. This guide will show
JakobKrieg0f29c1c2020-10-01 14:00:40 +020019different possible options to allow the greatest possible flexibility.
20
21Run CDS (Blueprint Processor)
22~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
23
24CDS can be run in Kubernetes (Minikube, Microk8s) or in an IDE. You can choose your favorite option.
25Just the blueprint processor of CDS is needed. If you have desktop access it is recommended to run CDS in an IDE since
26it is easy and enables debugging.
27
28* CDS in Microk8s: https://wiki.onap.org/display/DW/Running+CDS+on+Microk8s (RDT link to be added)
29* CDS in Minikube: https://wiki.onap.org/display/DW/Running+CDS+in+minikube (RDT link to be added)
30* CDS in an IDE: https://docs.onap.org/projects/onap-ccsdk-cds/en/latest/userguide/running-bp-processor-in-ide.html
31
JakobKrieg0f29c1c2020-10-01 14:00:40 +020032Run PNF Simulator and install module
33~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
34
35There are many different ways to run a Netconf Server to simulate the PNF, in this guide `sysrepo/sysrepo-netopeer2`
36docker image is commonly used. The easiest way is to run the out-of-the-box docker container without any
37other configuration, modules or scripts. In the ONAP community there are other workflows existing for running the
38PNF Simulator. These workflows are also using `sysrepo/sysrepo-netopeer2` docker image. These workflow are also linked
39here but they are not tested by the author of this guide.
40
41.. tabs::
42
43 .. tab:: sysrepo/sysrepo-netopeer2 (latest)
44
45 .. warning::
46 Currently there is an issue for the SSH connection between CDS and the netconf server because of unmatching
JakobKriegabfdc072020-10-06 16:49:39 +020047 exchange key algorhithms
48 (see `Stackoverflow <https://stackoverflow.com/questions/64047502/java-lang-illegalstateexception-unable-to-negotiate-key-exchange-for-server-hos>`_).
49 **Use legacy version (right tab) until the issue is resolved.**
JakobKrieg0f29c1c2020-10-01 14:00:40 +020050
51 Download and run docker container with ``docker run -d --name netopeer2 -p 830:830 -p 6513:6513 sysrepo/sysrepo-netopeer2:latest``
52
53 Enter the container with ``docker exec -it netopeer2 bin/bash``
54
55 Browse to the target location where all YANG modules exist: ``cd /etc/sysrepo/yang``
56
JakobKriegabfdc072020-10-06 16:49:39 +020057 Create a simple mock YANG model for a packet generator (:file:`pg.yang`).
JakobKrieg0f29c1c2020-10-01 14:00:40 +020058
59 .. code-block:: sh
60 :caption: **pg.yang**
61
62 module sample-plugin {
63
64 yang-version 1;
65 namespace "urn:opendaylight:params:xml:ns:yang:sample-plugin";
66 prefix "sample-plugin";
67
68 description
69 "This YANG module defines the generic configuration and
70 operational data for sample-plugin in VPP";
71
72 revision "2016-09-18" {
73 description "Initial revision of sample-plugin model";
74 }
75
76 container sample-plugin {
77
78 uses sample-plugin-params;
79 description "Configuration data of sample-plugin in Honeycomb";
80
81 // READ
82 // curl -u admin:admin http://localhost:8181/restconf/config/sample-plugin:sample-plugin
83
84 // WRITE
85 // curl http://localhost:8181/restconf/operational/sample-plugin:sample-plugin
86
87 }
88
89 grouping sample-plugin-params {
90 container pg-streams {
91 list pg-stream {
92
93 key id;
94 leaf id {
95 type string;
96 }
97
98 leaf is-enabled {
99 type boolean;
100 }
101 }
102 }
103 }
104 }
105
JakobKriegabfdc072020-10-06 16:49:39 +0200106 Create the following sample XML data definition for the above model (:file:`pg-data.xml`).
JakobKrieg0f29c1c2020-10-01 14:00:40 +0200107 Later on this will initialise one single PG stream.
108
109 .. code-block:: sh
110 :caption: **pg-data.xml**
111
112 <sample-plugin xmlns="urn:opendaylight:params:xml:ns:yang:sample-plugin">
113 <pg-streams>
114 <pg-stream>
115 <id>1</id>
116 <is-enabled>true</is-enabled>
117 </pg-stream>
118 </pg-streams>
119 </sample-plugin>
120
121 Execute the following command within netopeer docker container to install the pg.yang model
122
123 .. code-block:: sh
124
125 sysrepoctl -v3 -i pg.yang
126
127 .. note::
128 This command will just schedule the installation, it will be applied once the server is restarted.
129
130 Stop the container from outside with ``docker stop netopeer2`` and start it again with ``docker start netopeer2``
131
132 Enter the container like it's mentioned above with ``docker exec -it netopeer2 bin/bash``.
133
134 You can check all installed modules with ``sysrepoctl -l``. `sample-plugin` module should appear with ``I`` flag.
135
136 Execute the following the commands to initialise the Yang model with one pg-stream record.
JakobKriegebd1fbd2020-10-02 16:53:27 +0200137 We will be using CDS to perform the day-1 and day-2 configuration changes.
JakobKrieg0f29c1c2020-10-01 14:00:40 +0200138
139 .. code-block:: sh
140
141 netopeer2-cli
142 > connect --host localhost --login root
143 # passwort is root
144 > get --filter-xpath /sample-plugin:*
145 # shows existing pg-stream records (empty)
146 > edit-config --target running --config=/etc/sysrepo/yang/pg-data.xml
147 # initialises Yang model with one pg-stream record
148 > get --filter-xpath /sample-plugin:*
149 # shows initialised pg-stream
150
151 If the output of the last command is like this, everything went successful:
152
153 .. code-block:: sh
154
155 DATA
156 <sample-plugin xmlns="urn:opendaylight:params:xml:ns:yang:sample-plugin">
157 <pg-streams>
158 <pg-stream>
159 <id>1</id>
160 <is-enabled>true</is-enabled>
161 </pg-stream>
162 </pg-streams>
163 </sample-plugin>
164
165
166 .. tab:: sysrepo/sysrepo-netopeer2 (legacy)
167
168 Download and run docker container with ``docker run -d --name netopeer2 -p 830:830 -p 6513:6513 sysrepo/sysrepo-netopeer2:legacy``
169
170 Enter the container with ``docker exec -it netopeer2 bin/bash``
171
172 Browse to the target location where all YANG modules exist: ``cd /opt/dev/sysrepo/yang``
173
JakobKriegabfdc072020-10-06 16:49:39 +0200174 Create a simple mock YANG model for a packet generator (:file:`pg.yang`).
JakobKrieg0f29c1c2020-10-01 14:00:40 +0200175
176 .. code-block:: sh
177 :caption: **pg.yang**
178
179 module sample-plugin {
180
181 yang-version 1;
182 namespace "urn:opendaylight:params:xml:ns:yang:sample-plugin";
183 prefix "sample-plugin";
184
185 description
186 "This YANG module defines the generic configuration and
187 operational data for sample-plugin in VPP";
188
189 revision "2016-09-18" {
190 description "Initial revision of sample-plugin model";
191 }
192
193 container sample-plugin {
194
195 uses sample-plugin-params;
196 description "Configuration data of sample-plugin in Honeycomb";
197
198 // READ
199 // curl -u admin:admin http://localhost:8181/restconf/config/sample-plugin:sample-plugin
200
201 // WRITE
202 // curl http://localhost:8181/restconf/operational/sample-plugin:sample-plugin
203
204 }
205
206 grouping sample-plugin-params {
207 container pg-streams {
208 list pg-stream {
209
210 key id;
211 leaf id {
212 type string;
213 }
214
215 leaf is-enabled {
216 type boolean;
217 }
218 }
219 }
220 }
221 }
222
JakobKriegabfdc072020-10-06 16:49:39 +0200223 Create the following sample XML data definition for the above model (:file:`pg-data.xml`).
JakobKrieg0f29c1c2020-10-01 14:00:40 +0200224 Later on this will initialise one single PG (packet-generator) stream.
225
226 .. code-block:: sh
227 :caption: **pg-data.xml**
228
229 <sample-plugin xmlns="urn:opendaylight:params:xml:ns:yang:sample-plugin">
230 <pg-streams>
231 <pg-stream>
232 <id>1</id>
233 <is-enabled>true</is-enabled>
234 </pg-stream>
235 </pg-streams>
236 </sample-plugin>
237
238 Execute the following command within netopeer docker container to install the pg.yang model
239
240 .. code-block:: sh
241
242 sysrepoctl -i -g pg.yang
243
244 You can check all installed modules with ``sysrepoctl -l``. `sample-plugin` module should appear with ``I`` flag.
245
246 In legacy version of `sysrepo/sysrepo-netopeer2` subscribers of a module are required, otherwise they are not
247 running and configurations changes are not accepted, see https://github.com/sysrepo/sysrepo/issues/1395. There is
248 an predefined application mock up which can be used for that. The usage is described
JakobKriegabfdc072020-10-06 16:49:39 +0200249 here: https://asciinema.org/a/160247. You need to run the following
250 commands to start the example application for subscribing to our sample-plugin YANG module.
JakobKrieg0f29c1c2020-10-01 14:00:40 +0200251
252 .. code-block:: sh
253
254 cd /opt/dev/sysrepo/build/examples
255 ./application_example sample-plugin
256
257 Following output should appear:
258
259 .. code-block:: sh
260
JakobKriegabfdc072020-10-06 16:49:39 +0200261 ========== READING STARTUP CONFIG sample-plugin: ==========
JakobKrieg0f29c1c2020-10-01 14:00:40 +0200262
263 /sample-plugin:sample-plugin (container)
264 /sample-plugin:sample-plugin/pg-streams (container)
JakobKriegabfdc072020-10-06 16:49:39 +0200265
266
267 ========== STARTUP CONFIG sample-plugin APPLIED AS RUNNING ==========
268
JakobKrieg0f29c1c2020-10-01 14:00:40 +0200269
270 The terminal session needs to be kept open after application has started.
271
272 Open a new terminal and enter the container with ``docker exec -it netopeer2 bin/bash``.
273 Execute the following commands in the container to initialise the Yang model with one pg-stream record.
274 We will be using CDS to perform the day-1 configuration and day-2 configuration changes.
275
276 .. code-block:: sh
277
278 netopeer2-cli
279 > connect --host localhost --login netconf
280 # passwort is netconf
281 > get --filter-xpath /sample-plugin:*
282 # shows existing pg-stream records (empty)
283 > edit-config --target running --config=/opt/dev/sysrepo/yang/pg-data.xml
284 # initialises Yang model with one pg-stream record
285 > get --filter-xpath /sample-plugin:*
286 # shows initialised pg-stream
287
288 If the output of the last command is like this, everything went successful:
289
290 .. code-block:: sh
291
292 DATA
293 <sample-plugin xmlns="urn:opendaylight:params:xml:ns:yang:sample-plugin">
294 <pg-streams>
295 <pg-stream>
296 <id>1</id>
297 <is-enabled>true</is-enabled>
298 </pg-stream>
299 </pg-streams>
300 </sample-plugin>
301
JakobKriegabfdc072020-10-06 16:49:39 +0200302 You can also see that there are additional logs in the subscriber application after editing the configuration of our
303 YANG module.
304
JakobKrieg0f29c1c2020-10-01 14:00:40 +0200305 .. tab:: PNF simulator integration project
306
307 .. warning::
308 This method of setting up the PNF simulator is not tested by the author of this guide
309
310 You can refer to `PnP PNF Simulator wiki page <https://wiki.onap.org/display/DW/PnP+PNF+Simulator>`_
311 to clone the GIT repo and start the required docker containers. We are interested in the
312 `sysrepo/sysrepo-netopeer2` docker container to load a simple YANG similar to vFW Packet Generator.
313
314 Start PNF simulator docker containers. You can consider changing the netopeer image verion to image:
315 `sysrepo/sysrepo-netopeer2:iop` in docker-compose.yml file If you find any issues with the default image.
316
317 .. code-block:: sh
318
319 cd $HOME
320
321 git clone https://github.com/onap/integration.git
322
323 Start PNF simulator
324
325 cd ~/integration/test/mocks/pnfsimulator
326
327 ./simulator.sh start
328
329 Verify that you have netopeer docker container are up and running. It will be mapped to host port 830.
330
331 .. code-block:: sh
332
333 docker ps -a | grep netopeer
334
335
336Config-assign and config-deploy in CDS
337~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
338
JakobKriegfac42cc2020-11-06 19:17:56 +0100339In the following steps config-assignment is done and the config is deployed to the
340Netconf server through CDS. Example requests are in the following Postman collection
341:download:`JSON <media/pnf-simulator.postman_collection.json>`. You can also use bash scripting to call the APIs.
JakobKrieg0f29c1c2020-10-01 14:00:40 +0200342
JakobKriegfac42cc2020-11-06 19:17:56 +0100343.. note::
344 The CBA for this PNF Demo gets loaded, enriched and saved in CDS through calling bootstrap. If not done before, call
345 Bootstrap API
JakobKrieg0f29c1c2020-10-01 14:00:40 +0200346
JakobKriegfac42cc2020-11-06 19:17:56 +0100347Password and username for API calls will be `ccsdkapps`.
JakobKrieg0f29c1c2020-10-01 14:00:40 +0200348
JakobKriegfac42cc2020-11-06 19:17:56 +0100349**Config-Assign:**
JakobKrieg0f29c1c2020-10-01 14:00:40 +0200350
JakobKriegfac42cc2020-11-06 19:17:56 +0100351The assumption is that we are using the same host to run PNF NETCONF simulator as well as CDS. You will need the
352IP Adress of the Netconf server container which can be found out with
353``docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' netopeer2``. In the
354following example payloads we will use 172.17.0.2.
JakobKrieg0f29c1c2020-10-01 14:00:40 +0200355
JakobKriegfac42cc2020-11-06 19:17:56 +0100356Call the `process` API (``http://{{host}}:{{port}}/api/v1/execution-service/process``) with POST method to
357create day-1 configuration. Use the following payload:
JakobKrieg0f29c1c2020-10-01 14:00:40 +0200358
JakobKriegfac42cc2020-11-06 19:17:56 +0100359.. code-block:: JSON
JakobKrieg0f29c1c2020-10-01 14:00:40 +0200360
JakobKriegfac42cc2020-11-06 19:17:56 +0100361 {
362 "actionIdentifiers": {
363 "mode": "sync",
364 "blueprintName": "pnf_netconf",
365 "blueprintVersion": "1.0.0",
366 "actionName": "config-assign"
367 },
368 "payload": {
369 "config-assign-request": {
370 "resolution-key": "day-1",
371 "config-assign-properties": {
372 "stream-count": 5
373 }
374 }
375 },
376 "commonHeader": {
377 "subRequestId": "143748f9-3cd5-4910-81c9-a4601ff2ea58",
378 "requestId": "e5eb1f1e-3386-435d-b290-d49d8af8db4c",
379 "originatorId": "SDNC_DG"
380 }
381 }
JakobKrieg0f29c1c2020-10-01 14:00:40 +0200382
JakobKriegfac42cc2020-11-06 19:17:56 +0100383You can verify the day-1 NETCONF RPC payload looking into CDS DB. You should see the NETCONF RPC with 5
384streams (fw_udp_1 TO fw_udp_5). Connect to the DB and run the below statement. You should
385see the day-1 configuration as an output.
JakobKrieg0f29c1c2020-10-01 14:00:40 +0200386
JakobKriegfac42cc2020-11-06 19:17:56 +0100387.. code-block:: sh
JakobKrieg0f29c1c2020-10-01 14:00:40 +0200388
JakobKriegfac42cc2020-11-06 19:17:56 +0100389 MariaDB [sdnctl]> select * from TEMPLATE_RESOLUTION where resolution_key='day-1' AND artifact_name='netconfrpc';
JakobKrieg0f29c1c2020-10-01 14:00:40 +0200390
JakobKriegfac42cc2020-11-06 19:17:56 +0100391 <rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="1">
392 <edit-config>
393 <target>
394 <running/>
395 </target>
396 <config>
397 <sample-plugin xmlns="urn:opendaylight:params:xml:ns:yang:sample-plugin">
398 <pg-streams>
399 <pg-stream>
400 <id>fw_udp_1</id>
401 <is-enabled>true</is-enabled>
402 </pg-stream>
403 <pg-stream>
404 <id>fw_udp_2</id>
405 <is-enabled>true</is-enabled>
406 </pg-stream>
407 <pg-stream>
408 <id>fw_udp_3</id>
409 <is-enabled>true</is-enabled>
410 </pg-stream>
411 <pg-stream>
412 <id>fw_udp_4</id>
413 <is-enabled>true</is-enabled>
414 </pg-stream>
415 <pg-stream>
416 <id>fw_udp_5</id>
417 <is-enabled>true</is-enabled>
418 </pg-stream>
419 </pg-streams>
420 </sample-plugin>
421 </config>
422 </edit-config>
423 </rpc>
JakobKrieg0f29c1c2020-10-01 14:00:40 +0200424
JakobKriegfac42cc2020-11-06 19:17:56 +0100425For creating day-2 configuration call the same endpoint and use the following payload:
JakobKrieg0f29c1c2020-10-01 14:00:40 +0200426
JakobKriegfac42cc2020-11-06 19:17:56 +0100427.. code-block:: JSON
JakobKrieg0f29c1c2020-10-01 14:00:40 +0200428
JakobKriegfac42cc2020-11-06 19:17:56 +0100429 {
430 "actionIdentifiers": {
431 "mode": "sync",
432 "blueprintName": "pnf_netconf",
433 "blueprintVersion": "1.0.0",
434 "actionName": "config-assign"
435 },
436 "payload": {
437 "config-assign-request": {
438 "resolution-key": "day-2",
439 "config-assign-properties": {
440 "stream-count": 10
441 }
442 }
443 },
444 "commonHeader": {
445 "subRequestId": "143748f9-3cd5-4910-81c9-a4601ff2ea58",
446 "requestId": "e5eb1f1e-3386-435d-b290-d49d8af8db4c",
447 "originatorId": "SDNC_DG"
448 }
449 }
JakobKrieg0f29c1c2020-10-01 14:00:40 +0200450
JakobKrieg0f29c1c2020-10-01 14:00:40 +0200451
JakobKriegfac42cc2020-11-06 19:17:56 +0100452.. note::
453 Until this step CDS did not interact with the PNF simulator or device. We just created the day-1 and day-2
454 configurations and stored it in CDS database
JakobKriegabfdc072020-10-06 16:49:39 +0200455
JakobKriegfac42cc2020-11-06 19:17:56 +0100456**Config-Deploy:**
JakobKriegabfdc072020-10-06 16:49:39 +0200457
JakobKriegfac42cc2020-11-06 19:17:56 +0100458Now we will make the CDS REST API calls to push the day-1 and day-2 configuration changes to the PNF simulator.
459Call the same `process` endpoint with the following payload:
JakobKriegabfdc072020-10-06 16:49:39 +0200460
JakobKriegfac42cc2020-11-06 19:17:56 +0100461.. code-block:: JSON
JakobKrieg0f29c1c2020-10-01 14:00:40 +0200462
JakobKriegfac42cc2020-11-06 19:17:56 +0100463 {
464 "actionIdentifiers": {
465 "mode": "sync",
466 "blueprintName": "pnf_netconf",
467 "blueprintVersion": "1.0.0",
468 "actionName": "config-deploy"
469 },
470 "payload": {
471 "config-deploy-request": {
472 "resolution-key": "day-1",
473 "pnf-ipv4-address": "127.17.0.2",
474 "netconf-username": "netconf",
475 "netconf-password": "netconf"
476 }
477 },
478 "commonHeader": {
479 "subRequestId": "143748f9-3cd5-4910-81c9-a4601ff2ea58",
480 "requestId": "e5eb1f1e-3386-435d-b290-d49d8af8db4c",
481 "originatorId": "SDNC_DG"
482 }
483 }
JakobKrieg0f29c1c2020-10-01 14:00:40 +0200484
JakobKriegfac42cc2020-11-06 19:17:56 +0100485Go back to PNF netopeer cli console like mentioned above and verify if you can see 5 streams fw_udp_1 to fw_udp_5 enabled. If the 5 streams
486appear in the output as follows, the day-1 configuration got successfully deployed and the use case is successfully done.
JakobKrieg0f29c1c2020-10-01 14:00:40 +0200487
JakobKriegfac42cc2020-11-06 19:17:56 +0100488.. code-block:: sh
JakobKrieg0f29c1c2020-10-01 14:00:40 +0200489
JakobKriegfac42cc2020-11-06 19:17:56 +0100490 > get --filter-xpath /sample-plugin:*
491 DATA
492 <sample-plugin xmlns="urn:opendaylight:params:xml:ns:yang:sample-plugin">
493 <pg-streams>
494 <pg-stream>
495 <id>1</id>
496 <is-enabled>true</is-enabled>
497 </pg-stream>
498 <pg-stream>
499 <id>fw_udp_1</id>
500 <is-enabled>true</is-enabled>
501 </pg-stream>
502 <pg-stream>
503 <id>fw_udp_2</id>
504 <is-enabled>true</is-enabled>
505 </pg-stream>
506 <pg-stream>
507 <id>fw_udp_3</id>
508 <is-enabled>true</is-enabled>
509 </pg-stream>
510 <pg-stream>
511 <id>fw_udp_4</id>
512 <is-enabled>true</is-enabled>
513 </pg-stream>
514 <pg-stream>
515 <id>fw_udp_5</id>
516 <is-enabled>true</is-enabled>
517 </pg-stream>
518 </pg-streams>
519 </sample-plugin>
520 >
JakobKrieg0f29c1c2020-10-01 14:00:40 +0200521
JakobKriegfac42cc2020-11-06 19:17:56 +0100522The same can be done for day-2 config (follow same steps just with day-2 in payload).
JakobKrieg0f29c1c2020-10-01 14:00:40 +0200523
JakobKriegfac42cc2020-11-06 19:17:56 +0100524.. note::
525 Through deployment we did not deploy the PNF, we just modified the PNF. The PNF could also be installed by CDS
526 but this is not targeted in this guide.
JakobKriegabfdc072020-10-06 16:49:39 +0200527
528
529Creators of this guide
530~~~~~~~~~~~~~~~~~~~~~~~
531
532Deutsche Telekom AG
533
534Jakob Krieg (Rocketchat @jakob.Krieg); Eli Halych (Rocketchat @elihalych)
535
JakobKriegfac42cc2020-11-06 19:17:56 +0100536This guide is a derivate from https://wiki.onap.org/display/DW/PNF+Simulator+Day-N+config-assign+and+config-deploy+use+case.