1 .. 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.
6 PNF Simulator Day-N config-assign/deploy
7 ========================================
12 This use case shows in a very simple way how the day-n configuration is assigned and deployed to a PNF through CDS.
13 A Netconf server (docker image `sysrepo/sysrepo-netopeer2`) is used for simulating the PNF.
15 This use case (POC) solely requires a running CDS and the PNF Simulator running on a VM (Ubuntu is used by the author).
16 No other module of ONAP is needed.
18 There are different ways to run CDS and the PNF simulator. This guide will show
19 different possible options to allow the greatest possible flexibility.
21 Run CDS (Blueprint Processor)
22 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24 CDS can be run in Kubernetes (Minikube, Microk8s) or in an IDE. You can choose your favorite option.
25 Just the blueprint processor of CDS is needed. If you have desktop access it is recommended to run CDS in an IDE since
26 it is easy and enables debugging.
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
32 Run PNF Simulator and install module
33 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
35 There are many different ways to run a Netconf Server to simulate the PNF, in this guide `sysrepo/sysrepo-netopeer2`
36 docker image is commonly used. The easiest way is to run the out-of-the-box docker container without any
37 other configuration, modules or scripts. In the ONAP community there are other workflows existing for running the
38 PNF Simulator. These workflows are also using `sysrepo/sysrepo-netopeer2` docker image. These workflow are also linked
39 here but they are not tested by the author of this guide.
43 .. tab:: sysrepo/sysrepo-netopeer2 (latest)
45 Download and run docker container with ``docker run -d --name netopeer2 -p 830:830 -p 6513:6513 sysrepo/sysrepo-netopeer2:latest``
47 Enter the container with ``docker exec -it netopeer2 bin/bash``
49 Browse to the target location where all YANG modules exist: ``cd /etc/sysrepo/yang``
51 Create a simple mock YANG model for a packet generator (:file:`pg.yang`).
56 module sample-plugin {
59 namespace "urn:opendaylight:params:xml:ns:yang:sample-plugin";
60 prefix "sample-plugin";
63 "This YANG module defines the generic configuration and
64 operational data for sample-plugin in VPP";
66 revision "2016-09-18" {
67 description "Initial revision of sample-plugin model";
70 container sample-plugin {
72 uses sample-plugin-params;
73 description "Configuration data of sample-plugin in Honeycomb";
76 // curl -u admin:admin http://localhost:8181/restconf/config/sample-plugin:sample-plugin
79 // curl http://localhost:8181/restconf/operational/sample-plugin:sample-plugin
83 grouping sample-plugin-params {
84 container pg-streams {
100 Create the following sample XML data definition for the above model (:file:`pg-data.xml`).
101 Later on this will initialise one single PG stream.
104 :caption: **pg-data.xml**
106 <sample-plugin xmlns="urn:opendaylight:params:xml:ns:yang:sample-plugin">
110 <is-enabled>true</is-enabled>
115 Execute the following command within netopeer docker container to install the pg.yang model
119 sysrepoctl -v3 -i pg.yang
122 This command will just schedule the installation, it will be applied once the server is restarted.
124 Stop the container from outside with ``docker stop netopeer2`` and start it again with ``docker start netopeer2``
126 Enter the container like it's mentioned above with ``docker exec -it netopeer2 bin/bash``.
128 You can check all installed modules with ``sysrepoctl -l``. `sample-plugin` module should appear with ``I`` flag.
130 Execute the following the commands to initialise the Yang model with one pg-stream record.
131 We will be using CDS to perform the day-1 and day-2 configuration changes.
136 > connect --host localhost --login root
138 > get --filter-xpath /sample-plugin:*
139 # shows existing pg-stream records (empty)
140 > edit-config --target running --config=/etc/sysrepo/yang/pg-data.xml
141 # initialises Yang model with one pg-stream record
142 > get --filter-xpath /sample-plugin:*
143 # shows initialised pg-stream
145 If the output of the last command is like this, everything went successful:
150 <sample-plugin xmlns="urn:opendaylight:params:xml:ns:yang:sample-plugin">
154 <is-enabled>true</is-enabled>
160 .. tab:: sysrepo/sysrepo-netopeer2 (legacy)
162 Download and run docker container with ``docker run -d --name netopeer2 -p 830:830 -p 6513:6513 sysrepo/sysrepo-netopeer2:legacy``
164 Enter the container with ``docker exec -it netopeer2 bin/bash``
166 Browse to the target location where all YANG modules exist: ``cd /opt/dev/sysrepo/yang``
168 Create a simple mock YANG model for a packet generator (:file:`pg.yang`).
171 :caption: **pg.yang**
173 module sample-plugin {
176 namespace "urn:opendaylight:params:xml:ns:yang:sample-plugin";
177 prefix "sample-plugin";
180 "This YANG module defines the generic configuration and
181 operational data for sample-plugin in VPP";
183 revision "2016-09-18" {
184 description "Initial revision of sample-plugin model";
187 container sample-plugin {
189 uses sample-plugin-params;
190 description "Configuration data of sample-plugin in Honeycomb";
193 // curl -u admin:admin http://localhost:8181/restconf/config/sample-plugin:sample-plugin
196 // curl http://localhost:8181/restconf/operational/sample-plugin:sample-plugin
200 grouping sample-plugin-params {
201 container pg-streams {
217 Create the following sample XML data definition for the above model (:file:`pg-data.xml`).
218 Later on this will initialise one single PG (packet-generator) stream.
221 :caption: **pg-data.xml**
223 <sample-plugin xmlns="urn:opendaylight:params:xml:ns:yang:sample-plugin">
227 <is-enabled>true</is-enabled>
232 Execute the following command within netopeer docker container to install the pg.yang model
236 sysrepoctl -i -g pg.yang
238 You can check all installed modules with ``sysrepoctl -l``. `sample-plugin` module should appear with ``I`` flag.
240 In legacy version of `sysrepo/sysrepo-netopeer2` subscribers of a module are required, otherwise they are not
241 running and configurations changes are not accepted, see https://github.com/sysrepo/sysrepo/issues/1395. There is
242 an predefined application mock up which can be used for that. The usage is described
243 here: https://asciinema.org/a/160247. You need to run the following
244 commands to start the example application for subscribing to our sample-plugin YANG module.
248 cd /opt/dev/sysrepo/build/examples
249 ./application_example sample-plugin
251 Following output should appear:
255 ========== READING STARTUP CONFIG sample-plugin: ==========
257 /sample-plugin:sample-plugin (container)
258 /sample-plugin:sample-plugin/pg-streams (container)
261 ========== STARTUP CONFIG sample-plugin APPLIED AS RUNNING ==========
264 The terminal session needs to be kept open after application has started.
266 Open a new terminal and enter the container with ``docker exec -it netopeer2 bin/bash``.
267 Execute the following commands in the container to initialise the Yang model with one pg-stream record.
268 We will be using CDS to perform the day-1 configuration and day-2 configuration changes.
273 > connect --host localhost --login netconf
274 # passwort is netconf
275 > get --filter-xpath /sample-plugin:*
276 # shows existing pg-stream records (empty)
277 > edit-config --target running --config=/opt/dev/sysrepo/yang/pg-data.xml
278 # initialises Yang model with one pg-stream record
279 > get --filter-xpath /sample-plugin:*
280 # shows initialised pg-stream
282 If the output of the last command is like this, everything went successful:
287 <sample-plugin xmlns="urn:opendaylight:params:xml:ns:yang:sample-plugin">
291 <is-enabled>true</is-enabled>
296 You can also see that there are additional logs in the subscriber application after editing the configuration of our
299 .. tab:: PNF simulator integration project
302 This method of setting up the PNF simulator is not tested by the author of this guide
304 You can refer to `PnP PNF Simulator wiki page <https://wiki.onap.org/display/DW/PnP+PNF+Simulator>`_
305 to clone the GIT repo and start the required docker containers. We are interested in the
306 `sysrepo/sysrepo-netopeer2` docker container to load a simple YANG similar to vFW Packet Generator.
308 Start PNF simulator docker containers. You can consider changing the netopeer image verion to image:
309 `sysrepo/sysrepo-netopeer2:iop` in docker-compose.yml file If you find any issues with the default image.
315 git clone https://github.com/onap/integration.git
319 cd ~/integration/test/mocks/pnfsimulator
323 Verify that you have netopeer docker container are up and running. It will be mapped to host port 830.
327 docker ps -a | grep netopeer
330 Config-assign and config-deploy in CDS
331 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
333 In the following steps config-assignment is done and the config is deployed to the
334 Netconf server through CDS. Example requests are in the following Postman collection
335 :download:`JSON <media/pnf-simulator.postman_collection.json>`. You can also use bash scripting to call the APIs.
338 The CBA for this PNF Demo gets loaded, enriched and saved in CDS through calling bootstrap. If not done before, call
341 Password and username for API calls will be `ccsdkapps`.
345 The assumption is that we are using the same host to run PNF NETCONF simulator as well as CDS. You will need the
346 IP Adress of the Netconf server container which can be found out with
347 ``docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' netopeer2``. In the
348 following example payloads we will use 172.17.0.2.
350 Call the `process` API (``http://{{host}}:{{port}}/api/v1/execution-service/process``) with POST method to
351 create day-1 configuration. Use the following payload:
356 "actionIdentifiers": {
358 "blueprintName": "pnf_netconf",
359 "blueprintVersion": "1.0.0",
360 "actionName": "config-assign"
363 "config-assign-request": {
364 "resolution-key": "day-1",
365 "config-assign-properties": {
371 "subRequestId": "143748f9-3cd5-4910-81c9-a4601ff2ea58",
372 "requestId": "e5eb1f1e-3386-435d-b290-d49d8af8db4c",
373 "originatorId": "SDNC_DG"
377 You can verify the day-1 NETCONF RPC payload looking into CDS DB. You should see the NETCONF RPC with 5
378 streams (fw_udp_1 TO fw_udp_5). Connect to the DB and run the below statement. You should
379 see the day-1 configuration as an output.
383 MariaDB [sdnctl]> select * from TEMPLATE_RESOLUTION where resolution_key='day-1' AND artifact_name='netconfrpc';
385 <rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="1">
391 <sample-plugin xmlns="urn:opendaylight:params:xml:ns:yang:sample-plugin">
395 <is-enabled>true</is-enabled>
399 <is-enabled>true</is-enabled>
403 <is-enabled>true</is-enabled>
407 <is-enabled>true</is-enabled>
411 <is-enabled>true</is-enabled>
419 For creating day-2 configuration call the same endpoint and use the following payload:
424 "actionIdentifiers": {
426 "blueprintName": "pnf_netconf",
427 "blueprintVersion": "1.0.0",
428 "actionName": "config-assign"
431 "config-assign-request": {
432 "resolution-key": "day-2",
433 "config-assign-properties": {
439 "subRequestId": "143748f9-3cd5-4910-81c9-a4601ff2ea58",
440 "requestId": "e5eb1f1e-3386-435d-b290-d49d8af8db4c",
441 "originatorId": "SDNC_DG"
447 Until this step CDS did not interact with the PNF simulator or device. We just created the day-1 and day-2
448 configurations and stored it in CDS database
452 Now we will make the CDS REST API calls to push the day-1 and day-2 configuration changes to the PNF simulator.
453 Call the same endpoint `process` with the following payload:
458 "actionIdentifiers": {
460 "blueprintName": "pnf_netconf",
461 "blueprintVersion": "1.0.0",
462 "actionName": "config-deploy"
465 "config-deploy-request": {
466 "resolution-key": "day-1",
467 "pnf-ipv4-address": "127.17.0.2",
468 "netconf-username": "netconf",
469 "netconf-password": "netconf"
473 "subRequestId": "143748f9-3cd5-4910-81c9-a4601ff2ea58",
474 "requestId": "e5eb1f1e-3386-435d-b290-d49d8af8db4c",
475 "originatorId": "SDNC_DG"
479 Go 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
480 appear in the output as follows, the day-1 configuration got successfully deployed and the use case is successfully done.
484 > get --filter-xpath /sample-plugin:*
486 <sample-plugin xmlns="urn:opendaylight:params:xml:ns:yang:sample-plugin">
490 <is-enabled>true</is-enabled>
494 <is-enabled>true</is-enabled>
498 <is-enabled>true</is-enabled>
502 <is-enabled>true</is-enabled>
506 <is-enabled>true</is-enabled>
510 <is-enabled>true</is-enabled>
516 The same can be done for day-2 config (follow same steps just with day-2 in payload).
519 Through deployment we did not deploy the PNF, we just modified the PNF. The PNF could also be installed by CDS
520 but this is not targeted in this guide.
523 Creators of this guide
524 ~~~~~~~~~~~~~~~~~~~~~~~
528 Jakob Krieg (Rocketchat @jakob.Krieg); Eli Halych (Rocketchat @elihalych)
530 This guide is a derivate from https://wiki.onap.org/display/DW/PNF+Simulator+Day-N+config-assign+and+config-deploy+use+case.