Master branch is now Aluminium
[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 There are 2 ways for configuring netconf-connector: NETCONF or RESTCONF.
60 This guide focuses on using RESTCONF.
61
62 .. important::
63
64     There are 2 different endpoints related to RESTCONF protocols:
65
66     - | ``http://localhost:8181/restconf`` is related to `draft-bierman-netconf-restconf-02 <https://tools.ietf.org/html/draft-bierman-netconf-restconf-02>`__,
67       | can be activated by installing ``odl-restconf-nb-bierman02``
68        Karaf feature.
69       | This user guide uses this approach.
70
71     - | ``http://localhost:8181/rests`` is related to `RFC-8040 <https://tools.ietf.org/html/rfc8040>`__,
72       | can be activated by installing ``odl-restconf-nb-rfc8040``
73        Karaf feature.
74
75     | In case of `RFC-8040 <https://tools.ietf.org/html/rfc8040>`__
76      resources for configuration and operational datastores start
77      ``/rests/data/``,
78     | e. g. GET
79      http://localhost:8181/rests/data/network-topology:network-topology
80      with response of both datastores. It's allowed to use query
81      parameters to distinguish between them.
82     | e. g. GET
83      http://localhost:8181/rests/data/network-topology:network-topology?content=config
84      for configuration datastore
85     | and GET
86      http://localhost:8181/rests/data/network-topology:network-topology?content=nonconfig
87      for operational datastore.
88
89     | Also in case of `RFC-8040 <https://tools.ietf.org/html/rfc8040>`__,
90      if a data node in the path expression is a YANG leaf-list or list
91      node, the path segment has to be constructed by having leaf-list or
92      list node name, followed by an "=" character, then followed by the
93      leaf-list or list value. Any reserved characters must be
94      percent-encoded.
95     | e. g. GET
96      http://localhost:8181/rests/data/network-topology:network-topology/topology=topology-netconf?content=config
97      for retrieving data from configuration datastore for
98      topology-netconf value of topology list is equivalent to the deprecated request
99     | |ss| GET |se|
100      http://localhost:8181/restconf/config/network-topology:network-topology/topology/topology-netconf,
101      which is related to `draft-bierman-netconf-restconf-02
102      <https://tools.ietf.org/html/draft-bierman-netconf-restconf-02>`__.
103
104     Examples in the `Spawning new NETCONF connectors`_ section include both bierman02 and rfc8040
105     formats
106
107
108 Default configuration
109 ^^^^^^^^^^^^^^^^^^^^^
110
111 The default configuration contains all the necessary dependencies (file:
112 01-netconf.xml) and a single instance of netconf-connector (file:
113 99-netconf-connector.xml) called **controller-config** which connects
114 itself to the NETCONF northbound in OpenDaylight in a loopback fashion.
115 The connector mounts the NETCONF server for config-subsystem in order to
116 enable RESTCONF protocol for config-subsystem. This RESTCONF still goes
117 via NETCONF, but using RESTCONF is much more user friendly than using
118 NETCONF.
119
120 Spawning additional netconf-connectors while the controller is running
121 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
122
123 Preconditions:
124
125 1. OpenDaylight is running
126
127 2. In Karaf, you must have the netconf-connector installed (at the Karaf
128    prompt, type: ``feature:install odl-netconf-connector-all``); the
129    loopback NETCONF mountpoint will be automatically configured and
130    activated
131
132 3. Wait until log displays following entry:
133    RemoteDevice{controller-config}: NETCONF connector initialized
134    successfully
135
136 To configure a new netconf-connector you need to send following request
137 to RESTCONF:
138
139 POST
140 http://localhost:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/controller-config/yang-ext:mount/config:modules
141
142 Headers:
143
144 -  Accept application/xml
145
146 -  Content-Type application/xml
147
148 ::
149
150     <module xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
151       <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">prefix:sal-netconf-connector</type>
152       <name>new-netconf-device</name>
153       <address xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">127.0.0.1</address>
154       <port xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">830</port>
155       <username xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">admin</username>
156       <password xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">admin</password>
157       <tcp-only xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">false</tcp-only>
158       <event-executor xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">
159         <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty">prefix:netty-event-executor</type>
160         <name>global-event-executor</name>
161       </event-executor>
162       <binding-registry xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">
163         <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">prefix:binding-broker-osgi-registry</type>
164         <name>binding-osgi-broker</name>
165       </binding-registry>
166       <dom-registry xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">
167         <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">prefix:dom-broker-osgi-registry</type>
168         <name>dom-broker</name>
169       </dom-registry>
170       <client-dispatcher xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">
171         <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:netconf">prefix:netconf-client-dispatcher</type>
172         <name>global-netconf-dispatcher</name>
173       </client-dispatcher>
174       <processing-executor xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">
175         <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:threadpool">prefix:threadpool</type>
176         <name>global-netconf-processing-executor</name>
177       </processing-executor>
178       <keepalive-executor xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">
179         <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:threadpool">prefix:scheduled-threadpool</type>
180         <name>global-netconf-ssh-scheduled-executor</name>
181       </keepalive-executor>
182     </module>
183
184 This spawns a new netconf-connector which tries to connect to (or mount)
185 a NETCONF device at 127.0.0.1 and port 830. You can check the
186 configuration of config-subsystem’s configuration datastore. The new
187 netconf-connector will now be present there. Just invoke:
188
189 GET
190 http://localhost:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/controller-config/yang-ext:mount/config:modules
191
192 The response will contain the module for new-netconf-device.
193
194 Right after the new netconf-connector is created, it writes some useful
195 metadata into the datastore of MD-SAL under the network-topology
196 subtree. This metadata can be found at:
197
198 GET
199 http://localhost:8181/restconf/operational/network-topology:network-topology/
200
201 Information about connection status, device capabilities, etc. can be
202 found there.
203
204 Connecting to a device not supporting NETCONF monitoring
205 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
206
207 The netconf-connector in OpenDaylight relies on ietf-netconf-monitoring
208 support when connecting to remote NETCONF device. The
209 ietf-netconf-monitoring support allows netconf-connector to list and
210 download all YANG schemas that are used by the device. NETCONF connector
211 can only communicate with a device if it knows the set of used schemas
212 (or at least a subset). However, some devices use YANG models internally
213 but do not support NETCONF monitoring. Netconf-connector can also
214 communicate with these devices, but you have to side load the necessary
215 yang models into OpenDaylight’s YANG model cache for netconf-connector.
216 In general there are 2 situations you might encounter:
217
218 **1. NETCONF device does not support ietf-netconf-monitoring but it does
219 list all its YANG models as capabilities in HELLO message**
220
221 This could be a device that internally uses only ietf-inet-types YANG
222 model with revision 2010-09-24. In the HELLO message that is sent from
223 this device there is this capability reported:
224
225 ::
226
227     urn:ietf:params:xml:ns:yang:ietf-inet-types?module=ietf-inet-types&revision=2010-09-24
228
229 **For such devices you only need to put the schema into folder
230 cache/schema inside your Karaf distribution.**
231
232 .. important::
233
234     The file with YANG schema for ietf-inet-types has to be called
235     ietf-inet-types@2010-09-24.yang. It is the required naming format of
236     the cache.
237
238 **2. NETCONF device does not support ietf-netconf-monitoring and it does
239 NOT list its YANG models as capabilities in HELLO message**
240
241 Compared to device that lists its YANG models in HELLO message, in this
242 case there would be no capability with ietf-inet-types in the HELLO
243 message. This type of device basically provides no information about the
244 YANG schemas it uses so its up to the user of OpenDaylight to properly
245 configure netconf-connector for this device.
246
247 Netconf-connector has an optional configuration attribute called
248 yang-module-capabilities and this attribute can contain a list of "YANG
249 module based" capabilities. So by setting this configuration attribute,
250 it is possible to override the "yang-module-based" capabilities reported
251 in HELLO message of the device. To do this, we need to modify the
252 configuration of netconf-connector by adding this XML (It needs to be
253 added next to the address, port, username etc. configuration elements):
254
255 ::
256
257     <yang-module-capabilities xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">
258       <capability xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">
259         urn:ietf:params:xml:ns:yang:ietf-inet-types?module=ietf-inet-types&amp;revision=2010-09-24
260       </capability>
261     </yang-module-capabilities>
262
263 **Remember to also put the YANG schemas into the cache folder.**
264
265 .. note::
266
267     For putting multiple capabilities, you just need to replicate the
268     capability xml element inside yang-module-capability element.
269     Capability element is modeled as a leaf-list. With this
270     configuration, we would make the remote device report usage of
271     ietf-inet-types in the eyes of netconf-connector.
272
273 Reconfiguring Netconf-Connector While the Controller is Running
274 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
275
276 It is possible to change the configuration of a running module while the
277 whole controller is running. This example will continue where the last
278 left off and will change the configuration for the brand new
279 netconf-connector after it was spawned. Using one RESTCONF request, we
280 will change both username and password for the netconf-connector.
281
282 To update an existing netconf-connector you need to send following
283 request to RESTCONF:
284
285 PUT
286 http://localhost:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/controller-config/yang-ext:mount/config:modules/module/odl-sal-netconf-connector-cfg:sal-netconf-connector/new-netconf-device
287
288 ::
289
290     <module xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
291       <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">prefix:sal-netconf-connector</type>
292       <name>new-netconf-device</name>
293       <username xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">bob</username>
294       <password xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">passwd</password>
295       <tcp-only xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">false</tcp-only>
296       <event-executor xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">
297         <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty">prefix:netty-event-executor</type>
298         <name>global-event-executor</name>
299       </event-executor>
300       <binding-registry xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">
301         <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">prefix:binding-broker-osgi-registry</type>
302         <name>binding-osgi-broker</name>
303       </binding-registry>
304       <dom-registry xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">
305         <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">prefix:dom-broker-osgi-registry</type>
306         <name>dom-broker</name>
307       </dom-registry>
308       <client-dispatcher xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">
309         <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:netconf">prefix:netconf-client-dispatcher</type>
310         <name>global-netconf-dispatcher</name>
311       </client-dispatcher>
312       <processing-executor xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">
313         <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:threadpool">prefix:threadpool</type>
314         <name>global-netconf-processing-executor</name>
315       </processing-executor>
316       <keepalive-executor xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">
317         <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:threadpool">prefix:scheduled-threadpool</type>
318         <name>global-netconf-ssh-scheduled-executor</name>
319       </keepalive-executor>
320     </module>
321
322 Since a PUT is a replace operation, the whole configuration must be
323 specified along with the new values for username and password. This
324 should result in a 2xx response and the instance of netconf-connector
325 called new-netconf-device will be reconfigured to use username bob and
326 password passwd. New configuration can be verified by executing:
327
328 GET
329 http://localhost:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/controller-config/yang-ext:mount/config:modules/module/odl-sal-netconf-connector-cfg:sal-netconf-connector/new-netconf-device
330
331 With new configuration, the old connection will be closed and a new one
332 established.
333
334 Destroying Netconf-Connector While the Controller is Running
335 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
336
337 Using RESTCONF one can also destroy an instance of a module. In case of
338 netconf-connector, the module will be destroyed, NETCONF connection
339 dropped and all resources will be cleaned. To do this, simply issue a
340 request to following URL:
341
342 DELETE
343 http://localhost:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/controller-config/yang-ext:mount/config:modules/module/odl-sal-netconf-connector-cfg:sal-netconf-connector/new-netconf-device
344
345 The last element of the URL is the name of the instance and its
346 predecessor is the type of that module (In our case the type is
347 **sal-netconf-connector** and name **new-netconf-device**). The type and
348 name are actually the keys of the module list.
349
350 Netconf-connector configuration with MD-SAL
351 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
352
353 It is also possible to configure new NETCONF connectors directly through
354 MD-SAL with the usage of the network-topology model. You can configure
355 new NETCONF connectors both through the NETCONF server for MD-SAL (port
356 2830) or RESTCONF. This guide focuses on RESTCONF.
357
358 .. tip::
359
360     To enable NETCONF connector configuration through MD-SAL install
361     either the ``odl-netconf-topology`` or
362     ``odl-netconf-clustered-topology`` feature. We will explain the
363     difference between these features later.
364
365 Preconditions
366 ^^^^^^^^^^^^^
367
368 1. OpenDaylight is running
369
370 2. In Karaf, you must have the ``odl-netconf-topology`` or
371    ``odl-netconf-clustered-topology`` feature installed.
372
373 3. Feature ``odl-restconf`` must be installed
374
375 4. Wait until log displays following entry:
376
377    ::
378
379        Successfully pushed configuration snapshot 02-netconf-topology.xml(odl-netconf-topology,odl-netconf-topology)
380
381    or until
382
383    ::
384
385        GET http://localhost:8181/restconf/operational/network-topology:network-topology/topology/topology-netconf/
386
387    returns a non-empty response, for example:
388
389    ::
390
391        <topology xmlns="urn:TBD:params:xml:ns:yang:network-topology">
392          <topology-id>topology-netconf</topology-id>
393        </topology>
394
395 Spawning new NETCONF connectors
396 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
397
398 To create a new NETCONF connector you need to send the following PUT request
399 to RESTCONF:
400
401 .. list-table::
402    :widths: 1 5
403
404    * - bierman02
405      - http://localhost:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/new-netconf-device
406    * - rfc8040
407      - http://localhost:8181/rests/data/network-topology:network-topology/topology=topology-netconf/node=new-netconf-device
408
409 You could use the same body to create the new  NETCONF connector with a POST
410 without specifying the node in the URL:
411
412 .. list-table::
413    :widths: 1 5
414
415    * - bierman02
416      - http://localhost:8181/restconf/config/network-topology:network-topology/topology/topology-netconf
417    * - rfc8040
418      - http://localhost:8181/rests/data/network-topology:network-topology/topology=topology-netconf
419
420 Headers:
421
422 -  Accept: application/xml
423
424 -  Content-Type: application/xml
425
426 Payload:
427
428 ::
429
430     <node xmlns="urn:TBD:params:xml:ns:yang:network-topology">
431       <node-id>new-netconf-device</node-id>
432       <host xmlns="urn:opendaylight:netconf-node-topology">127.0.0.1</host>
433       <port xmlns="urn:opendaylight:netconf-node-topology">17830</port>
434       <username xmlns="urn:opendaylight:netconf-node-topology">admin</username>
435       <password xmlns="urn:opendaylight:netconf-node-topology">admin</password>
436       <tcp-only xmlns="urn:opendaylight:netconf-node-topology">false</tcp-only>
437       <!-- non-mandatory fields with default values, you can safely remove these if you do not wish to override any of these values-->
438       <reconnect-on-changed-schema xmlns="urn:opendaylight:netconf-node-topology">false</reconnect-on-changed-schema>
439       <connection-timeout-millis xmlns="urn:opendaylight:netconf-node-topology">20000</connection-timeout-millis>
440       <max-connection-attempts xmlns="urn:opendaylight:netconf-node-topology">0</max-connection-attempts>
441       <between-attempts-timeout-millis xmlns="urn:opendaylight:netconf-node-topology">2000</between-attempts-timeout-millis>
442       <sleep-factor xmlns="urn:opendaylight:netconf-node-topology">1.5</sleep-factor>
443       <!-- keepalive-delay set to 0 turns off keepalives-->
444       <keepalive-delay xmlns="urn:opendaylight:netconf-node-topology">120</keepalive-delay>
445     </node>
446
447 Note that the device name in <node-id> element must match the last
448 element of the restconf URL.
449
450 Reconfiguring an existing connector
451 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
452
453 The steps to reconfigure an existing connector are exactly the same as
454 when spawning a new connector. The old connection will be disconnected
455 and a new connector with the new configuration will be created. This needs
456 to be done with a PUT request because the node already exists. A POST
457 request will fail for that reason.
458
459 Additionally, a PATCH request can be used to modify an existing
460 configuration. Currently, only yang-patch (`RFC-8072 <https://tools.ietf.org/html/rfc8072>`__)
461 is supported. The URL would be the same as the above PUT examples.
462 Using JSON for the body, the headers needed for the request would
463 be:
464
465 Headers:
466
467 -  Accept: application/yang.patch-status+json
468
469 -  Content-Type: application/yang.patch+json
470
471 Example JSON payload to modify the password entry:
472
473 ::
474
475     {
476       "ietf-restconf:yang-patch" : {
477         "patch-id" : "0",
478         "edit" : [
479           {
480             "edit-id" : "edit1",
481             "operation" : "merge",
482             "target" : "",
483             "value" : {
484              "node": [
485                 {
486                  "node-id": "new-netconf-device",
487                  "netconf-node-topology:password" : "newpassword"
488                 }
489              ]
490             }
491          }
492         ]
493       }
494     }
495
496
497 Deleting an existing connector
498 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
499
500 To remove an already configured NETCONF connector you need to send a
501 DELETE request to the same PUT request URL that was used to create the
502 device:
503
504 .. list-table::
505    :widths: 1 5
506
507    * - bierman02
508      - http://localhost:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/new-netconf-device
509    * - rfc8040
510      - http://localhost:8181/rests/data/network-topology:network-topology/topology=topology-netconf/node=new-netconf-device
511
512 .. note::
513
514     No body is needed to delete the node/device
515
516 Connecting to a device supporting only NETCONF 1.0
517 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
518
519 OpenDaylight is schema-based distribution and heavily depends on YANG
520 models. However some legacy NETCONF devices are not schema-based and
521 implement just RFC 4741. This type of device does not utilize YANG
522 models internally and OpenDaylight does not know how to communicate
523 with such devices, how to validate data, or what the semantics of data
524 are.
525
526 NETCONF connector can communicate also with these devices, but the
527 trade-offs are worsened possibilities in utilization of NETCONF
528 mountpoints. Using RESTCONF with such devices is not suported. Also
529 communicating with schemaless devices from application code is slightly
530 different.
531
532 To connect to schemaless device, there is a optional configuration option
533 in netconf-node-topology model called schemaless. You have to set this
534 option to true.
535
536 Clustered NETCONF connector
537 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
538
539 To spawn NETCONF connectors that are cluster-aware you need to install
540 the ``odl-netconf-clustered-topology`` karaf feature.
541
542 .. warning::
543
544     The ``odl-netconf-topology`` and ``odl-netconf-clustered-topology``
545     features are considered **INCOMPATIBLE**. They both manage the same
546     space in the datastore and would issue conflicting writes if
547     installed together.
548
549 Configuration of clustered NETCONF connectors works the same as the
550 configuration through the topology model in the previous section.
551
552 When a new clustered connector is configured the configuration gets
553 distributed among the member nodes and a NETCONF connector is spawned on
554 each node. From these nodes a master is chosen which handles the schema
555 download from the device and all the communication with the device. You
556 will be able to read/write to/from the device from all slave nodes due
557 to the proxy data brokers implemented.
558
559 You can use the ``odl-netconf-clustered-topology`` feature in a single
560 node scenario as well but the code that uses akka will be used, so for a
561 scenario where only a single node is used, ``odl-netconf-topology``
562 might be preferred.
563
564 Netconf-connector utilization
565 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
566
567 Once the connector is up and running, users can utilize the new mount
568 point instance. By using RESTCONF or from their application code. This
569 chapter deals with using RESTCONF and more information for app
570 developers can be found in the developers guide or in the official
571 tutorial application **ncmount** that can be found in the coretutorials
572 project:
573
574 -  https://github.com/opendaylight/coretutorials/tree/master/ncmount
575
576 Reading data from the device
577 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
578
579 Just invoke (no body needed):
580
581 GET
582 http://localhost:8080/restconf/operational/network-topology:network-topology/topology/topology-netconf/node/new-netconf-device/yang-ext:mount/
583
584 This will return the entire content of operation datastore from the
585 device. To view just the configuration datastore, change **operational**
586 in this URL to **config**.
587
588 Writing configuration data to the device
589 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
590
591 In general, you cannot simply write any data you want to the device. The
592 data have to conform to the YANG models implemented by the device. In
593 this example we are adding a new interface-configuration to the mounted
594 device (assuming the device supports Cisco-IOS-XR-ifmgr-cfg YANG model).
595 In fact this request comes from the tutorial dedicated to the
596 **ncmount** tutorial app.
597
598 POST
599 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
600
601 ::
602
603     <interface-configuration xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg">
604         <active>act</active>
605         <interface-name>mpls</interface-name>
606         <description>Interface description</description>
607         <bandwidth>32</bandwidth>
608         <link-status></link-status>
609     </interface-configuration>
610
611 Should return 200 response code with no body.
612
613 .. tip::
614
615     This call is transformed into a couple of NETCONF RPCs. Resulting
616     NETCONF RPCs that go directly to the device can be found in the
617     OpenDaylight logs after invoking ``log:set TRACE
618     org.opendaylight.controller.sal.connect.netconf`` in the Karaf
619     shell. Seeing the NETCONF RPCs might help with debugging.
620
621 This request is very similar to the one where we spawned a new netconf
622 device. That’s because we used the loopback netconf-connector to write
623 configuration data into config-subsystem datastore and config-subsystem
624 picked it up from there.
625
626 Invoking custom RPC
627 ^^^^^^^^^^^^^^^^^^^
628
629 Devices can implement any additional RPC and as long as it provides YANG
630 models for it, it can be invoked from OpenDaylight. Following example
631 shows how to invoke the get-schema RPC (get-schema is quite common among
632 netconf devices). Invoke:
633
634 POST
635 http://localhost:8181/restconf/operations/network-topology:network-topology/topology/topology-netconf/node/new-netconf-device/yang-ext:mount/ietf-netconf-monitoring:get-schema
636
637 ::
638
639     <input xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring">
640       <identifier>ietf-yang-types</identifier>
641       <version>2013-07-15</version>
642     </input>
643
644 This call should fetch the source for ietf-yang-types YANG model from
645 the mounted device.
646
647 Netconf-connector + Netopeer
648 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
649
650 `Netopeer <https://github.com/cesnet/netopeer>`__ (an open-source
651 NETCONF server) can be used for testing/exploring NETCONF southbound in
652 OpenDaylight.
653
654 Netopeer installation
655 ^^^^^^^^^^^^^^^^^^^^^
656
657 A `Docker <https://www.docker.com/>`__ container with netopeer will be
658 used in this guide. To install Docker and start the `netopeer
659 image <https://index.docker.io/u/dockeruser/netopeer/>`__ perform
660 following steps:
661
662 1. Install docker http://docs.docker.com/linux/step_one/
663
664 2. Start the netopeer image:
665
666    ::
667
668        docker run --rm -t -p 1831:830 dockeruser/netopeer
669
670 3. Verify netopeer is running by invoking (netopeer should send its
671    HELLO message right away:
672
673    ::
674
675        ssh root@localhost -p 1831 -s netconf
676        (password root)
677
678 Mounting netopeer NETCONF server
679 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
680
681 Preconditions:
682
683 -  OpenDaylight is started with features ``odl-restconf-all`` and
684    ``odl-netconf-connector-all``.
685
686 -  Netopeer is up and running in docker
687
688 Now just follow the section: `Spawning new NETCONF connectors`_.
689 In the payload change the:
690
691 -  name, e.g., to netopeer
692
693 -  username/password to your system credentials
694
695 -  ip to localhost
696
697 -  port to 1831.
698
699 After netopeer is mounted successfully, its configuration can be read
700 using RESTCONF by invoking:
701
702 GET
703 http://localhost:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/netopeer/yang-ext:mount/
704
705 Northbound (NETCONF servers)
706 ----------------------------
707
708 OpenDaylight provides 2 types of NETCONF servers:
709
710 -  **NETCONF server for config-subsystem (listening by default on port
711    1830)**
712
713    -  Serves as a default interface for config-subsystem and allows
714       users to spawn/reconfigure/destroy modules (or applications) in
715       OpenDaylight
716
717 -  **NETCONF server for MD-SAL (listening by default on port 2830)**
718
719    -  Serves as an alternative interface for MD-SAL (besides RESTCONF)
720       and allows users to read/write data from MD-SAL’s datastore and to
721       invoke its rpcs (NETCONF notifications are not available in the
722       Boron release of OpenDaylight)
723
724 .. note::
725
726     The reason for having 2 NETCONF servers is that config-subsystem and
727     MD-SAL are 2 different components of OpenDaylight and require
728     different approach for NETCONF message handling and data
729     translation. These 2 components will probably merge in the future.
730
731 .. note::
732
733     Since Nitrogen release, there is performance regression in NETCONF
734     servers accepting SSH connections. While opening a connection takes
735     less than 10 seconds on Carbon, on Nitrogen time can increase up to
736     60 seconds. Please see https://bugs.opendaylight.org/show_bug.cgi?id=9020
737
738 NETCONF server for config-subsystem
739 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
740
741 This NETCONF server is the primary interface for config-subsystem. It
742 allows the users to interact with config-subsystem in a standardized
743 NETCONF manner.
744
745 In terms of RFCs, these are supported:
746
747 -  `RFC-6241 <http://tools.ietf.org/html/rfc6241>`__
748
749 -  `RFC-5277 <https://tools.ietf.org/html/rfc5277>`__
750
751 -  `RFC-6470 <https://tools.ietf.org/html/rfc6470>`__
752
753    -  (partially, only the schema-change notification is available in
754       Boron release)
755
756 -  `RFC-6022 <https://tools.ietf.org/html/rfc6022>`__
757
758 For regular users it is recommended to use RESTCONF + the
759 controller-config loopback mountpoint instead of using pure NETCONF. How
760 to do that is spesific for each component/module/application in
761 OpenDaylight and can be found in their dedicated user guides.
762
763 NETCONF server for MD-SAL
764 ~~~~~~~~~~~~~~~~~~~~~~~~~
765
766 This NETCONF server is just a generic interface to MD-SAL in
767 OpenDaylight. It uses the stadard MD-SAL APIs and serves as an
768 alternative to RESTCONF. It is fully model driven and supports any data
769 and rpcs that are supported by MD-SAL.
770
771 In terms of RFCs, these are supported:
772
773 -  `RFC-6241 <http://tools.ietf.org/html/rfc6241>`__
774
775 -  `RFC-6022 <https://tools.ietf.org/html/rfc6022>`__
776
777 -  `draft-ietf-netconf-yang-library-06 <https://tools.ietf.org/html/draft-ietf-netconf-yang-library-06>`__
778
779 Notifications over NETCONF are not supported in the Boron release.
780
781 .. tip::
782
783     Install NETCONF northbound for MD-SAL by installing feature:
784     ``odl-netconf-mdsal`` in karaf. Default binding port is **2830**.
785
786 Configuration
787 ^^^^^^^^^^^^^
788
789 The default configuration can be found in file: *08-netconf-mdsal.xml*.
790 The file contains the configuration for all necessary dependencies and a
791 single SSH endpoint starting on port 2830. There is also a (by default
792 disabled) TCP endpoint. It is possible to start multiple endpoints at
793 the same time either in the initial configuration file or while
794 OpenDaylight is running.
795
796 The credentials for SSH endpoint can also be configured here, the
797 defaults are admin/admin. Credentials in the SSH endpoint are not yet
798 managed by the centralized AAA component and have to be configured
799 separately.
800
801 Verifying MD-SAL’s NETCONF server
802 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
803
804 After the NETCONF server is available it can be examined by a command
805 line ssh tool:
806
807 ::
808
809     ssh admin@localhost -p 2830 -s netconf
810
811 The server will respond by sending its HELLO message and can be used as
812 a regular NETCONF server from then on.
813
814 Mounting the MD-SAL’s NETCONF server
815 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
816
817 To perform this operation, just spawn a new netconf-connector as
818 described in `Spawning new NETCONF connectors`_. Just change the ip to
819 "127.0.0.1" port to "2830" and its name to "controller-mdsal".
820
821 Now the MD-SAL’s datastore can be read over RESTCONF via NETCONF by
822 invoking:
823
824 GET
825 http://localhost:8181/restconf/operational/network-topology:network-topology/topology/topology-netconf/node/controller-mdsal/yang-ext:mount
826
827 .. note::
828
829     This might not seem very useful, since MD-SAL can be accessed
830     directly from RESTCONF or from Application code, but the same method
831     can be used to mount and control other OpenDaylight instances by the
832     "master OpenDaylight".
833
834 NETCONF stress/performance measuring tool
835 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
836
837 This is basically a NETCONF client that puts NETCONF servers under heavy
838 load of NETCONF RPCs and measures the time until a configurable amount
839 of them is processed.
840
841 RESTCONF stress-performance measuring tool
842 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
843
844 Very similar to NETCONF stress tool with the difference of using
845 RESTCONF protocol instead of NETCONF.
846
847 YANGLIB remote repository
848 -------------------------
849
850 There are scenarios in NETCONF deployment, that require for a centralized
851 YANG models repository. YANGLIB plugin provides such remote repository.
852
853 To start this plugin, you have to install odl-yanglib feature. Then you
854 have to configure YANGLIB either through RESTCONF or NETCONF. We will
855 show how to configure YANGLIB through RESTCONF.
856
857 YANGLIB configuration through RESTCONF
858 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
859
860 You have to specify what local YANG modules directory you want to provide.
861 Then you have to specify address and port whre you want to provide YANG
862 sources. For example, we want to serve yang sources from folder /sources
863 on localhost:5000 adress. The configuration for this scenario will be
864 as follows:
865
866 ::
867
868     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
869
870 Headers:
871
872 -  Accept: application/xml
873
874 -  Content-Type: application/xml
875
876 Payload:
877
878 ::
879
880    <module xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
881      <name>example</name>
882      <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:yanglib:impl">prefix:yanglib</type>
883      <broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:yanglib:impl">
884        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">prefix:binding-broker-osgi-registry</type>
885        <name>binding-osgi-broker</name>
886      </broker>
887      <cache-folder xmlns="urn:opendaylight:params:xml:ns:yang:controller:yanglib:impl">/sources</cache-folder>
888      <binding-addr xmlns="urn:opendaylight:params:xml:ns:yang:controller:yanglib:impl">localhost</binding-addr>
889      <binding-port xmlns="urn:opendaylight:params:xml:ns:yang:controller:yanglib:impl">5000</binding-port>
890    </module>
891
892 This should result in a 2xx response and new YANGLIB instance should be
893 created. This YANGLIB takes all YANG sources from /sources folder and
894 for each generates URL in form:
895
896 ::
897
898     http://localhost:5000/schemas/{modelName}/{revision}
899
900 On this URL will be hosted YANG source for particular module.
901
902 YANGLIB instance also write this URL along with source identifier to
903 ietf-netconf-yang-library/modules-state/module list.
904
905 Netconf-connector with YANG library as fallback
906 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
907
908 There is an optional configuration in netconf-connector called
909 yang-library. You can specify YANG library to be plugged as additional
910 source provider into the mount's schema repository. Since YANGLIB
911 plugin is advertising provided modules through yang-library model, we
912 can use it in mount point's configuration as YANG library.  To do this,
913 we need to modify the configuration of netconf-connector by adding this
914 XML
915
916 ::
917
918     <yang-library xmlns="urn:opendaylight:netconf-node-topology">
919       <yang-library-url xmlns="urn:opendaylight:netconf-node-topology">http://localhost:8181/restconf/operational/ietf-yang-library:modules-state</yang-library-url>
920       <username xmlns="urn:opendaylight:netconf-node-topology">admin</username>
921       <password xmlns="urn:opendaylight:netconf-node-topology">admin</password>
922     </yang-library>
923
924 This will register YANGLIB provided sources as a fallback schemas for
925 particular mount point.
926
927 NETCONF Call Home
928 -----------------
929
930 .. important::
931
932     The call home feature is experimental and will change in a future
933     release. In particular, the Yang models will change to those specified
934     in the `RFC 8071 <https://tools.ietf.org/html/rfc8071>`__
935
936 Call Home Installation
937 ~~~~~~~~~~~~~~~~~~~~~~
938
939 ODL Call-Home server is installed in Karaf by installing karaf feature
940 ``odl-netconf-callhome-ssh``. RESTCONF feature is recommended for
941 configuring Call Home & testing its functionality.
942
943 ::
944
945   feature:install odl-netconf-callhome-ssh
946
947
948 .. note::
949
950     In order to test Call Home functionality we recommend Netopeer.
951     See `Netopeer Call Home <https://github.com/CESNET/netopeer/wiki/CallHome>`__ to learn how to enable call-home on Netopeer.
952
953 Northbound Call-Home API
954 ~~~~~~~~~~~~~~~~~~~~~~~~
955
956 The northbound Call Home API is used for administering the Call-Home Server. The
957 following describes this configuration.
958
959 Global Configuration
960 ^^^^^^^^^^^^^^^^^^^^
961
962 Configuring global credentials
963 ''''''''''''''''''''''''''''''
964
965 ODL Call-Home server allows user to configure global credentials, which
966 will be used for devices which does not have device-specific credentials
967 configured.
968
969 This is done by creating
970 ``/odl-netconf-callhome-server:netconf-callhome-server/global/credentials``
971 with username and passwords specified.
972
973 *Configuring global username & passwords to try*
974
975 .. code-block:: none
976
977     PUT
978     /restconf/config/odl-netconf-callhome-server:netconf-callhome-server/global/credentials HTTP/1.1
979     Content-Type: application/json
980     Accept: application/json
981
982 .. code-block:: json
983
984     {
985       "credentials":
986       {
987         "username": "example",
988         "passwords": [ "first-password-to-try", "second-password-to-try" ]
989       }
990     }
991
992 Configuring to accept any ssh server key using global credentials
993 '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
994
995 By default Netconf Call-Home Server accepts only incoming connections
996 from allowed devices
997 ``/odl-netconf-callhome-server:netconf-callhome-server/allowed-devices``,
998 if user desire to allow all incoming connections, it is possible to set
999 ``accept-all-ssh-keys`` to ``true`` in
1000 ``/odl-netconf-callhome-server:netconf-callhome-server/global``.
1001
1002 The name of this devices in ``netconf-topology`` will be in format
1003 ``ip-address:port``. For naming devices see Device-Specific
1004 Configuration.
1005
1006 *Allowing unknown devices to connect*
1007
1008 This is a debug feature and should not be used in production. Besides being an obvious
1009 security issue, this also causes the Call-Home Server to drastically increase its output
1010 to the log.
1011
1012 .. code-block:: none
1013
1014     POST
1015     /restconf/config/odl-netconf-callhome-server:netconf-callhome-server/global HTTP/1.1
1016     Content-Type: application/json
1017     Accept: application/json
1018
1019 .. code-block:: json
1020
1021     {
1022       "global": {
1023         "accept-all-ssh-keys": "true"
1024       }
1025     }
1026
1027 Device-Specific Configuration
1028 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1029
1030 Allowing Device & Configuring Name
1031 ''''''''''''''''''''''''''''''''''
1032
1033 Netconf Call Home Server uses device provided SSH server key (host key)
1034 to identify device. The pairing of name and server key is configured in
1035 ``/odl-netconf-callhome-server:netconf-callhome-server/allowed-devices``.
1036 This list is colloquially called a whitelist.
1037
1038 If the Call-Home Server finds the SSH host key in the whitelist, it continues
1039 to negotiate a NETCONF connection over an SSH session. If the SSH host key is
1040 not found, the connection between the Call Home server and the device is dropped
1041 immediately. In either case, the device that connects to the Call home server
1042 leaves a record of its presence in the operational store.
1043
1044 *Example of configuring device*
1045
1046 .. code-block:: none
1047
1048     PUT
1049     /restconf/config/odl-netconf-callhome-server:netconf-callhome-server/allowed-devices/device/example HTTP/1.1
1050     Content-Type: application/json
1051     Accept: application/json
1052
1053 .. code-block:: json
1054
1055     {
1056       "device": {
1057         "unique-id": "example",
1058         "ssh-host-key": "AAAAB3NzaC1yc2EAAAADAQABAAABAQDHoH1jMjltOJnCt999uaSfc48ySutaD3ISJ9fSECe1Spdq9o9mxj0kBTTTq+2V8hPspuW75DNgN+V/rgJeoUewWwCAasRx9X4eTcRrJrwOQKzb5Fk+UKgQmenZ5uhLAefi2qXX/agFCtZi99vw+jHXZStfHm9TZCAf2zi+HIBzoVksSNJD0VvPo66EAvLn5qKWQD4AdpQQbKqXRf5/W8diPySbYdvOP2/7HFhDukW8yV/7ZtcywFUIu3gdXsrzwMnTqnATSLPPuckoi0V2jd8dQvEcu1DY+rRqmqu0tEkFBurlRZDf1yhNzq5xWY3OXcjgDGN+RxwuWQK3cRimcosH"
1059       }
1060     }
1061
1062 Configuring Device with Device-specific Credentials
1063 '''''''''''''''''''''''''''''''''''''''''''''''''''
1064
1065 Call Home Server also allows to configure credentials per device basis,
1066 this is done by introducing ``credentials`` container into
1067 device-specific configuration. Format is same as in global credentials.
1068
1069 *Configuring Device with Credentials*
1070
1071 .. code-block:: none
1072
1073     PUT
1074     /restconf/config/odl-netconf-callhome-server:netconf-callhome-server/allowed-devices/device/example HTTP/1.1
1075     Content-Type: application/json
1076     Accept: application/json
1077
1078 .. code-block:: json
1079
1080     {
1081       "device": {
1082         "unique-id": "example",
1083         "credentials": {
1084           "username": "example",
1085           "passwords": [ "password" ]
1086         },
1087         "ssh-host-key": "AAAAB3NzaC1yc2EAAAADAQABAAABAQDHoH1jMjltOJnCt999uaSfc48ySutaD3ISJ9fSECe1Spdq9o9mxj0kBTTTq+2V8hPspuW75DNgN+V/rgJeoUewWwCAasRx9X4eTcRrJrwOQKzb5Fk+UKgQmenZ5uhLAefi2qXX/agFCtZi99vw+jHXZStfHm9TZCAf2zi+HIBzoVksSNJD0VvPo66EAvLn5qKWQD4AdpQQbKqXRf5/W8diPySbYdvOP2/7HFhDukW8yV/7ZtcywFUIu3gdXsrzwMnTqnATSLPPuckoi0V2jd8dQvEcu1DY+rRqmqu0tEkFBurlRZDf1yhNzq5xWY3OXcjgDGN+RxwuWQK3cRimcosH"
1088       }
1089     }
1090
1091 Operational Status
1092 ^^^^^^^^^^^^^^^^^^
1093
1094 Once an entry is made into the config side of "allowed-devices", the Call-Home Server will
1095 populate an corresponding operational device that is the same as the config device but
1096 has an additional status. By default, this status is *DISCONNECTED*. Once a device calls
1097 home, this status will change to one of:
1098
1099 *CONNECTED* — The device is currently connected and the NETCONF mount is available for network
1100 management.
1101
1102 *FAILED_AUTH_FAILURE* — The last attempted connection was unsuccessful because the Call-Home
1103 Server was unable to provide the acceptable credentials of the device. The device is also
1104 disconnected and not available for network management.
1105
1106 *FAILED_NOT_ALLOWED* — The last attempted connection was unsuccessful because the device was
1107 not recognized as an acceptable device. The device is also disconnected and not available for
1108 network management.
1109
1110 *FAILED* — The last attempted connection was unsuccessful for a reason other than not
1111 allowed to connect or incorrect client credentials. The device is also disconnected and not
1112 available for network management.
1113
1114 *DISCONNECTED* — The device is currently disconnected.
1115
1116 Rogue Devices
1117 '''''''''''''
1118
1119 Devices which are not on the whitelist might try to connect to the Call-Home Server. In
1120 these cases, the server will keep a record by instantiating an operational device. There
1121 will be no corresponding config device for these rogues. They can be identified readily
1122 because their device id, rather than being user-supplied, will be of the form
1123 "address:port". Note that if a device calls back multiple times, there will only be
1124 a single operatinal entry (even if the port changes); these devices are recognized by
1125 their unique host key.
1126
1127 Southbound Call-Home API
1128 ~~~~~~~~~~~~~~~~~~~~~~~~
1129
1130 The Call-Home Server listens for incoming TCP connections and assumes that the other side of
1131 the connection is a device calling home via a NETCONF connection with SSH for
1132 management. The server uses port 6666 by default and this can be configured via a
1133 blueprint configuration file.
1134
1135 The device **must** initiate the connection and the server will not try to re-establish the
1136 connection in case of a drop. By requirement, the server cannot assume it has connectivity
1137 to the device due to NAT or firewalls among others.