Update NETCONF user documentation
[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 .. important::
805
806     The call home feature is experimental and will change in a future
807     release. In particular, the Yang models will change to those specified
808     in the `RFC 8071 <https://tools.ietf.org/html/rfc8071>`__
809
810 Call Home Installation
811 ~~~~~~~~~~~~~~~~~~~~~~
812
813 ODL Call-Home server is installed in Karaf by installing karaf feature
814 ``odl-netconf-callhome-ssh``. RESTCONF feature is recommended for
815 configuring Call Home & testing its functionality.
816
817 ::
818
819   feature:install odl-netconf-callhome-ssh
820
821
822 .. note::
823
824     In order to test Call Home functionality we recommend Netopeer.
825     See `Netopeer Call Home <https://github.com/CESNET/netopeer/wiki/CallHome>`__ to learn how to enable call-home on Netopeer.
826
827 Northbound Call-Home API
828 ~~~~~~~~~~~~~~~~~~~~~~~~
829
830 The northbound Call Home API is used for administering the Call-Home Server. The
831 following describes this configuration.
832
833 Global Configuration
834 ^^^^^^^^^^^^^^^^^^^^
835
836 Configuring global credentials
837 ''''''''''''''''''''''''''''''
838
839 ODL Call-Home server allows user to configure global credentials, which
840 will be used for devices which does not have device-specific credentials
841 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:: none
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:: none
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 Allowing Device & Configuring Name
905 ''''''''''''''''''''''''''''''''''
906
907 Netconf Call Home Server uses device provided SSH server key (host key)
908 to identify device. The pairing of name and server key is configured in
909 ``/odl-netconf-callhome-server:netconf-callhome-server/allowed-devices``.
910 This list is colloquially called a whitelist.
911
912 If the Call-Home Server finds the SSH host key in the whitelist, it continues
913 to negotiate a NETCONF connection over an SSH session. If the SSH host key is
914 not found, the connection between the Call Home server and the device is dropped
915 immediately. In either case, the device that connects to the Call home server
916 leaves a record of its presence in the operational store.
917
918 *Example of configuring device*
919
920 .. code-block:: none
921
922     PUT
923     /restconf/config/odl-netconf-callhome-server:netconf-callhome-server/allowed-devices/device/example HTTP/1.1
924     Content-Type: application/json
925     Accept: application/json
926
927 .. code-block:: json
928
929     {
930       "device": {
931         "unique-id": "example",
932         "ssh-host-key": "AAAAB3NzaC1yc2EAAAADAQABAAABAQDHoH1jMjltOJnCt999uaSfc48ySutaD3ISJ9fSECe1Spdq9o9mxj0kBTTTq+2V8hPspuW75DNgN+V/rgJeoUewWwCAasRx9X4eTcRrJrwOQKzb5Fk+UKgQmenZ5uhLAefi2qXX/agFCtZi99vw+jHXZStfHm9TZCAf2zi+HIBzoVksSNJD0VvPo66EAvLn5qKWQD4AdpQQbKqXRf5/W8diPySbYdvOP2/7HFhDukW8yV/7ZtcywFUIu3gdXsrzwMnTqnATSLPPuckoi0V2jd8dQvEcu1DY+rRqmqu0tEkFBurlRZDf1yhNzq5xWY3OXcjgDGN+RxwuWQK3cRimcosH"
933       }
934     }
935
936 Configuring Device with Device-specific Credentials
937 '''''''''''''''''''''''''''''''''''''''''''''''''''
938
939 Call Home Server also allows to configure credentials per device basis,
940 this is done by introducing ``credentials`` container into
941 device-specific configuration. Format is same as in global credentials.
942
943 *Configuring Device with Credentials*
944
945 .. code-block:: none
946
947     PUT
948     /restconf/config/odl-netconf-callhome-server:netconf-callhome-server/allowed-devices/device/example HTTP/1.1
949     Content-Type: application/json
950     Accept: application/json
951
952 .. code-block:: json
953
954     {
955       "device": {
956         "unique-id": "example",
957         "credentials": {
958           "username": "example",
959           "passwords": [ "password" ]
960         },
961         "ssh-host-key": "AAAAB3NzaC1yc2EAAAADAQABAAABAQDHoH1jMjltOJnCt999uaSfc48ySutaD3ISJ9fSECe1Spdq9o9mxj0kBTTTq+2V8hPspuW75DNgN+V/rgJeoUewWwCAasRx9X4eTcRrJrwOQKzb5Fk+UKgQmenZ5uhLAefi2qXX/agFCtZi99vw+jHXZStfHm9TZCAf2zi+HIBzoVksSNJD0VvPo66EAvLn5qKWQD4AdpQQbKqXRf5/W8diPySbYdvOP2/7HFhDukW8yV/7ZtcywFUIu3gdXsrzwMnTqnATSLPPuckoi0V2jd8dQvEcu1DY+rRqmqu0tEkFBurlRZDf1yhNzq5xWY3OXcjgDGN+RxwuWQK3cRimcosH"
962       }
963     }
964
965 Operational Status
966 ^^^^^^^^^^^^^^^^^^
967
968 Once an entry is made into the config side of "allowed-devices", the Call-Home Server will
969 populate an corresponding operational device that is the same as the config device but
970 has an additional status. By default, this status is *DISCONNECTED*. Once a device calls
971 home, this status will change to one of:
972
973 *CONNECTED* — The device is currently connected and the NETCONF mount is available for network
974 management.
975
976 *FAILED_AUTH_FAILURE* — The last attempted connection was unsuccessful because the Call-Home
977 Server was unable to provide the acceptable credentials of the device. The device is also
978 disconnected and not available for network management.
979
980 *FAILED_NOT_ALLOWED* — The last attempted connection was unsuccessful because the device was
981 not recognized as an acceptable device. The device is also disconnected and not available for
982 network management.
983
984 *FAILED* — The last attempted connection was unsuccessful for a reason other than not
985 allowed to connect or incorrect client credentials. The device is also disconnected and not
986 available for network management.
987
988 *DISCONNECTED* — The device is currently disconnected.
989
990 Rogue Devices
991 '''''''''''''
992
993 Devices which are not on the whitelist might try to connect to the Call-Home Server. In
994 these cases, the server will keep a record by instantiating an operational device. There
995 will be no corresponding config device for these rogues. They can be identified readily
996 because their device id, rather than being user-supplied, will be of the form
997 "address:port". Note that if a device calls back multiple times, there will only be
998 a single operatinal entry (even if the port changes); these devices are recognized by
999 their unique host key.
1000
1001 Southbound Call-Home API
1002 ~~~~~~~~~~~~~~~~~~~~~~~~
1003
1004 The Call-Home Server listens for incoming TCP connections and assumes that the other side of
1005 the connection is a device calling home via a NETCONF connection with SSH for
1006 management. The server uses port 6666 by default and this can be configured via a
1007 blueprint configuration file.
1008
1009 The device **must** initiate the connection and the server will not try to re-establish the
1010 connection in case of a drop. By requirement, the server cannot assume it has connectivity
1011 to the device due to NAT or firewalls among others.