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_use_case:
8 PNF Simulator Day-N config-assign/deploy
9 ========================================
14 This use case shows in a very simple way how the day-n configuration is assigned and deployed to a PNF through CDS.
15 A Netconf server (docker image `sysrepo/sysrepo-netopeer2`) is used for simulating the PNF.
17 This use case (POC) solely requires a running CDS and the PNF Simulator running on a VM (Ubuntu is used by the author).
18 No other module of ONAP is needed.
20 There are different ways to run CDS and the PNF simulator. This guide will show
21 different possible options to allow the greatest possible flexibility.
23 Run CDS (Blueprint Processor)
24 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
26 CDS can be run in Kubernetes (Minikube, Microk8s) or in an IDE. You can choose your favorite option.
27 Just the blueprint processor of CDS is needed. If you have desktop access it is recommended to run CDS in an IDE since
28 it is easy and enables debugging.
30 * CDS in Microk8s: https://wiki.onap.org/display/DW/Running+CDS+on+Microk8s (RDT link to be added)
31 * CDS in Minikube: https://wiki.onap.org/display/DW/Running+CDS+in+minikube (RDT link to be added)
32 * CDS in an IDE: https://docs.onap.org/projects/onap-ccsdk-cds/en/latest/userguide/running-bp-processor-in-ide.html
34 Run PNF Simulator and install module
35 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
37 There are many different ways to run a Netconf Server to simulate the PNF, in this guide `sysrepo/sysrepo-netopeer2`
38 docker image is commonly used. The easiest way is to run the out-of-the-box docker container without any
39 other configuration, modules or scripts. In the ONAP community there are other workflows existing for running the
40 PNF Simulator. These workflows are also using `sysrepo/sysrepo-netopeer2` docker image. These workflow are also linked
41 here but they are not tested by the author of this guide.
45 .. tab:: sysrepo/sysrepo-netopeer2 (latest)
47 Download and run docker container with ``docker run -d --name netopeer2 -p 830:830 -p 6513:6513 sysrepo/sysrepo-netopeer2:latest``
49 Enter the container with ``docker exec -it netopeer2 bin/bash``
51 Browse to the target location where all YANG modules exist: ``cd /etc/sysrepo/yang``
53 Create a simple mock YANG model for a packet generator (:file:`pg.yang`).
58 module sample-plugin {
61 namespace "urn:opendaylight:params:xml:ns:yang:sample-plugin";
62 prefix "sample-plugin";
65 "This YANG module defines the generic configuration and
66 operational data for sample-plugin in VPP";
68 revision "2016-09-18" {
69 description "Initial revision of sample-plugin model";
72 container sample-plugin {
74 uses sample-plugin-params;
75 description "Configuration data of sample-plugin in Honeycomb";
78 // curl -u admin:admin http://localhost:8181/restconf/config/sample-plugin:sample-plugin
81 // curl http://localhost:8181/restconf/operational/sample-plugin:sample-plugin
85 grouping sample-plugin-params {
86 container pg-streams {
102 Create the following sample XML data definition for the above model (:file:`pg-data.xml`).
103 Later on this will initialise one single PG stream.
106 :caption: **pg-data.xml**
108 <sample-plugin xmlns="urn:opendaylight:params:xml:ns:yang:sample-plugin">
112 <is-enabled>true</is-enabled>
117 Execute the following command within netopeer docker container to install the pg.yang model
121 sysrepoctl -v3 -i pg.yang
124 This command will just schedule the installation, it will be applied once the server is restarted.
126 Stop the container from outside with ``docker stop netopeer2`` and start it again with ``docker start netopeer2``
128 Enter the container like it's mentioned above with ``docker exec -it netopeer2 bin/bash``.
130 You can check all installed modules with ``sysrepoctl -l``. `sample-plugin` module should appear with ``I`` flag.
132 Execute the following the commands to initialise the Yang model with one pg-stream record.
133 We will be using CDS to perform the day-1 and day-2 configuration changes.
138 > connect --host localhost --login root
140 > get --filter-xpath /sample-plugin:*
141 # shows existing pg-stream records (empty)
142 > edit-config --target running --config=/etc/sysrepo/yang/pg-data.xml
143 # initialises Yang model with one pg-stream record
144 > get --filter-xpath /sample-plugin:*
145 # shows initialised pg-stream
147 If the output of the last command is like this, everything went successful:
152 <sample-plugin xmlns="urn:opendaylight:params:xml:ns:yang:sample-plugin">
156 <is-enabled>true</is-enabled>
162 .. tab:: sysrepo/sysrepo-netopeer2 (legacy)
164 Download and run docker container with ``docker run -d --name netopeer2 -p 830:830 -p 6513:6513 sysrepo/sysrepo-netopeer2:legacy``
166 Enter the container with ``docker exec -it netopeer2 bin/bash``
168 Browse to the target location where all YANG modules exist: ``cd /opt/dev/sysrepo/yang``
170 Create a simple mock YANG model for a packet generator (:file:`pg.yang`).
173 :caption: **pg.yang**
175 module sample-plugin {
178 namespace "urn:opendaylight:params:xml:ns:yang:sample-plugin";
179 prefix "sample-plugin";
182 "This YANG module defines the generic configuration and
183 operational data for sample-plugin in VPP";
185 revision "2016-09-18" {
186 description "Initial revision of sample-plugin model";
189 container sample-plugin {
191 uses sample-plugin-params;
192 description "Configuration data of sample-plugin in Honeycomb";
195 // curl -u admin:admin http://localhost:8181/restconf/config/sample-plugin:sample-plugin
198 // curl http://localhost:8181/restconf/operational/sample-plugin:sample-plugin
202 grouping sample-plugin-params {
203 container pg-streams {
219 Create the following sample XML data definition for the above model (:file:`pg-data.xml`).
220 Later on this will initialise one single PG (packet-generator) stream.
223 :caption: **pg-data.xml**
225 <sample-plugin xmlns="urn:opendaylight:params:xml:ns:yang:sample-plugin">
229 <is-enabled>true</is-enabled>
234 Execute the following command within netopeer docker container to install the pg.yang model
238 sysrepoctl -i -g pg.yang
240 You can check all installed modules with ``sysrepoctl -l``. `sample-plugin` module should appear with ``I`` flag.
242 In legacy version of `sysrepo/sysrepo-netopeer2` subscribers of a module are required, otherwise they are not
243 running and configurations changes are not accepted, see https://github.com/sysrepo/sysrepo/issues/1395. There is
244 an predefined application mock up which can be used for that. The usage is described
245 here: https://asciinema.org/a/160247. You need to run the following
246 commands to start the example application for subscribing to our sample-plugin YANG module.
250 cd /opt/dev/sysrepo/build/examples
251 ./application_example sample-plugin
253 Following output should appear:
257 ========== READING STARTUP CONFIG sample-plugin: ==========
259 /sample-plugin:sample-plugin (container)
260 /sample-plugin:sample-plugin/pg-streams (container)
263 ========== STARTUP CONFIG sample-plugin APPLIED AS RUNNING ==========
266 The terminal session needs to be kept open after application has started.
268 Open a new terminal and enter the container with ``docker exec -it netopeer2 bin/bash``.
269 Execute the following commands in the container to initialise the Yang model with one pg-stream record.
270 We will be using CDS to perform the day-1 configuration and day-2 configuration changes.
275 > connect --host localhost --login netconf
276 # passwort is netconf
277 > get --filter-xpath /sample-plugin:*
278 # shows existing pg-stream records (empty)
279 > edit-config --target running --config=/opt/dev/sysrepo/yang/pg-data.xml
280 # initialises Yang model with one pg-stream record
281 > get --filter-xpath /sample-plugin:*
282 # shows initialised pg-stream
284 If the output of the last command is like this, everything went successful:
289 <sample-plugin xmlns="urn:opendaylight:params:xml:ns:yang:sample-plugin">
293 <is-enabled>true</is-enabled>
298 You can also see that there are additional logs in the subscriber application after editing the configuration of our
301 .. tab:: PNF simulator integration project
304 This method of setting up the PNF simulator is not tested by the author of this guide
306 You can refer to `PnP PNF Simulator wiki page <https://wiki.onap.org/display/DW/PnP+PNF+Simulator>`_
307 to clone the GIT repo and start the required docker containers. We are interested in the
308 `sysrepo/sysrepo-netopeer2` docker container to load a simple YANG similar to vFW Packet Generator.
310 Start PNF simulator docker containers. You can consider changing the netopeer image verion to image:
311 `sysrepo/sysrepo-netopeer2:iop` in docker-compose.yml file If you find any issues with the default image.
317 git clone https://github.com/onap/integration.git
321 cd ~/integration/test/mocks/pnfsimulator
325 Verify that you have netopeer docker container are up and running. It will be mapped to host port 830.
329 docker ps -a | grep netopeer
332 .. _pnf_simulator_use_case_config_assign_deploy:
334 Config-assign and config-deploy in CDS
335 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
337 In the following steps config-assignment is done and the config is deployed to the
338 Netconf server through CDS. Example requests are in the following Postman collection
339 :download:`JSON <media/pnf-simulator.postman_collection.json>`. You can also use bash scripting to call the APIs.
342 The CBA for this PNF Demo gets loaded, enriched and saved in CDS through calling bootstrap. If not done before, call
345 Password and username for API calls will be `ccsdkapps`.
349 The assumption is that we are using the same host to run PNF NETCONF simulator as well as CDS. You will need the
350 IP Adress of the Netconf server container which can be found out with
351 ``docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' netopeer2``. In the
352 following example payloads we will use 172.17.0.2.
354 Call the `process` API (``http://{{host}}:{{port}}/api/v1/execution-service/process``) with POST method to
355 create day-1 configuration. Use the following payload:
360 "actionIdentifiers": {
362 "blueprintName": "pnf_netconf",
363 "blueprintVersion": "1.0.0",
364 "actionName": "config-assign"
367 "config-assign-request": {
368 "resolution-key": "day-1",
369 "config-assign-properties": {
375 "subRequestId": "143748f9-3cd5-4910-81c9-a4601ff2ea58",
376 "requestId": "e5eb1f1e-3386-435d-b290-d49d8af8db4c",
377 "originatorId": "SDNC_DG"
381 You can verify the day-1 NETCONF RPC payload looking into CDS DB. You should see the NETCONF RPC with 5
382 streams (fw_udp_1 TO fw_udp_5). Connect to the DB and run the below statement. You should
383 see the day-1 configuration as an output.
387 MariaDB [sdnctl]> select * from TEMPLATE_RESOLUTION where resolution_key='day-1' AND artifact_name='netconfrpc';
389 <rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="1">
395 <sample-plugin xmlns="urn:opendaylight:params:xml:ns:yang:sample-plugin">
399 <is-enabled>true</is-enabled>
403 <is-enabled>true</is-enabled>
407 <is-enabled>true</is-enabled>
411 <is-enabled>true</is-enabled>
415 <is-enabled>true</is-enabled>
423 For creating day-2 configuration call the same endpoint and use the following payload:
428 "actionIdentifiers": {
430 "blueprintName": "pnf_netconf",
431 "blueprintVersion": "1.0.0",
432 "actionName": "config-assign"
435 "config-assign-request": {
436 "resolution-key": "day-2",
437 "config-assign-properties": {
443 "subRequestId": "143748f9-3cd5-4910-81c9-a4601ff2ea58",
444 "requestId": "e5eb1f1e-3386-435d-b290-d49d8af8db4c",
445 "originatorId": "SDNC_DG"
451 Until this step CDS did not interact with the PNF simulator or device. We just created the day-1 and day-2
452 configurations and stored it in CDS database
456 Now we will make the CDS REST API calls to push the day-1 and day-2 configuration changes to the PNF simulator.
457 Call the same endpoint `process` with the following payload:
462 "actionIdentifiers": {
464 "blueprintName": "pnf_netconf",
465 "blueprintVersion": "1.0.0",
466 "actionName": "config-deploy"
469 "config-deploy-request": {
470 "resolution-key": "day-1",
471 "pnf-ipv4-address": "127.17.0.2",
472 "netconf-username": "netconf",
473 "netconf-password": "netconf"
477 "subRequestId": "143748f9-3cd5-4910-81c9-a4601ff2ea58",
478 "requestId": "e5eb1f1e-3386-435d-b290-d49d8af8db4c",
479 "originatorId": "SDNC_DG"
483 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
484 appear in the output as follows, the day-1 configuration got successfully deployed and the use case is successfully done.
488 > get --filter-xpath /sample-plugin:*
490 <sample-plugin xmlns="urn:opendaylight:params:xml:ns:yang:sample-plugin">
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>
514 <is-enabled>true</is-enabled>
520 The same can be done for day-2 config (follow same steps just with day-2 in payload).
523 Through deployment we did not deploy the PNF, we just modified the PNF. The PNF could also be installed by CDS
524 but this is not targeted in this guide.
527 Creators of this guide
528 ~~~~~~~~~~~~~~~~~~~~~~~
532 Jakob Krieg (Rocketchat @jakob.Krieg); Eli Halych (Rocketchat @elihalych)
534 This guide is a derivate from https://wiki.onap.org/display/DW/PNF+Simulator+Day-N+config-assign+and+config-deploy+use+case.