Understanding Junos Snapshot Administrator in Python Device Files
The Junos Snapshot Administrator in Python (jsnapy) devices file is a YAML file that contains IP addresses, group names, and login credentials for multiple Junos OS devices. IP addresses and login credentials within the file can be grouped by user-defined criteria such as model, device type, or location. There are no naming restrictions for the device file, so multiple device files can be created and any of them can be referenced by the jsnapy configuration files.
Junos Snapshot Administrator in Python Device File Elements
Jsnapy device files are built using combinations of keywords and values that are pertinent to your network. Like any YAML file, structure is derived through indentation (one or more spaces), sequence items are denoted by a dash (-), and key value pairs are separated by a colon (:). The IP addresses used to identify the Junos OS hosts to contact appear on lines by themselves, preceded by a dash (-) and followed by a colon (:); for example:
- 192.0.2.1:
If you want to create groups of devices in the devices file, you can enter a group name on a line by itself, followed by a colon (:); for example:
MX_Devices:
The host IP addresses listed after the group name are considered a part of this group until the next group name is encountered in the devices file. This allows smaller groups to be contacted by referencing the group name (or names) from within the hosts section of the configuration file. If there are no group names configured in the devices file, the entire list of devices is contacted whenever that particular devices file is referenced in the configuration file.
Login credentials follow each IP address unless an SSH trust
relationship has been established between the jsnapy server and the
Junos OS host. The login credentials specify the username and password
needed for that particular host IP using the keywords username:
and passwd:
, respectively.
Comments can be inserted into the devices file at any location
by simply starting the comment with a hash (#); for example, #This is a comment
.
Jsnapy device files should be stored in the same directory as
the configuration file that is being used with the jsnapy
command.
The following commented example shows the structure of a jsnapy devices file.
Example Devices File
user@host:~> cat devices_example.yml #Junos Snapshot Administrator in Python – Example Devices File MX_Devices: #This is a group name. - 192.0.2.33: #IP address of a Junos OS host username: username passwd: password - 192.0.2.65: username: yourname passwd: yourpassword QFX: #<-- Group name - 192.0.2.12: username: switchuser password: password1 - 198.51.100.10: username: switchuser passwd: password1 Finance: - 192.0.2.36: username: financeuser passwd: 1password - 192.0.2.11: username: financeuser passwd: 1password RandD: - 198.51.100.1 #No login credentials needed for these hosts because of existing SSH trust relationships. - 198.51.100.254