Remove NetconfServerSessionPreferences
[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 <http://tools.ietf.org/html/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 <http://tools.ietf.org/html/rfc6241>`__
39
40 -  `RFC-5277 <https://tools.ietf.org/html/rfc5277>`__
41
42 -  `RFC-6022 <https://tools.ietf.org/html/rfc6022>`__
43
44 -  `draft-ietf-netconf-yang-library-06 <https://tools.ietf.org/html/draft-ietf-netconf-yang-library-06>`__
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     There are 2 different endpoints related to RESTCONF protocols:
67
68     - | ``http://localhost:8181/restconf`` is related to `draft-bierman-netconf-restconf-02 <https://tools.ietf.org/html/draft-bierman-netconf-restconf-02>`__,
69       | can be activated by installing ``odl-restconf-nb-bierman02``
70        Karaf feature.
71       | This user guide uses this approach.
72
73     - | ``http://localhost:8181/rests`` is related to `RFC-8040 <https://tools.ietf.org/html/rfc8040>`__,
74       | can be activated by installing ``odl-restconf-nb-rfc8040``
75        Karaf feature.
76
77     | In case of `RFC-8040 <https://tools.ietf.org/html/rfc8040>`__
78      resources for configuration and operational datastores start
79      ``/rests/data/``,
80     | e. g. GET
81      http://localhost:8181/rests/data/network-topology:network-topology
82      with response of both datastores. It's allowed to use query
83      parameters to distinguish between them.
84     | e. g. GET
85      http://localhost:8181/rests/data/network-topology:network-topology?content=config
86      for configuration datastore
87     | and GET
88      http://localhost:8181/rests/data/network-topology:network-topology?content=nonconfig
89      for operational datastore.
90
91     | Also in case of `RFC-8040 <https://tools.ietf.org/html/rfc8040>`__,
92      if a data node in the path expression is a YANG leaf-list or list
93      node, the path segment has to be constructed by having leaf-list or
94      list node name, followed by an "=" character, then followed by the
95      leaf-list or list value. Any reserved characters must be
96      percent-encoded.
97     | e. g. GET
98      http://localhost:8181/rests/data/network-topology:network-topology/topology=topology-netconf?content=config
99      for retrieving data from configuration datastore for
100      topology-netconf value of topology list is equivalent to the deprecated request
101     | |ss| GET |se|
102      http://localhost:8181/restconf/config/network-topology:network-topology/topology/topology-netconf,
103      which is related to `draft-bierman-netconf-restconf-02
104      <https://tools.ietf.org/html/draft-bierman-netconf-restconf-02>`__.
105
106     Examples in the `Spawning new NETCONF connectors`_ section include both bierman02 and rfc8040
107     formats
108
109 Preconditions
110 ^^^^^^^^^^^^^
111
112 1. OpenDaylight is running
113
114 2. In Karaf, you must have the ``odl-netconf-topology`` or
115    ``odl-netconf-clustered-topology`` feature installed.
116
117 3. Feature ``odl-restconf`` must be installed
118
119 Spawning new NETCONF connectors
120 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
121
122 To create a new NETCONF connector you need to send the following PUT request
123 to RESTCONF:
124
125 .. list-table::
126    :widths: 1 5
127
128    * - bierman02
129      - http://localhost:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/new-netconf-device
130    * - rfc8040
131      - http://localhost:8181/rests/data/network-topology:network-topology/topology=topology-netconf/node=new-netconf-device
132
133 You could use the same body to create the new  NETCONF connector with a POST
134 without specifying the node in the URL:
135
136 .. list-table::
137    :widths: 1 5
138
139    * - bierman02
140      - http://localhost:8181/restconf/config/network-topology:network-topology/topology/topology-netconf
141    * - rfc8040
142      - http://localhost:8181/rests/data/network-topology:network-topology/topology=topology-netconf
143
144 Payload:
145
146 .. tabs::
147
148    .. tab:: XML
149
150       **Content-type:** ``application/xml``
151
152       **Accept:** ``application/xml``
153
154       **Authentication:** ``admin:admin``
155
156       .. code-block:: xml
157
158          <node xmlns="urn:TBD:params:xml:ns:yang:network-topology">
159            <node-id>new-netconf-device</node-id>
160            <host xmlns="urn:opendaylight:netconf-node-topology">127.0.0.1</host>
161            <port xmlns="urn:opendaylight:netconf-node-topology">17830</port>
162            <username xmlns="urn:opendaylight:netconf-node-topology">admin</username>
163            <password xmlns="urn:opendaylight:netconf-node-topology">admin</password>
164            <tcp-only xmlns="urn:opendaylight:netconf-node-topology">false</tcp-only>
165            <!-- non-mandatory fields with default values, you can safely remove these if you do not wish to override any of these values-->
166            <reconnect-on-changed-schema xmlns="urn:opendaylight:netconf-node-topology">false</reconnect-on-changed-schema>
167            <connection-timeout-millis xmlns="urn:opendaylight:netconf-node-topology">20000</connection-timeout-millis>
168            <max-connection-attempts xmlns="urn:opendaylight:netconf-node-topology">0</max-connection-attempts>
169            <between-attempts-timeout-millis xmlns="urn:opendaylight:netconf-node-topology">2000</between-attempts-timeout-millis>
170            <sleep-factor xmlns="urn:opendaylight:netconf-node-topology">1.5</sleep-factor>
171            <!-- keepalive-delay set to 0 turns off keepalives-->
172            <keepalive-delay xmlns="urn:opendaylight:netconf-node-topology">120</keepalive-delay>
173          </node>
174
175    .. tab:: JSON
176
177       **Content-type:** ``application/json``
178
179       **Accept:** ``application/json``
180
181       **Authentication:** ``admin:admin``
182
183       .. code-block:: json
184
185          {
186              "node": [
187                  {
188                      "node-id": "new-netconf-device",
189                      "netconf-node-topology:port": 17830,
190                      "netconf-node-topology:reconnect-on-changed-schema": false,
191                      "netconf-node-topology:connection-timeout-millis": 20000,
192                      "netconf-node-topology:tcp-only": false,
193                      "netconf-node-topology:max-connection-attempts": 0,
194                      "netconf-node-topology:username": "admin",
195                      "netconf-node-topology:password": "admin",
196                      "netconf-node-topology:sleep-factor": 1.5,
197                      "netconf-node-topology:host": "127.0.0.1",
198                      "netconf-node-topology:between-attempts-timeout-millis": 2000,
199                      "netconf-node-topology:keepalive-delay": 120
200                  }
201              ]
202          }
203
204 Note that the device name in <node-id> element must match the last
205 element of the restconf URL.
206
207 Reconfiguring an existing connector
208 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
209
210 The steps to reconfigure an existing connector are exactly the same as
211 when spawning a new connector. The old connection will be disconnected
212 and a new connector with the new configuration will be created. This needs
213 to be done with a PUT request because the node already exists. A POST
214 request will fail for that reason.
215
216 Additionally, a PATCH request can be used to modify an existing
217 configuration. Currently, only yang-patch (`RFC-8072 <https://tools.ietf.org/html/rfc8072>`__)
218 is supported. The URL would be the same as the above PUT examples.
219 Using JSON for the body, the headers needed for the request would
220 be:
221
222 Headers:
223
224 -  Accept: application/yang.patch-status+json
225
226 -  Content-Type: application/yang.patch+json
227
228 Example JSON payload to modify the password entry:
229
230 ::
231
232     {
233       "ietf-restconf:yang-patch" : {
234         "patch-id" : "0",
235         "edit" : [
236           {
237             "edit-id" : "edit1",
238             "operation" : "merge",
239             "target" : "",
240             "value" : {
241              "node": [
242                 {
243                  "node-id": "new-netconf-device",
244                  "netconf-node-topology:password" : "newpassword"
245                 }
246              ]
247             }
248          }
249         ]
250       }
251     }
252
253 Deleting an existing connector
254 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
255
256 To remove an already configured NETCONF connector you need to send a
257 DELETE request to the same PUT request URL that was used to create the
258 device:
259
260 .. list-table::
261    :widths: 1 5
262
263    * - bierman02
264      - http://localhost:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/new-netconf-device
265    * - rfc8040
266      - http://localhost:8181/rests/data/network-topology:network-topology/topology=topology-netconf/node=new-netconf-device
267
268 .. note::
269
270     No body is needed to delete the node/device
271
272 Connecting to a device not supporting NETCONF monitoring
273 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
274
275 The netconf-connector in OpenDaylight relies on ietf-netconf-monitoring
276 support when connecting to remote NETCONF device. The
277 ietf-netconf-monitoring support allows netconf-connector to list and
278 download all YANG schemas that are used by the device. NETCONF connector
279 can only communicate with a device if it knows the set of used schemas
280 (or at least a subset). However, some devices use YANG models internally
281 but do not support NETCONF monitoring. Netconf-connector can also
282 communicate with these devices, but you have to side load the necessary
283 yang models into OpenDaylight’s YANG model cache for netconf-connector.
284 In general there are 2 situations you might encounter:
285
286 **1. NETCONF device does not support ietf-netconf-monitoring but it does
287 list all its YANG models as capabilities in HELLO message**
288
289 This could be a device that internally uses only ietf-inet-types YANG
290 model with revision 2010-09-24. In the HELLO message that is sent from
291 this device there is this capability reported:
292
293 ::
294
295     urn:ietf:params:xml:ns:yang:ietf-inet-types?module=ietf-inet-types&revision=2010-09-24
296
297 **For such devices you only need to put the schema into folder
298 cache/schema inside your Karaf distribution.**
299
300 .. important::
301
302     The file with YANG schema for ietf-inet-types has to be called
303     ietf-inet-types@2010-09-24.yang. It is the required naming format of
304     the cache.
305
306 **2. NETCONF device does not support ietf-netconf-monitoring and it does
307 NOT list its YANG models as capabilities in HELLO message**
308
309 Compared to device that lists its YANG models in HELLO message, in this
310 case there would be no capability with ietf-inet-types in the HELLO
311 message. This type of device basically provides no information about the
312 YANG schemas it uses so its up to the user of OpenDaylight to properly
313 configure netconf-connector for this device.
314
315 Netconf-connector has an optional configuration attribute called
316 yang-module-capabilities and this attribute can contain a list of "YANG
317 module based" capabilities. So by setting this configuration attribute,
318 it is possible to override the "yang-module-based" capabilities reported
319 in HELLO message of the device. To do this, we need to modify the
320 configuration of netconf-connector like in the example below:
321
322 .. tabs::
323
324    .. tab:: XML
325
326       **Content-type:** ``application/xml``
327
328       **Accept:** ``application/xml``
329
330       **Authentication:** ``admin:admin``
331
332       .. code-block:: xml
333
334          <node xmlns="urn:TBD:params:xml:ns:yang:network-topology">
335            <node-id>r5</node-id>
336            <host xmlns="urn:opendaylight:netconf-node-topology">127.0.0.1</host>
337            <port xmlns="urn:opendaylight:netconf-node-topology">8305</port>
338            <username xmlns="urn:opendaylight:netconf-node-topology">root</username>
339            <password xmlns="urn:opendaylight:netconf-node-topology">root</password>
340            <tcp-only xmlns="urn:opendaylight:netconf-node-topology">false</tcp-only>
341            <keepalive-delay xmlns="urn:opendaylight:netconf-node-topology">30</keepalive-delay>
342            <yang-module-capabilities xmlns="urn:opendaylight:netconf-node-topology">
343              <override>true</override>
344              <capability xmlns="urn:opendaylight:netconf-node-topology">
345                urn:ietf:params:xml:ns:yang:ietf-inet-types?module=ietf-inet-types&amp;revision=2013-07-15
346              </capability>
347            </yang-module-capabilities>
348          </node>
349
350    .. tab:: JSON
351
352       **Content-type:** ``application/json``
353
354       **Accept:** ``application/json``
355
356       **Authentication:** ``admin:admin``
357
358       .. code-block:: json
359
360          {
361              "node": [
362                  {
363                      "node-id": "device",
364                      "netconf-node-topology:host": "127.0.0.1",
365                      "netconf-node-topology:password": "root",
366                      "netconf-node-topology:username": "root",
367                      "netconf-node-topology:yang-module-capabilities": {
368                          "override": true,
369                          "capability": [
370                              "urn:ietf:params:xml:ns:yang:ietf-inet-types?module=ietf-inet-types&revision=2013-07-15"
371                          ]
372                      },
373                      "netconf-node-topology:port": 8305,
374                      "netconf-node-topology:tcp-only": false,
375                      "netconf-node-topology:keepalive-delay": 30
376                  }
377              ]
378          }
379
380 **Remember to also put the YANG schemas into the cache folder.**
381
382 .. note::
383
384     For putting multiple capabilities, you just need to replicate the
385     capability element inside yang-module-capability element.
386     Capability element is modeled as a leaf-list. With this
387     configuration, we would make the remote device report usage of
388     ietf-inet-types in the eyes of netconf-connector.
389
390 Connecting to a device supporting only NETCONF 1.0
391 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
392
393 OpenDaylight is schema-based distribution and heavily depends on YANG
394 models. However some legacy NETCONF devices are not schema-based and
395 implement just RFC 4741. This type of device does not utilize YANG
396 models internally and OpenDaylight does not know how to communicate
397 with such devices, how to validate data, or what the semantics of data
398 are.
399
400 NETCONF connector can communicate also with these devices, but the
401 trade-offs are worsened possibilities in utilization of NETCONF
402 mountpoints. Using RESTCONF with such devices is not suported. Also
403 communicating with schemaless devices from application code is slightly
404 different.
405
406 To connect to schemaless device, there is a optional configuration option
407 in netconf-node-topology model called schemaless. You have to set this
408 option to true.
409
410 Clustered NETCONF connector
411 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
412
413 To spawn NETCONF connectors that are cluster-aware you need to install
414 the ``odl-netconf-clustered-topology`` karaf feature.
415
416 .. warning::
417
418     The ``odl-netconf-topology`` and ``odl-netconf-clustered-topology``
419     features are considered **INCOMPATIBLE**. They both manage the same
420     space in the datastore and would issue conflicting writes if
421     installed together.
422
423 Configuration of clustered NETCONF connectors works the same as the
424 configuration through the topology model in the previous section.
425
426 When a new clustered connector is configured the configuration gets
427 distributed among the member nodes and a NETCONF connector is spawned on
428 each node. From these nodes a master is chosen which handles the schema
429 download from the device and all the communication with the device. You
430 will be able to read/write to/from the device from all slave nodes due
431 to the proxy data brokers implemented.
432
433 You can use the ``odl-netconf-clustered-topology`` feature in a single
434 node scenario as well but the code that uses akka will be used, so for a
435 scenario where only a single node is used, ``odl-netconf-topology``
436 might be preferred.
437
438 Netconf-connector utilization
439 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
440
441 Once the connector is up and running, users can utilize the new mount
442 point instance. By using RESTCONF or from their application code. This
443 chapter deals with using RESTCONF and more information for app
444 developers can be found in the developers guide or in the official
445 tutorial application **ncmount** that can be found in the coretutorials
446 project:
447
448 -  https://github.com/opendaylight/coretutorials/tree/master/ncmount
449
450 Reading data from the device
451 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
452
453 Just invoke (no body needed):
454
455 GET
456 http://localhost:8080/restconf/operational/network-topology:network-topology/topology/topology-netconf/node/new-netconf-device/yang-ext:mount/
457
458 This will return the entire content of operation datastore from the
459 device. To view just the configuration datastore, change **operational**
460 in this URL to **config**.
461
462 Writing configuration data to the device
463 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
464
465 In general, you cannot simply write any data you want to the device. The
466 data have to conform to the YANG models implemented by the device. In
467 this example we are adding a new interface-configuration to the mounted
468 device (assuming the device supports Cisco-IOS-XR-ifmgr-cfg YANG model).
469 In fact this request comes from the tutorial dedicated to the
470 **ncmount** tutorial app.
471
472 POST
473 http://localhost:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/new-netconf-device/yang-ext:mount/Cisco-IOS-XR-ifmgr-cfg:interface-configurations
474
475 ::
476
477     <interface-configuration xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg">
478         <active>act</active>
479         <interface-name>mpls</interface-name>
480         <description>Interface description</description>
481         <bandwidth>32</bandwidth>
482         <link-status></link-status>
483     </interface-configuration>
484
485 Should return 200 response code with no body.
486
487 .. tip::
488
489     This call is transformed into a couple of NETCONF RPCs. Resulting
490     NETCONF RPCs that go directly to the device can be found in the
491     OpenDaylight logs after invoking ``log:set TRACE
492     org.opendaylight.controller.sal.connect.netconf`` in the Karaf
493     shell. Seeing the NETCONF RPCs might help with debugging.
494
495 This request is very similar to the one where we spawned a new netconf
496 device. That’s because we used the loopback netconf-connector to write
497 configuration data into config-subsystem datastore and config-subsystem
498 picked it up from there.
499
500 Invoking custom RPC
501 ^^^^^^^^^^^^^^^^^^^
502
503 Devices can implement any additional RPC and as long as it provides YANG
504 models for it, it can be invoked from OpenDaylight. Following example
505 shows how to invoke the get-schema RPC (get-schema is quite common among
506 netconf devices). Invoke:
507
508 POST
509 http://localhost:8181/restconf/operations/network-topology:network-topology/topology/topology-netconf/node/new-netconf-device/yang-ext:mount/ietf-netconf-monitoring:get-schema
510
511 ::
512
513     <input xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring">
514       <identifier>ietf-yang-types</identifier>
515       <version>2013-07-15</version>
516     </input>
517
518 This call should fetch the source for ietf-yang-types YANG model from
519 the mounted device.
520
521 Netconf-connector + Netopeer
522 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
523
524 `Netopeer <https://github.com/cesnet/netopeer>`__ (an open-source
525 NETCONF server) can be used for testing/exploring NETCONF southbound in
526 OpenDaylight.
527
528 Netopeer installation
529 ^^^^^^^^^^^^^^^^^^^^^
530
531 A `Docker <https://www.docker.com/>`__ container with netopeer will be
532 used in this guide. To install Docker and start the `netopeer
533 image <https://index.docker.io/u/dockeruser/netopeer/>`__ perform
534 following steps:
535
536 1. Install docker http://docs.docker.com/linux/step_one/
537
538 2. Start the netopeer image:
539
540    ::
541
542        docker run --rm -t -p 1831:830 dockeruser/netopeer
543
544 3. Verify netopeer is running by invoking (netopeer should send its
545    HELLO message right away:
546
547    ::
548
549        ssh root@localhost -p 1831 -s netconf
550        (password root)
551
552 Mounting netopeer NETCONF server
553 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
554
555 Preconditions:
556
557 -  OpenDaylight is started with features ``odl-restconf-all`` and
558    ``odl-netconf-connector-all``.
559
560 -  Netopeer is up and running in docker
561
562 Now just follow the section: `Spawning new NETCONF connectors`_.
563 In the payload change the:
564
565 -  name, e.g., to netopeer
566
567 -  username/password to your system credentials
568
569 -  ip to localhost
570
571 -  port to 1831.
572
573 After netopeer is mounted successfully, its configuration can be read
574 using RESTCONF by invoking:
575
576 GET
577 http://localhost:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/netopeer/yang-ext:mount/
578
579 Northbound (NETCONF servers)
580 ----------------------------
581
582 OpenDaylight provides 2 types of NETCONF servers:
583
584 -  **NETCONF server for config-subsystem (listening by default on port
585    1830)**
586
587    -  Serves as a default interface for config-subsystem and allows
588       users to spawn/reconfigure/destroy modules (or applications) in
589       OpenDaylight
590
591 -  **NETCONF server for MD-SAL (listening by default on port 2830)**
592
593    -  Serves as an alternative interface for MD-SAL (besides RESTCONF)
594       and allows users to read/write data from MD-SAL’s datastore and to
595       invoke its rpcs (NETCONF notifications are not available in the
596       Boron release of OpenDaylight)
597
598 .. note::
599
600     The reason for having 2 NETCONF servers is that config-subsystem and
601     MD-SAL are 2 different components of OpenDaylight and require
602     different approach for NETCONF message handling and data
603     translation. These 2 components will probably merge in the future.
604
605 .. note::
606
607     Since Nitrogen release, there is performance regression in NETCONF
608     servers accepting SSH connections. While opening a connection takes
609     less than 10 seconds on Carbon, on Nitrogen time can increase up to
610     60 seconds. Please see https://bugs.opendaylight.org/show_bug.cgi?id=9020
611
612 NETCONF server for config-subsystem
613 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
614
615 This NETCONF server is the primary interface for config-subsystem. It
616 allows the users to interact with config-subsystem in a standardized
617 NETCONF manner.
618
619 In terms of RFCs, these are supported:
620
621 -  `RFC-6241 <http://tools.ietf.org/html/rfc6241>`__
622
623 -  `RFC-5277 <https://tools.ietf.org/html/rfc5277>`__
624
625 -  `RFC-6470 <https://tools.ietf.org/html/rfc6470>`__
626
627    -  (partially, only the schema-change notification is available in
628       Boron release)
629
630 -  `RFC-6022 <https://tools.ietf.org/html/rfc6022>`__
631
632 For regular users it is recommended to use RESTCONF + the
633 controller-config loopback mountpoint instead of using pure NETCONF. How
634 to do that is spesific for each component/module/application in
635 OpenDaylight and can be found in their dedicated user guides.
636
637 NETCONF server for MD-SAL
638 ~~~~~~~~~~~~~~~~~~~~~~~~~
639
640 This NETCONF server is just a generic interface to MD-SAL in
641 OpenDaylight. It uses the stadard MD-SAL APIs and serves as an
642 alternative to RESTCONF. It is fully model driven and supports any data
643 and rpcs that are supported by MD-SAL.
644
645 In terms of RFCs, these are supported:
646
647 -  `RFC-6241 <http://tools.ietf.org/html/rfc6241>`__
648
649 -  `RFC-6022 <https://tools.ietf.org/html/rfc6022>`__
650
651 -  `draft-ietf-netconf-yang-library-06 <https://tools.ietf.org/html/draft-ietf-netconf-yang-library-06>`__
652
653 Notifications over NETCONF are not supported in the Boron release.
654
655 .. tip::
656
657     Install NETCONF northbound for MD-SAL by installing feature:
658     ``odl-netconf-mdsal`` in karaf. Default binding port is **2830**.
659
660 Configuration
661 ^^^^^^^^^^^^^
662
663 The default configuration can be found in file: *08-netconf-mdsal.xml*.
664 The file contains the configuration for all necessary dependencies and a
665 single SSH endpoint starting on port 2830. There is also a (by default
666 disabled) TCP endpoint. It is possible to start multiple endpoints at
667 the same time either in the initial configuration file or while
668 OpenDaylight is running.
669
670 The credentials for SSH endpoint can also be configured here, the
671 defaults are admin/admin. Credentials in the SSH endpoint are not yet
672 managed by the centralized AAA component and have to be configured
673 separately.
674
675 Verifying MD-SAL’s NETCONF server
676 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
677
678 After the NETCONF server is available it can be examined by a command
679 line ssh tool:
680
681 ::
682
683     ssh admin@localhost -p 2830 -s netconf
684
685 The server will respond by sending its HELLO message and can be used as
686 a regular NETCONF server from then on.
687
688 Mounting the MD-SAL’s NETCONF server
689 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
690
691 To perform this operation, just spawn a new netconf-connector as
692 described in `Spawning new NETCONF connectors`_. Just change the ip to
693 "127.0.0.1" port to "2830" and its name to "controller-mdsal".
694
695 Now the MD-SAL’s datastore can be read over RESTCONF via NETCONF by
696 invoking:
697
698 GET
699 http://localhost:8181/restconf/operational/network-topology:network-topology/topology/topology-netconf/node/controller-mdsal/yang-ext:mount
700
701 .. note::
702
703     This might not seem very useful, since MD-SAL can be accessed
704     directly from RESTCONF or from Application code, but the same method
705     can be used to mount and control other OpenDaylight instances by the
706     "master OpenDaylight".
707
708 NETCONF stress/performance measuring tool
709 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
710
711 This is basically a NETCONF client that puts NETCONF servers under heavy
712 load of NETCONF RPCs and measures the time until a configurable amount
713 of them is processed.
714
715 RESTCONF stress-performance measuring tool
716 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
717
718 Very similar to NETCONF stress tool with the difference of using
719 RESTCONF protocol instead of NETCONF.
720
721 YANGLIB remote repository
722 -------------------------
723
724 There are scenarios in NETCONF deployment, that require for a centralized
725 YANG models repository. YANGLIB plugin provides such remote repository.
726
727 To start this plugin, you have to install odl-yanglib feature. Then you
728 have to configure YANGLIB either through RESTCONF or NETCONF. We will
729 show how to configure YANGLIB through RESTCONF.
730
731 YANGLIB configuration through RESTCONF
732 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
733
734 You have to specify what local YANG modules directory you want to provide.
735 Then you have to specify address and port whre you want to provide YANG
736 sources. For example, we want to serve yang sources from folder /sources
737 on localhost:5000 adress. The configuration for this scenario will be
738 as follows:
739
740 ::
741
742     PUT  http://localhost:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/controller-config/yang-ext:mount/config:modules/module/yanglib:yanglib/example
743
744 Headers:
745
746 -  Accept: application/xml
747
748 -  Content-Type: application/xml
749
750 Payload:
751
752 ::
753
754    <module xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
755      <name>example</name>
756      <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:yanglib:impl">prefix:yanglib</type>
757      <broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:yanglib:impl">
758        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">prefix:binding-broker-osgi-registry</type>
759        <name>binding-osgi-broker</name>
760      </broker>
761      <cache-folder xmlns="urn:opendaylight:params:xml:ns:yang:controller:yanglib:impl">/sources</cache-folder>
762      <binding-addr xmlns="urn:opendaylight:params:xml:ns:yang:controller:yanglib:impl">localhost</binding-addr>
763      <binding-port xmlns="urn:opendaylight:params:xml:ns:yang:controller:yanglib:impl">5000</binding-port>
764    </module>
765
766 This should result in a 2xx response and new YANGLIB instance should be
767 created. This YANGLIB takes all YANG sources from /sources folder and
768 for each generates URL in form:
769
770 ::
771
772     http://localhost:5000/schemas/{modelName}/{revision}
773
774 On this URL will be hosted YANG source for particular module.
775
776 YANGLIB instance also write this URL along with source identifier to
777 ietf-netconf-yang-library/modules-state/module list.
778
779 Netconf-connector with YANG library as fallback
780 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
781
782 There is an optional configuration in netconf-connector called
783 yang-library. You can specify YANG library to be plugged as additional
784 source provider into the mount's schema repository. Since YANGLIB
785 plugin is advertising provided modules through yang-library model, we
786 can use it in mount point's configuration as YANG library.  To do this,
787 we need to modify the configuration of netconf-connector by adding this
788 XML
789
790 ::
791
792     <yang-library xmlns="urn:opendaylight:netconf-node-topology">
793       <yang-library-url xmlns="urn:opendaylight:netconf-node-topology">http://localhost:8181/restconf/operational/ietf-yang-library:modules-state</yang-library-url>
794       <username xmlns="urn:opendaylight:netconf-node-topology">admin</username>
795       <password xmlns="urn:opendaylight:netconf-node-topology">admin</password>
796     </yang-library>
797
798 This will register YANGLIB provided sources as a fallback schemas for
799 particular mount point.
800
801 NETCONF Call Home
802 -----------------
803
804 Call Home Installation
805 ~~~~~~~~~~~~~~~~~~~~~~
806
807 ODL Call-Home server is installed in Karaf by installing karaf feature
808 ``odl-netconf-callhome-ssh``. RESTCONF feature is recommended for
809 configuring Call Home & testing its functionality.
810
811 ::
812
813   feature:install odl-netconf-callhome-ssh
814
815
816 .. note::
817
818     In order to test Call Home functionality we recommend Netopeer or
819     Netopeer2. See `Netopeer Call Home <https://github.com/CESNET/netopeer/wiki/CallHome>`__
820     or `Netopeer2 <https://github.com/CESNET/netopeer2>`__ to learn how to
821     enable call-home on Netopeer.
822
823 Northbound Call-Home API
824 ~~~~~~~~~~~~~~~~~~~~~~~~
825
826 The northbound Call Home API is used for administering the Call-Home Server. The
827 following describes this configuration.
828
829 Global Configuration
830 ^^^^^^^^^^^^^^^^^^^^
831
832 .. important::
833   The global configuration is not a part of the `RFC 8071
834   <https://tools.ietf.org/html/rfc8071>`__ and, therefore, subject to change.
835
836 Configuring global credentials
837 ''''''''''''''''''''''''''''''
838
839 ODL Call-Home server allows user to configure global credentials, which will be
840 used for connected over SSH transport protocol devices which does not have
841 device-specific credentials configured.
842
843 This is done by creating
844 ``/odl-netconf-callhome-server:netconf-callhome-server/global/credentials``
845 with username and passwords specified.
846
847 *Configuring global username & passwords to try*
848
849 .. code-block::
850
851     PUT
852     /restconf/config/odl-netconf-callhome-server:netconf-callhome-server/global/credentials HTTP/1.1
853     Content-Type: application/json
854     Accept: application/json
855
856 .. code-block:: json
857
858     {
859       "credentials":
860       {
861         "username": "example",
862         "passwords": [ "first-password-to-try", "second-password-to-try" ]
863       }
864     }
865
866 Configuring to accept any ssh server key using global credentials
867 '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
868
869 By default Netconf Call-Home Server accepts only incoming connections
870 from allowed devices
871 ``/odl-netconf-callhome-server:netconf-callhome-server/allowed-devices``,
872 if user desire to allow all incoming connections, it is possible to set
873 ``accept-all-ssh-keys`` to ``true`` in
874 ``/odl-netconf-callhome-server:netconf-callhome-server/global``.
875
876 The name of this devices in ``netconf-topology`` will be in format
877 ``ip-address:port``. For naming devices see Device-Specific
878 Configuration.
879
880 *Allowing unknown devices to connect*
881
882 This is a debug feature and should not be used in production. Besides being an obvious
883 security issue, this also causes the Call-Home Server to drastically increase its output
884 to the log.
885
886 .. code-block::
887
888     POST
889     /restconf/config/odl-netconf-callhome-server:netconf-callhome-server/global HTTP/1.1
890     Content-Type: application/json
891     Accept: application/json
892
893 .. code-block:: json
894
895     {
896       "global": {
897         "accept-all-ssh-keys": "true"
898       }
899     }
900
901 Device-Specific Configuration
902 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
903
904 Netconf Call Home server supports both of the secure transports used
905 by the Network Configuration Protocol (NETCONF) - Secure Shell (SSH),
906 and Transport Layer Security (TLS).
907
908 Configure device to connect over SSH protocol
909 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
910
911 Netconf Call Home Server uses device provided SSH server key (host key)
912 to identify device. The pairing of name and server key is configured in
913 ``/odl-netconf-callhome-server:netconf-callhome-server/allowed-devices``.
914 This list is colloquially called a whitelist.
915
916 If the Call-Home Server finds the SSH host key in the whitelist, it continues
917 to negotiate a NETCONF connection over an SSH session. If the SSH host key is
918 not found, the connection between the Call Home server and the device is dropped
919 immediately. In either case, the device that connects to the Call home server
920 leaves a record of its presence in the operational store.
921
922 Configuring Device with Device-specific Credentials
923 '''''''''''''''''''''''''''''''''''''''''''''''''''
924
925 Adding specific device to the allowed list is done by creating
926 ``/odl-netconf-callhome-server:netconf-callhome-server/allowed-devices/device/{device}``
927 with device-id and connection parameters inside the ssh-client-params container.
928
929 *Configuring Device with Credentials*
930
931 .. code-block::
932
933     PUT
934     /restconf/config/odl-netconf-callhome-server:netconf-callhome-server/allowed-devices/device/example HTTP/1.1
935     Content-Type: application/json
936     Accept: application/json
937
938 .. code-block:: json
939
940     {
941       "device": {
942         "unique-id": "example",
943         "ssh-client-params": {
944           "credentials": {
945             "username": "example",
946             "passwords": [ "password" ]
947           },
948           "ssh-host-key": "AAAAB3NzaC1yc2EAAAADAQABAAABAQDHoH1jMjltOJnCt999uaSfc48ySutaD3ISJ9fSECe1Spdq9o9mxj0kBTTTq+2V8hPspuW75DNgN+V/rgJeoUewWwCAasRx9X4eTcRrJrwOQKzb5Fk+UKgQmenZ5uhLAefi2qXX/agFCtZi99vw+jHXZStfHm9TZCAf2zi+HIBzoVksSNJD0VvPo66EAvLn5qKWQD4AdpQQbKqXRf5/W8diPySbYdvOP2/7HFhDukW8yV/7ZtcywFUIu3gdXsrzwMnTqnATSLPPuckoi0V2jd8dQvEcu1DY+rRqmqu0tEkFBurlRZDf1yhNzq5xWY3OXcjgDGN+RxwuWQK3cRimcosH"
949         }
950       }
951     }
952
953 Configuring Device with Global Credentials
954 '''''''''''''''''''''''''''''''''''''''''''''''''''
955
956 It is possible to omit 'username' and 'password' for ssh-client-params,
957 in such case values from global credentials will be used.
958
959 *Example of configuring device*
960
961 .. code-block::
962
963     PUT
964     /restconf/config/odl-netconf-callhome-server:netconf-callhome-server/allowed-devices/device/example HTTP/1.1
965     Content-Type: application/json
966     Accept: application/json
967
968 .. code-block:: json
969
970     {
971       "device": {
972         "unique-id": "example",
973         "ssh-client-params": {
974           "host-key": "AAAAB3NzaC1yc2EAAAADAQABAAABAQDHoH1jMjltOJnCt999uaSfc48ySutaD3ISJ9fSECe1Spdq9o9mxj0kBTTTq+2V8hPspuW75DNgN+V/rgJeoUewWwCAasRx9X4eTcRrJrwOQKzb5Fk+UKgQmenZ5uhLAefi2qXX/agFCtZi99vw+jHXZStfHm9TZCAf2zi+HIBzoVksSNJD0VvPo66EAvLn5qKWQD4AdpQQbKqXRf5/W8diPySbYdvOP2/7HFhDukW8yV/7ZtcywFUIu3gdXsrzwMnTqnATSLPPuckoi0V2jd8dQvEcu1DY+rRqmqu0tEkFBurlRZDf1yhNzq5xWY3OXcjgDGN+RxwuWQK3cRimcosH"
975         }
976       }
977     }
978
979 Deprecated configuration models for devices accessed with SSH protocol
980 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
981
982 With `RFC 8071 <https://tools.ietf.org/html/rfc8071>`__ alignment and adding
983 support for TLS transport following configuration models has been marked
984 deprecated.
985
986 Configuring Device with Global Credentials
987 '''''''''''''''''''''''''''''''''''''''''''''''''''
988
989 *Example of configuring device*
990
991 .. code-block::
992
993     PUT
994     /restconf/config/odl-netconf-callhome-server:netconf-callhome-server/allowed-devices/device/example HTTP/1.1
995     Content-Type: application/json
996     Accept: application/json
997
998 .. code-block:: json
999
1000     {
1001       "device": {
1002         "unique-id": "example",
1003         "ssh-host-key": "AAAAB3NzaC1yc2EAAAADAQABAAABAQDHoH1jMjltOJnCt999uaSfc48ySutaD3ISJ9fSECe1Spdq9o9mxj0kBTTTq+2V8hPspuW75DNgN+V/rgJeoUewWwCAasRx9X4eTcRrJrwOQKzb5Fk+UKgQmenZ5uhLAefi2qXX/agFCtZi99vw+jHXZStfHm9TZCAf2zi+HIBzoVksSNJD0VvPo66EAvLn5qKWQD4AdpQQbKqXRf5/W8diPySbYdvOP2/7HFhDukW8yV/7ZtcywFUIu3gdXsrzwMnTqnATSLPPuckoi0V2jd8dQvEcu1DY+rRqmqu0tEkFBurlRZDf1yhNzq5xWY3OXcjgDGN+RxwuWQK3cRimcosH"
1004       }
1005     }
1006
1007 Configuring Device with Device-specific Credentials
1008 '''''''''''''''''''''''''''''''''''''''''''''''''''
1009
1010 Call Home Server also allows to configure credentials per device basis,
1011 this is done by introducing ``credentials`` container into
1012 device-specific configuration. Format is same as in global credentials.
1013
1014 *Configuring Device with Credentials*
1015
1016 .. code-block::
1017
1018     PUT
1019     /restconf/config/odl-netconf-callhome-server:netconf-callhome-server/allowed-devices/device/example HTTP/1.1
1020     Content-Type: application/json
1021     Accept: application/json
1022
1023 .. code-block:: json
1024
1025     {
1026       "device": {
1027         "unique-id": "example",
1028         "credentials": {
1029           "username": "example",
1030           "passwords": [ "password" ]
1031         },
1032         "ssh-host-key": "AAAAB3NzaC1yc2EAAAADAQABAAABAQDHoH1jMjltOJnCt999uaSfc48ySutaD3ISJ9fSECe1Spdq9o9mxj0kBTTTq+2V8hPspuW75DNgN+V/rgJeoUewWwCAasRx9X4eTcRrJrwOQKzb5Fk+UKgQmenZ5uhLAefi2qXX/agFCtZi99vw+jHXZStfHm9TZCAf2zi+HIBzoVksSNJD0VvPo66EAvLn5qKWQD4AdpQQbKqXRf5/W8diPySbYdvOP2/7HFhDukW8yV/7ZtcywFUIu3gdXsrzwMnTqnATSLPPuckoi0V2jd8dQvEcu1DY+rRqmqu0tEkFBurlRZDf1yhNzq5xWY3OXcjgDGN+RxwuWQK3cRimcosH"
1033       }
1034     }
1035
1036 Configure device to connect over TLS protocol
1037 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1038
1039 Netconf Call Home Server allows devices to use TLS transport protocol to
1040 establish a connection towards the NETCONF device. This communication
1041 requires proper setup to make two-way TLS authentication possible for client
1042 and server.
1043
1044 The initial step is to configure certificates and keys for two-way TLS by
1045 storing them within the netconf-keystore.
1046
1047 *Adding a client private key credential to the netconf-keystore*
1048
1049 .. code-block::
1050
1051     POST
1052     /rests/operations/netconf-keystore:add-keystore-entry HTTP/1.1
1053     Content-Type: application/json
1054     Accept: application/json
1055
1056 .. code-block:: json
1057
1058   {
1059     "input": {
1060       "key-credential": [
1061         {
1062           "key-id": "example-client-key-id",
1063           "private-key": "base64encoded-private-key",
1064           "passphrase": "passphrase"
1065         }
1066       ]
1067     }
1068   }
1069
1070 *Associate a private key with a client and CA certificates chain*
1071
1072 .. code-block::
1073
1074     POST
1075     /rests/operations/netconf-keystore:add-private-key HTTP/1.1
1076     Content-Type: application/json
1077     Accept: application/json
1078
1079 .. code-block:: json
1080
1081   {
1082     "input": {
1083       "private-key": [
1084         {
1085           "name": "example-client-key-id",
1086           "data": "key-data",
1087           "certificate-chain": [
1088             "certificate-data"
1089           ]
1090         }
1091       ]
1092     }
1093   }
1094
1095 *Add a list of trusted CA and server certificates*
1096
1097 .. code-block::
1098
1099     POST
1100     /rests/operations/netconf-keystore:add-trusted-certificate HTTP/1.1
1101     Content-Type: application/json
1102     Accept: application/json
1103
1104 .. code-block:: json
1105
1106   {
1107     "input": {
1108       "trusted-certificate": [
1109         {
1110           "name": "example-ca-certificate",
1111           "certificate": "ca-certificate-data"
1112         },
1113         {
1114           "name": "example-server-certificate",
1115           "certificate": "server-certificate-data"
1116         }
1117       ]
1118     }
1119   }
1120
1121 In a second step, it is required to create an allowed device associated with
1122 a server certificate and client key. The server certificate will be used to
1123 identify and pin the NETCONF device during SSL handshake and should be unique
1124 among the allowed devices.
1125
1126 *Add device configuration for TLS protocol to allowed devices list*
1127
1128 .. code-block::
1129
1130     PUT
1131     /restconf/config/odl-netconf-callhome-server:netconf-callhome-server/allowed-devices/device/example-device HTTP/1.1
1132     Content-Type: application/json
1133     Accept: application/json
1134
1135 .. code-block:: json
1136
1137   {
1138     "device": {
1139       "unique-id": "example-device",
1140       "tls-client-params": {
1141         "key-id": "example-client-key-id",
1142         "certificate-id": "example-server-certificate"
1143       }
1144     }
1145   }
1146
1147 Operational Status
1148 ^^^^^^^^^^^^^^^^^^
1149
1150 Once an entry is made into the config side of "allowed-devices", the Call-Home Server will
1151 populate an corresponding operational device that is the same as the config device but
1152 has an additional status. By default, this status is *DISCONNECTED*. Once a device calls
1153 home, this status will change to one of:
1154
1155 *CONNECTED* â€” The device is currently connected and the NETCONF mount is available for network
1156 management.
1157
1158 *FAILED_AUTH_FAILURE* â€” The last attempted connection was unsuccessful because the Call-Home
1159 Server was unable to provide the acceptable credentials of the device. The device is also
1160 disconnected and not available for network management.
1161
1162 *FAILED_NOT_ALLOWED* â€” The last attempted connection was unsuccessful because the device was
1163 not recognized as an acceptable device. The device is also disconnected and not available for
1164 network management.
1165
1166 *FAILED* â€” The last attempted connection was unsuccessful for a reason other than not
1167 allowed to connect or incorrect client credentials. The device is also disconnected and not
1168 available for network management.
1169
1170 *DISCONNECTED* â€” The device is currently disconnected.
1171
1172 Rogue Devices
1173 '''''''''''''
1174
1175 Devices which are not on the whitelist might try to connect to the Call-Home Server. In
1176 these cases, the server will keep a record by instantiating an operational device. There
1177 will be no corresponding config device for these rogues. They can be identified readily
1178 because their device id, rather than being user-supplied, will be of the form
1179 "address:port". Note that if a device calls back multiple times, there will only be
1180 a single operatinal entry (even if the port changes); these devices are recognized by
1181 their unique host key.
1182
1183 Southbound Call-Home API
1184 ~~~~~~~~~~~~~~~~~~~~~~~~
1185
1186 The Call-Home Server listens for incoming TCP connections and assumes that the other side of
1187 the connection is a device calling home via a NETCONF connection with SSH for
1188 management. The server uses port 6666 by default and this can be configured via a
1189 blueprint configuration file.
1190
1191 The device **must** initiate the connection and the server will not try to re-establish the
1192 connection in case of a drop. By requirement, the server cannot assume it has connectivity
1193 to the device due to NAT or firewalls among others.
1194
1195 Reading data with selected fields
1196 ---------------------------------
1197
1198 Overview
1199 ~~~~~~~~
1200
1201 If user would like to read only selected fields from NETCONF device, it is possible to use
1202 fields query parameter that is described by RFC-8040. RESTCONF parses content of query
1203 parameter into format that is accepted by NETCONF subtree filtering - filtering of data is done
1204 on NETCONF server, not on NETCONF client side. This approach optimizes network traffic load,
1205 because data in which user doesn't have interest, is not transferred over network.
1206
1207 Next advantages:
1208
1209 * using single RESTCONF request and single NETCONF RPC for reading multiple subtrees
1210 * possibility to read only selected fields under list node across multiple hierarchies
1211   (it cannot be done without proper selection API)
1212
1213 .. note::
1214
1215   More information about fields query parameter: `RFC 8071 <https://tools.ietf.org/html/rfc8040#section-4.8.3>`__
1216
1217 Preparation of data
1218 ~~~~~~~~~~~~~~~~~~~
1219
1220 Mounting NETCONF device that runs on NETCONF testtool:
1221
1222 .. code-block:: bash
1223
1224   curl --location --request PUT 'http://127.0.0.1:8181/rests/data/network-topology:network-topology/topology=topology-netconf/node=testtool' \
1225   --header 'Authorization: Basic YWRtaW46YWRtaW4=' \
1226   --header 'Content-Type: application/json' \
1227   --data-raw '{
1228       "node": [
1229           {
1230               "node-id": "testtool",
1231               "netconf-node-topology:host": "127.0.0.1",
1232               "netconf-node-topology:port": 36000,
1233               "netconf-node-topology:keepalive-delay": 100,
1234               "netconf-node-topology:tcp-only": false,
1235               "netconf-node-topology:username": "admin",
1236               "netconf-node-topology:password": "admin"
1237           }
1238       ]
1239   }'
1240
1241 Setting initial configuration on NETCONF device:
1242
1243 .. code-block:: bash
1244
1245   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' \
1246   --header 'Authorization: Basic YWRtaW46YWRtaW4=' \
1247   --header 'Content-Type: application/json' \
1248   --data-raw '{
1249       "root": {
1250           "simple-root": {
1251               "leaf-a": "asddhg",
1252               "leaf-b": "ffffff",
1253               "ll": [
1254                   "str1",
1255                   "str2",
1256                   "str3"
1257               ],
1258               "nested": {
1259                   "sample-x": true,
1260                   "sample-y": false
1261               }
1262           },
1263           "list-root": {
1264               "branch-ab": 5,
1265               "top-list": [
1266                   {
1267                       "key-1": "ka",
1268                       "key-2": "kb",
1269                       "next-data": {
1270                           "switch-1": [
1271                               null
1272                           ],
1273                           "switch-2": [
1274                               null
1275                           ]
1276                       },
1277                       "nested-list": [
1278                           {
1279                               "identifier": "f1",
1280                               "foo": 1
1281                           },
1282                           {
1283                               "identifier": "f2",
1284                               "foo": 10
1285                           },
1286                           {
1287                               "identifier": "f3",
1288                               "foo": 20
1289                           }
1290                       ]
1291                   },
1292                   {
1293                       "key-1": "kb",
1294                       "key-2": "ka",
1295                       "next-data": {
1296                           "switch-1": [
1297                               null
1298                           ]
1299                       },
1300                       "nested-list": [
1301                           {
1302                               "identifier": "e1",
1303                               "foo": 1
1304                           },
1305                           {
1306                               "identifier": "e2",
1307                               "foo": 2
1308                           },
1309                           {
1310                               "identifier": "e3",
1311                               "foo": 3
1312                           }
1313                       ]
1314                   },
1315                   {
1316                       "key-1": "kc",
1317                       "key-2": "ke",
1318                       "next-data": {
1319                           "switch-2": [
1320                               null
1321                           ]
1322                       },
1323                       "nested-list": [
1324                           {
1325                               "identifier": "q1",
1326                               "foo": 13
1327                           },
1328                           {
1329                               "identifier": "q2",
1330                               "foo": 14
1331                           },
1332                           {
1333                               "identifier": "q3",
1334                               "foo": 15
1335                           }
1336                       ]
1337                   }
1338               ]
1339           }
1340       }
1341   }'
1342
1343 Examples
1344 --------
1345
1346 1. Reading whole leaf-list 'll' and leaf 'nested/sample-x' under 'simple-root' container.
1347
1348 RESTCONF request:
1349
1350 .. code-block:: bash
1351
1352     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' \
1353     --header 'Authorization: Basic YWRtaW46YWRtaW4=' \
1354     --header 'Cookie: JSESSIONID=node01h4w82eorc1k61866b71qjgj503.node0'
1355
1356 Generated NETCONF RPC request:
1357
1358 .. code-block:: xml
1359
1360     <rpc message-id="m-18" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
1361         <get-config>
1362             <source>
1363                 <running/>
1364             </source>
1365             <filter xmlns:ns0="urn:ietf:params:xml:ns:netconf:base:1.0" ns0:type="subtree">
1366                 <root xmlns="urn:ietf:params:xml:ns:yang:test-model">
1367                     <simple-root>
1368                         <ll/>
1369                         <nested>
1370                             <sample-x/>
1371                         </nested>
1372                     </simple-root>
1373                 </root>
1374             </filter>
1375         </get-config>
1376     </rpc>
1377
1378 .. note::
1379
1380     Using fields query parameter it is also possible to read whole leaf-list or list without
1381     necessity to specify value / key predicate (without reading parent entity). Such scenario
1382     is not permitted in RFC-8040 paths alone - fields query parameter can be used as
1383     workaround for this case.
1384
1385 RESTCONF response:
1386
1387 .. code-block:: json
1388
1389     {
1390         "test-module:simple-root": {
1391             "ll": [
1392                 "str3",
1393                 "str1",
1394                 "str2"
1395             ],
1396             "nested": {
1397                 "sample-x": true
1398             }
1399         }
1400     }
1401
1402 2. Reading all identifiers of 'nested-list' under all elements of 'top-list'.
1403
1404 RESTCONF request:
1405
1406 .. code-block:: bash
1407
1408     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)' \
1409     --header 'Authorization: Basic YWRtaW46YWRtaW4=' \
1410     --header 'Cookie: JSESSIONID=node01h4w82eorc1k61866b71qjgj503.node0'
1411
1412 Generated NETCONF RPC request:
1413
1414 .. code-block:: xml
1415
1416     <rpc message-id="m-27" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
1417         <get-config>
1418             <source>
1419                 <running/>
1420             </source>
1421             <filter xmlns:ns0="urn:ietf:params:xml:ns:netconf:base:1.0" ns0:type="subtree">
1422                 <root xmlns="urn:ietf:params:xml:ns:yang:test-model">
1423                     <list-root>
1424                         <top-list>
1425                             <nested-list>
1426                                 <identifier/>
1427                             </nested-list>
1428                             <key-1/>
1429                             <key-2/>
1430                         </top-list>
1431                     </list-root>
1432                 </root>
1433             </filter>
1434         </get-config>
1435     </rpc>
1436
1437 .. note::
1438
1439     NETCONF client automatically fetches values of list keys since they are required for correct
1440     deserialization of NETCONF response and at the end serialization of response to RESTCONF
1441     response (JSON/XML).
1442
1443 RESTCONF response:
1444
1445 .. code-block:: json
1446
1447     {
1448         "test-module:list-root": {
1449             "top-list": [
1450                 {
1451                     "key-1": "ka",
1452                     "key-2": "kb",
1453                     "nested-list": [
1454                         {
1455                             "identifier": "f3"
1456                         },
1457                         {
1458                             "identifier": "f2"
1459                         },
1460                         {
1461                             "identifier": "f1"
1462                         }
1463                     ]
1464                 },
1465                 {
1466                     "key-1": "kb",
1467                     "key-2": "ka",
1468                     "nested-list": [
1469                         {
1470                             "identifier": "e3"
1471                         },
1472                         {
1473                             "identifier": "e2"
1474                         },
1475                         {
1476                             "identifier": "e1"
1477                         }
1478                     ]
1479                 },
1480                 {
1481                     "key-1": "kc",
1482                     "key-2": "ke",
1483                     "nested-list": [
1484                         {
1485                             "identifier": "q3"
1486                         },
1487                         {
1488                             "identifier": "q2"
1489                         },
1490                         {
1491                             "identifier": "q1"
1492                         }
1493                     ]
1494                 }
1495             ]
1496         }
1497     }
1498
1499 3. Reading value of leaf 'branch-ab' and all values of leaves 'switch-1' that are placed
1500    under 'top-list' list elements.
1501
1502 RESTCONF request:
1503
1504 .. code-block:: bash
1505
1506     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' \
1507     --header 'Authorization: Basic YWRtaW46YWRtaW4=' \
1508     --header 'Cookie: JSESSIONID=node01jx6o5thwae9t1ft7c2zau5zbz4.node0'
1509
1510 Generated NETCONF RPC request:
1511
1512 .. code-block:: xml
1513
1514     <rpc message-id="m-42" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
1515         <get-config>
1516             <source>
1517                 <running/>
1518             </source>
1519             <filter xmlns:ns0="urn:ietf:params:xml:ns:netconf:base:1.0" ns0:type="subtree">
1520                 <root xmlns="urn:ietf:params:xml:ns:yang:test-model">
1521                     <list-root>
1522                         <branch-ab/>
1523                         <top-list>
1524                             <next-data>
1525                                 <switch-1/>
1526                             </next-data>
1527                             <key-1/>
1528                             <key-2/>
1529                         </top-list>
1530                     </list-root>
1531                 </root>
1532             </filter>
1533         </get-config>
1534     </rpc>
1535
1536 RESTCONF response:
1537
1538 .. code-block:: json
1539
1540     {
1541         "test-module:list-root": {
1542             "branch-ab": 5,
1543             "top-list": [
1544                 {
1545                     "key-1": "ka",
1546                     "key-2": "kb",
1547                     "next-data": {
1548                         "switch-1": [
1549                             null
1550                         ]
1551                     }
1552                 },
1553                 {
1554                     "key-1": "kb",
1555                     "key-2": "ka",
1556                     "next-data": {
1557                         "switch-1": [
1558                             null
1559                         ]
1560                     }
1561                 },
1562                 {
1563                     "key-1": "kc",
1564                     "key-2": "ke"
1565                 }
1566             ]
1567         }
1568     }