Automation
netconf-console2
A NETCONF client: reads and edits a device's YANG-modelled config over SSH, in its running or candidate datastore.
NETCONF carries a device's config as XML shaped by YANG models (ietf-interfaces, ietf-ip), over SSH on
port 830. --get-config reads a datastore, running unless --db names another, and -x filters it with an
XPath. --edit-config FILE merges the file's XML into a datastore, usually the candidate, a shared draft;
the device checks it against its models and refuses an invalid edit whole. --commit copies the candidate into
running, and the device applies it. --hello prints the device's capabilities.
netconf-console2 command usage
netconf-console2 --host HOST --port 830 -u USER -p PASSWORD [--db DATASTORE] OPERATION
Options
-
--hello - print the device's hello: the capabilities it supports
-
--get-config - read a datastore's config (running unless --db says otherwise)
-
-x XPATH - keep only this part of the reply, such as /interfaces
-
--db candidate - work on the candidate datastore, the draft
-
--edit-config FILE - merge the file's XML into the datastore
-
--commit - copy the candidate into running
-
--discard-changes - throw the candidate's edits away
-
--get-schema MODULE - fetch a YANG model's source from the device
netconf-console2 examples
-
netconf-console2 --host 10.0.1.2 --port 830 -u admin -p netconf-lab --get-config -x /interfaces - Prints the running config's interfaces as XML.
-
netconf-console2 --host 10.0.1.2 --port 830 -u admin -p netconf-lab --db candidate --edit-config card.xml - Sends an edit to the candidate, where it waits for a commit.
-
netconf-console2 --host 10.0.1.2 --port 830 -u admin -p netconf-lab --commit - Makes the candidate the running config.
Pitfalls
- Its default port is 2022, not NETCONF's 830, so most devices need --port 830.
- An edit merges: what the file leaves out stays as it was, so removing an entry takes nc:operation="delete" on it.