NETCONF Device Configuration
The yangcli-pro program can be configured to associate a name with a set of device parameters to start a NETCONF device with a server. These named devices are saved in a configuration file. Use the --autodevices to suppress automatic loading of this file. The default is to load this file at start-up and save it upon exit.
By default, the devices configuration is saved in
$HOME/.yumapro/yangcli_pro_devices.conf
. To override this file, set
--autodevices=false and use the devices-cfg command to load a
specific devices configuration file.
Creating Devices
> device-cfg create=device-B server=192.168.0.57 protocols=netconf1.0
A new device is created: device-id=device-B name=device-B server=192.168.0.57
> device-cfg show=device-B
Device 'device-B':
server: 192.168.0.57
connected: false
Saving Devices
To save a device, the text configuration file can be edited or the device-cfg 'save' command can be used.
> connect user=andy server=myserver password=mypassword
... startup screen ...
andy@myserver> device-cfg save device-A
Saved current device as 'device-A'
andy@myserver>
Multiple Devices
Multiple devices can be active at once, however only one command at a time can be sent. This will be improved in a future release. Just use the start-session command to start a different session. Only one instance of each named session with its device can be active at the same time.
Saving the Configured Devices
The device configuration can be saved or loaded at run-time, even if the --autodevices=true parameter is used (the default). The devices-cfg command is used to load and save this file.
session-A> devices-cfg save
Saved 2 sessions OK to '~/.yumapro/yangcli_pro_devices.conf'
session-A>
To save the devices to a different file, simply provide the filespec in the 'devices-cfg save' command:
session-A> devices-cfg save myusers.conf
Saved 2 devices OK to 'mydevices.conf'
session-A>
Loading Additional Configured Devices
Additional devices can be added to the configuration in memory with the 'devices-cfg load' command. The named devices in the file cannot conflict with names already in use or the duplicate devices will be skipped.
session-A> devices-cfg load devices.conf
Loaded 3 sessions OK from 'devices.conf'
session-A>
Displaying the Configured Devices
The devices that are available can be displayed with the devices-cfg 'show' command. The --brief and --full extensions are available for this command.
session-A> devices-cfg show
Saved devices source: '~/.yumapro/.yangcli_pro_devices.conf'
Device 'desktop':
server: 10.0.0.7
connected: false
Device 'device-A':
server: localhost
connected: false
Device 'device-B':
server: 192.168.0.57
connected: false
Displaying Devices
Displaying a Specific Device
To see information about a specific device, use the 'device-cfg show' command:
> device-cfg show device-A
Device 'device-A':
server: localhost
connected: false
Saved Device Configuration File Format
The saved sessions are stored in a YumaPro configuration file.
The file contents must conform to the following YANG container definition:
container saved-devices {
ncx:abstract;
description
"Represents all the saved devices in
the ~/.yumapro/yangcli_pro_devices file.
Use the 'devices' command to access this file.
Edit by hand only if you follow this YANG definition.";
list device {
description
"The list of devices to use during this test-suite.";
key name;
leaf name {
type nt:NcxName;
description
"The name of the saved device.
The 'device save' command will use the
string <user>@<server-address> as the default.";
}
leaf devicetype {
type string;
description
"Device type for NETCONF devices.";
}
leaf server {
type inet:host;
mandatory true;
description
"IP address or DNS name of the NETCONF server target.";
}
leaf ncport {
type uint16 {
range "1..max";
}
default 830;
description
"NETCONF port number to use. If not present, then
port 830, followed by port 22, will be tried.";
}
uses EntryPointParm;
uses ncxapp:ProtocolsParm;
leaf transport {
description
"Identifies the transport protocol that should be used.";
type ywt:transport-type;
default ssh;
}
uses CommentParm;
}
}
Device Configuration File Example
The following example file shows a valid device configuration file:
saved-devices
device 'desktop' {
server '10.0.0.7'
ncport 830
protocols "netconf1.0 netconf1.1"
}
device 'device-A' {
server 'localhost'
ncport 830
protocols "netconf1.0 netconf1.1"
}
device 'device-B' {
server '192.168.0.57'
ncport 830
protocols "netconf1.1"
}
}