Table of Contents
Netconf Karaf Console Feature
Netconf Karaf Console (odl-netconf-console) is a feature that:
- Offers a way to externally administer Netconf through Karaf Command Line Interface. Supports CRUD type of operations on netconf-connector.
- Provides a very user-friendly way to manage Netconf devices.
Gerrit patch details
https://git.opendaylight.org/gerrit/#/q/topic:netconf-cli
Building odl-netconf-console
- Check out the latest netconf repository (Boron branch) from git
- Dive into opendaylight/netconf folder
- Build the netconf project using "mvn clean install" command.
This will build the netconf-console and the netconf-testtool bundles that we shall need for the following instructions.
Prerequisites
In this Wiki we shall be using netconf-testtool to simulate Netconf devices. More details on testtool can be found here testtool. Run the "netconf-testtool" to start of Netconf devices. In this example we start 2 Netconf devices.
$ cd netconf/netconf/tools/netconf-testtool/target $ java -Xmx1G -XX:MaxPermSize=256M -jar netconf-testtool-1.1.0-SNAPSHOT-executable.jar --device-count 2 Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256M; support was removed in 8.0 14:06:32.887 [main] INFO o.o.n.t.tool.NetconfDeviceSimulator - Starting 2, SSH simulated devices starting on port 17830 14:06:34.337 [main] INFO o.a.sshd.common.util.SecurityUtils - Trying to register BouncyCastle as a JCE provider 14:06:35.538 [main] INFO o.a.sshd.common.util.SecurityUtils - BouncyCastle not registered, using the default JCE provider 14:06:35.687 [main] INFO o.o.n.t.tool.NetconfDeviceSimulator - All simulated devices started successfully from port 17830 to 17831 14:06:44.599 [sshd-netconf-ssh-server-nio-group-thread-1] INFO o.a.s.server.session.ServerSession - Server session created from /127.0.0.1:61995 14:06:44.704 [sshd-netconf-ssh-server-nio-group-thread-1] INFO o.a.s.s.k.PEMGeneratorHostKeyProvider - Generating host key... 14:06:44.854 [sshd-netconf-ssh-server-nio-group-thread-5] INFO o.a.s.s.s.ServerUserAuthService - Session admin@/127.0.0.1:61995 authenticated 14:06:48.488 [sshd-netconf-ssh-server-nio-group-thread-8] INFO o.a.s.server.session.ServerSession - Server session created from /127.0.0.1:61997 14:06:48.570 [sshd-netconf-ssh-server-nio-group-thread-4] INFO o.a.s.s.s.ServerUserAuthService - Session admin@/127.0.0.1:61997 authenticated
Running 'odl-netconf-console'
- After a successful build run karaf from the Netconf project as shown below. Once you have a karaf instance running, the feature that provides Netconf Karaf CLI needs to be installed.
$ ./karaf/target/assembly/bin/karaf clean ________ ________ .__ .__ .__ __ \_____ \ ______ ____ ____ \______ \ _____ ___.__.| | |__| ____ | |___/ |_ / | \\____ \_/ __ \ / \ | | \\__ \< | || | | |/ ___\| | \ __\ / | \ |_> > ___/| | \| ` \/ __ \\___ || |_| / /_/ > Y \ | \_______ / __/ \___ >___| /_______ (____ / ____||____/__\___ /|___| /__| \/|__| \/ \/ \/ \/\/ /_____/ \/ Hit '<tab>' for a list of available commands and '[cmd] --help' for help on a specific command. Hit '<ctrl-d>' or type 'system:shutdown' or 'logout' to shutdown OpenDaylight. opendaylight-user@root>feature:install odl-netconf-consoleTo verify if the feature was installed correctly you could check karaf logs for the below line or also check Karaf console to see if the CLI commands are available
2016-05-31 13:41:00,051 | INFO | config-pusher | NetconfConsoleProvider | 284 - org.opendaylight.netconf.console - 1.1.0.SNAPSHOT | NetconfProvider Session Initiated opendaylight-user@root>netconf:<HIT_TAB> netconf:connect-device netconf:disconnect-device netconf:list-devices netconf:show-device netconf:update-deviceYou should be able to see five commands as listed above.
Using 'odl-netconf-console' Help
To display command usage type: <command> --help. For example:
opendaylight-user@root>netconf:show-device --help DESCRIPTION netconf:netconf:show-device Shows netconf device attributes. SYNTAX netconf:netconf:show-device [options] OPTIONS -i, --ipaddress IP address of the netconf device -id, --identifier Node Identifier of the netconf device -p, --port Port of the netconf device --help Display this help message
CLI description and samples
List all Netconf devices
After installing the feature verify if the controller-config connector is up by running "netconf:list-devices" command. This command does not take any arguments and displays basic information (Netconf ID, IP address, Port and the connectivity status of the device) about all the netconf devices connected to the running ODL instance.
opendaylight-user@root>netconf:list-devices NETCONF ID | NETCONF IP | NETCONF Port | Status --------------------------------------------------------- controller-config | 127.0.0.1 | 1830 | connected
Connect to a Netconf Device
In order to connect a Netconf device to ODL, use "netconf:connect-device" command and provide the IP, Port, Login credentials - all of which are mandatory arguments for successfully adding a netconf connector. Optionally if you wish to specify the device ID yourself that can also be passed to the CLI as an argument. If no device ID is passed the feature assigns a randomly generated UUID.
opendaylight-user@root>netconf:connect-device -i 127.0.0.1 -p 17831 -U admin -P admin Netconf connector added succesfully opendaylight-user@root>netconf:connect-device -i 127.0.0.1 -p 17830 -U admin -P admin -id test Netconf connector added succesfully opendaylight-user@root>netconf:list-devices NETCONF ID | NETCONF IP | NETCONF Port | Status ------------------------------------------------------------------------- 87b31eaad1634bb080025ef35fcc831d | 127.0.0.1 | 17831 | connected test | 127.0.0.1 | 17830 | connected controller-config | 127.0.0.1 | 1830 | connected
Show a Netconf device attributes
Use "netconf:show-device" command to list the attributes of a Netconf device. "netconf:show-device" command accepts either IP and Port OR the device ID to list the attributes. For example:
opendaylight-user@root>netconf:show-device -i 127.0.0.1 -p 17830 NETCONF ID | NETCONF IP | NETCONF Port | Status | Available Capabilities ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- test | 127.0.0.1 | 17830 | Connected | (urn:ietf:params:xml:ns:yang:ietf-inet-types?revision=2010-09-24)ietf-inet-types | | | | urn:ietf:params:netconf:capability:candidate:1.0 | | | | urn:ietf:params:netconf:base:1.1 | | | | urn:ietf:params:netconf:base:1.0 | | | | (urn:ietf:params:xml:ns:yang:ietf-yang-types?revision=2010-09-24)ietf-yang-types | | | | (urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring-extension?revision=2013-12-10)ietf-netconf-monitoring-extension | | | | urn:ietf:params:netconf:capability:exi:1.0 | | | | (urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring?revision=2010-10-04)ietf-netconf-monitoring opendaylight-user@root>netconf:show-device -id test NETCONF ID | NETCONF IP | NETCONF Port | Status | Available Capabilities ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- test | 127.0.0.1 | 17830 | Connected | (urn:ietf:params:xml:ns:yang:ietf-inet-types?revision=2010-09-24)ietf-inet-types | | | | urn:ietf:params:netconf:capability:candidate:1.0 | | | | urn:ietf:params:netconf:base:1.1 | | | | urn:ietf:params:netconf:base:1.0 | | | | (urn:ietf:params:xml:ns:yang:ietf-yang-types?revision=2010-09-24)ietf-yang-types | | | | (urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring-extension?revision=2013-12-10)ietf-netconf-monitoring-extension | | | | urn:ietf:params:netconf:capability:exi:1.0 | | | | (urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring?revision=2010-10-04)ietf-netconf-monitoring
Update Netconf device attributes
In order to update device attributes (IP, port, credentials) use the "netconf:update-device" command. Note that, for update command the device ID, username and password are mandatory arguments to pass. For example: to update the username and password specify new username and password as below.
opendaylight-user@root>netconf:update-device -id test -U admin -P admin -nU test -nP test NETCONF node: test updated successfully. opendaylight-user@root>netconf:list-devices NETCONF ID | NETCONF IP | NETCONF Port | Status ------------------------------------------------------------------------ 87b31eaad1634bb080025ef35fcc831d | 127.0.0.1 | 17831 | connected test | 127.0.0.1 | 17830 | connected controller-config | 127.0.0.1 | 1830 | connected
Disconnect from a Netconf device
Use "netconf:disconnect-device" command in order to remove a netconf connector. "netconf:disconnect-device" command accepts either IP and Port OR the device ID for disconnection to happen.
opendaylight-user@root>netconf:disconnect-device -i 127.0.0.1 -p 17830 OR opendaylight-user@root>netconf:disconnect-device -id test Netconf connector disconnected succesfully opendaylight-user@root>netconf:list-devices NETCONF ID | NETCONF IP | NETCONF Port | Status ------------------------------------------------------------------------- 87b31eaad1634bb080025ef35fcc831d | 127.0.0.1 | 17831 | connected controller-config | 127.0.0.1 | 1830 | connected