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