1 .. _netconf-user-guide:
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 <https://www.rfc-editor.org/rfc/rfc6241>`__.
21 **NETCONF in OpenDaylight:.**
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.
27 Southbound (netconf-connector)
28 ------------------------------
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
36 In terms of RFCs, the connector supports:
38 - `RFC-6241 <https://www.rfc-editor.org/rfc/rfc6241>`__
40 - `RFC-5277 <https://www.rfc-editor.org/rfc/rfc5277>`__
42 - `RFC-6022 <https://www.rfc-editor.org/rfc/rfc6022>`__
44 - `RFC-7895 <https://www.rfc-editor.org/rfc/rfc7895>`__
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
53 NETCONF southbound can be activated by installing
54 ``odl-netconf-connector-all`` Karaf feature.
56 .. _netconf-connector:
58 Netconf-connector configuration
59 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
61 NETCONF connectors are configured directly through the usage of the
62 network-topology model. You can configure new NETCONF connectors both
63 through the NETCONF server for MD-SAL (port 2830) or RESTCONF. This guide
68 Since 2022.09 Chlorine there is only one RESTCONF endpoint:
70 - | ``http://localhost:8181/rests`` is related to `RFC-8040 <https://www.rfc-editor.org/rfc/rfc8040>`__,
71 | can be activated by installing ``odl-restconf-nb``
74 | Resources for configuration and operational datastores start
77 http://localhost:8181/rests/data/network-topology:network-topology
78 with response of both datastores. It's allowed to use query
79 parameters to distinguish between them.
81 http://localhost:8181/rests/data/network-topology:network-topology?content=config
82 for configuration datastore
84 http://localhost:8181/rests/data/network-topology:network-topology?content=nonconfig
85 for operational datastore.
87 | Also if a data node in the path expression is a YANG leaf-list or list
88 node, the path segment has to be constructed by having leaf-list or
89 list node name, followed by an "=" character, then followed by the
90 leaf-list or list value. Any reserved characters must be
93 http://localhost:8181/rests/data/network-topology:network-topology/topology=topology-netconf?content=config
94 for retrieving data from configuration datastore for
95 topology-netconf value of topology list.
100 1. OpenDaylight is running
102 2. In Karaf, you must have the ``odl-netconf-topology`` or
103 ``odl-netconf-clustered-topology`` feature installed.
105 3. Feature ``odl-restconf-nb`` must be installed
107 Spawning new NETCONF connectors
108 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
110 To create a new NETCONF connector you need to send the following PUT request
117 - http://localhost:8181/rests/data/network-topology:network-topology/topology=topology-netconf/node=new-netconf-device
119 You could use the same body to create the new NETCONF connector with a POST
120 without specifying the node in the URL:
126 - http://localhost:8181/rests/data/network-topology:network-topology/topology=topology-netconf
134 **Content-type:** ``application/xml``
136 **Accept:** ``application/xml``
138 **Authentication:** ``admin:admin``
142 <node xmlns="urn:TBD:params:xml:ns:yang:network-topology">
143 <node-id>new-netconf-device</node-id>
144 <host xmlns="urn:opendaylight:netconf-node-topology">127.0.0.1</host>
145 <port xmlns="urn:opendaylight:netconf-node-topology">17830</port>
146 <login-password-unencrypted xmlns="urn:opendaylight:netconf-node-topology">
147 <username xmlns="urn:opendaylight:netconf-node-topology">admin</username>
148 <password xmlns="urn:opendaylight:netconf-node-topology">admin</password>
149 </login-password-unencrypted>
150 <tcp-only xmlns="urn:opendaylight:netconf-node-topology">false</tcp-only>
151 <!-- non-mandatory fields with default values, you can safely remove these if you do not wish to override any of these values-->
152 <reconnect-on-changed-schema xmlns="urn:opendaylight:netconf-node-topology">false</reconnect-on-changed-schema>
153 <connection-timeout-millis xmlns="urn:opendaylight:netconf-node-topology">20000</connection-timeout-millis>
154 <max-connection-attempts xmlns="urn:opendaylight:netconf-node-topology">0</max-connection-attempts>
155 <between-attempts-timeout-millis xmlns="urn:opendaylight:netconf-node-topology">2000</between-attempts-timeout-millis>
156 <sleep-factor xmlns="urn:opendaylight:netconf-node-topology">1.5</sleep-factor>
157 <!-- keepalive-delay set to 0 turns off keepalives-->
158 <keepalive-delay xmlns="urn:opendaylight:netconf-node-topology">120</keepalive-delay>
163 **Content-type:** ``application/json``
165 **Accept:** ``application/json``
167 **Authentication:** ``admin:admin``
174 "node-id": "new-netconf-device",
175 "netconf-node-topology:port": 17830,
176 "netconf-node-topology:reconnect-on-changed-schema": false,
177 "netconf-node-topology:connection-timeout-millis": 20000,
178 "netconf-node-topology:tcp-only": false,
179 "netconf-node-topology:max-connection-attempts": 0,
180 "netconf-node-topology:login-password-unencrypted": {
181 "netconf-node-topology:username": "admin",
182 "netconf-node-topology:password": "admin"
184 "netconf-node-topology:sleep-factor": 1.5,
185 "netconf-node-topology:host": "127.0.0.1",
186 "netconf-node-topology:between-attempts-timeout-millis": 2000,
187 "netconf-node-topology:keepalive-delay": 120
192 Note that the device name in <node-id> element must match the last
193 element of the restconf URL.
195 Reconfiguring an existing connector
196 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
198 The steps to reconfigure an existing connector are exactly the same as
199 when spawning a new connector. The old connection will be disconnected
200 and a new connector with the new configuration will be created. This needs
201 to be done with a PUT request because the node already exists. A POST
202 request will fail for that reason.
204 Additionally, a PATCH request can be used to modify an existing
205 configuration. Currently, only yang-patch (`RFC-8072 <https://www.rfc-editor.org/rfc/rfc8072>`__)
206 is supported. The URL would be the same as the above PUT examples.
207 Using JSON for the body, the headers needed for the request would
212 - Accept: application/yang-data+json
214 - Content-Type: application/yang-patch+json
216 Example JSON payload to modify the password entry:
221 "ietf-restconf:yang-patch" : {
226 "operation" : "merge",
231 "node-id": "new-netconf-device",
232 "netconf-node-topology:password" : "newpassword"
241 Deleting an existing connector
242 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
244 To remove an already configured NETCONF connector you need to send a
245 DELETE request to the same PUT request URL that was used to create the
252 - http://localhost:8181/rests/data/network-topology:network-topology/topology=topology-netconf/node=new-netconf-device
256 No body is needed to delete the node/device
258 Connecting to a device not supporting NETCONF monitoring
259 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
261 The netconf-connector in OpenDaylight relies on ietf-netconf-monitoring
262 support when connecting to remote NETCONF device. The
263 ietf-netconf-monitoring support allows netconf-connector to list and
264 download all YANG schemas that are used by the device. NETCONF connector
265 can only communicate with a device if it knows the set of used schemas
266 (or at least a subset). However, some devices use YANG models internally
267 but do not support NETCONF monitoring. Netconf-connector can also
268 communicate with these devices, but you have to side load the necessary
269 yang models into OpenDaylight’s YANG model cache for netconf-connector.
270 In general there are 2 situations you might encounter:
272 **1. NETCONF device does not support ietf-netconf-monitoring but it does
273 list all its YANG models as capabilities in HELLO message**
275 This could be a device that internally uses only ietf-inet-types YANG
276 model with revision 2010-09-24. In the HELLO message that is sent from
277 this device there is this capability reported:
281 urn:ietf:params:xml:ns:yang:ietf-inet-types?module=ietf-inet-types&revision=2010-09-24
283 **For such devices you only need to put the schema into folder
284 cache/schema inside your Karaf distribution.**
288 The file with YANG schema for ietf-inet-types has to be called
289 ietf-inet-types@2010-09-24.yang. It is the required naming format of
292 **2. NETCONF device does not support ietf-netconf-monitoring and it does
293 NOT list its YANG models as capabilities in HELLO message**
295 Compared to device that lists its YANG models in HELLO message, in this
296 case there would be no capability with ietf-inet-types in the HELLO
297 message. This type of device basically provides no information about the
298 YANG schemas it uses so its up to the user of OpenDaylight to properly
299 configure netconf-connector for this device.
301 Netconf-connector has an optional configuration attribute called
302 yang-module-capabilities and this attribute can contain a list of "YANG
303 module based" capabilities. So by setting this configuration attribute,
304 it is possible to override the "yang-module-based" capabilities reported
305 in HELLO message of the device. To do this, we need to modify the
306 configuration of netconf-connector like in the example below:
312 **Content-type:** ``application/xml``
314 **Accept:** ``application/xml``
316 **Authentication:** ``admin:admin``
320 <node xmlns="urn:TBD:params:xml:ns:yang:network-topology">
321 <node-id>r5</node-id>
322 <host xmlns="urn:opendaylight:netconf-node-topology">127.0.0.1</host>
323 <port xmlns="urn:opendaylight:netconf-node-topology">8305</port>
324 <login-password-unencrypted xmlns="urn:opendaylight:netconf-node-topology">
325 <username xmlns="urn:opendaylight:netconf-node-topology">root</username>
326 <password xmlns="urn:opendaylight:netconf-node-topology">root</password>
327 </login-password-unencrypted>
328 <tcp-only xmlns="urn:opendaylight:netconf-node-topology">false</tcp-only>
329 <keepalive-delay xmlns="urn:opendaylight:netconf-node-topology">30</keepalive-delay>
330 <yang-module-capabilities xmlns="urn:opendaylight:netconf-node-topology">
331 <override>true</override>
332 <capability xmlns="urn:opendaylight:netconf-node-topology">
333 urn:ietf:params:xml:ns:yang:ietf-inet-types?module=ietf-inet-types&revision=2013-07-15
335 </yang-module-capabilities>
340 **Content-type:** ``application/json``
342 **Accept:** ``application/json``
344 **Authentication:** ``admin:admin``
352 "netconf-node-topology:host": "127.0.0.1",
353 "netconf-node-topology:login-password-unencrypted": {
354 "netconf-node-topology:password": "root",
355 "netconf-node-topology:username": "root"
357 "netconf-node-topology:yang-module-capabilities": {
360 "urn:ietf:params:xml:ns:yang:ietf-inet-types?module=ietf-inet-types&revision=2013-07-15"
363 "netconf-node-topology:port": 8305,
364 "netconf-node-topology:tcp-only": false,
365 "netconf-node-topology:keepalive-delay": 30
370 **Remember to also put the YANG schemas into the cache folder.**
374 For putting multiple capabilities, you just need to replicate the
375 capability element inside yang-module-capability element.
376 Capability element is modeled as a leaf-list. With this
377 configuration, we would make the remote device report usage of
378 ietf-inet-types in the eyes of netconf-connector.
380 Connecting to a device supporting only NETCONF 1.0
381 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
383 OpenDaylight is schema-based distribution and heavily depends on YANG
384 models. However some legacy NETCONF devices are not schema-based and
385 implement just RFC 4741. This type of device does not utilize YANG
386 models internally and OpenDaylight does not know how to communicate
387 with such devices, how to validate data, or what the semantics of data
390 NETCONF connector can communicate also with these devices, but the
391 trade-offs are worsened possibilities in utilization of NETCONF
392 mountpoints. Using RESTCONF with such devices is not supported. Also
393 communicating with schemaless devices from application code is slightly
396 To connect to schemaless device, there is a optional configuration option
397 in netconf-node-topology model called schemaless. You have to set this
400 Clustered NETCONF connector
401 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
403 To spawn NETCONF connectors that are cluster-aware you need to install
404 the ``odl-netconf-clustered-topology`` karaf feature.
408 The ``odl-netconf-topology`` and ``odl-netconf-clustered-topology``
409 features are considered **INCOMPATIBLE**. They both manage the same
410 space in the datastore and would issue conflicting writes if
413 Configuration of clustered NETCONF connectors works the same as the
414 configuration through the topology model in the previous section.
416 When a new clustered connector is configured the configuration gets
417 distributed among the member nodes and a NETCONF connector is spawned on
418 each node. From these nodes a master is chosen which handles the schema
419 download from the device and all the communication with the device. You
420 will be able to read/write to/from the device from all slave nodes due
421 to the proxy data brokers implemented.
423 You can use the ``odl-netconf-clustered-topology`` feature in a single
424 node scenario as well but the code that uses akka will be used, so for a
425 scenario where only a single node is used, ``odl-netconf-topology``
428 Netconf-connector utilization
429 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
431 Once the connector is up and running, users can utilize the new mount
432 point instance. By using RESTCONF or from their application code. This
433 chapter deals with using RESTCONF and more information for app
434 developers can be found in the developers guide or in the official
435 tutorial application **ncmount** that can be found in the coretutorials
438 - https://github.com/opendaylight/coretutorials/tree/master/ncmount
440 Reading data from the device
441 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
443 Just invoke (no body needed):
446 http://localhost:8181/rests/data/network-topology:network-topology/topology=topology-netconf/node=new-netconf-device/yang-ext:mount?content=nonconfig
448 This will return the entire content of operation datastore from the
449 device. To view just the configuration datastore, change **nonconfig**
450 in this URL to **config**.
452 Writing configuration data to the device
453 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
455 In general, you cannot simply write any data you want to the device. The
456 data have to conform to the YANG models implemented by the device. In
457 this example we are adding a new interface-configuration to the mounted
458 device (assuming the device supports Cisco-IOS-XR-ifmgr-cfg YANG model).
459 In fact this request comes from the tutorial dedicated to the
460 **ncmount** tutorial app.
463 http://localhost:8181/rests/data/network-topology:network-topology/topology=topology-netconf/node=new-netconf-device/yang-ext:mount/Cisco-IOS-XR-ifmgr-cfg:interface-configurations
467 <interface-configuration xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg">
469 <interface-name>mpls</interface-name>
470 <description>Interface description</description>
471 <bandwidth>32</bandwidth>
472 <link-status></link-status>
473 </interface-configuration>
475 Should return 200 response code with no body.
479 This call is transformed into a couple of NETCONF RPCs. Resulting
480 NETCONF RPCs that go directly to the device can be found in the
481 OpenDaylight logs after invoking ``log:set TRACE
482 org.opendaylight.controller.sal.connect.netconf`` in the Karaf
483 shell. Seeing the NETCONF RPCs might help with debugging.
485 This request is very similar to the one where we spawned a new netconf
486 device. That’s because we used the loopback netconf-connector to write
487 configuration data into config-subsystem datastore and config-subsystem
488 picked it up from there.
493 Devices can implement any additional RPC and as long as it provides YANG
494 models for it, it can be invoked from OpenDaylight. Following example
495 shows how to invoke the get-schema RPC (get-schema is quite common among
496 netconf devices). Invoke:
499 http://localhost:8181/rests/operations/network-topology:network-topology/topology=topology-netconf/node=new-netconf-device/yang-ext:mount/ietf-netconf-monitoring:get-schema
503 <input xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring">
504 <identifier>ietf-yang-types</identifier>
505 <version>2013-07-15</version>
508 This call should fetch the source for ietf-yang-types YANG model from
511 Receiving Netconf Device Notifications on a http client
512 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
514 Devices emit netconf alarms and notifications in certain situations, which can demand
515 attention from Device Administration. The notifications are received as Netconf messages on an
516 active Netconf session.
518 Opendaylight provides the way to stream the device notifications over a http session.
520 - Step 1: Mount the device (assume node name is test_device)
522 - Step 2: Wait for the device to be connected.
524 - Step 3: Create the Subscription for notification on the active session.
529 http://localhost:8181/rests/operations/network-topology:network-topology/topology=topology-netconf/node=test_device/yang-ext:mount/notifications:create-subscription
530 Content-Type: application/json
531 Accept: application/json
541 - Step 4: Create the http Stream for the events.
546 http://localhost:8181/rests/operations/odl-device-notification:subscribe-device-notification
547 Content-Type: application/json
548 Accept: application/json
554 "path":"/network-topology:network-topology/topology[topology-id='topology-netconf']/node[node-id='test_device']"
558 The response suggests the http url for reading the notifications.
563 "odl-device-notification:output": {
564 "stream-path": "http://localhost:8181/rests/notif/test_device?notificationType=test_device"
568 - Step 5: User can access the url in the response and the notifications will be as follows.
573 http://localhost:8181/rests/notif/test_device?notificationType=test_device
574 Content-Type: application/xml
575 Accept: application/xml
590 data: <notification xmlns="urn:ietf:params:xml:ns:netconf:notification:1.0"><eventTime>2022-06-17T07:01:08.60228Z</eventTime><netconf-session-start xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-notifications"><username>root</username><source-host>127.0.0.1</source-host><session-id>2</session-id></netconf-session-start></notification>
592 data: <notification xmlns="urn:ietf:params:xml:ns:netconf:notification:1.0"><eventTime>2022-06-17T07:01:12.458258Z</eventTime><netconf-session-end xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-notifications"><username>root</username><source-host>127.0.0.1</source-host><termination-reason>closed</termination-reason><session-id>2</session-id></netconf-session-end></notification>
594 Change event notification subscription tutorial
595 -----------------------------------------------
597 Subscribing to data change notifications makes it possible to obtain
598 notifications about data manipulation (insert, change, delete) which are
599 done on any specified **path** of any specified **datastore** with
600 specific **scope**. In following examples *{odlAddress}* is address of
601 server where ODL is running and *{odlPort}* is port on which
602 OpenDaylight is running. OpenDaylight offers two methods for receiving notifications:
603 Server-Sent Events (SSE) and WebSocket. SSE is the default notification mechanism used in OpenDaylight.
605 SSE notifications subscription process
606 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
608 In this section we will learn what steps need to be taken in order to
609 successfully subscribe to data change event notifications.
614 In order to use event notifications you first need to call RPC that
615 creates notification stream that you can later listen to. You need to
616 provide three parameters to this RPC:
618 - **path**: data store path that you plan to listen to. You can
619 register listener on containers, lists and leaves.
621 - **datastore**: data store type. *OPERATIONAL* or *CONFIGURATION*.
623 - **scope**: Represents scope of data change. Possible options are:
625 - BASE: only changes directly to the data tree node specified in the
626 path will be reported
628 - ONE: changes to the node and to direct child nodes will be
631 - SUBTREE: changes anywhere in the subtree starting at the node will
634 The RPC to create the stream can be invoked via RESTCONF like this:
639 URI: http://{odlAddress}:{odlPort}/rests/operations/sal-remote:create-data-change-event-subscription
640 HEADER: Content-Type=application/json
641 Accept=application/json
647 "path": "/toaster:toaster/toaster:toasterStatus",
648 "sal-remote-augment:datastore": "OPERATIONAL",
649 "sal-remote-augment:scope": "ONE"
653 The response should look something like this:
658 "sal-remote:output": {
659 "stream-name": "data-change-event-subscription/toaster:toaster/toaster:toasterStatus/datastore=CONFIGURATION/scope=SUBTREE"
663 **stream-name** is important because you will need to use it when you
664 subscribe to the stream in the next step.
668 Internally, this will create a new listener for *stream-name* if it
669 did not already exist.
674 In order to subscribe to stream and obtain SSE location you need
675 to call *GET* on your stream path. The URI should generally be
676 `http://{odlAddress}:{odlPort}/rests/data/ietf-restconf-monitoring:restconf-state/streams/stream/{streamName}`,
677 where *{streamName}* is the *stream-name* parameter contained in
678 response from *create-data-change-event-subscription* RPC from the
684 URI: http://{odlAddress}:{odlPort}/rests/data/ietf-restconf-monitoring:restconf-state/streams/stream/data-change-event-subscription/toaster:toaster/datastore=CONFIGURATION/scope=SUBTREE
686 The subscription call may be modified with the following query parameters defined in the RESTCONF RFC:
688 - `filter <https://www.rfc-editor.org/rfc/rfc8040#section-4.8.4>`__
690 - `start-time <https://www.rfc-editor.org/rfc/rfc8040#section-4.8.7>`__
692 - `end-time <https://www.rfc-editor.org/rfc/rfc8040#section-4.8.8>`__
694 In addition, the following ODL extension query parameter is supported:
696 :odl-leaf-nodes-only:
697 If this parameter is set to "true", create and update notifications will only
698 contain the leaf nodes modified instead of the entire subscription subtree.
699 This can help in reducing the size of the notifications.
701 :odl-skip-notification-data:
702 If this parameter is set to "true", create and update notifications will only
703 contain modified leaf nodes without data.
704 This can help in reducing the size of the notifications.
706 The response should look something like this:
711 "subscribe-to-notification:location": "http://localhost:8181/rests/notif/data-change-event-subscription/network-topology:network-topology/datastore=CONFIGURATION/scope=SUBTREE"
716 During this phase there is an internal check for to see if a
717 listener for the *stream-name* from the URI exists. If not, new a
718 new listener is registered with the DOM data broker.
720 Receive notifications
721 ^^^^^^^^^^^^^^^^^^^^^
723 Once you got SSE location you can now connect to it and
724 start receiving data change events. The request should look something like this:
728 curl -v -X GET http://localhost:8181/rests/notif/data-change-event-subscription/toaster:toaster/toasterStatus/datastore=OPERATIONAL/scope=ONE -H "Content-Type: text/event-stream" -H "Authorization: Basic YWRtaW46YWRtaW4="
731 WebSocket notifications subscription process
732 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
734 Enabling WebSocket notifications in OpenDaylight requires a manual setup before starting the application.
735 The following steps can be followed to enable WebSocket notifications in OpenDaylight:
737 1. Open the file `restconf8040.cfg`, at `etc/` folder inside your Karaf distribution.
738 2. Locate the `use-sse` configuration parameter and change its value from `true` to `false`.
739 3. Uncomment the `use-sse` parameter if it is commented out.
740 4. Save the changes made to the `restconf8040.cfg` file.
741 5. Restart OpenDaylight if it is already running.
743 Once these steps are completed, WebSocket notifications will be enabled in OpenDaylight,
744 and they can be used for receiving notifications instead of SSE.
746 WebSocket Notifications subscription process is the same as SSE until you receive a location of WebSocket.
747 You can follow steps given above and after subscribing to a notification stream over WebSocket,
748 you will receive a response indicating that the subscription was successful:
753 "subscribe-to-notification:location": "ws://localhost:8181/rests/notif/data-change-event-subscription/network-topology:network-topology/datastore=CONFIGURATION/scope=SUBTREE"
756 You can use this WebSocket to listen to data
757 change notifications. To listen to notifications you can use a
758 JavaScript client or if you are using chrome browser you can use the
760 Client <https://chrome.google.com/webstore/detail/simple-websocket-client/pfdhoblngboilpfeibdedpjgfnlcodoo>`__.
762 Also, for testing purposes, there is simple Java application named
763 WebSocketClient. The application is placed in the
764 */restconf/websocket-client* project. It accepts a WebSocket URI
765 as an input parameter. After starting the utility (WebSocketClient
766 class directly in Eclipse/InteliJ Idea) received notifications should be
767 displayed in console.
769 Notifications are always in XML format and look like this:
773 <notification xmlns="urn:ietf:params:xml:ns:netconf:notification:1.0">
774 <eventTime>2014-09-11T09:58:23+02:00</eventTime>
775 <data-changed-notification xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote">
777 <path xmlns:meae="http://netconfcentral.org/ns/toaster">/meae:toaster</path>
778 <operation>updated</operation>
780 <!-- updated data -->
783 </data-changed-notification>
789 The typical use case is listening to data change events to update web
790 page data in real time. In this tutorial we will be using toaster as the
793 When you call *make-toast* RPC, it sets *toasterStatus* to "down" to
794 reflect that the toaster is busy making toast. When it finishes,
795 *toasterStatus* is set to "up" again. We will listen to these toaster
796 status changes in data store and will reflect it on our web page in
797 real-time thanks to WebSocket data change notification.
799 Simple javascript client implementation
800 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
802 We will create a simple JavaScript web application that will listen for
803 updates on *toasterStatus* leaf and update some elements of our web page
804 according to the new toaster status state.
809 First you need to create stream that you are planning to subscribe to.
810 This can be achieved by invoking "create-data-change-event-subscription"
811 RPC on RESTCONF via AJAX request. You need to provide data store
812 **path** that you plan to listen on, **data store type** and **scope**.
813 If the request is successful you can extract the **stream-name** from
814 the response and use that to subscribe to the newly created stream. The
815 *{username}* and *{password}* fields represent the credentials that you
816 use to connect to OpenDaylight via RESTCONF:
820 The default user name and password are "admin".
822 .. code-block:: javascript
824 function createStream() {
827 url: 'http://{odlAddress}:{odlPort}/rests/operations/sal-remote:create-data-change-event-subscription',
830 'Authorization': 'Basic ' + btoa('{username}:{password}'),
831 'Content-Type': 'application/json'
833 data: JSON.stringify(
836 'path': '/toaster:toaster/toaster:toasterStatus',
837 'sal-remote-augment:datastore': 'OPERATIONAL',
838 'sal-remote-augment:scope': 'ONE'
842 }).done(function (data) {
843 // this function will be called when ajax call is executed successfully
844 subscribeToStream(data.output['stream-name']);
845 }).fail(function (data) {
846 // this function will be called when ajax call fails
847 console.log("Create stream call unsuccessful");
854 The Next step is to subscribe to the stream. To subscribe to the stream
855 you need to call *GET* on
856 *http://{odlAddress}:{odlPort}/rests/data/ietf-restconf-monitoring:restconf-state/streams/stream/{stream-name}*.
857 If the call is successful, you get WebSocket address for this stream in
858 **Location** parameter inside response header. You can get response
859 header by calling *getResponseHeader(\ *Location*)* on HttpRequest
860 object inside *done()* function call:
862 .. code-block:: javascript
864 function subscribeToStream(streamName) {
867 url: 'http://{odlAddress}:{odlPort}/rests/data/ietf-restconf-monitoring:restconf-state/streams/stream/' + streamName;
870 'Authorization': 'Basic ' + btoa('{username}:{password}'),
873 ).done(function (data, textStatus, httpReq) {
874 // we need function that has http request object parameter in order to access response headers.
875 listenToNotifications(httpReq.getResponseHeader('Location'));
876 }).fail(function (data) {
877 console.log("Subscribe to stream call unsuccessful");
881 Receive notifications
882 ^^^^^^^^^^^^^^^^^^^^^
884 Once you have WebSocket server location you can now connect to it and
885 start receiving data change events. You need to define functions that
886 will handle events on WebSocket. In order to process incoming events
887 from OpenDaylight you need to provide a function that will handle
888 *onmessage* events. The function must have one parameter that represents
889 the received event object. The event data will be stored in
890 *event.data*. The data will be in an XML format that you can then easily
893 .. code-block:: javascript
895 function listenToNotifications(socketLocation) {
897 var notificatinSocket = new WebSocket(socketLocation);
899 notificatinSocket.onmessage = function (event) {
900 // we process our received event here
901 console.log('Received toaster data change event.');
902 $($.parseXML(event.data)).find('data-change-event').each(
904 var operation = $(this).find('operation').text();
905 if (operation == 'updated') {
906 // toaster status was updated so we call function that gets the value of toasterStatus leaf
907 updateToasterStatus();
913 notificatinSocket.onerror = function (error) {
914 console.log("Socket error: " + error);
916 notificatinSocket.onopen = function (event) {
917 console.log("Socket connection opened.");
919 notificatinSocket.onclose = function (event) {
920 console.log("Socket connection closed.");
922 // if there is a problem on socket creation we get exception (i.e. when socket address is incorrect)
924 alert("Error when creating WebSocket" + e );
928 The *updateToasterStatus()* function represents function that calls
929 *GET* on the path that was modified and sets toaster status in some web
930 page element according to received data. After the WebSocket connection
931 has been established you can test events by calling make-toast RPC via
936 for more information about WebSockets in JavaScript visit `Writing
938 applications <https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API/Writing_WebSocket_client_applications>`__
940 Netconf-connector + Netopeer
941 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
943 `Netopeer <https://github.com/cesnet/netopeer>`__ (an open-source
944 NETCONF server) can be used for testing/exploring NETCONF southbound in
947 Netopeer installation
948 ^^^^^^^^^^^^^^^^^^^^^
950 A `Docker <https://www.docker.com/>`__ container with netopeer will be
951 used in this guide. To install Docker and start the `netopeer
952 image <https://hub.docker.com/r/sysrepo/sysrepo-netopeer2>`__ perform
955 1. Install docker https://docs.docker.com/get-started/
957 2. Start the netopeer image:
961 docker run -it --name sysrepo -p 830:830 --rm sysrepo/sysrepo-netopeer2:latest
963 3. Verify netopeer is running by invoking (netopeer should send its
964 HELLO message right away:
968 ssh root@localhost -p 830 -s netconf
971 Mounting netopeer NETCONF server
972 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
976 - OpenDaylight is started with features ``odl-restconf-all`` and
977 ``odl-netconf-connector-all``.
979 - Netopeer is up and running in docker
981 Now just follow the section: `Spawning new NETCONF connectors`_.
982 In the payload change the:
984 - name, e.g., to netopeer
986 - username/password to your system credentials
992 After netopeer is mounted successfully, its configuration can be read
993 using RESTCONF by invoking:
996 http://localhost:8181/rests/data/network-topology:network-topology/topology=topology-netconf/node=netopeer/yang-ext:mount?content:config
998 Northbound (NETCONF servers)
999 ----------------------------
1001 OpenDaylight provides 2 types of NETCONF servers:
1003 - **NETCONF server for config-subsystem (listening by default on port
1006 - Serves as a default interface for config-subsystem and allows
1007 users to spawn/reconfigure/destroy modules (or applications) in
1010 - **NETCONF server for MD-SAL (listening by default on port 2830)**
1012 - Serves as an alternative interface for MD-SAL (besides RESTCONF)
1013 and allows users to read/write data from MD-SAL’s datastore and to
1014 invoke its rpcs (NETCONF notifications are not available in the
1015 Boron release of OpenDaylight)
1019 The reason for having 2 NETCONF servers is that config-subsystem and
1020 MD-SAL are 2 different components of OpenDaylight and require
1021 different approaches for NETCONF message handling and data
1022 translation. These 2 components will probably merge in the future.
1026 Since Nitrogen release, there has been performance regression in NETCONF
1027 servers accepting SSH connections. While opening a connection takes
1028 less than 10 seconds on Carbon, on Nitrogen time can increase up to
1029 60 seconds. Please see https://jira.opendaylight.org/browse/ODLPARENT-112
1031 NETCONF server for config-subsystem
1032 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1034 This NETCONF server is the primary interface for config-subsystem. It
1035 allows the users to interact with config-subsystem in a standardized
1038 In terms of RFCs, these are supported:
1040 - `RFC-6241 <https://www.rfc-editor.org/rfc/rfc6241>`__
1042 - `RFC-5277 <https://www.rfc-editor.org/rfc/rfc5277>`__
1044 - `RFC-6470 <https://www.rfc-editor.org/rfc/rfc6470>`__
1046 - (partially, only the schema-change notification is available in
1049 - `RFC-6022 <https://www.rfc-editor.org/rfc/rfc6022>`__
1051 For regular users it is recommended to use RESTCONF + the
1052 controller-config loopback mountpoint instead of using pure NETCONF. How
1053 to do that is specific for each component/module/application in
1054 OpenDaylight and can be found in their dedicated user guides.
1056 NETCONF server for MD-SAL
1057 ~~~~~~~~~~~~~~~~~~~~~~~~~
1059 This NETCONF server is just a generic interface to MD-SAL in
1060 OpenDaylight. It uses the standard MD-SAL APIs and serves as an
1061 alternative to RESTCONF. It is fully model-driven and supports any data
1062 and rpcs that are supported by MD-SAL.
1064 In terms of RFCs, these are supported:
1066 - `RFC-6241 <https://www.rfc-editor.org/rfc/rfc6241>`__
1068 - `RFC-6022 <https://www.rfc-editor.org/rfc/rfc6022>`__
1070 - `RFC-7895 <https://www.rfc-editor.org/rfc/rfc7895>`__
1072 Notifications over NETCONF are not supported in the Boron release.
1076 Install NETCONF northbound for MD-SAL by installing feature:
1077 ``odl-netconf-mdsal`` in karaf. Default binding port is **2830**.
1082 The default configuration can be found in file: *08-netconf-mdsal.xml*.
1083 The file contains the configuration for all necessary dependencies and a
1084 single SSH endpoint starting on port 2830. There is also a (by default
1085 disabled) TCP endpoint. It is possible to start multiple endpoints at
1086 the same time either in the initial configuration file or while
1087 OpenDaylight is running.
1089 The credentials for SSH endpoint can also be configured here, the
1090 defaults are admin/admin. Credentials in the SSH endpoint are not yet
1091 managed by the centralized AAA component and have to be configured
1094 Verifying MD-SAL’s NETCONF server
1095 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1097 After the NETCONF server is available it can be examined by a command
1102 ssh admin@localhost -p 2830 -s netconf
1104 The server will respond by sending its HELLO message and can be used as
1105 a regular NETCONF server from then on.
1107 Mounting the MD-SAL’s NETCONF server
1108 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1110 To perform this operation, just spawn a new netconf-connector as
1111 described in `Spawning new NETCONF connectors`_. Just change the ip to
1112 "127.0.0.1" port to "2830" and its name to "controller-mdsal".
1114 Now the MD-SAL’s datastore can be read over RESTCONF via NETCONF by
1118 http://localhost:8181/rests/data/network-topology:network-topology/topology=topology-netconf/node=controller-mdsal/yang-ext:mount?content:nonconfig
1122 This might not seem very useful, since MD-SAL can be accessed
1123 directly from RESTCONF or from Application code, but the same method
1124 can be used to mount and control other OpenDaylight instances by the
1125 "master OpenDaylight".
1127 NETCONF stress/performance measuring tool
1128 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1130 This is basically a NETCONF client that puts NETCONF servers under heavy
1131 load of NETCONF RPCs and measures the time until a configurable amount
1132 of them is processed.
1134 RESTCONF stress-performance measuring tool
1135 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1137 Very similar to NETCONF stress tool with the difference of using
1138 RESTCONF protocol instead of NETCONF.
1140 YANGLIB remote repository
1141 -------------------------
1143 There are scenarios in NETCONF deployment, that require for a centralized
1144 YANG models repository. YANGLIB plugin provides such remote repository.
1146 To start this plugin, you have to install odl-yanglib feature. Then you
1147 have to configure YANGLIB either through RESTCONF or NETCONF. We will
1148 show how to configure YANGLIB through RESTCONF.
1150 YANGLIB configuration
1151 ~~~~~~~~~~~~~~~~~~~~~
1152 YANGLIB configuration works through OSGi Configuration Admin interface, in the
1153 ``org.opendaylight.netconf.yanglib`` configuration PID. There are three tuneables you can
1156 * ``cache-folder``, which defaults to ``cache/schema``
1157 * ``binding-address``, which defaults to ``localhost``
1158 * ``binding-port``, which defaults to ``8181``
1160 In order to change these settings, you can either modify the corresponding configuration
1161 file, ``etc/org.opendaylight.netconf.yanglib.cfg``, for example:
1164 cache-folder = cache/newSchema
1165 binding-address = localhost
1171 opendaylight-user@root>config:edit org.opendaylight.netconf.yanglib
1172 opendaylight-user@root>config:property-set cache-folder cache/newSchema
1173 opendaylight-user@root>config:property-set binding-address localhost
1174 opendaylight-user@root>config:property-set binding-port 8181
1175 opendaylight-user@root>config:update
1177 This YANGLIB takes all YANG sources from the configured sources folder and
1178 for each generates URL in form:
1182 http://localhost:8181/yanglib/schemas/{modelName}/{revision}
1184 On this URL will be hosted YANG source for particular module.
1186 YANGLIB instance also writes this URL along with source identifier to
1187 ietf-netconf-yang-library/modules-state/module list.
1189 Netconf-connector with YANG library as fallback
1190 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1192 There is an optional configuration in netconf-connector called
1193 yang-library. You can specify YANG library to be plugged as additional
1194 source provider into the mount's schema repository. Since YANGLIB
1195 plugin is advertising provided modules through yang-library model, we
1196 can use it in mount point's configuration as YANG library. To do this,
1197 we need to modify the configuration of netconf-connector by adding this
1202 <yang-library xmlns="urn:opendaylight:netconf-node-topology">
1203 <yang-library-url xmlns="urn:opendaylight:netconf-node-topology">http://localhost:8181/rests/data/ietf-yang-library:modules-state</yang-library-url>
1204 <username xmlns="urn:opendaylight:netconf-node-topology">admin</username>
1205 <password xmlns="urn:opendaylight:netconf-node-topology">admin</password>
1208 This will register YANGLIB provided sources as a fallback schemas for
1209 particular mount point.
1214 Call Home Installation
1215 ~~~~~~~~~~~~~~~~~~~~~~
1217 ODL Call-Home server is installed in Karaf by installing karaf feature
1218 ``odl-netconf-callhome-ssh``. RESTCONF feature is recommended for
1219 configuring Call Home & testing its functionality.
1223 feature:install odl-netconf-callhome-ssh
1228 In order to test Call Home functionality we recommend Netopeer or
1229 Netopeer2. See `Netopeer Call Home <https://github.com/CESNET/netopeer/wiki/CallHome>`__
1230 or `Netopeer2 <https://github.com/CESNET/netopeer2>`__ to learn how to
1231 enable call-home on Netopeer.
1233 Northbound Call-Home API
1234 ~~~~~~~~~~~~~~~~~~~~~~~~
1236 The northbound Call Home API is used for administering the Call-Home Server. The
1237 following describes this configuration.
1239 Global Configuration
1240 ^^^^^^^^^^^^^^^^^^^^
1243 The global configuration is not a part of the `RFC 8071
1244 <https://www.rfc-editor.org/rfc/rfc8071>`__ and, therefore, subject to change.
1246 Configuring global credentials
1247 ''''''''''''''''''''''''''''''
1249 The ODL Call-Home server allows user to configure global credentials, which will be
1250 used for devices connecting over SSH transport protocol that do not have
1251 device-specific credentials configured.
1253 This is done by creating
1254 ``/odl-netconf-callhome-server:netconf-callhome-server/global/credentials``
1255 with username and passwords specified.
1257 *Configuring global username & passwords to try*
1262 /rests/data/odl-netconf-callhome-server:netconf-callhome-server/global/credentials
1263 Content-Type: application/json
1264 Accept: application/json
1266 .. code-block:: json
1271 "username": "example",
1272 "passwords": [ "first-password-to-try", "second-password-to-try" ]
1276 Configuring to accept any ssh server key using global credentials
1277 '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
1279 By default Netconf Call-Home Server accepts only incoming connections
1280 from allowed devices
1281 ``/odl-netconf-callhome-server:netconf-callhome-server/allowed-devices``,
1282 if user desires to allow all incoming connections, it is possible to set
1283 ``accept-all-ssh-keys`` to ``true`` in
1284 ``/odl-netconf-callhome-server:netconf-callhome-server/global``.
1286 The name of these devices in ``netconf-topology`` will be in format
1287 ``ip-address:port``. For naming devices see Device-Specific
1290 *Allowing unknown devices to connect*
1292 This is a debug feature and should not be used in production. Besides being an obvious
1293 security issue, this also causes the Call-Home Server to drastically increase its output
1299 /rests/data/odl-netconf-callhome-server:netconf-callhome-server/global/accept-all-ssh-keys
1300 Content-Type: application/json
1301 Accept: application/json
1303 .. code-block:: json
1306 "accept-all-ssh-keys": "true"
1309 Device-Specific Configuration
1310 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1312 Netconf Call Home server supports both of the secure transports used
1313 by the Network Configuration Protocol (NETCONF) - Secure Shell (SSH),
1314 and Transport Layer Security (TLS).
1316 Configure device to connect over SSH protocol
1317 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1319 Netconf Call Home Server uses device provided SSH server key (host key)
1320 to identify device. The pairing of name and server key is configured in
1321 ``/odl-netconf-callhome-server:netconf-callhome-server/allowed-devices``.
1322 This list is colloquially called a allowlist.
1324 If the Call-Home Server finds the SSH host key in the allowlist, it continues
1325 to negotiate a NETCONF connection over an SSH session. If the SSH host key is
1326 not found, the connection between the Call Home server and the device is dropped
1327 immediately. In either case, the device that connects to the Call home server
1328 leaves a record of its presence in the operational store.
1330 Configuring Device with Device-specific Credentials
1331 '''''''''''''''''''''''''''''''''''''''''''''''''''
1333 Adding specific device to the allowed list is done by creating
1334 ``/odl-netconf-callhome-server:netconf-callhome-server/allowed-devices/device={device}``
1335 with device-id and connection parameters inside the ssh-client-params container.
1337 *Configuring Device with Credentials*
1342 /rests/data/odl-netconf-callhome-server:netconf-callhome-server/allowed-devices/device=example
1343 Content-Type: application/json
1344 Accept: application/json
1346 .. code-block:: json
1350 "unique-id": "example",
1351 "ssh-client-params": {
1353 "username": "example",
1354 "passwords": [ "password" ]
1356 "host-key": "AAAAB3NzaC1yc2EAAAADAQABAAABAQDHoH1jMjltOJnCt999uaSfc48ySutaD3ISJ9fSECe1Spdq9o9mxj0kBTTTq+2V8hPspuW75DNgN+V/rgJeoUewWwCAasRx9X4eTcRrJrwOQKzb5Fk+UKgQmenZ5uhLAefi2qXX/agFCtZi99vw+jHXZStfHm9TZCAf2zi+HIBzoVksSNJD0VvPo66EAvLn5qKWQD4AdpQQbKqXRf5/W8diPySbYdvOP2/7HFhDukW8yV/7ZtcywFUIu3gdXsrzwMnTqnATSLPPuckoi0V2jd8dQvEcu1DY+rRqmqu0tEkFBurlRZDf1yhNzq5xWY3OXcjgDGN+RxwuWQK3cRimcosH"
1361 Configuring Device with Global Credentials
1362 '''''''''''''''''''''''''''''''''''''''''''''''''''
1364 It is possible to omit ``username`` and ``password`` for ssh-client-params,
1365 in such case values from global credentials will be used.
1367 *Example of configuring device*
1372 /rests/data/odl-netconf-callhome-server:netconf-callhome-server/allowed-devices/device=example
1373 Content-Type: application/json
1374 Accept: application/json
1376 .. code-block:: json
1380 "unique-id": "example",
1381 "ssh-client-params": {
1382 "host-key": "AAAAB3NzaC1yc2EAAAADAQABAAABAQDHoH1jMjltOJnCt999uaSfc48ySutaD3ISJ9fSECe1Spdq9o9mxj0kBTTTq+2V8hPspuW75DNgN+V/rgJeoUewWwCAasRx9X4eTcRrJrwOQKzb5Fk+UKgQmenZ5uhLAefi2qXX/agFCtZi99vw+jHXZStfHm9TZCAf2zi+HIBzoVksSNJD0VvPo66EAvLn5qKWQD4AdpQQbKqXRf5/W8diPySbYdvOP2/7HFhDukW8yV/7ZtcywFUIu3gdXsrzwMnTqnATSLPPuckoi0V2jd8dQvEcu1DY+rRqmqu0tEkFBurlRZDf1yhNzq5xWY3OXcjgDGN+RxwuWQK3cRimcosH"
1387 Deprecated configuration models for devices accessed with SSH protocol
1388 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
1390 With `RFC 8071 <https://www.rfc-editor.org/rfc/rfc8071>`__ alignment and adding
1391 support for TLS transport following configuration models have been marked
1394 Configuring Device with Global Credentials
1395 '''''''''''''''''''''''''''''''''''''''''''''''''''
1397 *Example of configuring device*
1402 /rests/data/odl-netconf-callhome-server:netconf-callhome-server/allowed-devices/device=example
1403 Content-Type: application/json
1404 Accept: application/json
1406 .. code-block:: json
1410 "unique-id": "example",
1411 "ssh-host-key": "AAAAB3NzaC1yc2EAAAADAQABAAABAQDHoH1jMjltOJnCt999uaSfc48ySutaD3ISJ9fSECe1Spdq9o9mxj0kBTTTq+2V8hPspuW75DNgN+V/rgJeoUewWwCAasRx9X4eTcRrJrwOQKzb5Fk+UKgQmenZ5uhLAefi2qXX/agFCtZi99vw+jHXZStfHm9TZCAf2zi+HIBzoVksSNJD0VvPo66EAvLn5qKWQD4AdpQQbKqXRf5/W8diPySbYdvOP2/7HFhDukW8yV/7ZtcywFUIu3gdXsrzwMnTqnATSLPPuckoi0V2jd8dQvEcu1DY+rRqmqu0tEkFBurlRZDf1yhNzq5xWY3OXcjgDGN+RxwuWQK3cRimcosH"
1415 Configuring Device with Device-specific Credentials
1416 '''''''''''''''''''''''''''''''''''''''''''''''''''
1418 Call Home Server also allows the configuration of credentials per device basis.
1419 This is done by introducing ``credentials`` container into the
1420 device-specific configuration. Format is same as in global credentials.
1422 *Configuring Device with Credentials*
1427 /rests/data/odl-netconf-callhome-server:netconf-callhome-server/allowed-devices/device=example
1428 Content-Type: application/json
1429 Accept: application/json
1431 .. code-block:: json
1435 "unique-id": "example",
1437 "username": "example",
1438 "passwords": [ "password" ]
1440 "ssh-host-key": "AAAAB3NzaC1yc2EAAAADAQABAAABAQDHoH1jMjltOJnCt999uaSfc48ySutaD3ISJ9fSECe1Spdq9o9mxj0kBTTTq+2V8hPspuW75DNgN+V/rgJeoUewWwCAasRx9X4eTcRrJrwOQKzb5Fk+UKgQmenZ5uhLAefi2qXX/agFCtZi99vw+jHXZStfHm9TZCAf2zi+HIBzoVksSNJD0VvPo66EAvLn5qKWQD4AdpQQbKqXRf5/W8diPySbYdvOP2/7HFhDukW8yV/7ZtcywFUIu3gdXsrzwMnTqnATSLPPuckoi0V2jd8dQvEcu1DY+rRqmqu0tEkFBurlRZDf1yhNzq5xWY3OXcjgDGN+RxwuWQK3cRimcosH"
1444 Configure device to connect over TLS protocol
1445 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1447 Netconf Call Home Server allows devices to use TLS transport protocol to
1448 establish a connection towards the NETCONF device. This communication
1449 requires proper setup to make two-way TLS authentication possible for client
1452 The initial step is to configure certificates and keys for two-way TLS by
1453 storing them within the netconf-keystore.
1455 *Adding a client private key credential to the netconf-keystore*
1460 /rests/operations/netconf-keystore:add-keystore-entry
1461 Content-Type: application/json
1462 Accept: application/json
1464 .. code-block:: json
1470 "key-id": "example-client-key-id",
1471 "private-key": "base64encoded-private-key",
1472 "passphrase": "passphrase"
1478 *Associate a private key with a client and CA certificates chain*
1483 /rests/operations/netconf-keystore:add-private-key
1484 Content-Type: application/json
1485 Accept: application/json
1487 .. code-block:: json
1493 "name": "example-client-key-id",
1495 "certificate-chain": [
1503 *Add a list of trusted CA and server certificates*
1508 /rests/operations/netconf-keystore:add-trusted-certificate
1509 Content-Type: application/json
1510 Accept: application/json
1512 .. code-block:: json
1516 "trusted-certificate": [
1518 "name": "example-ca-certificate",
1519 "certificate": "ca-certificate-data"
1522 "name": "example-server-certificate",
1523 "certificate": "server-certificate-data"
1529 In a second step, it is required to create an allowed device associated with
1530 a server certificate and client key. The server certificate will be used to
1531 identify and pin the NETCONF device during SSL handshake and should be unique
1532 among the allowed devices.
1534 *Add device configuration for TLS protocol to allowed devices list*
1539 /rests/data/odl-netconf-callhome-server:netconf-callhome-server/allowed-devices/device=example-device
1540 Content-Type: application/json
1541 Accept: application/json
1543 .. code-block:: json
1547 "unique-id": "example-device",
1548 "tls-client-params": {
1549 "key-id": "example-client-key-id",
1550 "certificate-id": "example-server-certificate"
1558 Once an entry is made on the config side of "allowed-devices", the Call-Home Server will
1559 populate a corresponding operational device that is the same as the config device but
1560 has an additional status. By default, this status is *DISCONNECTED*. Once a device calls
1561 home, this status will change to one of:
1563 *CONNECTED* — The device is currently connected and the NETCONF mount is available for network
1566 *FAILED_AUTH_FAILURE* — The last attempted connection was unsuccessful because the Call-Home
1567 Server was unable to provide the acceptable credentials of the device. The device is also
1568 disconnected and not available for network management.
1570 *FAILED_NOT_ALLOWED* — The last attempted connection was unsuccessful because the device was
1571 not recognized as an acceptable device. The device is also disconnected and not available for
1574 *FAILED* — The last attempted connection was unsuccessful for a reason other than not
1575 allowed to connect or incorrect client credentials. The device is also disconnected and not
1576 available for network management.
1578 *DISCONNECTED* — The device is currently disconnected.
1583 Devices that are not on the allowlist might try to connect to the Call-Home Server. In
1584 these cases, the server will keep a record by instantiating an operational device. There
1585 will be no corresponding config device for these rogues. They can be identified readily
1586 because their device id, rather than being user-supplied, will be of the form
1587 "address:port". Note that if a device calls back multiple times, there will only be
1588 a single operatinal entry (even if the port changes); these devices are recognized by
1589 their unique host key.
1591 Southbound Call-Home API
1592 ~~~~~~~~~~~~~~~~~~~~~~~~
1594 The Call-Home Server listens for incoming TCP connections and assumes that the other side of
1595 the connection is a device calling home via a NETCONF connection with SSH for
1596 management. The server uses port 4334 by default and this can be configured via a
1597 blueprint configuration file.
1599 The device **must** initiate the connection and the server will not try to re-establish the
1600 connection in case of a drop. By requirement, the server cannot assume it has connectivity
1601 to the device due to NAT or firewalls among others.
1603 Reading data with selected fields
1604 ---------------------------------
1609 If user would like to read only selected fields from a NETCONF device, it is possible to use
1610 the fields query parameter that is described by RFC-8040. RESTCONF parses content of query
1611 parameter into format that is accepted by NETCONF subtree filtering - filtering of data is done
1612 on NETCONF server, not on NETCONF client side. This approach optimizes network traffic load,
1613 because data in which user doesn't have interest, is not transferred over network.
1617 * using single RESTCONF request and single NETCONF RPC for reading multiple subtrees
1618 * possibility to read only selected fields under list node across multiple hierarchies
1619 (it cannot be done without proper selection API)
1623 More information about fields query parameter: `RFC 8071 <https://www.rfc-editor.org/rfc/rfc8040#section-4.8.3>`__
1628 For demonstration, we will define next YANG model:
1632 module test-module {
1634 namespace "urn:opendaylight:test-module";
1636 revision "2023-02-16";
1639 container simple-root {
1659 container list-root {
1672 container next-data {
1694 Follow the :doc:`testtool` instructions to save this schema and run it with testtool.
1696 Mounting NETCONF device that runs on NETCONF testtool:
1698 .. code-block:: bash
1700 curl --location --request PUT 'http://127.0.0.1:8181/rests/data/network-topology:network-topology/topology=topology-netconf/node=testtool' \
1701 --header 'Authorization: Basic YWRtaW46YWRtaW4=' \
1702 --header 'Content-Type: application/json' \
1706 "node-id": "testtool",
1707 "netconf-node-topology:host": "127.0.0.1",
1708 "netconf-node-topology:port": 17830,
1709 "netconf-node-topology:keepalive-delay": 100,
1710 "netconf-node-topology:tcp-only": false,
1711 "netconf-node-topology:login-password-unencrypted": {
1712 "netconf-node-topology:username": "admin",
1713 "netconf-node-topology:password": "admin"
1719 Setting initial configuration on NETCONF device:
1721 .. code-block:: bash
1723 curl --location --request PUT 'http://127.0.0.1:8181/rests/data/network-topology:network-topology/topology=topology-netconf/node=testtool/yang-ext:mount/test-module:root' \
1724 --header 'Authorization: Basic YWRtaW46YWRtaW4=' \
1725 --header 'Content-Type: application/json' \
1824 1. Reading whole leaf-list 'll' and leaf 'nested/sample-x' under 'simple-root' container.
1828 .. code-block:: bash
1830 curl --location --request GET 'http://localhost:8181/rests/data/network-topology:network-topology/topology=topology-netconf/node=testtool/yang-ext:mount/test-module:root/simple-root?content=config&fields=ll;nested/sample-x' \
1831 --header 'Authorization: Basic YWRtaW46YWRtaW4=' \
1832 --header 'Cookie: JSESSIONID=node01h4w82eorc1k61866b71qjgj503.node0'
1834 Generated NETCONF RPC request:
1838 <rpc message-id="m-18" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
1843 <filter xmlns:ns0="urn:ietf:params:xml:ns:netconf:base:1.0" ns0:type="subtree">
1844 <root xmlns="urn:ietf:params:xml:ns:yang:test-model">
1858 Using fields query parameter it is also possible to read whole leaf-list or list without
1859 necessity to specify value / key predicate (without reading parent entity). Such scenario
1860 is not permitted in RFC-8040 paths alone - fields query parameter can be used as
1861 workaround for this case.
1865 .. code-block:: json
1868 "test-module:simple-root": {
1880 2. Reading all identifiers of 'nested-list' under all elements of 'top-list'.
1884 .. code-block:: bash
1886 curl --location --request GET 'http://localhost:8181/rests/data/network-topology:network-topology/topology=topology-netconf/node=testtool/yang-ext:mount/test-module:root/list-root?content=config&fields=top-list(nested-list/identifier)' \
1887 --header 'Authorization: Basic YWRtaW46YWRtaW4=' \
1888 --header 'Cookie: JSESSIONID=node01h4w82eorc1k61866b71qjgj503.node0'
1890 Generated NETCONF RPC request:
1894 <rpc message-id="m-27" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
1899 <filter xmlns:ns0="urn:ietf:params:xml:ns:netconf:base:1.0" ns0:type="subtree">
1900 <root xmlns="urn:ietf:params:xml:ns:yang:test-model">
1917 NETCONF client automatically fetches values of list keys since they are required for correct
1918 deserialization of NETCONF response and at the end serialization of response to RESTCONF
1919 response (JSON/XML).
1923 .. code-block:: json
1926 "test-module:list-root": {
1977 3. Reading value of leaf 'branch-ab' and all values of leaves 'switch-1' that are placed
1978 under 'top-list' list elements.
1982 .. code-block:: bash
1984 curl --location --request GET 'http://localhost:8181/rests/data/network-topology:network-topology/topology=topology-netconf/node=testtool/yang-ext:mount/test-module:root/list-root?content=config&fields=branch-ab;top-list/next-data/switch-1' \
1985 --header 'Authorization: Basic YWRtaW46YWRtaW4=' \
1986 --header 'Cookie: JSESSIONID=node01jx6o5thwae9t1ft7c2zau5zbz4.node0'
1988 Generated NETCONF RPC request:
1992 <rpc message-id="m-42" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
1997 <filter xmlns:ns0="urn:ietf:params:xml:ns:netconf:base:1.0" ns0:type="subtree">
1998 <root xmlns="urn:ietf:params:xml:ns:yang:test-model">
2016 .. code-block:: json
2019 "test-module:list-root": {
2054 The OpenAPI provides full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).
2055 For operational data we only provide GET API. For the majority of requests you can see only config data in examples.
2056 That’s because we can show only one example per request. The exception when you can see operational data in an
2057 example is when data are representing an operational (config false) container with no config data in it.
2060 Using the OpenAPI Explorer through HTTP
2061 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2063 1. Install OpenApi into Karaf by installing karaf feature:
2067 $ feature:install odl-restconf-openapi
2069 2. Navigate to OpenAPI in your web browser which is available at URLs:
2071 - http://localhost:8181/openapi/explorer/index.html for general overview
2073 - http://localhost:8181/openapi/api/v3/single for JSON data
2077 In the URL links for OpenAPI, change *localhost* to the IP/Host name of your actual server.
2079 3. Enter the username and password.
2080 By default the credentials are *admin/admin*.
2082 4. Select any model to try out.
2084 5. Select any available request to try out.
2086 6. Click on the **Try it out** button.
2088 7. Provide any required parameters or edit request body.
2090 8. Click the **Execute** button.
2092 9. You can see responses to the given request.
2095 OpenAPI Explorer can also be used for connected device. How to connect a device can be found :ref:`here <netconf-connector>`.
2097 OpenAPI URLs in that case would look like this:
2099 - `http://localhost:8181/openapi/explorer/index.html?urls.primaryName=17830-sim-device resources - RestConf RFC 8040 <http://localhost:8181/openapi/explorer/index.html?urls.primaryName=17830-sim-device%20resources%20-%20RestConf%20RFC%208040>`_ for device overview
2101 - http://localhost:8181/openapi/api/v3/mounts/1 for JSON data
2103 - `http://localhost:8181/openapi/api/v3/mounts/1/toaster(2009-11-20) <http://localhost:8181/openapi/api/v3/mounts/1/toaster(2009-11-20)>`__ JSON data for given model
2107 The URL links for OpenAPI are made for device with name *17830-sim-device* and model toaster
2108 with *2009-11-20* revision and need to be changed accordingly to connected device.