Convert yanglib to OSGi DS
[netconf.git] / docs / user-guide.rst
1 .. _netconf-user-guide:
2
3 .. |ss| raw:: html
4
5    <strike>
6
7 .. |se| raw:: html
8
9    </strike>
10
11 NETCONF User Guide
12 ==================
13
14 Overview
15 --------
16
17 NETCONF is an XML-based protocol used for configuration and monitoring
18 devices in the network. The base NETCONF protocol is described in
19 `RFC-6241 <https://www.rfc-editor.org/rfc/rfc6241>`__.
20
21 **NETCONF in OpenDaylight:.**
22
23 OpenDaylight supports the NETCONF protocol as a northbound server as
24 well as a southbound plugin. It also includes a set of test tools for
25 simulating NETCONF devices and clients.
26
27 Southbound (netconf-connector)
28 ------------------------------
29
30 The NETCONF southbound plugin is capable of connecting to remote NETCONF
31 devices and exposing their configuration/operational datastores, RPCs
32 and notifications as MD-SAL mount points. These mount points allow
33 applications and remote users (over RESTCONF) to interact with the
34 mounted devices.
35
36 In terms of RFCs, the connector supports:
37
38 -  `RFC-6241 <https://www.rfc-editor.org/rfc/rfc6241>`__
39
40 -  `RFC-5277 <https://www.rfc-editor.org/rfc/rfc5277>`__
41
42 -  `RFC-6022 <https://www.rfc-editor.org/rfc/rfc6022>`__
43
44 -  `RFC-7895 <https://www.rfc-editor.org/rfc/rfc7895>`__
45
46 **Netconf-connector is fully model-driven (utilizing the YANG modeling
47 language) so in addition to the above RFCs, it supports any
48 data/RPC/notifications described by a YANG model that is implemented by
49 the device.**
50
51 .. tip::
52
53     NETCONF southbound can be activated by installing
54     ``odl-netconf-connector-all`` Karaf feature.
55
56 Netconf-connector configuration
57 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
58
59 NETCONF connectors are configured directly through the usage of the
60 network-topology model. You can configure new NETCONF connectors both
61 through the NETCONF server for MD-SAL (port 2830) or RESTCONF. This guide
62 focuses on RESTCONF.
63
64 .. important::
65
66     Since 2022.09 Chlorine there is only one RESTCONF endpoint:
67
68     - | ``http://localhost:8181/rests`` is related to `RFC-8040 <https://www.rfc-editor.org/rfc/rfc8040>`__,
69       | can be activated by installing ``odl-restconf-nb``
70        Karaf feature.
71
72     | Resources for configuration and operational datastores start
73      ``/rests/data/``,
74     | e. g. GET
75      http://localhost:8181/rests/data/network-topology:network-topology
76      with response of both datastores. It's allowed to use query
77      parameters to distinguish between them.
78     | e. g. GET
79      http://localhost:8181/rests/data/network-topology:network-topology?content=config
80      for configuration datastore
81     | and GET
82      http://localhost:8181/rests/data/network-topology:network-topology?content=nonconfig
83      for operational datastore.
84
85     | Also if a data node in the path expression is a YANG leaf-list or list
86      node, the path segment has to be constructed by having leaf-list or
87      list node name, followed by an "=" character, then followed by the
88      leaf-list or list value. Any reserved characters must be
89      percent-encoded.
90     | e. g. GET
91      http://localhost:8181/rests/data/network-topology:network-topology/topology=topology-netconf?content=config
92      for retrieving data from configuration datastore for
93      topology-netconf value of topology list.
94
95 Preconditions
96 ^^^^^^^^^^^^^
97
98 1. OpenDaylight is running
99
100 2. In Karaf, you must have the ``odl-netconf-topology`` or
101    ``odl-netconf-clustered-topology`` feature installed.
102
103 3. Feature ``odl-restconf-nb`` must be installed
104
105 Spawning new NETCONF connectors
106 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
107
108 To create a new NETCONF connector you need to send the following PUT request
109 to RESTCONF:
110
111 .. list-table::
112    :widths: 1 5
113
114    * - rfc8040
115      - http://localhost:8181/rests/data/network-topology:network-topology/topology=topology-netconf/node=new-netconf-device
116
117 You could use the same body to create the new  NETCONF connector with a POST
118 without specifying the node in the URL:
119
120 .. list-table::
121    :widths: 1 5
122
123    * - rfc8040
124      - http://localhost:8181/rests/data/network-topology:network-topology/topology=topology-netconf
125
126 Payload:
127
128 .. tabs::
129
130    .. tab:: XML
131
132       **Content-type:** ``application/xml``
133
134       **Accept:** ``application/xml``
135
136       **Authentication:** ``admin:admin``
137
138       .. code-block:: xml
139
140          <node xmlns="urn:TBD:params:xml:ns:yang:network-topology">
141            <node-id>new-netconf-device</node-id>
142            <host xmlns="urn:opendaylight:netconf-node-topology">127.0.0.1</host>
143            <port xmlns="urn:opendaylight:netconf-node-topology">17830</port>
144            <username xmlns="urn:opendaylight:netconf-node-topology">admin</username>
145            <password xmlns="urn:opendaylight:netconf-node-topology">admin</password>
146            <tcp-only xmlns="urn:opendaylight:netconf-node-topology">false</tcp-only>
147            <!-- non-mandatory fields with default values, you can safely remove these if you do not wish to override any of these values-->
148            <reconnect-on-changed-schema xmlns="urn:opendaylight:netconf-node-topology">false</reconnect-on-changed-schema>
149            <connection-timeout-millis xmlns="urn:opendaylight:netconf-node-topology">20000</connection-timeout-millis>
150            <max-connection-attempts xmlns="urn:opendaylight:netconf-node-topology">0</max-connection-attempts>
151            <between-attempts-timeout-millis xmlns="urn:opendaylight:netconf-node-topology">2000</between-attempts-timeout-millis>
152            <sleep-factor xmlns="urn:opendaylight:netconf-node-topology">1.5</sleep-factor>
153            <!-- keepalive-delay set to 0 turns off keepalives-->
154            <keepalive-delay xmlns="urn:opendaylight:netconf-node-topology">120</keepalive-delay>
155          </node>
156
157    .. tab:: JSON
158
159       **Content-type:** ``application/json``
160
161       **Accept:** ``application/json``
162
163       **Authentication:** ``admin:admin``
164
165       .. code-block:: json
166
167          {
168              "node": [
169                  {
170                      "node-id": "new-netconf-device",
171                      "netconf-node-topology:port": 17830,
172                      "netconf-node-topology:reconnect-on-changed-schema": false,
173                      "netconf-node-topology:connection-timeout-millis": 20000,
174                      "netconf-node-topology:tcp-only": false,
175                      "netconf-node-topology:max-connection-attempts": 0,
176                      "netconf-node-topology:username": "admin",
177                      "netconf-node-topology:password": "admin",
178                      "netconf-node-topology:sleep-factor": 1.5,
179                      "netconf-node-topology:host": "127.0.0.1",
180                      "netconf-node-topology:between-attempts-timeout-millis": 2000,
181                      "netconf-node-topology:keepalive-delay": 120
182                  }
183              ]
184          }
185
186 Note that the device name in <node-id> element must match the last
187 element of the restconf URL.
188
189 Reconfiguring an existing connector
190 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
191
192 The steps to reconfigure an existing connector are exactly the same as
193 when spawning a new connector. The old connection will be disconnected
194 and a new connector with the new configuration will be created. This needs
195 to be done with a PUT request because the node already exists. A POST
196 request will fail for that reason.
197
198 Additionally, a PATCH request can be used to modify an existing
199 configuration. Currently, only yang-patch (`RFC-8072 <https://www.rfc-editor.org/rfc/rfc8072>`__)
200 is supported. The URL would be the same as the above PUT examples.
201 Using JSON for the body, the headers needed for the request would
202 be:
203
204 Headers:
205
206 -  Accept: application/yang-data+json
207
208 -  Content-Type: application/yang-patch+json
209
210 Example JSON payload to modify the password entry:
211
212 ::
213
214     {
215       "ietf-restconf:yang-patch" : {
216         "patch-id" : "0",
217         "edit" : [
218           {
219             "edit-id" : "edit1",
220             "operation" : "merge",
221             "target" : "",
222             "value" : {
223              "node": [
224                 {
225                  "node-id": "new-netconf-device",
226                  "netconf-node-topology:password" : "newpassword"
227                 }
228              ]
229             }
230          }
231         ]
232       }
233     }
234
235 Deleting an existing connector
236 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
237
238 To remove an already configured NETCONF connector you need to send a
239 DELETE request to the same PUT request URL that was used to create the
240 device:
241
242 .. list-table::
243    :widths: 1 5
244
245    * - rfc8040
246      - http://localhost:8181/rests/data/network-topology:network-topology/topology=topology-netconf/node=new-netconf-device
247
248 .. note::
249
250     No body is needed to delete the node/device
251
252 Connecting to a device not supporting NETCONF monitoring
253 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
254
255 The netconf-connector in OpenDaylight relies on ietf-netconf-monitoring
256 support when connecting to remote NETCONF device. The
257 ietf-netconf-monitoring support allows netconf-connector to list and
258 download all YANG schemas that are used by the device. NETCONF connector
259 can only communicate with a device if it knows the set of used schemas
260 (or at least a subset). However, some devices use YANG models internally
261 but do not support NETCONF monitoring. Netconf-connector can also
262 communicate with these devices, but you have to side load the necessary
263 yang models into OpenDaylight’s YANG model cache for netconf-connector.
264 In general there are 2 situations you might encounter:
265
266 **1. NETCONF device does not support ietf-netconf-monitoring but it does
267 list all its YANG models as capabilities in HELLO message**
268
269 This could be a device that internally uses only ietf-inet-types YANG
270 model with revision 2010-09-24. In the HELLO message that is sent from
271 this device there is this capability reported:
272
273 ::
274
275     urn:ietf:params:xml:ns:yang:ietf-inet-types?module=ietf-inet-types&revision=2010-09-24
276
277 **For such devices you only need to put the schema into folder
278 cache/schema inside your Karaf distribution.**
279
280 .. important::
281
282     The file with YANG schema for ietf-inet-types has to be called
283     ietf-inet-types@2010-09-24.yang. It is the required naming format of
284     the cache.
285
286 **2. NETCONF device does not support ietf-netconf-monitoring and it does
287 NOT list its YANG models as capabilities in HELLO message**
288
289 Compared to device that lists its YANG models in HELLO message, in this
290 case there would be no capability with ietf-inet-types in the HELLO
291 message. This type of device basically provides no information about the
292 YANG schemas it uses so its up to the user of OpenDaylight to properly
293 configure netconf-connector for this device.
294
295 Netconf-connector has an optional configuration attribute called
296 yang-module-capabilities and this attribute can contain a list of "YANG
297 module based" capabilities. So by setting this configuration attribute,
298 it is possible to override the "yang-module-based" capabilities reported
299 in HELLO message of the device. To do this, we need to modify the
300 configuration of netconf-connector like in the example below:
301
302 .. tabs::
303
304    .. tab:: XML
305
306       **Content-type:** ``application/xml``
307
308       **Accept:** ``application/xml``
309
310       **Authentication:** ``admin:admin``
311
312       .. code-block:: xml
313
314          <node xmlns="urn:TBD:params:xml:ns:yang:network-topology">
315            <node-id>r5</node-id>
316            <host xmlns="urn:opendaylight:netconf-node-topology">127.0.0.1</host>
317            <port xmlns="urn:opendaylight:netconf-node-topology">8305</port>
318            <username xmlns="urn:opendaylight:netconf-node-topology">root</username>
319            <password xmlns="urn:opendaylight:netconf-node-topology">root</password>
320            <tcp-only xmlns="urn:opendaylight:netconf-node-topology">false</tcp-only>
321            <keepalive-delay xmlns="urn:opendaylight:netconf-node-topology">30</keepalive-delay>
322            <yang-module-capabilities xmlns="urn:opendaylight:netconf-node-topology">
323              <override>true</override>
324              <capability xmlns="urn:opendaylight:netconf-node-topology">
325                urn:ietf:params:xml:ns:yang:ietf-inet-types?module=ietf-inet-types&amp;revision=2013-07-15
326              </capability>
327            </yang-module-capabilities>
328          </node>
329
330    .. tab:: JSON
331
332       **Content-type:** ``application/json``
333
334       **Accept:** ``application/json``
335
336       **Authentication:** ``admin:admin``
337
338       .. code-block:: json
339
340          {
341              "node": [
342                  {
343                      "node-id": "device",
344                      "netconf-node-topology:host": "127.0.0.1",
345                      "netconf-node-topology:password": "root",
346                      "netconf-node-topology:username": "root",
347                      "netconf-node-topology:yang-module-capabilities": {
348                          "override": true,
349                          "capability": [
350                              "urn:ietf:params:xml:ns:yang:ietf-inet-types?module=ietf-inet-types&revision=2013-07-15"
351                          ]
352                      },
353                      "netconf-node-topology:port": 8305,
354                      "netconf-node-topology:tcp-only": false,
355                      "netconf-node-topology:keepalive-delay": 30
356                  }
357              ]
358          }
359
360 **Remember to also put the YANG schemas into the cache folder.**
361
362 .. note::
363
364     For putting multiple capabilities, you just need to replicate the
365     capability element inside yang-module-capability element.
366     Capability element is modeled as a leaf-list. With this
367     configuration, we would make the remote device report usage of
368     ietf-inet-types in the eyes of netconf-connector.
369
370 Connecting to a device supporting only NETCONF 1.0
371 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
372
373 OpenDaylight is schema-based distribution and heavily depends on YANG
374 models. However some legacy NETCONF devices are not schema-based and
375 implement just RFC 4741. This type of device does not utilize YANG
376 models internally and OpenDaylight does not know how to communicate
377 with such devices, how to validate data, or what the semantics of data
378 are.
379
380 NETCONF connector can communicate also with these devices, but the
381 trade-offs are worsened possibilities in utilization of NETCONF
382 mountpoints. Using RESTCONF with such devices is not suported. Also
383 communicating with schemaless devices from application code is slightly
384 different.
385
386 To connect to schemaless device, there is a optional configuration option
387 in netconf-node-topology model called schemaless. You have to set this
388 option to true.
389
390 Clustered NETCONF connector
391 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
392
393 To spawn NETCONF connectors that are cluster-aware you need to install
394 the ``odl-netconf-clustered-topology`` karaf feature.
395
396 .. warning::
397
398     The ``odl-netconf-topology`` and ``odl-netconf-clustered-topology``
399     features are considered **INCOMPATIBLE**. They both manage the same
400     space in the datastore and would issue conflicting writes if
401     installed together.
402
403 Configuration of clustered NETCONF connectors works the same as the
404 configuration through the topology model in the previous section.
405
406 When a new clustered connector is configured the configuration gets
407 distributed among the member nodes and a NETCONF connector is spawned on
408 each node. From these nodes a master is chosen which handles the schema
409 download from the device and all the communication with the device. You
410 will be able to read/write to/from the device from all slave nodes due
411 to the proxy data brokers implemented.
412
413 You can use the ``odl-netconf-clustered-topology`` feature in a single
414 node scenario as well but the code that uses akka will be used, so for a
415 scenario where only a single node is used, ``odl-netconf-topology``
416 might be preferred.
417
418 Netconf-connector utilization
419 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
420
421 Once the connector is up and running, users can utilize the new mount
422 point instance. By using RESTCONF or from their application code. This
423 chapter deals with using RESTCONF and more information for app
424 developers can be found in the developers guide or in the official
425 tutorial application **ncmount** that can be found in the coretutorials
426 project:
427
428 -  https://github.com/opendaylight/coretutorials/tree/master/ncmount
429
430 Reading data from the device
431 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
432
433 Just invoke (no body needed):
434
435 GET
436 http://localhost:8181/rests/data/network-topology:network-topology/topology=topology-netconf/node=new-netconf-device/yang-ext:mount?content=nonconfig
437
438 This will return the entire content of operation datastore from the
439 device. To view just the configuration datastore, change **nonconfig**
440 in this URL to **config**.
441
442 Writing configuration data to the device
443 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
444
445 In general, you cannot simply write any data you want to the device. The
446 data have to conform to the YANG models implemented by the device. In
447 this example we are adding a new interface-configuration to the mounted
448 device (assuming the device supports Cisco-IOS-XR-ifmgr-cfg YANG model).
449 In fact this request comes from the tutorial dedicated to the
450 **ncmount** tutorial app.
451
452 POST
453 http://localhost:8181/rests/data/network-topology:network-topology/topology=topology-netconf/node=new-netconf-device/yang-ext:mount/Cisco-IOS-XR-ifmgr-cfg:interface-configurations
454
455 ::
456
457     <interface-configuration xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg">
458         <active>act</active>
459         <interface-name>mpls</interface-name>
460         <description>Interface description</description>
461         <bandwidth>32</bandwidth>
462         <link-status></link-status>
463     </interface-configuration>
464
465 Should return 200 response code with no body.
466
467 .. tip::
468
469     This call is transformed into a couple of NETCONF RPCs. Resulting
470     NETCONF RPCs that go directly to the device can be found in the
471     OpenDaylight logs after invoking ``log:set TRACE
472     org.opendaylight.controller.sal.connect.netconf`` in the Karaf
473     shell. Seeing the NETCONF RPCs might help with debugging.
474
475 This request is very similar to the one where we spawned a new netconf
476 device. That’s because we used the loopback netconf-connector to write
477 configuration data into config-subsystem datastore and config-subsystem
478 picked it up from there.
479
480 Invoking custom RPC
481 ^^^^^^^^^^^^^^^^^^^
482
483 Devices can implement any additional RPC and as long as it provides YANG
484 models for it, it can be invoked from OpenDaylight. Following example
485 shows how to invoke the get-schema RPC (get-schema is quite common among
486 netconf devices). Invoke:
487
488 POST
489 http://localhost:8181/rests/operations/network-topology:network-topology/topology=topology-netconf/node=new-netconf-device/yang-ext:mount/ietf-netconf-monitoring:get-schema
490
491 ::
492
493     <input xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring">
494       <identifier>ietf-yang-types</identifier>
495       <version>2013-07-15</version>
496     </input>
497
498 This call should fetch the source for ietf-yang-types YANG model from
499 the mounted device.
500
501 Receiving Netconf Device Notifications on a http client
502 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
503
504 Devices emit netconf alarms and notifictions on certain situtations, which can demand
505 attention from Device Administration. The notifications are received as Netconf messages on an
506 active Netconf session.
507
508 Opendaylight provides the way to stream the device notifications over a http session.
509
510 - Step 1: Mount the device (assume node name is test_device)
511
512 - Step 2: Wait for the device to be connected.
513
514 - Step 3: Create the Subscription for notification on the active session.
515
516  .. code-block::
517
518     POST
519     http://localhost:8181/rests/operations/network-topology:network-topology/topology=topology-netconf/node=test_device/yang-ext:mount/notifications:create-subscription
520     Content-Type: application/json
521     Accept: application/json
522
523  .. code-block:: json
524
525     {
526       "input": {
527         "stream": "NETCONF"
528        }
529     }
530
531 - Step 4: Create the http Stream for the events.
532
533 .. code-block::
534
535     POST
536     http://localhost:8181/rests/operations/odl-device-notification:subscribe-device-notification
537     Content-Type: application/json
538     Accept: application/json
539
540 .. code-block:: json
541
542     {
543       "input": {
544          "path":"/network-topology:network-topology/topology[topology-id='topology-netconf']/node[node-id='test_device']"
545       }
546     }
547
548 The response suggests the http url for reading the notifications.
549
550 .. code-block:: json
551
552     {
553        "odl-device-notification:output": {
554             "stream-path": "http://localhost:8181/rests/notif/test_device?notificationType=test_device"
555         }
556     }
557
558 - Step 5: User can access the url in the response and the notifications will be as follows.
559
560 .. code-block::
561
562     GET
563     http://localhost:8181/rests/notif/test_device?notificationType=test_device
564     Content-Type: application/xml
565     Accept: application/xml
566
567
568 .. code-block:: xml
569
570     : ping
571
572     : ping
573
574     : ping
575
576     : ping
577
578     : ping
579
580     data: <notification xmlns="urn:ietf:params:xml:ns:netconf:notification:1.0"><eventTime>2022-06-17T07:01:08.60228Z</eventTime><netconf-session-start xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-notifications"><username>root</username><source-host>127.0.0.1</source-host><session-id>2</session-id></netconf-session-start></notification>
581
582     data: <notification xmlns="urn:ietf:params:xml:ns:netconf:notification:1.0"><eventTime>2022-06-17T07:01:12.458258Z</eventTime><netconf-session-end xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-notifications"><username>root</username><source-host>127.0.0.1</source-host><termination-reason>closed</termination-reason><session-id>2</session-id></netconf-session-end></notification>
583
584 Change event notification subscription tutorial
585 -----------------------------------------------
586
587 Subscribing to data change notifications makes it possible to obtain
588 notifications about data manipulation (insert, change, delete) which are
589 done on any specified **path** of any specified **datastore** with
590 specific **scope**. In following examples *{odlAddress}* is address of
591 server where ODL is running and *{odlPort}* is port on which
592 OpenDaylight is running. OpenDaylight offers two methods for receiving notifications:
593 Server-Sent Events (SSE) and WebSocket. SSE is the default notification mechanism used in OpenDaylight.
594
595 SSE notifications subscription process
596 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
597
598 In this section we will learn what steps need to be taken in order to
599 successfully subscribe to data change event notifications.
600
601 Create stream
602 ^^^^^^^^^^^^^
603
604 In order to use event notifications you first need to call RPC that
605 creates notification stream that you can later listen to. You need to
606 provide three parameters to this RPC:
607
608 -  **path**: data store path that you plan to listen to. You can
609    register listener on containers, lists and leaves.
610
611 -  **datastore**: data store type. *OPERATIONAL* or *CONFIGURATION*.
612
613 -  **scope**: Represents scope of data change. Possible options are:
614
615    -  BASE: only changes directly to the data tree node specified in the
616       path will be reported
617
618    -  ONE: changes to the node and to direct child nodes will be
619       reported
620
621    -  SUBTREE: changes anywhere in the subtree starting at the node will
622       be reported
623
624 The RPC to create the stream can be invoked via RESTCONF like this:
625
626 ::
627
628     OPERATION: POST
629     URI:  http://{odlAddress}:{odlPort}/rests/operations/sal-remote:create-data-change-event-subscription
630     HEADER: Content-Type=application/json
631             Accept=application/json
632
633 .. code-block:: json
634
635        {
636            "input": {
637                "path": "/toaster:toaster/toaster:toasterStatus",
638                "sal-remote-augment:datastore": "OPERATIONAL",
639                "sal-remote-augment:scope": "ONE"
640            }
641        }
642
643 The response should look something like this:
644
645 .. code-block:: json
646
647     {
648         "sal-remote:output": {
649             "stream-name": "data-change-event-subscription/toaster:toaster/toaster:toasterStatus/datastore=CONFIGURATION/scope=SUBTREE"
650         }
651     }
652
653 **stream-name** is important because you will need to use it when you
654 subscribe to the stream in the next step.
655
656 .. note::
657
658     Internally, this will create a new listener for *stream-name* if it
659     did not already exist.
660
661 Subscribe to stream
662 ^^^^^^^^^^^^^^^^^^^
663
664 In order to subscribe to stream and obtain SSE location you need
665 to call *GET* on your stream path. The URI should generally be
666 `http://{odlAddress}:{odlPort}/rests/data/ietf-restconf-monitoring:restconf-state/streams/stream/{streamName}`,
667 where *{streamName}* is the *stream-name* parameter contained in
668 response from *create-data-change-event-subscription* RPC from the
669 previous step.
670
671 ::
672
673    OPERATION: GET
674    URI: http://{odlAddress}:{odlPort}/rests/data/ietf-restconf-monitoring:restconf-state/streams/stream/data-change-event-subscription/toaster:toaster/datastore=CONFIGURATION/scope=SUBTREE
675
676 The subscription call may be modified with the following query parameters defined in the RESTCONF RFC:
677
678 -  `filter <https://www.rfc-editor.org/rfc/rfc8040#section-4.8.4>`__
679
680 -  `start-time <https://www.rfc-editor.org/rfc/rfc8040#section-4.8.7>`__
681
682 -  `end-time <https://www.rfc-editor.org/rfc/rfc8040#section-4.8.8>`__
683
684 In addition, the following ODL extension query parameter is supported:
685
686 :odl-leaf-nodes-only:
687   If this parameter is set to "true", create and update notifications will only
688   contain the leaf nodes modified instead of the entire subscription subtree.
689   This can help in reducing the size of the notifications.
690
691 :odl-skip-notification-data:
692   If this parameter is set to "true", create and update notifications will only
693   contain modified leaf nodes without data.
694   This can help in reducing the size of the notifications.
695
696 The response should look something like this:
697
698 .. code-block:: json
699
700     {
701         "subscribe-to-notification:location": "http://localhost:8181/rests/notif/data-change-event-subscription/network-topology:network-topology/datastore=CONFIGURATION/scope=SUBTREE"
702     }
703
704 .. note::
705
706     During this phase there is an internal check for to see if a
707     listener for the *stream-name* from the URI exists. If not, new a
708     new listener is registered with the DOM data broker.
709
710 Receive notifications
711 ^^^^^^^^^^^^^^^^^^^^^
712
713 Once you got SSE location you can now connect to it and
714 start receiving data change events. The request should look something like this:
715
716 ::
717
718     curl -v -X GET  http://localhost:8181/rests/notif/data-change-event-subscription/toaster:toaster/toasterStatus/datastore=OPERATIONAL/scope=ONE  -H "Content-Type: text/event-stream" -H "Authorization: Basic YWRtaW46YWRtaW4="
719
720
721 WebSocket notifications subscription process
722 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
723
724 Enabling WebSocket notifications in OpenDaylight requires a manual setup before starting the application.
725 The following steps can be followed to enable WebSocket notifications in OpenDaylight:
726
727 1. Open the file `restconf8040.cfg`, at `etc/` folder inside your Karaf distribution.
728 2. Locate the `use-sse` configuration parameter and change its value from `true` to `false`.
729 3. Uncomment the `use-sse` parameter if it is commented out.
730 4. Save the changes made to the `restconf8040.cfg` file.
731 5. Restart OpenDaylight if it is already running.
732
733 Once these steps are completed, WebSocket notifications will be enabled in OpenDaylight,
734 and they can be used for receiving notifications instead of SSE.
735
736 WebSocket Notifications subscription process is the same as SSE until you receive a location of WebSocket.
737 You can follow steps given above and after subscribing to a notification stream over WebSocket,
738 you will receive a response indicating that the subscription was successful:
739
740 .. code-block:: json
741
742     {
743         "subscribe-to-notification:location": "ws://localhost:8181/rests/notif/data-change-event-subscription/network-topology:network-topology/datastore=CONFIGURATION/scope=SUBTREE"
744     }
745
746 You can use this WebSocket to listen to data
747 change notifications. To listen to notifications you can use a
748 JavaScript client or if you are using chrome browser you can use the
749 `Simple WebSocket
750 Client <https://chrome.google.com/webstore/detail/simple-websocket-client/pfdhoblngboilpfeibdedpjgfnlcodoo>`__.
751
752 Also, for testing purposes, there is simple Java application named
753 WebSocketClient. The application is placed in the
754 */restconf/websocket-client* project. It accepts a WebSocket URI
755 as and input parameter. After starting the utility (WebSocketClient
756 class directly in Eclipse/InteliJ Idea) received notifications should be
757 displayed in console.
758
759 Notifications are always in XML format and look like this:
760
761 .. code-block:: xml
762
763     <notification xmlns="urn:ietf:params:xml:ns:netconf:notification:1.0">
764         <eventTime>2014-09-11T09:58:23+02:00</eventTime>
765         <data-changed-notification xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote">
766             <data-change-event>
767                 <path xmlns:meae="http://netconfcentral.org/ns/toaster">/meae:toaster</path>
768                 <operation>updated</operation>
769                 <data>
770                    <!-- updated data -->
771                 </data>
772             </data-change-event>
773         </data-changed-notification>
774     </notification>
775
776 Example use case
777 ~~~~~~~~~~~~~~~~
778
779 The typical use case is listening to data change events to update web
780 page data in real-time. In this tutorial we will be using toaster as the
781 base.
782
783 When you call *make-toast* RPC, it sets *toasterStatus* to "down" to
784 reflect that the toaster is busy making toast. When it finishes,
785 *toasterStatus* is set to "up" again. We will listen to this toaster
786 status changes in data store and will reflect it on our web page in
787 real-time thanks to WebSocket data change notification.
788
789 Simple javascript client implementation
790 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
791
792 We will create simple JavaScript web application that will listen
793 updates on *toasterStatus* leaf and update some element of our web page
794 according to new toaster status state.
795
796 Create stream
797 ^^^^^^^^^^^^^
798
799 First you need to create stream that you are planing to subscribe to.
800 This can be achieved by invoking "create-data-change-event-subscription"
801 RPC on RESTCONF via AJAX request. You need to provide data store
802 **path** that you plan to listen on, **data store type** and **scope**.
803 If the request is successful you can extract the **stream-name** from
804 the response and use that to subscribe to the newly created stream. The
805 *{username}* and *{password}* fields represent your credentials that you
806 use to connect to OpenDaylight via RESTCONF:
807
808 .. note::
809
810     The default user name and password are "admin".
811
812 .. code-block:: javascript
813
814     function createStream() {
815         $.ajax(
816             {
817                 url: 'http://{odlAddress}:{odlPort}/rests/operations/sal-remote:create-data-change-event-subscription',
818                 type: 'POST',
819                 headers: {
820                   'Authorization': 'Basic ' + btoa('{username}:{password}'),
821                   'Content-Type': 'application/json'
822                 },
823                 data: JSON.stringify(
824                     {
825                         'input': {
826                             'path': '/toaster:toaster/toaster:toasterStatus',
827                             'sal-remote-augment:datastore': 'OPERATIONAL',
828                             'sal-remote-augment:scope': 'ONE'
829                         }
830                     }
831                 )
832             }).done(function (data) {
833                 // this function will be called when ajax call is executed successfully
834                 subscribeToStream(data.output['stream-name']);
835             }).fail(function (data) {
836                 // this function will be called when ajax call fails
837                 console.log("Create stream call unsuccessful");
838             })
839     }
840
841 Subscribe to stream
842 ^^^^^^^^^^^^^^^^^^^
843
844 The Next step is to subscribe to the stream. To subscribe to the stream
845 you need to call *GET* on
846 *http://{odlAddress}:{odlPort}/rests/data/ietf-restconf-monitoring:restconf-state/streams/stream/{stream-name}*.
847 If the call is successful, you get WebSocket address for this stream in
848 **Location** parameter inside response header. You can get response
849 header by calling *getResponseHeader(\ *Location*)* on HttpRequest
850 object inside *done()* function call:
851
852 .. code-block:: javascript
853
854     function subscribeToStream(streamName) {
855         $.ajax(
856             {
857                 url: 'http://{odlAddress}:{odlPort}/rests/data/ietf-restconf-monitoring:restconf-state/streams/stream/' + streamName;
858                 type: 'GET',
859                 headers: {
860                   'Authorization': 'Basic ' + btoa('{username}:{password}'),
861                 }
862             }
863         ).done(function (data, textStatus, httpReq) {
864             // we need function that has http request object parameter in order to access response headers.
865             listenToNotifications(httpReq.getResponseHeader('Location'));
866         }).fail(function (data) {
867             console.log("Subscribe to stream call unsuccessful");
868         });
869     }
870
871 Receive notifications
872 ^^^^^^^^^^^^^^^^^^^^^
873
874 Once you got WebSocket server location you can now connect to it and
875 start receiving data change events. You need to define functions that
876 will handle events on WebSocket. In order to process incoming events
877 from OpenDaylight you need to provide a function that will handle
878 *onmessage* events. The function must have one parameter that represents
879 the received event object. The event data will be stored in
880 *event.data*. The data will be in an XML format that you can then easily
881 parse using jQuery.
882
883 .. code-block:: javascript
884
885     function listenToNotifications(socketLocation) {
886         try {
887             var notificatinSocket = new WebSocket(socketLocation);
888
889             notificatinSocket.onmessage = function (event) {
890                 // we process our received event here
891                 console.log('Received toaster data change event.');
892                 $($.parseXML(event.data)).find('data-change-event').each(
893                     function (index) {
894                         var operation = $(this).find('operation').text();
895                         if (operation == 'updated') {
896                             // toaster status was updated so we call function that gets the value of toasterStatus leaf
897                             updateToasterStatus();
898                             return false;
899                         }
900                     }
901                 );
902             }
903             notificatinSocket.onerror = function (error) {
904                 console.log("Socket error: " + error);
905             }
906             notificatinSocket.onopen = function (event) {
907                 console.log("Socket connection opened.");
908             }
909             notificatinSocket.onclose = function (event) {
910                 console.log("Socket connection closed.");
911             }
912             // if there is a problem on socket creation we get exception (i.e. when socket address is incorrect)
913         } catch(e) {
914             alert("Error when creating WebSocket" + e );
915         }
916     }
917
918 The *updateToasterStatus()* function represents function that calls
919 *GET* on the path that was modified and sets toaster status in some web
920 page element according to received data. After the WebSocket connection
921 has been established you can test events by calling make-toast RPC via
922 RESTCONF.
923
924 .. note::
925
926     for more information about WebSockets in JavaScript visit `Writing
927     WebSocket client
928     applications <https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API/Writing_WebSocket_client_applications>`__
929
930 Netconf-connector + Netopeer
931 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
932
933 `Netopeer <https://github.com/cesnet/netopeer>`__ (an open-source
934 NETCONF server) can be used for testing/exploring NETCONF southbound in
935 OpenDaylight.
936
937 Netopeer installation
938 ^^^^^^^^^^^^^^^^^^^^^
939
940 A `Docker <https://www.docker.com/>`__ container with netopeer will be
941 used in this guide. To install Docker and start the `netopeer
942 image <https://hub.docker.com/r/sysrepo/sysrepo-netopeer2>`__ perform
943 following steps:
944
945 1. Install docker https://docs.docker.com/get-started/
946
947 2. Start the netopeer image:
948
949    ::
950
951        docker run -it --name sysrepo -p 830:830 --rm sysrepo/sysrepo-netopeer2:latest
952
953 3. Verify netopeer is running by invoking (netopeer should send its
954    HELLO message right away:
955
956    ::
957
958        ssh root@localhost -p 830 -s netconf
959        (password root)
960
961 Mounting netopeer NETCONF server
962 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
963
964 Preconditions:
965
966 -  OpenDaylight is started with features ``odl-restconf-all`` and
967    ``odl-netconf-connector-all``.
968
969 -  Netopeer is up and running in docker
970
971 Now just follow the section: `Spawning new NETCONF connectors`_.
972 In the payload change the:
973
974 -  name, e.g., to netopeer
975
976 -  username/password to your system credentials
977
978 -  ip to localhost
979
980 -  port to 1831.
981
982 After netopeer is mounted successfully, its configuration can be read
983 using RESTCONF by invoking:
984
985 GET
986 http://localhost:8181/rests/data/network-topology:network-topology/topology=topology-netconf/node=netopeer/yang-ext:mount?content:config
987
988 Northbound (NETCONF servers)
989 ----------------------------
990
991 OpenDaylight provides 2 types of NETCONF servers:
992
993 -  **NETCONF server for config-subsystem (listening by default on port
994    1830)**
995
996    -  Serves as a default interface for config-subsystem and allows
997       users to spawn/reconfigure/destroy modules (or applications) in
998       OpenDaylight
999
1000 -  **NETCONF server for MD-SAL (listening by default on port 2830)**
1001
1002    -  Serves as an alternative interface for MD-SAL (besides RESTCONF)
1003       and allows users to read/write data from MD-SAL’s datastore and to
1004       invoke its rpcs (NETCONF notifications are not available in the
1005       Boron release of OpenDaylight)
1006
1007 .. note::
1008
1009     The reason for having 2 NETCONF servers is that config-subsystem and
1010     MD-SAL are 2 different components of OpenDaylight and require
1011     different approach for NETCONF message handling and data
1012     translation. These 2 components will probably merge in the future.
1013
1014 .. note::
1015
1016     Since Nitrogen release, there is performance regression in NETCONF
1017     servers accepting SSH connections. While opening a connection takes
1018     less than 10 seconds on Carbon, on Nitrogen time can increase up to
1019     60 seconds. Please see https://jira.opendaylight.org/browse/ODLPARENT-112
1020
1021 NETCONF server for config-subsystem
1022 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1023
1024 This NETCONF server is the primary interface for config-subsystem. It
1025 allows the users to interact with config-subsystem in a standardized
1026 NETCONF manner.
1027
1028 In terms of RFCs, these are supported:
1029
1030 -  `RFC-6241 <https://www.rfc-editor.org/rfc/rfc6241>`__
1031
1032 -  `RFC-5277 <https://www.rfc-editor.org/rfc/rfc5277>`__
1033
1034 -  `RFC-6470 <https://www.rfc-editor.org/rfc/rfc6470>`__
1035
1036    -  (partially, only the schema-change notification is available in
1037       Boron release)
1038
1039 -  `RFC-6022 <https://www.rfc-editor.org/rfc/rfc6022>`__
1040
1041 For regular users it is recommended to use RESTCONF + the
1042 controller-config loopback mountpoint instead of using pure NETCONF. How
1043 to do that is spesific for each component/module/application in
1044 OpenDaylight and can be found in their dedicated user guides.
1045
1046 NETCONF server for MD-SAL
1047 ~~~~~~~~~~~~~~~~~~~~~~~~~
1048
1049 This NETCONF server is just a generic interface to MD-SAL in
1050 OpenDaylight. It uses the stadard MD-SAL APIs and serves as an
1051 alternative to RESTCONF. It is fully model driven and supports any data
1052 and rpcs that are supported by MD-SAL.
1053
1054 In terms of RFCs, these are supported:
1055
1056 -  `RFC-6241 <https://www.rfc-editor.org/rfc/rfc6241>`__
1057
1058 -  `RFC-6022 <https://www.rfc-editor.org/rfc/rfc6022>`__
1059
1060 -  `RFC-7895 <https://www.rfc-editor.org/rfc/rfc7895>`__
1061
1062 Notifications over NETCONF are not supported in the Boron release.
1063
1064 .. tip::
1065
1066     Install NETCONF northbound for MD-SAL by installing feature:
1067     ``odl-netconf-mdsal`` in karaf. Default binding port is **2830**.
1068
1069 Configuration
1070 ^^^^^^^^^^^^^
1071
1072 The default configuration can be found in file: *08-netconf-mdsal.xml*.
1073 The file contains the configuration for all necessary dependencies and a
1074 single SSH endpoint starting on port 2830. There is also a (by default
1075 disabled) TCP endpoint. It is possible to start multiple endpoints at
1076 the same time either in the initial configuration file or while
1077 OpenDaylight is running.
1078
1079 The credentials for SSH endpoint can also be configured here, the
1080 defaults are admin/admin. Credentials in the SSH endpoint are not yet
1081 managed by the centralized AAA component and have to be configured
1082 separately.
1083
1084 Verifying MD-SAL’s NETCONF server
1085 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1086
1087 After the NETCONF server is available it can be examined by a command
1088 line ssh tool:
1089
1090 ::
1091
1092     ssh admin@localhost -p 2830 -s netconf
1093
1094 The server will respond by sending its HELLO message and can be used as
1095 a regular NETCONF server from then on.
1096
1097 Mounting the MD-SAL’s NETCONF server
1098 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1099
1100 To perform this operation, just spawn a new netconf-connector as
1101 described in `Spawning new NETCONF connectors`_. Just change the ip to
1102 "127.0.0.1" port to "2830" and its name to "controller-mdsal".
1103
1104 Now the MD-SAL’s datastore can be read over RESTCONF via NETCONF by
1105 invoking:
1106
1107 GET
1108 http://localhost:8181/rests/data/network-topology:network-topology/topology=topology-netconf/node=controller-mdsal/yang-ext:mount?content:nonconfig
1109
1110 .. note::
1111
1112     This might not seem very useful, since MD-SAL can be accessed
1113     directly from RESTCONF or from Application code, but the same method
1114     can be used to mount and control other OpenDaylight instances by the
1115     "master OpenDaylight".
1116
1117 NETCONF stress/performance measuring tool
1118 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1119
1120 This is basically a NETCONF client that puts NETCONF servers under heavy
1121 load of NETCONF RPCs and measures the time until a configurable amount
1122 of them is processed.
1123
1124 RESTCONF stress-performance measuring tool
1125 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1126
1127 Very similar to NETCONF stress tool with the difference of using
1128 RESTCONF protocol instead of NETCONF.
1129
1130 YANGLIB remote repository
1131 -------------------------
1132
1133 There are scenarios in NETCONF deployment, that require for a centralized
1134 YANG models repository. YANGLIB plugin provides such remote repository.
1135
1136 To start this plugin, you have to install odl-yanglib feature. Then you
1137 have to configure YANGLIB either through RESTCONF or NETCONF. We will
1138 show how to configure YANGLIB through RESTCONF.
1139
1140 YANGLIB configuration
1141 ~~~~~~~~~~~~~~~~~~~~~
1142 YANGLIB configuration works through OSGi Configuration Admin interface, in the
1143 ``org.opendaylight.netconf.yanglib`` configuration PID. There are three tuneables you can
1144 set:
1145
1146 * ``cache-folder``, which defaults to ``cache/schema``
1147 * ``binding-address``, which defaults to ``localhost``
1148 * ``binding-port``, which defaults to ``8181``
1149
1150 In order to change these settings, you can either modify the corresponding configuration
1151 file, ``etc/org.opendaylight.netconf.yanglib.cfg``, for example:
1152
1153 ::
1154     cache-folder = cache/newSchema
1155     binding-address = localhost
1156     binding-port = 8181
1157
1158 Or use Karaf CLI:
1159
1160 ::
1161     opendaylight-user@root>config:edit org.opendaylight.netconf.yanglib
1162     opendaylight-user@root>config:property-set cache-folder cache/newSchema
1163     opendaylight-user@root>config:property-set binding-address localhost
1164     opendaylight-user@root>config:property-set binding-port 8181
1165     opendaylight-user@root>config:update
1166
1167 This YANGLIB takes all YANG sources from the configured sources folder and
1168 for each generates URL in form:
1169
1170 ::
1171
1172     http://localhost:8181/yanglib/schemas/{modelName}/{revision}
1173
1174 On this URL will be hosted YANG source for particular module.
1175
1176 YANGLIB instance also write this URL along with source identifier to
1177 ietf-netconf-yang-library/modules-state/module list.
1178
1179 Netconf-connector with YANG library as fallback
1180 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1181
1182 There is an optional configuration in netconf-connector called
1183 yang-library. You can specify YANG library to be plugged as additional
1184 source provider into the mount's schema repository. Since YANGLIB
1185 plugin is advertising provided modules through yang-library model, we
1186 can use it in mount point's configuration as YANG library.  To do this,
1187 we need to modify the configuration of netconf-connector by adding this
1188 XML
1189
1190 ::
1191
1192     <yang-library xmlns="urn:opendaylight:netconf-node-topology">
1193       <yang-library-url xmlns="urn:opendaylight:netconf-node-topology">http://localhost:8181/rests/data/ietf-yang-library:modules-state</yang-library-url>
1194       <username xmlns="urn:opendaylight:netconf-node-topology">admin</username>
1195       <password xmlns="urn:opendaylight:netconf-node-topology">admin</password>
1196     </yang-library>
1197
1198 This will register YANGLIB provided sources as a fallback schemas for
1199 particular mount point.
1200
1201 NETCONF Call Home
1202 -----------------
1203
1204 Call Home Installation
1205 ~~~~~~~~~~~~~~~~~~~~~~
1206
1207 ODL Call-Home server is installed in Karaf by installing karaf feature
1208 ``odl-netconf-callhome-ssh``. RESTCONF feature is recommended for
1209 configuring Call Home & testing its functionality.
1210
1211 ::
1212
1213   feature:install odl-netconf-callhome-ssh
1214
1215
1216 .. note::
1217
1218     In order to test Call Home functionality we recommend Netopeer or
1219     Netopeer2. See `Netopeer Call Home <https://github.com/CESNET/netopeer/wiki/CallHome>`__
1220     or `Netopeer2 <https://github.com/CESNET/netopeer2>`__ to learn how to
1221     enable call-home on Netopeer.
1222
1223 Northbound Call-Home API
1224 ~~~~~~~~~~~~~~~~~~~~~~~~
1225
1226 The northbound Call Home API is used for administering the Call-Home Server. The
1227 following describes this configuration.
1228
1229 Global Configuration
1230 ^^^^^^^^^^^^^^^^^^^^
1231
1232 .. important::
1233   The global configuration is not a part of the `RFC 8071
1234   <https://www.rfc-editor.org/rfc/rfc8071>`__ and, therefore, subject to change.
1235
1236 Configuring global credentials
1237 ''''''''''''''''''''''''''''''
1238
1239 ODL Call-Home server allows user to configure global credentials, which will be
1240 used for connected over SSH transport protocol devices which does not have
1241 device-specific credentials configured.
1242
1243 This is done by creating
1244 ``/odl-netconf-callhome-server:netconf-callhome-server/global/credentials``
1245 with username and passwords specified.
1246
1247 *Configuring global username & passwords to try*
1248
1249 .. code-block::
1250
1251     PUT HTTP/1.1
1252     /rests/data/odl-netconf-callhome-server:netconf-callhome-server/global/credentials
1253     Content-Type: application/json
1254     Accept: application/json
1255
1256 .. code-block:: json
1257
1258     {
1259       "credentials":
1260       {
1261         "username": "example",
1262         "passwords": [ "first-password-to-try", "second-password-to-try" ]
1263       }
1264     }
1265
1266 Configuring to accept any ssh server key using global credentials
1267 '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
1268
1269 By default Netconf Call-Home Server accepts only incoming connections
1270 from allowed devices
1271 ``/odl-netconf-callhome-server:netconf-callhome-server/allowed-devices``,
1272 if user desire to allow all incoming connections, it is possible to set
1273 ``accept-all-ssh-keys`` to ``true`` in
1274 ``/odl-netconf-callhome-server:netconf-callhome-server/global``.
1275
1276 The name of this devices in ``netconf-topology`` will be in format
1277 ``ip-address:port``. For naming devices see Device-Specific
1278 Configuration.
1279
1280 *Allowing unknown devices to connect*
1281
1282 This is a debug feature and should not be used in production. Besides being an obvious
1283 security issue, this also causes the Call-Home Server to drastically increase its output
1284 to the log.
1285
1286 .. code-block::
1287
1288     PUT HTTP/1.1
1289     /rests/data/odl-netconf-callhome-server:netconf-callhome-server/global/accept-all-ssh-keys
1290     Content-Type: application/json
1291     Accept: application/json
1292
1293 .. code-block:: json
1294
1295     {
1296         "accept-all-ssh-keys": "true"
1297     }
1298
1299 Device-Specific Configuration
1300 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1301
1302 Netconf Call Home server supports both of the secure transports used
1303 by the Network Configuration Protocol (NETCONF) - Secure Shell (SSH),
1304 and Transport Layer Security (TLS).
1305
1306 Configure device to connect over SSH protocol
1307 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1308
1309 Netconf Call Home Server uses device provided SSH server key (host key)
1310 to identify device. The pairing of name and server key is configured in
1311 ``/odl-netconf-callhome-server:netconf-callhome-server/allowed-devices``.
1312 This list is colloquially called a whitelist.
1313
1314 If the Call-Home Server finds the SSH host key in the whitelist, it continues
1315 to negotiate a NETCONF connection over an SSH session. If the SSH host key is
1316 not found, the connection between the Call Home server and the device is dropped
1317 immediately. In either case, the device that connects to the Call home server
1318 leaves a record of its presence in the operational store.
1319
1320 Configuring Device with Device-specific Credentials
1321 '''''''''''''''''''''''''''''''''''''''''''''''''''
1322
1323 Adding specific device to the allowed list is done by creating
1324 ``/odl-netconf-callhome-server:netconf-callhome-server/allowed-devices/device={device}``
1325 with device-id and connection parameters inside the ssh-client-params container.
1326
1327 *Configuring Device with Credentials*
1328
1329 .. code-block::
1330
1331     PUT HTTP/1.1
1332     /rests/data/odl-netconf-callhome-server:netconf-callhome-server/allowed-devices/device=example
1333     Content-Type: application/json
1334     Accept: application/json
1335
1336 .. code-block:: json
1337
1338     {
1339       "device": {
1340         "unique-id": "example",
1341         "ssh-client-params": {
1342           "credentials": {
1343             "username": "example",
1344             "passwords": [ "password" ]
1345           },
1346           "host-key": "AAAAB3NzaC1yc2EAAAADAQABAAABAQDHoH1jMjltOJnCt999uaSfc48ySutaD3ISJ9fSECe1Spdq9o9mxj0kBTTTq+2V8hPspuW75DNgN+V/rgJeoUewWwCAasRx9X4eTcRrJrwOQKzb5Fk+UKgQmenZ5uhLAefi2qXX/agFCtZi99vw+jHXZStfHm9TZCAf2zi+HIBzoVksSNJD0VvPo66EAvLn5qKWQD4AdpQQbKqXRf5/W8diPySbYdvOP2/7HFhDukW8yV/7ZtcywFUIu3gdXsrzwMnTqnATSLPPuckoi0V2jd8dQvEcu1DY+rRqmqu0tEkFBurlRZDf1yhNzq5xWY3OXcjgDGN+RxwuWQK3cRimcosH"
1347         }
1348       }
1349     }
1350
1351 Configuring Device with Global Credentials
1352 '''''''''''''''''''''''''''''''''''''''''''''''''''
1353
1354 It is possible to omit ``username`` and ``password`` for ssh-client-params,
1355 in such case values from global credentials will be used.
1356
1357 *Example of configuring device*
1358
1359 .. code-block::
1360
1361     PUT HTTP/1.1
1362     /rests/data/odl-netconf-callhome-server:netconf-callhome-server/allowed-devices/device=example
1363     Content-Type: application/json
1364     Accept: application/json
1365
1366 .. code-block:: json
1367
1368     {
1369       "device": {
1370         "unique-id": "example",
1371         "ssh-client-params": {
1372           "host-key": "AAAAB3NzaC1yc2EAAAADAQABAAABAQDHoH1jMjltOJnCt999uaSfc48ySutaD3ISJ9fSECe1Spdq9o9mxj0kBTTTq+2V8hPspuW75DNgN+V/rgJeoUewWwCAasRx9X4eTcRrJrwOQKzb5Fk+UKgQmenZ5uhLAefi2qXX/agFCtZi99vw+jHXZStfHm9TZCAf2zi+HIBzoVksSNJD0VvPo66EAvLn5qKWQD4AdpQQbKqXRf5/W8diPySbYdvOP2/7HFhDukW8yV/7ZtcywFUIu3gdXsrzwMnTqnATSLPPuckoi0V2jd8dQvEcu1DY+rRqmqu0tEkFBurlRZDf1yhNzq5xWY3OXcjgDGN+RxwuWQK3cRimcosH"
1373         }
1374       }
1375     }
1376
1377 Deprecated configuration models for devices accessed with SSH protocol
1378 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
1379
1380 With `RFC 8071 <https://www.rfc-editor.org/rfc/rfc8071>`__ alignment and adding
1381 support for TLS transport following configuration models has been marked
1382 deprecated.
1383
1384 Configuring Device with Global Credentials
1385 '''''''''''''''''''''''''''''''''''''''''''''''''''
1386
1387 *Example of configuring device*
1388
1389 .. code-block::
1390
1391     PUT HTTP/1.1
1392     /rests/data/odl-netconf-callhome-server:netconf-callhome-server/allowed-devices/device=example
1393     Content-Type: application/json
1394     Accept: application/json
1395
1396 .. code-block:: json
1397
1398     {
1399       "device": {
1400         "unique-id": "example",
1401         "ssh-host-key": "AAAAB3NzaC1yc2EAAAADAQABAAABAQDHoH1jMjltOJnCt999uaSfc48ySutaD3ISJ9fSECe1Spdq9o9mxj0kBTTTq+2V8hPspuW75DNgN+V/rgJeoUewWwCAasRx9X4eTcRrJrwOQKzb5Fk+UKgQmenZ5uhLAefi2qXX/agFCtZi99vw+jHXZStfHm9TZCAf2zi+HIBzoVksSNJD0VvPo66EAvLn5qKWQD4AdpQQbKqXRf5/W8diPySbYdvOP2/7HFhDukW8yV/7ZtcywFUIu3gdXsrzwMnTqnATSLPPuckoi0V2jd8dQvEcu1DY+rRqmqu0tEkFBurlRZDf1yhNzq5xWY3OXcjgDGN+RxwuWQK3cRimcosH"
1402       }
1403     }
1404
1405 Configuring Device with Device-specific Credentials
1406 '''''''''''''''''''''''''''''''''''''''''''''''''''
1407
1408 Call Home Server also allows to configure credentials per device basis,
1409 this is done by introducing ``credentials`` container into
1410 device-specific configuration. Format is same as in global credentials.
1411
1412 *Configuring Device with Credentials*
1413
1414 .. code-block::
1415
1416     PUT HTTP/1.1
1417     /rests/data/odl-netconf-callhome-server:netconf-callhome-server/allowed-devices/device=example
1418     Content-Type: application/json
1419     Accept: application/json
1420
1421 .. code-block:: json
1422
1423     {
1424       "device": {
1425         "unique-id": "example",
1426         "credentials": {
1427           "username": "example",
1428           "passwords": [ "password" ]
1429         },
1430         "ssh-host-key": "AAAAB3NzaC1yc2EAAAADAQABAAABAQDHoH1jMjltOJnCt999uaSfc48ySutaD3ISJ9fSECe1Spdq9o9mxj0kBTTTq+2V8hPspuW75DNgN+V/rgJeoUewWwCAasRx9X4eTcRrJrwOQKzb5Fk+UKgQmenZ5uhLAefi2qXX/agFCtZi99vw+jHXZStfHm9TZCAf2zi+HIBzoVksSNJD0VvPo66EAvLn5qKWQD4AdpQQbKqXRf5/W8diPySbYdvOP2/7HFhDukW8yV/7ZtcywFUIu3gdXsrzwMnTqnATSLPPuckoi0V2jd8dQvEcu1DY+rRqmqu0tEkFBurlRZDf1yhNzq5xWY3OXcjgDGN+RxwuWQK3cRimcosH"
1431       }
1432     }
1433
1434 Configure device to connect over TLS protocol
1435 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1436
1437 Netconf Call Home Server allows devices to use TLS transport protocol to
1438 establish a connection towards the NETCONF device. This communication
1439 requires proper setup to make two-way TLS authentication possible for client
1440 and server.
1441
1442 The initial step is to configure certificates and keys for two-way TLS by
1443 storing them within the netconf-keystore.
1444
1445 *Adding a client private key credential to the netconf-keystore*
1446
1447 .. code-block::
1448
1449     POST HTTP/1.1
1450     /rests/operations/netconf-keystore:add-keystore-entry
1451     Content-Type: application/json
1452     Accept: application/json
1453
1454 .. code-block:: json
1455
1456   {
1457     "input": {
1458       "key-credential": [
1459         {
1460           "key-id": "example-client-key-id",
1461           "private-key": "base64encoded-private-key",
1462           "passphrase": "passphrase"
1463         }
1464       ]
1465     }
1466   }
1467
1468 *Associate a private key with a client and CA certificates chain*
1469
1470 .. code-block::
1471
1472     POST HTTP/1.1
1473     /rests/operations/netconf-keystore:add-private-key
1474     Content-Type: application/json
1475     Accept: application/json
1476
1477 .. code-block:: json
1478
1479   {
1480     "input": {
1481       "private-key": [
1482         {
1483           "name": "example-client-key-id",
1484           "data": "key-data",
1485           "certificate-chain": [
1486             "certificate-data"
1487           ]
1488         }
1489       ]
1490     }
1491   }
1492
1493 *Add a list of trusted CA and server certificates*
1494
1495 .. code-block::
1496
1497     POST HTTP/1.1
1498     /rests/operations/netconf-keystore:add-trusted-certificate
1499     Content-Type: application/json
1500     Accept: application/json
1501
1502 .. code-block:: json
1503
1504   {
1505     "input": {
1506       "trusted-certificate": [
1507         {
1508           "name": "example-ca-certificate",
1509           "certificate": "ca-certificate-data"
1510         },
1511         {
1512           "name": "example-server-certificate",
1513           "certificate": "server-certificate-data"
1514         }
1515       ]
1516     }
1517   }
1518
1519 In a second step, it is required to create an allowed device associated with
1520 a server certificate and client key. The server certificate will be used to
1521 identify and pin the NETCONF device during SSL handshake and should be unique
1522 among the allowed devices.
1523
1524 *Add device configuration for TLS protocol to allowed devices list*
1525
1526 .. code-block::
1527
1528     PUT HTTP/1.1
1529     /rests/data/odl-netconf-callhome-server:netconf-callhome-server/allowed-devices/device=example-device
1530     Content-Type: application/json
1531     Accept: application/json
1532
1533 .. code-block:: json
1534
1535   {
1536     "device": {
1537       "unique-id": "example-device",
1538       "tls-client-params": {
1539         "key-id": "example-client-key-id",
1540         "certificate-id": "example-server-certificate"
1541       }
1542     }
1543   }
1544
1545 Operational Status
1546 ^^^^^^^^^^^^^^^^^^
1547
1548 Once an entry is made into the config side of "allowed-devices", the Call-Home Server will
1549 populate an corresponding operational device that is the same as the config device but
1550 has an additional status. By default, this status is *DISCONNECTED*. Once a device calls
1551 home, this status will change to one of:
1552
1553 *CONNECTED* â€” The device is currently connected and the NETCONF mount is available for network
1554 management.
1555
1556 *FAILED_AUTH_FAILURE* â€” The last attempted connection was unsuccessful because the Call-Home
1557 Server was unable to provide the acceptable credentials of the device. The device is also
1558 disconnected and not available for network management.
1559
1560 *FAILED_NOT_ALLOWED* â€” The last attempted connection was unsuccessful because the device was
1561 not recognized as an acceptable device. The device is also disconnected and not available for
1562 network management.
1563
1564 *FAILED* â€” The last attempted connection was unsuccessful for a reason other than not
1565 allowed to connect or incorrect client credentials. The device is also disconnected and not
1566 available for network management.
1567
1568 *DISCONNECTED* â€” The device is currently disconnected.
1569
1570 Rogue Devices
1571 '''''''''''''
1572
1573 Devices which are not on the whitelist might try to connect to the Call-Home Server. In
1574 these cases, the server will keep a record by instantiating an operational device. There
1575 will be no corresponding config device for these rogues. They can be identified readily
1576 because their device id, rather than being user-supplied, will be of the form
1577 "address:port". Note that if a device calls back multiple times, there will only be
1578 a single operatinal entry (even if the port changes); these devices are recognized by
1579 their unique host key.
1580
1581 Southbound Call-Home API
1582 ~~~~~~~~~~~~~~~~~~~~~~~~
1583
1584 The Call-Home Server listens for incoming TCP connections and assumes that the other side of
1585 the connection is a device calling home via a NETCONF connection with SSH for
1586 management. The server uses port 6666 by default and this can be configured via a
1587 blueprint configuration file.
1588
1589 The device **must** initiate the connection and the server will not try to re-establish the
1590 connection in case of a drop. By requirement, the server cannot assume it has connectivity
1591 to the device due to NAT or firewalls among others.
1592
1593 Reading data with selected fields
1594 ---------------------------------
1595
1596 Overview
1597 ~~~~~~~~
1598
1599 If user would like to read only selected fields from NETCONF device, it is possible to use
1600 fields query parameter that is described by RFC-8040. RESTCONF parses content of query
1601 parameter into format that is accepted by NETCONF subtree filtering - filtering of data is done
1602 on NETCONF server, not on NETCONF client side. This approach optimizes network traffic load,
1603 because data in which user doesn't have interest, is not transferred over network.
1604
1605 Next advantages:
1606
1607 * using single RESTCONF request and single NETCONF RPC for reading multiple subtrees
1608 * possibility to read only selected fields under list node across multiple hierarchies
1609   (it cannot be done without proper selection API)
1610
1611 .. note::
1612
1613   More information about fields query parameter: `RFC 8071 <https://www.rfc-editor.org/rfc/rfc8040#section-4.8.3>`__
1614
1615 Preparation of data
1616 ~~~~~~~~~~~~~~~~~~~
1617
1618 For demonstration, we will define next YANG model:
1619
1620 ::
1621
1622     module test-module {
1623         yang-version 1.1;
1624         namespace "urn:opendaylight:test-module";
1625         prefix "tm";
1626         revision "2023-02-16";
1627
1628         container root {
1629             container simple-root {
1630                 leaf leaf-a {
1631                     type string;
1632                 }
1633                 leaf leaf-b {
1634                     type string;
1635                 }
1636                 leaf-list ll {
1637                     type string;
1638                 }
1639                 container nested {
1640                     leaf sample-x {
1641                         type boolean;
1642                     }
1643                     leaf sample-y {
1644                         type boolean;
1645                     }
1646                 }
1647             }
1648
1649             container list-root {
1650                 leaf branch-ab {
1651                     type int32;
1652                 }
1653                 list top-list {
1654                     key "key-1 key-2";
1655                     ordered-by user;
1656                     leaf key-1 {
1657                         type string;
1658                     }
1659                     leaf key-2 {
1660                         type string;
1661                     }
1662                     container next-data {
1663                         leaf switch-1 {
1664                             type empty;
1665                         }
1666                         leaf switch-2 {
1667                             type empty;
1668                         }
1669                     }
1670                     list nested-list {
1671                         key "identifier";
1672                         leaf identifier {
1673                             type string;
1674                         }
1675                         leaf foo {
1676                             type int32;
1677                         }
1678                     }
1679                 }
1680             }
1681         }
1682     }
1683
1684 Follow the :doc:`testtool` instructions to save this schema and run it with testtool.
1685
1686 Mounting NETCONF device that runs on NETCONF testtool:
1687
1688 .. code-block:: bash
1689
1690   curl --location --request PUT 'http://127.0.0.1:8181/rests/data/network-topology:network-topology/topology=topology-netconf/node=testtool' \
1691   --header 'Authorization: Basic YWRtaW46YWRtaW4=' \
1692   --header 'Content-Type: application/json' \
1693   --data-raw '{
1694       "node": [
1695           {
1696               "node-id": "testtool",
1697               "netconf-node-topology:host": "127.0.0.1",
1698               "netconf-node-topology:port": 17830,
1699               "netconf-node-topology:keepalive-delay": 100,
1700               "netconf-node-topology:tcp-only": false,
1701               "netconf-node-topology:username": "admin",
1702               "netconf-node-topology:password": "admin"
1703           }
1704       ]
1705   }'
1706
1707 Setting initial configuration on NETCONF device:
1708
1709 .. code-block:: bash
1710
1711   curl --location --request PUT 'http://127.0.0.1:8181/rests/data/network-topology:network-topology/topology=topology-netconf/node=testtool/yang-ext:mount/test-module:root' \
1712   --header 'Authorization: Basic YWRtaW46YWRtaW4=' \
1713   --header 'Content-Type: application/json' \
1714   --data-raw '{
1715       "root": {
1716           "simple-root": {
1717               "leaf-a": "asddhg",
1718               "leaf-b": "ffffff",
1719               "ll": [
1720                   "str1",
1721                   "str2",
1722                   "str3"
1723               ],
1724               "nested": {
1725                   "sample-x": true,
1726                   "sample-y": false
1727               }
1728           },
1729           "list-root": {
1730               "branch-ab": 5,
1731               "top-list": [
1732                   {
1733                       "key-1": "ka",
1734                       "key-2": "kb",
1735                       "next-data": {
1736                           "switch-1": [
1737                               null
1738                           ],
1739                           "switch-2": [
1740                               null
1741                           ]
1742                       },
1743                       "nested-list": [
1744                           {
1745                               "identifier": "f1",
1746                               "foo": 1
1747                           },
1748                           {
1749                               "identifier": "f2",
1750                               "foo": 10
1751                           },
1752                           {
1753                               "identifier": "f3",
1754                               "foo": 20
1755                           }
1756                       ]
1757                   },
1758                   {
1759                       "key-1": "kb",
1760                       "key-2": "ka",
1761                       "next-data": {
1762                           "switch-1": [
1763                               null
1764                           ]
1765                       },
1766                       "nested-list": [
1767                           {
1768                               "identifier": "e1",
1769                               "foo": 1
1770                           },
1771                           {
1772                               "identifier": "e2",
1773                               "foo": 2
1774                           },
1775                           {
1776                               "identifier": "e3",
1777                               "foo": 3
1778                           }
1779                       ]
1780                   },
1781                   {
1782                       "key-1": "kc",
1783                       "key-2": "ke",
1784                       "next-data": {
1785                           "switch-2": [
1786                               null
1787                           ]
1788                       },
1789                       "nested-list": [
1790                           {
1791                               "identifier": "q1",
1792                               "foo": 13
1793                           },
1794                           {
1795                               "identifier": "q2",
1796                               "foo": 14
1797                           },
1798                           {
1799                               "identifier": "q3",
1800                               "foo": 15
1801                           }
1802                       ]
1803                   }
1804               ]
1805           }
1806       }
1807   }'
1808
1809 Examples
1810 --------
1811
1812 1. Reading whole leaf-list 'll' and leaf 'nested/sample-x' under 'simple-root' container.
1813
1814 RESTCONF request:
1815
1816 .. code-block:: bash
1817
1818     curl --location --request GET 'http://localhost:8181/rests/data/network-topology:network-topology/topology=topology-netconf/node=testtool/yang-ext:mount/test-module:root/simple-root?content=config&fields=ll;nested/sample-x' \
1819     --header 'Authorization: Basic YWRtaW46YWRtaW4=' \
1820     --header 'Cookie: JSESSIONID=node01h4w82eorc1k61866b71qjgj503.node0'
1821
1822 Generated NETCONF RPC request:
1823
1824 .. code-block:: xml
1825
1826     <rpc message-id="m-18" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
1827         <get-config>
1828             <source>
1829                 <running/>
1830             </source>
1831             <filter xmlns:ns0="urn:ietf:params:xml:ns:netconf:base:1.0" ns0:type="subtree">
1832                 <root xmlns="urn:ietf:params:xml:ns:yang:test-model">
1833                     <simple-root>
1834                         <ll/>
1835                         <nested>
1836                             <sample-x/>
1837                         </nested>
1838                     </simple-root>
1839                 </root>
1840             </filter>
1841         </get-config>
1842     </rpc>
1843
1844 .. note::
1845
1846     Using fields query parameter it is also possible to read whole leaf-list or list without
1847     necessity to specify value / key predicate (without reading parent entity). Such scenario
1848     is not permitted in RFC-8040 paths alone - fields query parameter can be used as
1849     workaround for this case.
1850
1851 RESTCONF response:
1852
1853 .. code-block:: json
1854
1855     {
1856         "test-module:simple-root": {
1857             "ll": [
1858                 "str3",
1859                 "str1",
1860                 "str2"
1861             ],
1862             "nested": {
1863                 "sample-x": true
1864             }
1865         }
1866     }
1867
1868 2. Reading all identifiers of 'nested-list' under all elements of 'top-list'.
1869
1870 RESTCONF request:
1871
1872 .. code-block:: bash
1873
1874     curl --location --request GET 'http://localhost:8181/rests/data/network-topology:network-topology/topology=topology-netconf/node=testtool/yang-ext:mount/test-module:root/list-root?content=config&fields=top-list(nested-list/identifier)' \
1875     --header 'Authorization: Basic YWRtaW46YWRtaW4=' \
1876     --header 'Cookie: JSESSIONID=node01h4w82eorc1k61866b71qjgj503.node0'
1877
1878 Generated NETCONF RPC request:
1879
1880 .. code-block:: xml
1881
1882     <rpc message-id="m-27" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
1883         <get-config>
1884             <source>
1885                 <running/>
1886             </source>
1887             <filter xmlns:ns0="urn:ietf:params:xml:ns:netconf:base:1.0" ns0:type="subtree">
1888                 <root xmlns="urn:ietf:params:xml:ns:yang:test-model">
1889                     <list-root>
1890                         <top-list>
1891                             <nested-list>
1892                                 <identifier/>
1893                             </nested-list>
1894                             <key-1/>
1895                             <key-2/>
1896                         </top-list>
1897                     </list-root>
1898                 </root>
1899             </filter>
1900         </get-config>
1901     </rpc>
1902
1903 .. note::
1904
1905     NETCONF client automatically fetches values of list keys since they are required for correct
1906     deserialization of NETCONF response and at the end serialization of response to RESTCONF
1907     response (JSON/XML).
1908
1909 RESTCONF response:
1910
1911 .. code-block:: json
1912
1913     {
1914         "test-module:list-root": {
1915             "top-list": [
1916                 {
1917                     "key-1": "ka",
1918                     "key-2": "kb",
1919                     "nested-list": [
1920                         {
1921                             "identifier": "f3"
1922                         },
1923                         {
1924                             "identifier": "f2"
1925                         },
1926                         {
1927                             "identifier": "f1"
1928                         }
1929                     ]
1930                 },
1931                 {
1932                     "key-1": "kb",
1933                     "key-2": "ka",
1934                     "nested-list": [
1935                         {
1936                             "identifier": "e3"
1937                         },
1938                         {
1939                             "identifier": "e2"
1940                         },
1941                         {
1942                             "identifier": "e1"
1943                         }
1944                     ]
1945                 },
1946                 {
1947                     "key-1": "kc",
1948                     "key-2": "ke",
1949                     "nested-list": [
1950                         {
1951                             "identifier": "q3"
1952                         },
1953                         {
1954                             "identifier": "q2"
1955                         },
1956                         {
1957                             "identifier": "q1"
1958                         }
1959                     ]
1960                 }
1961             ]
1962         }
1963     }
1964
1965 3. Reading value of leaf 'branch-ab' and all values of leaves 'switch-1' that are placed
1966    under 'top-list' list elements.
1967
1968 RESTCONF request:
1969
1970 .. code-block:: bash
1971
1972     curl --location --request GET 'http://localhost:8181/rests/data/network-topology:network-topology/topology=topology-netconf/node=testtool/yang-ext:mount/test-module:root/list-root?content=config&fields=branch-ab;top-list/next-data/switch-1' \
1973     --header 'Authorization: Basic YWRtaW46YWRtaW4=' \
1974     --header 'Cookie: JSESSIONID=node01jx6o5thwae9t1ft7c2zau5zbz4.node0'
1975
1976 Generated NETCONF RPC request:
1977
1978 .. code-block:: xml
1979
1980     <rpc message-id="m-42" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
1981         <get-config>
1982             <source>
1983                 <running/>
1984             </source>
1985             <filter xmlns:ns0="urn:ietf:params:xml:ns:netconf:base:1.0" ns0:type="subtree">
1986                 <root xmlns="urn:ietf:params:xml:ns:yang:test-model">
1987                     <list-root>
1988                         <branch-ab/>
1989                         <top-list>
1990                             <next-data>
1991                                 <switch-1/>
1992                             </next-data>
1993                             <key-1/>
1994                             <key-2/>
1995                         </top-list>
1996                     </list-root>
1997                 </root>
1998             </filter>
1999         </get-config>
2000     </rpc>
2001
2002 RESTCONF response:
2003
2004 .. code-block:: json
2005
2006     {
2007         "test-module:list-root": {
2008             "branch-ab": 5,
2009             "top-list": [
2010                 {
2011                     "key-1": "ka",
2012                     "key-2": "kb",
2013                     "next-data": {
2014                         "switch-1": [
2015                             null
2016                         ]
2017                     }
2018                 },
2019                 {
2020                     "key-1": "kb",
2021                     "key-2": "ka",
2022                     "next-data": {
2023                         "switch-1": [
2024                             null
2025                         ]
2026                     }
2027                 },
2028                 {
2029                     "key-1": "kc",
2030                     "key-2": "ke"
2031                 }
2032             ]
2033         }
2034     }