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