Skip to content

Device profiles ​

A device profile is data describing a kind of device: how to recognise it from its hello, the quirks the library works around, how to commit a change, short names for its paths, and operations of its own. nnc uses the same profiles as the library; see Device profiles.

Which profile ​

nnc chooses a profile when it connects, and the connected line names it. The target can name one with profile; otherwise nnc detects one from the hello. profile shows the choice:

nnc
nnc lab> profile

The lab device follows the RFCs, so its profile, lab, corrects nothing: it only names paths for these examples. It has no rule to recognise the device by, so the lab target names it:

Output
connected to lab (sim:lab) · session-id 1 · base:1.1 · profile lab
nnc lab> profile
profile   lab (verified)
source    built in
chosen    named by target lab
quirks    (none)
workflow  (library defaults)

named paths:
  @systemName     /ietf-system:system/hostname
  @systemLeaf     /ietf-system:system/{{leaf}}
                    params: leaf
  @interface      /ietf-interfaces:interfaces/interface[name={{ifName}}]
                    params: ifName (optional)
…

A target that names no profile, for a device no built-in profile matches, gets none, and profile lists the profiles it considered:

Output
no device profile is in use in this session
auto-detection considered nokia-7210-sas, nokia-sros-md, sysrepo-netopeer2; none matched the device's hello

A Nokia router named by its target:

Output
nnc> connect router1
connected to router1 (192.0.2.10:830) · session-id 2 · base:1.1 · profile nokia-7210-sas · read-only
nnc router1 [ro]> profile
profile   nokia-7210-sas (verified)
source    built in
chosen    named by target router1
quirks    invalidXmlChars strip, paddedEmptyElements strip, subtreeFilter containers, subtreeFilterDepth 2
workflow  editTarget running, lock true, validate false, commit false (the rest: library defaults)

named paths:
  @systemName  /alu-conf-r13:configure/system/name/system-name

(no operations)

profile --json adds the profile's full definition, after extends and overrides are applied. profile reads only what the library loaded, so it sends nothing.

Quirks ​

Quirks work around a device's departures from the RFCs, so the rest of the library and nnc can follow them. Among those a profile can set (all are in Quirks):

Quirk
invalidXmlCharsstrip characters XML doesn't allow, such as a BEL in an error message, instead of failing the parse
paddedEmptyElementsread an element holding only whitespace as empty
replyWithoutMessageIdmatch a reply that has no message-id to the oldest request waiting
forceBaseVersionuse base 1.0 or 1.1 whatever the hello says
closeTimeouthow long to wait for the reply to <close-session>
subtreeFilter, subtreeFilterDepththe shape of subtree filter the device answers correctly

Without the quirk the library reports the defect: a malformed reply ends the session, and a reply it can't match is a warning above the prompt. show-last --raw always shows the reply as received, before any quirk.

Workflow ​

The workflow is how set, remove and apply change the device: which datastore to edit, and whether to lock, validate and commit. A device with a candidate is edited there and committed; a device without one is edited in running:

Output
workflow  editTarget candidate, lock true, validate true, commit true

Paths shows each step as it runs.

Capabilities ​

A profile can add or remove capabilities, for a device whose hello is wrong. capabilities lists them after the corrections, and commands for operations the device lacks are left out of help and Tab completion.

Named paths ​

A profile names paths it uses often: @systemName and @interface(eth0) above. They work wherever a path does; see Named paths.

Profile operations ​

A profile can add operations of its own, written as XML templates: running a CLI command over NETCONF, for example. device lists them with their parameters, and profile <operation> shows what one sends and how its reply is read, without sending it:

Output
nnc router3> device
operations of profile nokia-sros-md (* changes state):
  cli *  Run an MD-CLI command and return its text output.
      --command <string>
nnc router3> profile cli
operation  cli  (profile nokia-sros-md)
about      Run an MD-CLI command and return its text output.
changes    counted as yes (the profile doesn't say, so it is treated as a change)
params     --command <string>
request    <md-cli-raw-command xmlns="urn:nokia.com:sros:ns:yang:sr:oper-global"><md-cli-input-line>{{command}}</md-cli-input-line></md-cli-raw-command>
result     md-cli-output-block, as text
run with   device cli --command <string>

device <operation> --param value runs one:

Output
nnc router3> device cli --command "show version"

On a read-only target, an operation runs only if the profile marks it "mutates": false. Any other is refused, saying so:

Output
device cli: refused: router3 is read-only, and profile nokia-sros-md doesn't mark cli as read-only. If it doesn't change state, mark it "mutates": false in the profile; nothing was sent

Your own profiles ​

A target's profilesDir adds a directory of your own profiles, and profile names one. A profile can extend a built-in one and override part of it: a lab profile that removes :candidate, say, or one with a shorter closeTimeout:

json
{
  "id": "acme-lab",
  "extends": "sysrepo-netopeer2",
  "quirks": { "closeTimeout": 1000 }
}
json
{
  "lab2": {
    "host": "192.0.2.40", "username": "netconf",
    "password": { "prompt": true },
    "profile": "acme-lab",
    "profilesDir": "~/.config/net-netconf/profiles"
  }
}

The format is in Writing a profile.

Next ​

Released under the MIT Licence.