Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Netconf-CLI Capabilities #24

pikimk started this conversation in General
Discussion options

Netconf-cli is a command-line interface tool designed for interacting with network devices
using the NETCONF protocol. To establish a connection to the NETCONF server, the
following command is used:

netconf-cli admin@192.168.0.105

Additional connection options are:

-p (Port, default 830 if unspecified)
-d (Datastore to start on, default operational)
--socket (option to connect via socket)

By successful connection to the NETCONF server, the following message should appear
and, a session should be opened, ready to receive further commands:

Connected via NETCONF [datastore target: operational]
/>

This is the list of command that the session supports:

  • cancel - Cancel an ongoing RPC/action input.
  • cd - Enter a different node.
  • commit - Commit current changes.
  • copy - Copy configuration.
  • create - Create a node.
  • delete - Delete a node.
  • describe - Print information about YANG tree path.
  • discard - Discard current changes.
  • dump - Print out datastore content as JSON or XML.
  • exec - Execute RPC/action.
  • get - Retrieve configuration from the server.
  • help - Print help for commands.
  • ls - List available nodes.
  • move - Move (leaf)list instances.
  • prepare - Initiate RPC/action.
  • quit - Quit the console.
  • set - Set value of a leaf.
  • switch - Switch datastore target.

Examples:

1. Get operational data on some node, via NETCONF:

When the session is connected, type the ls command and it will print a list of modules that you can choose of. Lets say we pick ietf-system:system.
Then we can change the directory of the node by typing cd ietf-system:system.
Once we are navigated inside ietf-system:system we can also use ls to see the directories in that node and navigate further.
We can use the get command in order to get a leaf value, or a whole tree value. By executing get hostname,
this is the output:

/ietf-system:system/hostname = test_hostname

we can also do a whole tree get by executing get command on a node that is not a leaf.

For example executing get ntp will return this result:

/ietf-system:system> get ntp
/ietf-system:system/ntp = (presence container)
/ietf-system:system/ntp/enabled = true
/ietf-system:system/ntp/server[name='Server 0'] = (list)
/ietf-system:system/ntp/server[name='Server 0']/name = Server 0
/ietf-system:system/ntp/server[name='Server 0']/udp/address = 0.pool.ntp.org
/ietf-system:system/ntp/server[name='Server 0']/association-type = pool
/ietf-system:system/ntp/server[name='Server 0']/iburst = true
/ietf-system:system/ntp/server[name='Server 0']/prefer = false
/ietf-system:system/ntp/server[name='Server 1'] = (list)
/ietf-system:system/ntp/server[name='Server 1']/name = Server 1
/ietf-system:system/ntp/server[name='Server 1']/udp/address = 1.pool.ntp.org
/ietf-system:system/ntp/server[name='Server 1']/association-type = pool
/ietf-system:system/ntp/server[name='Server 1']/iburst = true
/ietf-system:system/ntp/server[name='Server 1']/prefer = false
/ietf-system:system/ntp/server[name='Server 2'] = (list)
/ietf-system:system/ntp/server[name='Server 2']/name = Server 2
/ietf-system:system/ntp/server[name='Server 2']/udp/address = 2.pool.ntp.org
/ietf-system:system/ntp/server[name='Server 2']/association-type = pool
/ietf-system:system/ntp/server[name='Server 2']/iburst = true
/ietf-system:system/ntp/server[name='Server 2']/prefer = false
/ietf-system:system/ntp/server[name='Server 3'] = (list)
/ietf-system:system/ntp/server[name='Server 3']/name = Server 3
/ietf-system:system/ntp/server[name='Server 3']/udp/address = 3.pool.ntp.org
/ietf-system:system/ntp/server[name='Server 3']/association-type = pool
/ietf-system:system/ntp/server[name='Server 3']/iburst = true
/ietf-system:system/ntp/server[name='Server 3']/prefer = false

2. Setting up and / or change some value via netconf-cli:

The first thing we should do is change the datastore from operational to running by
executing switch running command
Lets say we want to add new server node in the list. First we have to add values to all the leaf nodes
in the tree and then commit the changes.

This is the order of commands:

/ietf-system:system/ntp> set server[name='Server 4']/association-type pool
/ietf-system:system/ntp> set server[name='Server 4']/iburst true
/ietf-system:system/ntp> set server[name='Server 4']/prefer true
/ietf-system:system/ntp> set server[name='Server 4']/udp/address example.ntp.com
/ietf-system:system/ntp> commit

If there is no error showing, then changes should be commited to the running datastore, and we can
confirm that with:
/ietf-system:system/ntp> get server[name='Server 4']
result:

/ietf-system:system/ntp = (presence container)
/ietf-system:system/ntp/server[name='Server 4'] = (list)
/ietf-system:system/ntp/server[name='Server 4']/name = Server 4
/ietf-system:system/ntp/server[name='Server 4']/udp/address = example.ntp.com
/ietf-system:system/ntp/server[name='Server 4']/association-type = pool
/ietf-system:system/ntp/server[name='Server 4']/iburst = true
/ietf-system:system/ntp/server[name='Server 4']/prefer = true
/ietf-system:system/ntp>

If the user wants to discard some changes that are not yet commited, one can just use the discard
command and it will discard the changes that are set / created, but not yet commited.

In the same way as we used set, we can use delete command.

NOTE: netconf-cli has an auto-complete feature built in, and if you press on the tab key, it will list
the user a list of possible commands / values that can be used in the current situation .

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /