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