Update documentation for YangLib feature
[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:8181 adress. The configuration for this scenario will be
738 as follows:
739
740 ::
741
742     PUT  http://localhost:8181/rests/data/yanglib:yanglib-config
743
744 Headers:
745
746 -  Accept: application/xml
747
748 -  Content-Type: application/xml
749
750 Payload:
751
752 ::
753
754     <yanglib-config xmlns="urn:opendaylight:params:xml:ns:yang:controller:yanglib:impl">
755         <cache-folder>cache/newSchema</cache-folder>
756         <binding-addr>localhost</binding-addr>
757         <binding-port>8181</binding-port>
758     </yanglib-config>
759
760 This should result in a 2xx response and new YANGLIB instance should be
761 created. This YANGLIB takes all YANG sources from /sources folder and
762 for each generates URL in form:
763
764 ::
765
766     http://localhost:8181/yanglib/schemas/{modelName}/{revision}
767
768 On this URL will be hosted YANG source for particular module.
769
770 YANGLIB instance also write this URL along with source identifier to
771 ietf-netconf-yang-library/modules-state/module list.
772
773 Netconf-connector with YANG library as fallback
774 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
775
776 There is an optional configuration in netconf-connector called
777 yang-library. You can specify YANG library to be plugged as additional
778 source provider into the mount's schema repository. Since YANGLIB
779 plugin is advertising provided modules through yang-library model, we
780 can use it in mount point's configuration as YANG library.  To do this,
781 we need to modify the configuration of netconf-connector by adding this
782 XML
783
784 ::
785
786     <yang-library xmlns="urn:opendaylight:netconf-node-topology">
787       <yang-library-url xmlns="urn:opendaylight:netconf-node-topology">http://localhost:8181/restconf/operational/ietf-yang-library:modules-state</yang-library-url>
788       <username xmlns="urn:opendaylight:netconf-node-topology">admin</username>
789       <password xmlns="urn:opendaylight:netconf-node-topology">admin</password>
790     </yang-library>
791
792 This will register YANGLIB provided sources as a fallback schemas for
793 particular mount point.
794
795 NETCONF Call Home
796 -----------------
797
798 Call Home Installation
799 ~~~~~~~~~~~~~~~~~~~~~~
800
801 ODL Call-Home server is installed in Karaf by installing karaf feature
802 ``odl-netconf-callhome-ssh``. RESTCONF feature is recommended for
803 configuring Call Home & testing its functionality.
804
805 ::
806
807   feature:install odl-netconf-callhome-ssh
808
809
810 .. note::
811
812     In order to test Call Home functionality we recommend Netopeer or
813     Netopeer2. See `Netopeer Call Home <https://github.com/CESNET/netopeer/wiki/CallHome>`__
814     or `Netopeer2 <https://github.com/CESNET/netopeer2>`__ to learn how to
815     enable call-home on Netopeer.
816
817 Northbound Call-Home API
818 ~~~~~~~~~~~~~~~~~~~~~~~~
819
820 The northbound Call Home API is used for administering the Call-Home Server. The
821 following describes this configuration.
822
823 Global Configuration
824 ^^^^^^^^^^^^^^^^^^^^
825
826 .. important::
827   The global configuration is not a part of the `RFC 8071
828   <https://tools.ietf.org/html/rfc8071>`__ and, therefore, subject to change.
829
830 Configuring global credentials
831 ''''''''''''''''''''''''''''''
832
833 ODL Call-Home server allows user to configure global credentials, which will be
834 used for connected over SSH transport protocol devices which does not have
835 device-specific credentials configured.
836
837 This is done by creating
838 ``/odl-netconf-callhome-server:netconf-callhome-server/global/credentials``
839 with username and passwords specified.
840
841 *Configuring global username & passwords to try*
842
843 .. code-block::
844
845     PUT
846     /restconf/config/odl-netconf-callhome-server:netconf-callhome-server/global/credentials HTTP/1.1
847     Content-Type: application/json
848     Accept: application/json
849
850 .. code-block:: json
851
852     {
853       "credentials":
854       {
855         "username": "example",
856         "passwords": [ "first-password-to-try", "second-password-to-try" ]
857       }
858     }
859
860 Configuring to accept any ssh server key using global credentials
861 '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
862
863 By default Netconf Call-Home Server accepts only incoming connections
864 from allowed devices
865 ``/odl-netconf-callhome-server:netconf-callhome-server/allowed-devices``,
866 if user desire to allow all incoming connections, it is possible to set
867 ``accept-all-ssh-keys`` to ``true`` in
868 ``/odl-netconf-callhome-server:netconf-callhome-server/global``.
869
870 The name of this devices in ``netconf-topology`` will be in format
871 ``ip-address:port``. For naming devices see Device-Specific
872 Configuration.
873
874 *Allowing unknown devices to connect*
875
876 This is a debug feature and should not be used in production. Besides being an obvious
877 security issue, this also causes the Call-Home Server to drastically increase its output
878 to the log.
879
880 .. code-block::
881
882     POST
883     /restconf/config/odl-netconf-callhome-server:netconf-callhome-server/global HTTP/1.1
884     Content-Type: application/json
885     Accept: application/json
886
887 .. code-block:: json
888
889     {
890       "global": {
891         "accept-all-ssh-keys": "true"
892       }
893     }
894
895 Device-Specific Configuration
896 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
897
898 Netconf Call Home server supports both of the secure transports used
899 by the Network Configuration Protocol (NETCONF) - Secure Shell (SSH),
900 and Transport Layer Security (TLS).
901
902 Configure device to connect over SSH protocol
903 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
904
905 Netconf Call Home Server uses device provided SSH server key (host key)
906 to identify device. The pairing of name and server key is configured in
907 ``/odl-netconf-callhome-server:netconf-callhome-server/allowed-devices``.
908 This list is colloquially called a whitelist.
909
910 If the Call-Home Server finds the SSH host key in the whitelist, it continues
911 to negotiate a NETCONF connection over an SSH session. If the SSH host key is
912 not found, the connection between the Call Home server and the device is dropped
913 immediately. In either case, the device that connects to the Call home server
914 leaves a record of its presence in the operational store.
915
916 Configuring Device with Device-specific Credentials
917 '''''''''''''''''''''''''''''''''''''''''''''''''''
918
919 Adding specific device to the allowed list is done by creating
920 ``/odl-netconf-callhome-server:netconf-callhome-server/allowed-devices/device/{device}``
921 with device-id and connection parameters inside the ssh-client-params container.
922
923 *Configuring Device with Credentials*
924
925 .. code-block::
926
927     PUT
928     /restconf/config/odl-netconf-callhome-server:netconf-callhome-server/allowed-devices/device/example HTTP/1.1
929     Content-Type: application/json
930     Accept: application/json
931
932 .. code-block:: json
933
934     {
935       "device": {
936         "unique-id": "example",
937         "ssh-client-params": {
938           "credentials": {
939             "username": "example",
940             "passwords": [ "password" ]
941           },
942           "ssh-host-key": "AAAAB3NzaC1yc2EAAAADAQABAAABAQDHoH1jMjltOJnCt999uaSfc48ySutaD3ISJ9fSECe1Spdq9o9mxj0kBTTTq+2V8hPspuW75DNgN+V/rgJeoUewWwCAasRx9X4eTcRrJrwOQKzb5Fk+UKgQmenZ5uhLAefi2qXX/agFCtZi99vw+jHXZStfHm9TZCAf2zi+HIBzoVksSNJD0VvPo66EAvLn5qKWQD4AdpQQbKqXRf5/W8diPySbYdvOP2/7HFhDukW8yV/7ZtcywFUIu3gdXsrzwMnTqnATSLPPuckoi0V2jd8dQvEcu1DY+rRqmqu0tEkFBurlRZDf1yhNzq5xWY3OXcjgDGN+RxwuWQK3cRimcosH"
943         }
944       }
945     }
946
947 Configuring Device with Global Credentials
948 '''''''''''''''''''''''''''''''''''''''''''''''''''
949
950 It is possible to omit 'username' and 'password' for ssh-client-params,
951 in such case values from global credentials will be used.
952
953 *Example of configuring device*
954
955 .. code-block::
956
957     PUT
958     /restconf/config/odl-netconf-callhome-server:netconf-callhome-server/allowed-devices/device/example HTTP/1.1
959     Content-Type: application/json
960     Accept: application/json
961
962 .. code-block:: json
963
964     {
965       "device": {
966         "unique-id": "example",
967         "ssh-client-params": {
968           "host-key": "AAAAB3NzaC1yc2EAAAADAQABAAABAQDHoH1jMjltOJnCt999uaSfc48ySutaD3ISJ9fSECe1Spdq9o9mxj0kBTTTq+2V8hPspuW75DNgN+V/rgJeoUewWwCAasRx9X4eTcRrJrwOQKzb5Fk+UKgQmenZ5uhLAefi2qXX/agFCtZi99vw+jHXZStfHm9TZCAf2zi+HIBzoVksSNJD0VvPo66EAvLn5qKWQD4AdpQQbKqXRf5/W8diPySbYdvOP2/7HFhDukW8yV/7ZtcywFUIu3gdXsrzwMnTqnATSLPPuckoi0V2jd8dQvEcu1DY+rRqmqu0tEkFBurlRZDf1yhNzq5xWY3OXcjgDGN+RxwuWQK3cRimcosH"
969         }
970       }
971     }
972
973 Deprecated configuration models for devices accessed with SSH protocol
974 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
975
976 With `RFC 8071 <https://tools.ietf.org/html/rfc8071>`__ alignment and adding
977 support for TLS transport following configuration models has been marked
978 deprecated.
979
980 Configuring Device with Global Credentials
981 '''''''''''''''''''''''''''''''''''''''''''''''''''
982
983 *Example of configuring device*
984
985 .. code-block::
986
987     PUT
988     /restconf/config/odl-netconf-callhome-server:netconf-callhome-server/allowed-devices/device/example HTTP/1.1
989     Content-Type: application/json
990     Accept: application/json
991
992 .. code-block:: json
993
994     {
995       "device": {
996         "unique-id": "example",
997         "ssh-host-key": "AAAAB3NzaC1yc2EAAAADAQABAAABAQDHoH1jMjltOJnCt999uaSfc48ySutaD3ISJ9fSECe1Spdq9o9mxj0kBTTTq+2V8hPspuW75DNgN+V/rgJeoUewWwCAasRx9X4eTcRrJrwOQKzb5Fk+UKgQmenZ5uhLAefi2qXX/agFCtZi99vw+jHXZStfHm9TZCAf2zi+HIBzoVksSNJD0VvPo66EAvLn5qKWQD4AdpQQbKqXRf5/W8diPySbYdvOP2/7HFhDukW8yV/7ZtcywFUIu3gdXsrzwMnTqnATSLPPuckoi0V2jd8dQvEcu1DY+rRqmqu0tEkFBurlRZDf1yhNzq5xWY3OXcjgDGN+RxwuWQK3cRimcosH"
998       }
999     }
1000
1001 Configuring Device with Device-specific Credentials
1002 '''''''''''''''''''''''''''''''''''''''''''''''''''
1003
1004 Call Home Server also allows to configure credentials per device basis,
1005 this is done by introducing ``credentials`` container into
1006 device-specific configuration. Format is same as in global credentials.
1007
1008 *Configuring Device with Credentials*
1009
1010 .. code-block::
1011
1012     PUT
1013     /restconf/config/odl-netconf-callhome-server:netconf-callhome-server/allowed-devices/device/example HTTP/1.1
1014     Content-Type: application/json
1015     Accept: application/json
1016
1017 .. code-block:: json
1018
1019     {
1020       "device": {
1021         "unique-id": "example",
1022         "credentials": {
1023           "username": "example",
1024           "passwords": [ "password" ]
1025         },
1026         "ssh-host-key": "AAAAB3NzaC1yc2EAAAADAQABAAABAQDHoH1jMjltOJnCt999uaSfc48ySutaD3ISJ9fSECe1Spdq9o9mxj0kBTTTq+2V8hPspuW75DNgN+V/rgJeoUewWwCAasRx9X4eTcRrJrwOQKzb5Fk+UKgQmenZ5uhLAefi2qXX/agFCtZi99vw+jHXZStfHm9TZCAf2zi+HIBzoVksSNJD0VvPo66EAvLn5qKWQD4AdpQQbKqXRf5/W8diPySbYdvOP2/7HFhDukW8yV/7ZtcywFUIu3gdXsrzwMnTqnATSLPPuckoi0V2jd8dQvEcu1DY+rRqmqu0tEkFBurlRZDf1yhNzq5xWY3OXcjgDGN+RxwuWQK3cRimcosH"
1027       }
1028     }
1029
1030 Configure device to connect over TLS protocol
1031 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1032
1033 Netconf Call Home Server allows devices to use TLS transport protocol to
1034 establish a connection towards the NETCONF device. This communication
1035 requires proper setup to make two-way TLS authentication possible for client
1036 and server.
1037
1038 The initial step is to configure certificates and keys for two-way TLS by
1039 storing them within the netconf-keystore.
1040
1041 *Adding a client private key credential to the netconf-keystore*
1042
1043 .. code-block::
1044
1045     POST
1046     /rests/operations/netconf-keystore:add-keystore-entry HTTP/1.1
1047     Content-Type: application/json
1048     Accept: application/json
1049
1050 .. code-block:: json
1051
1052   {
1053     "input": {
1054       "key-credential": [
1055         {
1056           "key-id": "example-client-key-id",
1057           "private-key": "base64encoded-private-key",
1058           "passphrase": "passphrase"
1059         }
1060       ]
1061     }
1062   }
1063
1064 *Associate a private key with a client and CA certificates chain*
1065
1066 .. code-block::
1067
1068     POST
1069     /rests/operations/netconf-keystore:add-private-key HTTP/1.1
1070     Content-Type: application/json
1071     Accept: application/json
1072
1073 .. code-block:: json
1074
1075   {
1076     "input": {
1077       "private-key": [
1078         {
1079           "name": "example-client-key-id",
1080           "data": "key-data",
1081           "certificate-chain": [
1082             "certificate-data"
1083           ]
1084         }
1085       ]
1086     }
1087   }
1088
1089 *Add a list of trusted CA and server certificates*
1090
1091 .. code-block::
1092
1093     POST
1094     /rests/operations/netconf-keystore:add-trusted-certificate HTTP/1.1
1095     Content-Type: application/json
1096     Accept: application/json
1097
1098 .. code-block:: json
1099
1100   {
1101     "input": {
1102       "trusted-certificate": [
1103         {
1104           "name": "example-ca-certificate",
1105           "certificate": "ca-certificate-data"
1106         },
1107         {
1108           "name": "example-server-certificate",
1109           "certificate": "server-certificate-data"
1110         }
1111       ]
1112     }
1113   }
1114
1115 In a second step, it is required to create an allowed device associated with
1116 a server certificate and client key. The server certificate will be used to
1117 identify and pin the NETCONF device during SSL handshake and should be unique
1118 among the allowed devices.
1119
1120 *Add device configuration for TLS protocol to allowed devices list*
1121
1122 .. code-block::
1123
1124     PUT
1125     /restconf/config/odl-netconf-callhome-server:netconf-callhome-server/allowed-devices/device/example-device HTTP/1.1
1126     Content-Type: application/json
1127     Accept: application/json
1128
1129 .. code-block:: json
1130
1131   {
1132     "device": {
1133       "unique-id": "example-device",
1134       "tls-client-params": {
1135         "key-id": "example-client-key-id",
1136         "certificate-id": "example-server-certificate"
1137       }
1138     }
1139   }
1140
1141 Operational Status
1142 ^^^^^^^^^^^^^^^^^^
1143
1144 Once an entry is made into the config side of "allowed-devices", the Call-Home Server will
1145 populate an corresponding operational device that is the same as the config device but
1146 has an additional status. By default, this status is *DISCONNECTED*. Once a device calls
1147 home, this status will change to one of:
1148
1149 *CONNECTED* â€” The device is currently connected and the NETCONF mount is available for network
1150 management.
1151
1152 *FAILED_AUTH_FAILURE* â€” The last attempted connection was unsuccessful because the Call-Home
1153 Server was unable to provide the acceptable credentials of the device. The device is also
1154 disconnected and not available for network management.
1155
1156 *FAILED_NOT_ALLOWED* â€” The last attempted connection was unsuccessful because the device was
1157 not recognized as an acceptable device. The device is also disconnected and not available for
1158 network management.
1159
1160 *FAILED* â€” The last attempted connection was unsuccessful for a reason other than not
1161 allowed to connect or incorrect client credentials. The device is also disconnected and not
1162 available for network management.
1163
1164 *DISCONNECTED* â€” The device is currently disconnected.
1165
1166 Rogue Devices
1167 '''''''''''''
1168
1169 Devices which are not on the whitelist might try to connect to the Call-Home Server. In
1170 these cases, the server will keep a record by instantiating an operational device. There
1171 will be no corresponding config device for these rogues. They can be identified readily
1172 because their device id, rather than being user-supplied, will be of the form
1173 "address:port". Note that if a device calls back multiple times, there will only be
1174 a single operatinal entry (even if the port changes); these devices are recognized by
1175 their unique host key.
1176
1177 Southbound Call-Home API
1178 ~~~~~~~~~~~~~~~~~~~~~~~~
1179
1180 The Call-Home Server listens for incoming TCP connections and assumes that the other side of
1181 the connection is a device calling home via a NETCONF connection with SSH for
1182 management. The server uses port 6666 by default and this can be configured via a
1183 blueprint configuration file.
1184
1185 The device **must** initiate the connection and the server will not try to re-establish the
1186 connection in case of a drop. By requirement, the server cannot assume it has connectivity
1187 to the device due to NAT or firewalls among others.
1188
1189 Reading data with selected fields
1190 ---------------------------------
1191
1192 Overview
1193 ~~~~~~~~
1194
1195 If user would like to read only selected fields from NETCONF device, it is possible to use
1196 fields query parameter that is described by RFC-8040. RESTCONF parses content of query
1197 parameter into format that is accepted by NETCONF subtree filtering - filtering of data is done
1198 on NETCONF server, not on NETCONF client side. This approach optimizes network traffic load,
1199 because data in which user doesn't have interest, is not transferred over network.
1200
1201 Next advantages:
1202
1203 * using single RESTCONF request and single NETCONF RPC for reading multiple subtrees
1204 * possibility to read only selected fields under list node across multiple hierarchies
1205   (it cannot be done without proper selection API)
1206
1207 .. note::
1208
1209   More information about fields query parameter: `RFC 8071 <https://tools.ietf.org/html/rfc8040#section-4.8.3>`__
1210
1211 Preparation of data
1212 ~~~~~~~~~~~~~~~~~~~
1213
1214 Mounting NETCONF device that runs on NETCONF testtool:
1215
1216 .. code-block:: bash
1217
1218   curl --location --request PUT 'http://127.0.0.1:8181/rests/data/network-topology:network-topology/topology=topology-netconf/node=testtool' \
1219   --header 'Authorization: Basic YWRtaW46YWRtaW4=' \
1220   --header 'Content-Type: application/json' \
1221   --data-raw '{
1222       "node": [
1223           {
1224               "node-id": "testtool",
1225               "netconf-node-topology:host": "127.0.0.1",
1226               "netconf-node-topology:port": 36000,
1227               "netconf-node-topology:keepalive-delay": 100,
1228               "netconf-node-topology:tcp-only": false,
1229               "netconf-node-topology:username": "admin",
1230               "netconf-node-topology:password": "admin"
1231           }
1232       ]
1233   }'
1234
1235 Setting initial configuration on NETCONF device:
1236
1237 .. code-block:: bash
1238
1239   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' \
1240   --header 'Authorization: Basic YWRtaW46YWRtaW4=' \
1241   --header 'Content-Type: application/json' \
1242   --data-raw '{
1243       "root": {
1244           "simple-root": {
1245               "leaf-a": "asddhg",
1246               "leaf-b": "ffffff",
1247               "ll": [
1248                   "str1",
1249                   "str2",
1250                   "str3"
1251               ],
1252               "nested": {
1253                   "sample-x": true,
1254                   "sample-y": false
1255               }
1256           },
1257           "list-root": {
1258               "branch-ab": 5,
1259               "top-list": [
1260                   {
1261                       "key-1": "ka",
1262                       "key-2": "kb",
1263                       "next-data": {
1264                           "switch-1": [
1265                               null
1266                           ],
1267                           "switch-2": [
1268                               null
1269                           ]
1270                       },
1271                       "nested-list": [
1272                           {
1273                               "identifier": "f1",
1274                               "foo": 1
1275                           },
1276                           {
1277                               "identifier": "f2",
1278                               "foo": 10
1279                           },
1280                           {
1281                               "identifier": "f3",
1282                               "foo": 20
1283                           }
1284                       ]
1285                   },
1286                   {
1287                       "key-1": "kb",
1288                       "key-2": "ka",
1289                       "next-data": {
1290                           "switch-1": [
1291                               null
1292                           ]
1293                       },
1294                       "nested-list": [
1295                           {
1296                               "identifier": "e1",
1297                               "foo": 1
1298                           },
1299                           {
1300                               "identifier": "e2",
1301                               "foo": 2
1302                           },
1303                           {
1304                               "identifier": "e3",
1305                               "foo": 3
1306                           }
1307                       ]
1308                   },
1309                   {
1310                       "key-1": "kc",
1311                       "key-2": "ke",
1312                       "next-data": {
1313                           "switch-2": [
1314                               null
1315                           ]
1316                       },
1317                       "nested-list": [
1318                           {
1319                               "identifier": "q1",
1320                               "foo": 13
1321                           },
1322                           {
1323                               "identifier": "q2",
1324                               "foo": 14
1325                           },
1326                           {
1327                               "identifier": "q3",
1328                               "foo": 15
1329                           }
1330                       ]
1331                   }
1332               ]
1333           }
1334       }
1335   }'
1336
1337 Examples
1338 --------
1339
1340 1. Reading whole leaf-list 'll' and leaf 'nested/sample-x' under 'simple-root' container.
1341
1342 RESTCONF request:
1343
1344 .. code-block:: bash
1345
1346     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' \
1347     --header 'Authorization: Basic YWRtaW46YWRtaW4=' \
1348     --header 'Cookie: JSESSIONID=node01h4w82eorc1k61866b71qjgj503.node0'
1349
1350 Generated NETCONF RPC request:
1351
1352 .. code-block:: xml
1353
1354     <rpc message-id="m-18" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
1355         <get-config>
1356             <source>
1357                 <running/>
1358             </source>
1359             <filter xmlns:ns0="urn:ietf:params:xml:ns:netconf:base:1.0" ns0:type="subtree">
1360                 <root xmlns="urn:ietf:params:xml:ns:yang:test-model">
1361                     <simple-root>
1362                         <ll/>
1363                         <nested>
1364                             <sample-x/>
1365                         </nested>
1366                     </simple-root>
1367                 </root>
1368             </filter>
1369         </get-config>
1370     </rpc>
1371
1372 .. note::
1373
1374     Using fields query parameter it is also possible to read whole leaf-list or list without
1375     necessity to specify value / key predicate (without reading parent entity). Such scenario
1376     is not permitted in RFC-8040 paths alone - fields query parameter can be used as
1377     workaround for this case.
1378
1379 RESTCONF response:
1380
1381 .. code-block:: json
1382
1383     {
1384         "test-module:simple-root": {
1385             "ll": [
1386                 "str3",
1387                 "str1",
1388                 "str2"
1389             ],
1390             "nested": {
1391                 "sample-x": true
1392             }
1393         }
1394     }
1395
1396 2. Reading all identifiers of 'nested-list' under all elements of 'top-list'.
1397
1398 RESTCONF request:
1399
1400 .. code-block:: bash
1401
1402     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)' \
1403     --header 'Authorization: Basic YWRtaW46YWRtaW4=' \
1404     --header 'Cookie: JSESSIONID=node01h4w82eorc1k61866b71qjgj503.node0'
1405
1406 Generated NETCONF RPC request:
1407
1408 .. code-block:: xml
1409
1410     <rpc message-id="m-27" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
1411         <get-config>
1412             <source>
1413                 <running/>
1414             </source>
1415             <filter xmlns:ns0="urn:ietf:params:xml:ns:netconf:base:1.0" ns0:type="subtree">
1416                 <root xmlns="urn:ietf:params:xml:ns:yang:test-model">
1417                     <list-root>
1418                         <top-list>
1419                             <nested-list>
1420                                 <identifier/>
1421                             </nested-list>
1422                             <key-1/>
1423                             <key-2/>
1424                         </top-list>
1425                     </list-root>
1426                 </root>
1427             </filter>
1428         </get-config>
1429     </rpc>
1430
1431 .. note::
1432
1433     NETCONF client automatically fetches values of list keys since they are required for correct
1434     deserialization of NETCONF response and at the end serialization of response to RESTCONF
1435     response (JSON/XML).
1436
1437 RESTCONF response:
1438
1439 .. code-block:: json
1440
1441     {
1442         "test-module:list-root": {
1443             "top-list": [
1444                 {
1445                     "key-1": "ka",
1446                     "key-2": "kb",
1447                     "nested-list": [
1448                         {
1449                             "identifier": "f3"
1450                         },
1451                         {
1452                             "identifier": "f2"
1453                         },
1454                         {
1455                             "identifier": "f1"
1456                         }
1457                     ]
1458                 },
1459                 {
1460                     "key-1": "kb",
1461                     "key-2": "ka",
1462                     "nested-list": [
1463                         {
1464                             "identifier": "e3"
1465                         },
1466                         {
1467                             "identifier": "e2"
1468                         },
1469                         {
1470                             "identifier": "e1"
1471                         }
1472                     ]
1473                 },
1474                 {
1475                     "key-1": "kc",
1476                     "key-2": "ke",
1477                     "nested-list": [
1478                         {
1479                             "identifier": "q3"
1480                         },
1481                         {
1482                             "identifier": "q2"
1483                         },
1484                         {
1485                             "identifier": "q1"
1486                         }
1487                     ]
1488                 }
1489             ]
1490         }
1491     }
1492
1493 3. Reading value of leaf 'branch-ab' and all values of leaves 'switch-1' that are placed
1494    under 'top-list' list elements.
1495
1496 RESTCONF request:
1497
1498 .. code-block:: bash
1499
1500     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' \
1501     --header 'Authorization: Basic YWRtaW46YWRtaW4=' \
1502     --header 'Cookie: JSESSIONID=node01jx6o5thwae9t1ft7c2zau5zbz4.node0'
1503
1504 Generated NETCONF RPC request:
1505
1506 .. code-block:: xml
1507
1508     <rpc message-id="m-42" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
1509         <get-config>
1510             <source>
1511                 <running/>
1512             </source>
1513             <filter xmlns:ns0="urn:ietf:params:xml:ns:netconf:base:1.0" ns0:type="subtree">
1514                 <root xmlns="urn:ietf:params:xml:ns:yang:test-model">
1515                     <list-root>
1516                         <branch-ab/>
1517                         <top-list>
1518                             <next-data>
1519                                 <switch-1/>
1520                             </next-data>
1521                             <key-1/>
1522                             <key-2/>
1523                         </top-list>
1524                     </list-root>
1525                 </root>
1526             </filter>
1527         </get-config>
1528     </rpc>
1529
1530 RESTCONF response:
1531
1532 .. code-block:: json
1533
1534     {
1535         "test-module:list-root": {
1536             "branch-ab": 5,
1537             "top-list": [
1538                 {
1539                     "key-1": "ka",
1540                     "key-2": "kb",
1541                     "next-data": {
1542                         "switch-1": [
1543                             null
1544                         ]
1545                     }
1546                 },
1547                 {
1548                     "key-1": "kb",
1549                     "key-2": "ka",
1550                     "next-data": {
1551                         "switch-1": [
1552                             null
1553                         ]
1554                     }
1555                 },
1556                 {
1557                     "key-1": "kc",
1558                     "key-2": "ke"
1559                 }
1560             ]
1561         }
1562     }