Replace supported admonitions with rst directives
[docs.git] / docs / user-guide / netconf-user-guide.rst
1 NETCONF User Guide
2 ==================
3
4 Overview
5 --------
6
7 NETCONF is an XML-based protocol used for configuration and monitoring
8 devices in the network. The base NETCONF protocol is described in
9 `RFC-6241 <http://tools.ietf.org/html/rfc6241>`__.
10
11 **NETCONF in OpenDaylight:.**
12
13 OpenDaylight supports the NETCONF protocol as a northbound server as
14 well as a southbound plugin. It also includes a set of test tools for
15 simulating NETCONF devices and clients.
16
17 Southbound (netconf-connector)
18 ------------------------------
19
20 The NETCONF southbound plugin is capable of connecting to remote NETCONF
21 devices and exposing their configuration/operational datastores, RPCs
22 and notifications as MD-SAL mount points. These mount points allow
23 applications and remote users (over RESTCONF) to interact with the
24 mounted devices.
25
26 In terms of RFCs, the connector supports:
27
28 -  `RFC-6241 <http://tools.ietf.org/html/rfc6241>`__
29
30 -  `RFC-5277 <https://tools.ietf.org/html/rfc5277>`__
31
32 -  `RFC-6022 <https://tools.ietf.org/html/rfc6022>`__
33
34 -  `draft-ietf-netconf-yang-library-06 <https://tools.ietf.org/html/draft-ietf-netconf-yang-library-06>`__
35
36 **Netconf-connector is fully model-driven (utilizing the YANG modeling
37 language) so in addition to the above RFCs, it supports any
38 data/RPC/notifications described by a YANG model that is implemented by
39 the device.**
40
41 .. tip::
42
43     NETCONF southbound can be activated by installing
44     ``odl-netconf-connector-all`` Karaf feature.
45
46 Netconf-connector configuration
47 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
48
49 There are 2 ways for configuring netconf-connector: NETCONF or RESTCONF.
50 This guide focuses on using RESTCONF.
51
52 Default configuration
53 ^^^^^^^^^^^^^^^^^^^^^
54
55 The default configuration contains all the necessary dependencies (file:
56 01-netconf.xml) and a single instance of netconf-connector (file:
57 99-netconf-connector.xml) called **controller-config** which connects
58 itself to the NETCONF northbound in OpenDaylight in a loopback fashion.
59 The connector mounts the NETCONF server for config-subsystem in order to
60 enable RESTCONF protocol for config-subsystem. This RESTCONF still goes
61 via NETCONF, but using RESTCONF is much more user friendly than using
62 NETCONF.
63
64 Spawning additional netconf-connectors while the controller is running
65 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
67 Preconditions:
68
69 1. OpenDaylight is running
70
71 2. In Karaf, you must have the netconf-connector installed (at the Karaf
72    prompt, type: ``feature:install odl-netconf-connector-all``); the
73    loopback NETCONF mountpoint will be automatically configured and
74    activated
75
76 3. Wait until log displays following entry:
77    RemoteDevice{controller-config}: NETCONF connector initialized
78    successfully
79
80 To configure a new netconf-connector you need to send following request
81 to RESTCONF:
82
83 POST
84 http://localhost:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/controller-config/yang-ext:mount/config:modules
85
86 Headers:
87
88 -  Accept application/xml
89
90 -  Content-Type application/xml
91
92 ::
93
94     <module xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
95       <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">prefix:sal-netconf-connector</type>
96       <name>new-netconf-device</name>
97       <address xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">127.0.0.1</address>
98       <port xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">830</port>
99       <username xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">admin</username>
100       <password xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">admin</password>
101       <tcp-only xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">false</tcp-only>
102       <event-executor xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">
103         <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty">prefix:netty-event-executor</type>
104         <name>global-event-executor</name>
105       </event-executor>
106       <binding-registry xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">
107         <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">prefix:binding-broker-osgi-registry</type>
108         <name>binding-osgi-broker</name>
109       </binding-registry>
110       <dom-registry xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">
111         <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">prefix:dom-broker-osgi-registry</type>
112         <name>dom-broker</name>
113       </dom-registry>
114       <client-dispatcher xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">
115         <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:netconf">prefix:netconf-client-dispatcher</type>
116         <name>global-netconf-dispatcher</name>
117       </client-dispatcher>
118       <processing-executor xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">
119         <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:threadpool">prefix:threadpool</type>
120         <name>global-netconf-processing-executor</name>
121       </processing-executor>
122       <keepalive-executor xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">
123         <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:threadpool">prefix:scheduled-threadpool</type>
124         <name>global-netconf-ssh-scheduled-executor</name>
125       </keepalive-executor>
126     </module>
127
128 This spawns a new netconf-connector which tries to connect to (or mount)
129 a NETCONF device at 127.0.0.1 and port 830. You can check the
130 configuration of config-subsystem’s configuration datastore. The new
131 netconf-connector will now be present there. Just invoke:
132
133 GET
134 http://localhost:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/controller-config/yang-ext:mount/config:modules
135
136 The response will contain the module for new-netconf-device.
137
138 Right after the new netconf-connector is created, it writes some useful
139 metadata into the datastore of MD-SAL under the network-topology
140 subtree. This metadata can be found at:
141
142 GET
143 http://localhost:8181/restconf/operational/network-topology:network-topology/
144
145 Information about connection status, device capabilities, etc. can be
146 found there.
147
148 Connecting to a device not supporting NETCONF monitoring
149 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
150
151 The netconf-connector in OpenDaylight relies on ietf-netconf-monitoring
152 support when connecting to remote NETCONF device. The
153 ietf-netconf-monitoring support allows netconf-connector to list and
154 download all YANG schemas that are used by the device. NETCONF connector
155 can only communicate with a device if it knows the set of used schemas
156 (or at least a subset). However, some devices use YANG models internally
157 but do not support NETCONF monitoring. Netconf-connector can also
158 communicate with these devices, but you have to side load the necessary
159 yang models into OpenDaylight’s YANG model cache for netconf-connector.
160 In general there are 2 situations you might encounter:
161
162 **1. NETCONF device does not support ietf-netconf-monitoring but it does
163 list all its YANG models as capabilities in HELLO message**
164
165 This could be a device that internally uses only ietf-inet-types YANG
166 model with revision 2010-09-24. In the HELLO message that is sent from
167 this device there is this capability reported:
168
169 ::
170
171     urn:ietf:params:xml:ns:yang:ietf-inet-types?module=ietf-inet-types&revision=2010-09-24
172
173 **For such devices you only need to put the schema into folder
174 cache/schema inside your Karaf distribution.**
175
176 .. important::
177
178     The file with YANG schema for ietf-inet-types has to be called
179     ietf-inet-types@2010-09-24.yang. It is the required naming format of
180     the cache.
181
182 **2. NETCONF device does not support ietf-netconf-monitoring and it does
183 NOT list its YANG models as capabilities in HELLO message**
184
185 Compared to device that lists its YANG models in HELLO message, in this
186 case there would be no capability with ietf-inet-types in the HELLO
187 message. This type of device basically provides no information about the
188 YANG schemas it uses so its up to the user of OpenDaylight to properly
189 configure netconf-connector for this device.
190
191 Netconf-connector has an optional configuration attribute called
192 yang-module-capabilities and this attribute can contain a list of "YANG
193 module based" capabilities. So by setting this configuration attribute,
194 it is possible to override the "yang-module-based" capabilities reported
195 in HELLO message of the device. To do this, we need to modify the
196 configuration of netconf-connector by adding this XML (It needs to be
197 added next to the address, port, username etc. configuration elements):
198
199 ::
200
201     <yang-module-capabilities xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">
202       <capability xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">
203         urn:ietf:params:xml:ns:yang:ietf-inet-types?module=ietf-inet-types&amp;revision=2010-09-24
204       </capability>
205     </yang-module-capabilities>
206
207 **Remember to also put the YANG schemas into the cache folder.**
208
209 .. note::
210
211     For putting multiple capabilities, you just need to replicate the
212     capability xml element inside yang-module-capability element.
213     Capability element is modeled as a leaf-list. With this
214     configuration, we would make the remote device report usage of
215     ietf-inet-types in the eyes of netconf-connector.
216
217 Reconfiguring Netconf-Connector While the Controller is Running
218 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
219
220 It is possible to change the configuration of a running module while the
221 whole controller is running. This example will continue where the last
222 left off and will change the configuration for the brand new
223 netconf-connector after it was spawned. Using one RESTCONF request, we
224 will change both username and password for the netconf-connector.
225
226 To update an existing netconf-connector you need to send following
227 request to RESTCONF:
228
229 PUT
230 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
231
232 ::
233
234     <module xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
235       <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">prefix:sal-netconf-connector</type>
236       <name>new-netconf-device</name>
237       <username xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">bob</username>
238       <password xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">passwd</password>
239       <tcp-only xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">false</tcp-only>
240       <event-executor xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">
241         <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty">prefix:netty-event-executor</type>
242         <name>global-event-executor</name>
243       </event-executor>
244       <binding-registry xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">
245         <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">prefix:binding-broker-osgi-registry</type>
246         <name>binding-osgi-broker</name>
247       </binding-registry>
248       <dom-registry xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">
249         <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">prefix:dom-broker-osgi-registry</type>
250         <name>dom-broker</name>
251       </dom-registry>
252       <client-dispatcher xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">
253         <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:netconf">prefix:netconf-client-dispatcher</type>
254         <name>global-netconf-dispatcher</name>
255       </client-dispatcher>
256       <processing-executor xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">
257         <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:threadpool">prefix:threadpool</type>
258         <name>global-netconf-processing-executor</name>
259       </processing-executor>
260       <keepalive-executor xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">
261         <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:threadpool">prefix:scheduled-threadpool</type>
262         <name>global-netconf-ssh-scheduled-executor</name>
263       </keepalive-executor>
264     </module>
265
266 Since a PUT is a replace operation, the whole configuration must be
267 specified along with the new values for username and password. This
268 should result in a 2xx response and the instance of netconf-connector
269 called new-netconf-device will be reconfigured to use username bob and
270 password passwd. New configuration can be verified by executing:
271
272 GET
273 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
274
275 With new configuration, the old connection will be closed and a new one
276 established.
277
278 Destroying Netconf-Connector While the Controller is Running
279 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
280
281 Using RESTCONF one can also destroy an instance of a module. In case of
282 netconf-connector, the module will be destroyed, NETCONF connection
283 dropped and all resources will be cleaned. To do this, simply issue a
284 request to following URL:
285
286 DELETE
287 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
288
289 The last element of the URL is the name of the instance and its
290 predecessor is the type of that module (In our case the type is
291 **sal-netconf-connector** and name **new-netconf-device**). The type and
292 name are actually the keys of the module list.
293
294 Netconf-connector configuration with MD-SAL
295 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
296
297 It is also possible to configure new NETCONF connectors directly through
298 MD-SAL with the usage of the network-topology model. You can configure
299 new NETCONF connectors both through the NETCONF server for MD-SAL (port
300 2830) or RESTCONF. This guide focuses on RESTCONF.
301
302 .. tip::
303
304     To enable NETCONF connector configuration through MD-SAL install
305     either the ``odl-netconf-topology`` or
306     ``odl-netconf-clustered-topology`` feature. We will explain the
307     difference between these features later.
308
309 Preconditions
310 ^^^^^^^^^^^^^
311
312 1. OpenDaylight is running
313
314 2. In Karaf, you must have the ``odl-netconf-topology`` or
315    ``odl-netconf-clustered-topology`` feature installed.
316
317 3. Feature ``odl-restconf`` must be installed
318
319 4. Wait until log displays following entry:
320
321    ::
322
323        Successfully pushed configuration snapshot 02-netconf-topology.xml(odl-netconf-topology,odl-netconf-topology)
324
325    or until
326
327    ::
328
329        GET http://localhost:8181/restconf/operational/network-topology:network-topology/topology/topology-netconf/
330
331    returns a non-empty response, for example:
332
333    ::
334
335        <topology xmlns="urn:TBD:params:xml:ns:yang:network-topology">
336          <topology-id>topology-netconf</topology-id>
337        </topology>
338
339 Spawning new NETCONF connectors
340 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
341
342 To create a new NETCONF connector you need to send the following request
343 to RESTCONF:
344
345 ::
346
347     PUT http://localhost:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/new-netconf-device
348
349 Headers:
350
351 -  Accept: application/xml
352
353 -  Content-Type: application/xml
354
355 Payload:
356
357 ::
358
359     <node xmlns="urn:TBD:params:xml:ns:yang:network-topology">
360       <node-id>new-netconf-device</node-id>
361       <host xmlns="urn:opendaylight:netconf-node-topology">127.0.0.1</host>
362       <port xmlns="urn:opendaylight:netconf-node-topology">17830</port>
363       <username xmlns="urn:opendaylight:netconf-node-topology">admin</username>
364       <password xmlns="urn:opendaylight:netconf-node-topology">admin</password>
365       <tcp-only xmlns="urn:opendaylight:netconf-node-topology">false</tcp-only>
366       <!-- non-mandatory fields with default values, you can safely remove these if you do not wish to override any of these values-->
367       <reconnect-on-changed-schema xmlns="urn:opendaylight:netconf-node-topology">false</reconnect-on-changed-schema>
368       <connection-timeout-millis xmlns="urn:opendaylight:netconf-node-topology">20000</connection-timeout-millis>
369       <max-connection-attempts xmlns="urn:opendaylight:netconf-node-topology">0</max-connection-attempts>
370       <between-attempts-timeout-millis xmlns="urn:opendaylight:netconf-node-topology">2000</between-attempts-timeout-millis>
371       <sleep-factor xmlns="urn:opendaylight:netconf-node-topology">1.5</sleep-factor>
372       <!-- keepalive-delay set to 0 turns off keepalives-->
373       <keepalive-delay xmlns="urn:opendaylight:netconf-node-topology">120</keepalive-delay>
374     </node>
375
376 Note that the device name in <node-id> element must match the last
377 element of the restconf URL.
378
379 Reconfiguring an existing connector
380 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
381
382 The steps to reconfigure an existing connector are exactly the same as
383 when spawning a new connector. The old connection will be disconnected
384 and a new connector with the new configuration will be created.
385
386 Deleting an existing connector
387 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
388
389 To remove an already configured NETCONF connector you need to send the
390 following:
391
392 ::
393
394     DELETE http://localhost:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/new-netconf-device
395
396 Connecting to a device supporting only NETCONF 1.0
397 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
398
399 OpenDaylight is schema-based distribution and heavily depends on YANG
400 models. However some legacy NETCONF devices are not schema-based and
401 implement just RFC 4741. This type of device does not utilize YANG
402 models internally and OpenDaylight does not know how to communicate
403 with such devices, how to validate data, or what the semantics of data
404 are.
405
406 NETCONF connector can communicate also with these devices, but the
407 trade-offs are worsened possibilities in utilization of NETCONF
408 mountpoints. Using RESTCONF with such devices is not suported. Also
409 communicating with schemaless devices from application code is slightly
410 different.
411
412 To connect to schemaless device, there is a optional configuration option
413 in netconf-node-topology model called schemaless. You have to set this
414 option to true.
415
416 Clustered NETCONF connector
417 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
418
419 To spawn NETCONF connectors that are cluster-aware you need to install
420 the ``odl-netconf-clustered-topology`` karaf feature.
421
422 .. warning::
423
424     The ``odl-netconf-topology`` and ``odl-netconf-clustered-topology``
425     features are considered **INCOMPATIBLE**. They both manage the same
426     space in the datastore and would issue conflicting writes if
427     installed together.
428
429 Configuration of clustered NETCONF connectors works the same as the
430 configuration through the topology model in the previous section.
431
432 When a new clustered connector is configured the configuration gets
433 distributed among the member nodes and a NETCONF connector is spawned on
434 each node. From these nodes a master is chosen which handles the schema
435 download from the device and all the communication with the device. You
436 will be able to read/write to/from the device from all slave nodes due
437 to the proxy data brokers implemented.
438
439 You can use the ``odl-netconf-clustered-topology`` feature in a single
440 node scenario as well but the code that uses akka will be used, so for a
441 scenario where only a single node is used, ``odl-netconf-topology``
442 might be preferred.
443
444 Netconf-connector utilization
445 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
446
447 Once the connector is up and running, users can utilize the new mount
448 point instance. By using RESTCONF or from their application code. This
449 chapter deals with using RESTCONF and more information for app
450 developers can be found in the developers guide or in the official
451 tutorial application **ncmount** that can be found in the coretutorials
452 project:
453
454 -  https://github.com/opendaylight/coretutorials/tree/stable/beryllum/ncmount
455
456 Reading data from the device
457 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
458
459 Just invoke (no body needed):
460
461 GET
462 http://localhost:8080/restconf/operational/network-topology:network-topology/topology/topology-netconf/node/new-netconf-device/yang-ext:mount/
463
464 This will return the entire content of operation datastore from the
465 device. To view just the configuration datastore, change **operational**
466 in this URL to **config**.
467
468 Writing configuration data to the device
469 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
470
471 In general, you cannot simply write any data you want to the device. The
472 data have to conform to the YANG models implemented by the device. In
473 this example we are adding a new interface-configuration to the mounted
474 device (assuming the device supports Cisco-IOS-XR-ifmgr-cfg YANG model).
475 In fact this request comes from the tutorial dedicated to the
476 **ncmount** tutorial app.
477
478 POST
479 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
480
481 ::
482
483     <interface-configuration xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg">
484         <active>act</active>
485         <interface-name>mpls</interface-name>
486         <description>Interface description</description>
487         <bandwidth>32</bandwidth>
488         <link-status></link-status>
489     </interface-configuration>
490
491 Should return 200 response code with no body.
492
493 .. tip::
494
495     This call is transformed into a couple of NETCONF RPCs. Resulting
496     NETCONF RPCs that go directly to the device can be found in the
497     OpenDaylight logs after invoking ``log:set TRACE
498     org.opendaylight.controller.sal.connect.netconf`` in the Karaf
499     shell. Seeing the NETCONF RPCs might help with debugging.
500
501 This request is very similar to the one where we spawned a new netconf
502 device. That’s because we used the loopback netconf-connector to write
503 configuration data into config-subsystem datastore and config-subsystem
504 picked it up from there.
505
506 Invoking custom RPC
507 ^^^^^^^^^^^^^^^^^^^
508
509 Devices can implement any additional RPC and as long as it provides YANG
510 models for it, it can be invoked from OpenDaylight. Following example
511 shows how to invoke the get-schema RPC (get-schema is quite common among
512 netconf devices). Invoke:
513
514 POST
515 http://localhost:8181/restconf/operations/network-topology:network-topology/topology/topology-netconf/node/new-netconf-device/yang-ext:mount/ietf-netconf-monitoring:get-schema
516
517 ::
518
519     <input xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring">
520       <identifier>ietf-yang-types</identifier>
521       <version>2013-07-15</version>
522     </input>
523
524 This call should fetch the source for ietf-yang-types YANG model from
525 the mounted device.
526
527 Netconf-connector + Netopeer
528 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
529
530 `Netopeer <https://github.com/cesnet/netopeer>`__ (an open-source
531 NETCONF server) can be used for testing/exploring NETCONF southbound in
532 OpenDaylight.
533
534 Netopeer installation
535 ^^^^^^^^^^^^^^^^^^^^^
536
537 A `Docker <https://www.docker.com/>`__ container with netopeer will be
538 used in this guide. To install Docker and start the `netopeer
539 image <https://index.docker.io/u/dockeruser/netopeer/>`__ perform
540 following steps:
541
542 1. Install docker http://docs.docker.com/linux/step_one/
543
544 2. Start the netopeer image:
545
546    ::
547
548        docker run -rm -t -p 1831:830 dockeruser/netopeer
549
550 3. Verify netopeer is running by invoking (netopeer should send its
551    HELLO message right away:
552
553    ::
554
555        ssh root@localhost -p 1831 -s netconf
556        (password root)
557
558 Mounting netopeer NETCONF server
559 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
560
561 Preconditions:
562
563 -  OpenDaylight is started with features ``odl-restconf-all`` and
564    ``odl-netconf-connector-all``.
565
566 -  Netopeer is up and running in docker
567
568 Now just follow the chapter: `Spawning
569 netconf-connector <#_spawning_additional_netconf_connectors_while_the_controller_is_running>`__.
570 In the payload change the:
571
572 -  name, e.g., to netopeer
573
574 -  username/password to your system credentials
575
576 -  ip to localhost
577
578 -  port to 1831.
579
580 After netopeer is mounted successfully, its configuration can be read
581 using RESTCONF by invoking:
582
583 GET
584 http://localhost:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/netopeer/yang-ext:mount/
585
586 Northbound (NETCONF servers)
587 ----------------------------
588
589 OpenDaylight provides 2 types of NETCONF servers:
590
591 -  **NETCONF server for config-subsystem (listening by default on port
592    1830)**
593
594    -  Serves as a default interface for config-subsystem and allows
595       users to spawn/reconfigure/destroy modules (or applications) in
596       OpenDaylight
597
598 -  **NETCONF server for MD-SAL (listening by default on port 2830)**
599
600    -  Serves as an alternative interface for MD-SAL (besides RESTCONF)
601       and allows users to read/write data from MD-SAL’s datastore and to
602       invoke its rpcs (NETCONF notifications are not available in the
603       Boron release of OpenDaylight)
604
605 .. note::
606
607     The reason for having 2 NETCONF servers is that config-subsystem and
608     MD-SAL are 2 different components of OpenDaylight and require
609     different approach for NETCONF message handling and data
610     translation. These 2 components will probably merge in the future.
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
693 netconf-connector <#_spawning_additional_netconf_connectors_while_the_controller_is_running>`__.
694 Just change the ip to "127.0.0.1" port to "2830" and its name to
695 "controller-mdsal".
696
697 Now the MD-SAL’s datastore can be read over RESTCONF via NETCONF by
698 invoking:
699
700 GET
701 http://localhost:8181/restconf/operational/network-topology:network-topology/topology/topology-netconf/node/controller-mdsal/yang-ext:mount
702
703 .. note::
704
705     This might not seem very useful, since MD-SAL can be accessed
706     directly from RESTCONF or from Application code, but the same method
707     can be used to mount and control other OpenDaylight instances by the
708     "master OpenDaylight".
709
710 NETCONF testtool
711 ----------------
712
713 **NETCONF testtool is a set of standalone runnable jars that can:**
714
715 -  Simulate NETCONF devices (suitable for scale testing)
716
717 -  Stress/Performance test NETCONF devices
718
719 -  Stress/Performance test RESTCONF devices
720
721 These jars are part of OpenDaylight’s controller project and are built
722 from the NETCONF codebase in OpenDaylight.
723
724 .. tip::
725
726     Download testtool from OpenDaylight Nexus at:
727     https://nexus.opendaylight.org/content/repositories/public/org/opendaylight/netconf/netconf-testtool/1.1.0-Boron/
728
729 **Nexus contains 3 executable tools:**
730
731 -  executable.jar - device simulator
732
733 -  stress.client.tar.gz - NETCONF stress/performance measuring tool
734
735 -  perf-client.jar - RESTCONF stress/performance measuring tool
736
737 .. tip::
738
739     Each executable tool provides help. Just invoke ``java -jar
740     <name-of-the-tool.jar> --help``
741
742 NETCONF device simulator
743 ~~~~~~~~~~~~~~~~~~~~~~~~
744
745 NETCONF testtool (or NETCONF device simulator) is a tool that
746
747 -  Simulates 1 or more NETCONF devices
748
749 -  Is suitable for scale, performance or crud testing
750
751 -  Uses core implementation of NETCONF server from OpenDaylight
752
753 -  Generates configuration files for controller so that the OpenDaylight
754    distribution (Karaf) can easily connect to all simulated devices
755
756 -  Provides broad configuration options
757
758 -  Can start a fully fledged MD-SAL datastore
759
760 -  Supports notifications
761
762 Building testtool
763 ^^^^^^^^^^^^^^^^^
764
765 1. Check out latest NETCONF repository from
766    `git <https://git.opendaylight.org/gerrit/#/admin/projects/netconf>`__
767
768 2. Move into the ``opendaylight/netconf/tools/netconf-testtool/`` folder
769
770 3. Build testtool using the ``mvn clean install`` command
771
772 Downloading testtool
773 ^^^^^^^^^^^^^^^^^^^^
774
775 Netconf-testtool is now part of default maven build profile for
776 controller and can be also downloaded from nexus. The executable jar for
777 testtool can be found at:
778 `nexus-artifacts <https://nexus.opendaylight.org/content/repositories/public/org/opendaylight/netconf/netconf-testtool/1.1.0-Boron/>`__
779
780 Running testtool
781 ^^^^^^^^^^^^^^^^
782
783 1. After successfully building or downloading, move into the
784    ``opendaylight/netconf/tools/netconf-testtool/target/`` folder and
785    there is file ``netconf-testtool-1.1.0-SNAPSHOT-executable.jar`` (or
786    if downloaded from nexus just take that jar file)
787
788 2. Execute this file using, e.g.:
789
790    ::
791
792        java -jar netconf-testtool-1.1.0-SNAPSHOT-executable.jar
793
794    This execution runs the testtool with default for all parameters and
795    you should see this log output from the testtool :
796
797    ::
798
799        10:31:08.206 [main] INFO  o.o.c.n.t.t.NetconfDeviceSimulator - Starting 1, SSH simulated devices starting on port 17830
800        10:31:08.675 [main] INFO  o.o.c.n.t.t.NetconfDeviceSimulator - All simulated devices started successfully from port 17830 to 17830
801
802 Default Parameters
803 ''''''''''''''''''
804
805 The default parameters for testtool are:
806
807 -  Use SSH
808
809 -  Run 1 simulated device
810
811 -  Device port is 17830
812
813 -  YANG modules used by device are only: ietf-netconf-monitoring,
814    ietf-yang-types, ietf-inet-types (these modules are required for
815    device in order to support NETCONF monitoring and are included in the
816    netconf-testtool)
817
818 -  Connection timeout is set to 30 minutes (quite high, but when testing
819    with 10000 devices it might take some time for all of them to fully
820    establish a connection)
821
822 -  Debug level is set to false
823
824 -  No distribution is modified to connect automatically to the NETCONF
825    testtool
826
827 Verifying testtool
828 ^^^^^^^^^^^^^^^^^^
829
830 To verify that the simulated device is up and running, we can try to
831 connect to it using command line ssh tool. Execute this command to
832 connect to the device:
833
834 ::
835
836     ssh admin@localhost -p 17830 -s netconf
837
838 Just accept the server with yes (if required) and provide any password
839 (testtool accepts all users with all passwords). You should see the
840 hello message sent by simulated device.
841
842 Testtool help
843 ^^^^^^^^^^^^^
844
845 ::
846
847     usage: netconf testool [-h] [--device-count DEVICES-COUNT] [--devices-per-port DEVICES-PER-PORT] [--schemas-dir SCHEMAS-DIR] [--notification-file NOTIFICATION-FILE]
848                            [--initial-config-xml-file INITIAL-CONFIG-XML-FILE] [--starting-port STARTING-PORT] [--generate-config-connection-timeout GENERATE-CONFIG-CONNECTION-TIMEOUT]
849                            [--generate-config-address GENERATE-CONFIG-ADDRESS] [--generate-configs-batch-size GENERATE-CONFIGS-BATCH-SIZE] [--distribution-folder DISTRO-FOLDER] [--ssh SSH] [--exi EXI]
850                            [--debug DEBUG] [--md-sal MD-SAL]
851
852     NETCONF device simulator. Detailed info can be found at https://wiki.opendaylight.org/view/OpenDaylight_Controller:Netconf:Testtool#Building_testtool
853
854     optional arguments:
855       -h, --help             show this help message and exit
856       --device-count DEVICES-COUNT
857                              Number of simulated netconf devices to spin. This is the number of actual ports open for the devices.
858       --devices-per-port DEVICES-PER-PORT
859                              Amount of config files generated per port to spoof more devices then are actually running
860       --schemas-dir SCHEMAS-DIR
861                              Directory containing yang schemas to describe simulated devices. Some schemas e.g. netconf monitoring and inet types are included by default
862       --notification-file NOTIFICATION-FILE
863                              Xml file containing notifications that should be sent to clients after create subscription is called
864       --initial-config-xml-file INITIAL-CONFIG-XML-FILE
865                              Xml file containing initial simulatted configuration to be returned via get-config rpc
866       --starting-port STARTING-PORT
867                              First port for simulated device. Each other device will have previous+1 port number
868       --generate-config-connection-timeout GENERATE-CONFIG-CONNECTION-TIMEOUT
869                              Timeout to be generated in initial config files
870       --generate-config-address GENERATE-CONFIG-ADDRESS
871                              Address to be placed in generated configs
872       --generate-configs-batch-size GENERATE-CONFIGS-BATCH-SIZE
873                              Number of connector configs per generated file
874       --distribution-folder DISTRO-FOLDER
875                              Directory where the karaf distribution for controller is located
876       --ssh SSH              Whether to use ssh for transport or just pure tcp
877       --exi EXI              Whether to use exi to transport xml content
878       --debug DEBUG          Whether to use debug log level instead of INFO
879       --md-sal MD-SAL        Whether to use md-sal datastore instead of default simulated datastore.
880
881 Supported operations
882 ^^^^^^^^^^^^^^^^^^^^
883
884 Testtool default simple datastore supported operations:
885
886 get-schema
887     returns YANG schemas loaded from user specified directory,
888
889 edit-config
890     always returns OK and stores the XML from the input in a local
891     variable available for get-config and get RPC. Every edit-config
892     replaces the previous data,
893
894 commit
895     always returns OK, but does not actually commit the data,
896
897 get-config
898     returns local XML stored by edit-config,
899
900 get
901     returns local XML stored by edit-config with netconf-state subtree,
902     but also supports filtering.
903
904 (un)lock
905     returns always OK with no lock guarantee
906
907 create-subscription
908     returns always OK and after the operation is triggered, provided
909     NETCONF notifications (if any) are fed to the client. No filtering
910     or stream recognition is supported.
911
912 Note: when operation="delete" is present in the payload for edit-config,
913 it will wipe its local store to simulate the removal of data.
914
915 When using the MD-SAL datastore testtool behaves more like normal
916 NETCONF server and is suitable for crud testing. create-subscription is
917 not supported when testtool is running with the MD-SAL datastore.
918
919 Notification support
920 ^^^^^^^^^^^^^^^^^^^^
921
922 Testtool supports notifications via the --notification-file switch. To
923 trigger the notification feed, create-subscription operation has to be
924 invoked. The XML file provided should look like this example file:
925
926 ::
927
928     <?xml version='1.0' encoding='UTF-8' standalone='yes'?>
929     <notifications>
930
931     <!-- Notifications are processed in the order they are defined in XML -->
932
933     <!-- Notification that is sent only once right after create-subscription is called -->
934     <notification>
935         <!-- Content of each notification entry must contain the entire notification with event time. Event time can be hardcoded, or generated by testtool if XXXX is set as eventtime in this XML -->
936         <content><![CDATA[
937             <notification xmlns="urn:ietf:params:xml:ns:netconf:notification:1.0">
938                 <eventTime>2011-01-04T12:30:46</eventTime>
939                 <random-notification xmlns="http://www.opendaylight.org/netconf/event:1.0">
940                     <random-content>single no delay</random-content>
941                 </random-notification>
942             </notification>
943         ]]></content>
944     </notification>
945
946     <!-- Repeated Notification that is sent 5 times with 2 second delay inbetween -->
947     <notification>
948         <!-- Delay in seconds from previous notification -->
949         <delay>2</delay>
950         <!-- Number of times this notification should be repeated -->
951         <times>5</times>
952         <content><![CDATA[
953             <notification xmlns="urn:ietf:params:xml:ns:netconf:notification:1.0">
954                 <eventTime>XXXX</eventTime>
955                 <random-notification xmlns="http://www.opendaylight.org/netconf/event:1.0">
956                     <random-content>scheduled 5 times 10 seconds each</random-content>
957                 </random-notification>
958             </notification>
959         ]]></content>
960     </notification>
961
962     <!-- Single notification that is sent only once right after the previous notification -->
963     <notification>
964         <delay>2</delay>
965         <content><![CDATA[
966             <notification xmlns="urn:ietf:params:xml:ns:netconf:notification:1.0">
967                 <eventTime>XXXX</eventTime>
968                 <random-notification xmlns="http://www.opendaylight.org/netconf/event:1.0">
969                     <random-content>single with delay</random-content>
970                 </random-notification>
971             </notification>
972         ]]></content>
973     </notification>
974
975     </notifications>
976
977 Connecting testtool with controller Karaf distribution
978 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
979
980 Auto connect to OpenDaylight
981 ''''''''''''''''''''''''''''
982
983 It is possible to make OpenDaylight auto connect to the simulated
984 devices spawned by testtool (so user does not have to post a
985 configuration for every NETCONF connector via RESTCONF). The testtool is
986 able to modify the OpenDaylight distribution to auto connect to the
987 simulated devices after feature ``odl-netconf-connector-all`` is
988 installed. When running testtool, issue this command (just point the
989 testool to the distribution:
990
991 ::
992
993     java -jar netconf-testtool-1.1.0-SNAPSHOT-executable.jar --device-count 10 --distribution-folder ~/distribution-karaf-0.4.0-SNAPSHOT/ --debug true
994
995 With the distribution-folder parameter, the testtool will modify the
996 distribution to include configuration for netconf-connector to connect
997 to all simulated devices. So there is no need to spawn
998 netconf-connectors via RESTCONF.
999
1000 Running testtool and OpenDaylight on different machines
1001 '''''''''''''''''''''''''''''''''''''''''''''''''''''''
1002
1003 The testtool binds by default to 0.0.0.0 so it should be accessible from
1004 remote machines. However you need to set the parameter
1005 "generate-config-address" (when using autoconnect) to the address of
1006 machine where testtool will be run so OpenDaylight can connect. The
1007 default value is localhost.
1008
1009 Executing operations via RESTCONF on a mounted simulated device
1010 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1011
1012 Simulated devices support basic RPCs for editing their config. This part
1013 shows how to edit data for simulated device via RESTCONF.
1014
1015 Test YANG schema
1016 ''''''''''''''''
1017
1018 The controller and RESTCONF assume that the data that can be manipulated
1019 for mounted device is described by a YANG schema. For demonstration, we
1020 will define a simple YANG model:
1021
1022 ::
1023
1024     module test {
1025         yang-version 1;
1026         namespace "urn:opendaylight:test";
1027         prefix "tt";
1028
1029         revision "2014-10-17";
1030
1031
1032        container cont {
1033
1034             leaf l {
1035                 type string;
1036             }
1037        }
1038     }
1039
1040 Save this schema in file called test@2014-10-17.yang and store it a
1041 directory called test-schemas/, e.g., your home folder.
1042
1043 Editing data for simulated device
1044 '''''''''''''''''''''''''''''''''
1045
1046 -  Start the device with following command:
1047
1048    ::
1049
1050        java -jar netconf-testtool-1.1.0-SNAPSHOT-executable.jar --device-count 10 --distribution-folder ~/distribution-karaf-0.4.0-SNAPSHOT/ --debug true --schemas-dir ~/test-schemas/
1051
1052 -  Start OpenDaylight
1053
1054 -  Install odl-netconf-connector-all feature
1055
1056 -  Install odl-restconf feature
1057
1058 -  Check that you can see config data for simulated device by executing
1059    GET request to
1060
1061    ::
1062
1063        http://localhost:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/17830-sim-device/yang-ext:mount/
1064
1065 -  The data should be just and empty data container
1066
1067 -  Now execute edit-config request by executing a POST request to:
1068
1069    ::
1070
1071        http://localhost:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/17830-sim-device/yang-ext:mount
1072
1073    with headers:
1074
1075    ::
1076
1077        Accept application/xml
1078        Content-Type application/xml
1079
1080    and payload:
1081
1082    ::
1083
1084        <cont xmlns="urn:opendaylight:test">
1085          <l>Content</l>
1086        </cont>
1087
1088 -  Check that you can see modified config data for simulated device by
1089    executing GET request to
1090
1091    ::
1092
1093        http://localhost:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/17830-sim-device/yang-ext:mount/
1094
1095 -  Check that you can see the same modified data in operational for
1096    simulated device by executing GET request to
1097
1098    ::
1099
1100        http://localhost:8181/restconf/operational/network-topology:network-topology/topology/topology-netconf/node/17830-sim-device/yang-ext:mount/
1101
1102 .. warning::
1103
1104     Data will be mirrored in operational datastore only when using the
1105     default simple datastore.
1106
1107 Known problems
1108 ^^^^^^^^^^^^^^
1109
1110 Slow creation of devices on virtual machines
1111 ''''''''''''''''''''''''''''''''''''''''''''
1112
1113 When testtool seems to take unusually long time to create the devices
1114 use this flag when running it:
1115
1116 ::
1117
1118     -Dorg.apache.sshd.registerBouncyCastle=false
1119
1120 Too many files open
1121 '''''''''''''''''''
1122
1123 When testtool or OpenDaylight starts to fail with TooManyFilesOpen
1124 exception, you need to increase the limit of open files in your OS. To
1125 find out the limit in linux execute:
1126
1127 ::
1128
1129     ulimit -a
1130
1131 Example sufficient configuration in linux:
1132
1133 ::
1134
1135     core file size          (blocks, -c) 0
1136     data seg size           (kbytes, -d) unlimited
1137     scheduling priority             (-e) 0
1138     file size               (blocks, -f) unlimited
1139     pending signals                 (-i) 63338
1140     max locked memory       (kbytes, -l) 64
1141     max memory size         (kbytes, -m) unlimited
1142     open files                      (-n) 500000
1143     pipe size            (512 bytes, -p) 8
1144     POSIX message queues     (bytes, -q) 819200
1145     real-time priority              (-r) 0
1146     stack size              (kbytes, -s) 8192
1147     cpu time               (seconds, -t) unlimited
1148     max user processes              (-u) 63338
1149     virtual memory          (kbytes, -v) unlimited
1150     file locks                      (-x) unlimited
1151
1152 To set these limits edit file: /etc/security/limits.conf, for example:
1153
1154 ::
1155
1156     *         hard    nofile      500000
1157     *         soft    nofile      500000
1158     root      hard    nofile      500000
1159     root      soft    nofile      500000
1160
1161 "Killed"
1162 ''''''''
1163
1164 The testtool might end unexpectedly with a simple message: "Killed".
1165 This means that the OS killed the tool due to too much memory consumed
1166 or too many threads spawned. To find out the reason on linux you can use
1167 following command:
1168
1169 ::
1170
1171     dmesg | egrep -i -B100 'killed process'
1172
1173 Also take a look at this file: /proc/sys/kernel/threads-max. It limits
1174 the number of threads spawned by a process. Sufficient (but probably
1175 much more than enough) value is, e.g., 126676
1176
1177 NETCONF stress/performance measuring tool
1178 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1179
1180 This is basically a NETCONF client that puts NETCONF servers under heavy
1181 load of NETCONF RPCs and measures the time until a configurable amount
1182 of them is processed.
1183
1184 RESTCONF stress-performance measuring tool
1185 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1186
1187 Very similar to NETCONF stress tool with the difference of using
1188 RESTCONF protocol instead of NETCONF.
1189
1190 YANGLIB remote repository
1191 -------------------------
1192
1193 There are scenarios in NETCONF deployment, that require for a centralized
1194 YANG models repository. YANGLIB plugin provides such remote repository.
1195
1196 To start this plugin, you have to install odl-yanglib feature. Then you
1197 have to configure YANGLIB either through RESTCONF or NETCONF. We will
1198 show how to configure YANGLIB through RESTCONF.
1199
1200 YANGLIB configuration through RESTCONF
1201 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1202
1203 You have to specify what local YANG modules directory you want to provide.
1204 Then you have to specify address and port whre you want to provide YANG
1205 sources. For example, we want to serve yang sources from folder /sources
1206 on localhost:5000 adress. The configuration for this scenario will be
1207 as follows:
1208
1209 ::
1210
1211     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
1212
1213 Headers:
1214
1215 -  Accept: application/xml
1216
1217 -  Content-Type: application/xml
1218
1219 Payload:
1220
1221 ::
1222
1223    <module xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
1224      <name>example</name>
1225      <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:yanglib:impl">prefix:yanglib</type>
1226      <broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:yanglib:impl">
1227        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">prefix:binding-broker-osgi-registry</type>
1228        <name>binding-osgi-broker</name>
1229      </broker>
1230      <cache-folder xmlns="urn:opendaylight:params:xml:ns:yang:controller:yanglib:impl">/sources</cache-folder>
1231      <binding-addr xmlns="urn:opendaylight:params:xml:ns:yang:controller:yanglib:impl">localhost</binding-addr>
1232      <binding-port xmlns="urn:opendaylight:params:xml:ns:yang:controller:yanglib:impl">5000</binding-port>
1233    </module>
1234
1235 This should result in a 2xx response and new YANGLIB instance should be
1236 created. This YANGLIB takes all YANG sources from /sources folder and
1237 for each generates URL in form:
1238
1239 ::
1240
1241     http://localhost:5000/schemas/{modelName}/{revision}
1242
1243 On this URL will be hosted YANG source for particular module.
1244
1245 YANGLIB instance also write this URL along with source identifier to
1246 ietf-netconf-yang-library/modules-state/module list.
1247
1248 Netconf-connector with YANG library as fallback
1249 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1250
1251 There is an optional configuration in netconf-connector called
1252 yang-library. You can specify YANG library to be plugged as additional
1253 source provider into the mount's schema repository. Since YANGLIB
1254 plugin is advertising provided modules through yang-library model, we
1255 can use it in mount point's configuration as YANG library.  To do this,
1256 we need to modify the configuration of netconf-connector by adding this
1257 XML
1258
1259 ::
1260
1261     <yang-library xmlns="urn:opendaylight:netconf-node-topology">
1262       <yang-library-url xmlns="urn:opendaylight:netconf-node-topology">http://localhost:8181/restconf/operational/ietf-yang-library:modules-state</yang-library-url>
1263       <username xmlns="urn:opendaylight:netconf-node-topology">admin</username>
1264       <password xmlns="urn:opendaylight:netconf-node-topology">admin</password>
1265     </yang-library>
1266
1267 This will register YANGLIB provided sources as a fallback schemas for
1268 particular mount point.