Perform the following steps:
- Start the OpenDaylight Karaf distribution using the karaf script. Using this script will give you access to the Karaf CLI:
$ ./bin/karaf
- Install the user-facing feature responsible for pulling in all dependencies needed to connect a NETCONF device:
opendaylight-user@root>feature:install odl-netconf-topology odl-restconf
It might take a minute or so to complete the installation.
- Start your NETCONF device.
If you want to use the NETCONF test tool, it is time to simulate a NETCONF device using the following command:
$ java -jar netconf-testtool-1.0.1-Beryllium-SR4-executable.jar --device-count 1
This will simulate one device that will be bound to port 17830.
- Configure a new netconf-connector.
Send the following request using RESTCONF:
- URL: http://localhost:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/new-netconf-device
By looking closer at the URL you will notice that the last part is new-netconf-device. This must match the node-id that we will define in the payload.
Accept: application/xml
Content-Type: application/xml
Authorization: Basic YWRtaW46YWRtaW4=
<node xmlns="urn:TBD:params:xml:ns:yang:network-topology">
<node-id>new-netconf-device</node-id>
<host xmlns="urn:opendaylight:netconf-node-topology">127.0.0.1</host>
<port xmlns="urn:opendaylight:netconf-node-topology">17830</port>
<username xmlns="urn:opendaylight:netconf-node-topology">admin</username>
<password xmlns="urn:opendaylight:netconf-node-topology">admin</password>
<tcp-only xmlns="urn:opendaylight:netconf-node-topology">false</tcp-only>
</node>
- Let's have a closer look at this payload:
- node-id: Defines the name of the netconf-connector.
- address: Defines the IP address of the NETCONF device.
- port: Defines the port for the NETCONF session.
- username: Defines the username of the NETCONF session. This should be provided by the NETCONF device configuration.
- password: Defines the password of the NETCONF session. As for the username, this should be provided by the NETCONF device configuration.
- tcp-only: Defines whether or not the NETCONF session should use TCP or SSL. If set to true it will use TCP.
This is the default configuration of the netconf-connector; it actually has more configurable elements that we will look at later.
Once you have completed the request, send it. This will spawn a new netconf-connector that connects to the NETCONF device at the provided IP address and port using the provided credentials.
- Verify that the netconf-connector has correctly been pushed and get information about the connected NETCONF device.
First, you could look at the log to see if any errors occurred. If no error has occurred, you will see the following:
2016-05-07 11:37:42,470 | INFO | sing-executor-11 | NetconfDevice | 253 - org.opendaylight.netconf.sal-netconf-connector - 1.3.0.Beryllium | RemoteDevice{new-netconf-device}: Netconf connector initialized successfully
Once the new netconf-connector is created, some useful metadata is written into the MD-SAL's operational data store under the network-topology subtree. To retrieve this information, you should send the following request:
Authorization: Basic YWRtaW46YWRtaW4=
- URL: http://localhost:8181/restconf/operational/network-topology:network-topology/topology/topology-netconf/node/new-netconf-device
We're using new-netconf-device as the node-id because this is the name we assigned to the netconf-connector in a previous step.
This request will provide information about the connection status and device capabilities. The device capabilities are all the YANG models the NETCONF device is providing in its hello-message that was used to create the schema context.
- More configuration for the netconf-connector.
As mentioned previously, the netconf-connector contains various configuration elements. Those fields are non-mandatory, with default values. If you do not wish to override any of these values, you shouldn't provide them:
- schema-cache-directory: This corresponds to the destination schema repository for YANG files downloaded from the NETCONF device. By default, those schemas are saved in the cache directory ($ODL_ROOT/cache/schema). Using this configuration will define where to save the downloaded schema related to the cache directory. For instance, if you assigned new-schema-cache, schemas related to this device would be located under $ODL_ROOT/cache/new-schema-cache/.
- reconnect-on-changed-schema: If set to true, the connector will auto disconnect/reconnect when schemas are changed in the remote device. The netconf-connector will subscribe to base NETCONF notifications and listen for netconf-capability-change notifications. The default value is false.
- connection-timeout-millis: Timeout in milliseconds after which the connection must be established. The default value is 20000 milliseconds.
- default-request-timeout-millis: Timeout for blocking operations within transactions. Once this timer is reached, if the request is not yet finished, it will be canceled. The default value is 60000 milliseconds.
- max-connection-attempts: Maximum number of connection attempts. Nonpositive or null values are interpreted as infinity. The default value is 0, which means it will retry forever.
- between-attempts-timeout-millis: Initial timeout in milliseconds between connection attempts. This will be multiplied by the sleep-factor for every new attempt. The default value is 2000 milliseconds.
- sleep-factor: Back-off factor used to increase the delay between connection attempt(s). The default value is 1.5.
- keepalive-delay: netconf-connector sends keep-alive RPCs while the session is idle to ensure session connectivity. This delay specifies the timeout between keep-alive RPCs in seconds. Providing a 0 value will disable this mechanism. The default value is 120 seconds.
Using this configuration, your payload would look like this:
<node xmlns="urn:TBD:params:xml:ns:yang:network-topology">
<node-id>new-netconf-device</node-id>
<host xmlns="urn:opendaylight:netconf-node-topology">127.0.0.1</host>
<port xmlns="urn:opendaylight:netconf-node-topology">17830</port>
<username xmlns="urn:opendaylight:netconf-node-topology">admin</username>
<password xmlns="urn:opendaylight:netconf-node-topology">admin</password>
<tcp-only xmlns="urn:opendaylight:netconf-node-topology">false</tcp-only>
<schema-cache-directory xmlns="urn:opendaylight:netconf-node-topology">new_netconf_device_cache</schema-cache-directory>
<reconnect-on-changed-schema xmlns="urn:opendaylight:netconf-node-topology">false</reconnect-on-changed-schema>
<connection-timeout-millis xmlns="urn:opendaylight:netconf-node-topology">20000</connection-timeout-millis>
<default-request-timeout-millis xmlns="urn:opendaylight:netconf-node-topology">60000</default-request-timeout-millis>
<max-connection-attempts xmlns="urn:opendaylight:netconf-node-topology">0</max-connection-attempts>
<between-attempts-timeout-millis xmlns="urn:opendaylight:netconf-node-topology">2000</between-attempts-timeout-millis>
<sleep-factor xmlns="urn:opendaylight:netconf-node-topology">1.5</sleep-factor>
<keepalive-delay xmlns="urn:opendaylight:netconf-node-topology">120</keepalive-delay>
</node>