Skip to content

Paths ​

The content commands work with YANG paths, such as /ietf-system:system/hostname, instead of XML. nnc resolves each module to its namespace, builds the filter or edit, and, for a change, locks, edits, validates and commits as the device needs, showing each step. They are the library's client.content.

Reading ​

read shows the nodes at a path, from the running configuration by default. value prints one leaf's value as plain text:

nnc
nnc lab> read /ietf-system:system
nnc lab> value /ietf-system:system/hostname

A list entry is selected by its keys in [...], with quotes as typed:

nnc
nnc lab> read /ietf-interfaces:interfaces/interface[name="eth0"]

--datastore candidate (or startup) reads another datastore, and --state reads state data as well, with <get>:

nnc
nnc lab> read /ietf-interfaces:interfaces/interface[name="eth0"] --state

OpenConfig paths work the same way. The lab device's components, with its transceiver's readings:

nnc
nnc lab> read /openconfig-platform:components --state

How a path resolves ​

resolve shows each step of a path: its module, namespace and keys, and the filter a read would send. It sends nothing:

nnc
nnc lab> resolve /openconfig-interfaces:interfaces/interface[name="eth0"]/config
Output
path  /openconfig-interfaces:interfaces/interface[name="eth0"]/config

step 1  interfaces
  module     openconfig-interfaces
  namespace  http://openconfig.net/yang/interfaces

step 2  interface
  module     openconfig-interfaces
  namespace  http://openconfig.net/yang/interfaces
  keys       name="eth0"

step 3  config
  module     openconfig-interfaces
  namespace  http://openconfig.net/yang/interfaces

filter a read sends:
  <interfaces xmlns="http://openconfig.net/yang/interfaces">
    <interface>
      <name>eth0</name>
      <config/>
    </interface>
  </interfaces>

A module the server doesn't have is an error before anything is sent:

Output
nnc lab> read /acme-system:system
read: Unknown YANG module "acme-system" in "/acme-system:system": the server did not advertise it, and no profile or schema defines its namespace; nothing was sent

Where namespaces come from ​

namespaces lists the module namespaces paths resolve with, and where each came from: the target's own namespaces, the device profile, the hello, or the YANG library:

nnc
nnc lab> namespaces ietf-system
nnc lab> namespaces ietf-interfaces

On the lab device ietf-system comes from the hello, and ietf-interfaces from the YANG library: a server lists YANG 1.1 modules, such as ietf-interfaces, only in its YANG library. When the device profile corrects a namespace the hello gets wrong, the hello's is shown under OVERRIDES.

Changing ​

set changes a leaf, and remove removes a node, and is fine if it isn't there. Each follows the device's workflow, and shows each step as it completes. On the lab device, that is: lock running and candidate, discard anything left in the candidate, edit it, validate, commit, unlock:

nnc
nnc lab> set /ietf-system:system/location rack-1
nnc lab> remove /ietf-system:system/location
Output
nnc lab> set /ietf-system:system/location rack-1
lock running: ok
lock candidate: ok
discard-changes candidate: ok
edit-config candidate: ok
validate candidate: ok
commit candidate: ok
unlock candidate: ok
unlock running: ok
ok

A device without a candidate datastore is edited in running, with fewer steps. The device profile says which; see Device profiles.

When a step fails, set says which, discards the change, and releases the locks:

Output
nnc lab> set /ietf-system:system/hostname ""
set: failed at edit-config; the changes were discarded and the locks released
rpc-error: invalid-value
  type      application
  severity  error
  path      /ietf-system:system/ietf-system:hostname
  message   length 0 is outside the allowed lengths 1..253

To make several changes at once, see Transactions.

Comparing datastores ​

diff shows how two datastores differ, compared by nnc with the device's YANG schema, so it works on any server. By default it shows what the candidate would commit (running → candidate):

nnc
nnc lab> edit-config candidate {"ietf-system:system": {"location": "lab"}}
nnc lab> diff
nnc lab> diff /ietf-system:system --source running --target candidate
nnc lab> discard-changes
Output
+ create   /ietf-system:system/location   lab
1 change (running → candidate)

A server with RFC 9144 compares NMDA datastores itself, with compare; see Server data.

Named paths ​

A device profile can name paths, so a long one has a short name. The lab device's profile names a few: @systemName for its hostname, and @ifDescription(eth0) for an interface's description, with the interface as a parameter. They work wherever a path does, and Tab completes them after @:

nnc
nnc lab> value @systemName
nnc lab> read @interface(eth0)
nnc lab> value @systemLeaf(contact)
nnc lab> read @port(eth0)

A read may leave out a parameter that fills a whole predicate, to read every entry:

nnc
nnc lab> read @ifDescription

set and remove need them all:

nnc
nnc lab> set @ifDescription(eth1) "spare port"
nnc lab> set @ifDescription(eth1) spare

profile lists each named path and its parameters; see Device profiles.

Next ​

Released under the MIT Licence.