Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

Example: Creating the Junos Snapshot Administrator in Python Configuration Files

This example demonstrates how to create some basic Junos Snapshot Administrator in Python (jsnapy) configuration files. The examples in this topic us specific numbers of spaces sometimes before any other text is entered on a line. These spaces are required for proper formatting of the YAML file.When usernames and passwords need to be typed in these examples, replace the word user with a valid username and the <password> text with a valid password.

Requirements

  • Junos Snapshot Administrator in Python Release 1.0 is installed on the server.

Overview

This topic describes, how to create multiple jsnapy configuration files:

  • A configuration file that connects to one specific host and runs one specific test

  • A configuration file that connects to one specific host, runs two tests, and sends the results by e-mail

  • A configuration file that connects to a group of hosts, runs one test, and stores the snapshot in an SQLite database

Junos Snapshot Administrator in Python configuration files consist of two mandatory sections: hosts and tests, and two optional sections: sqlilte and mail. The configuration files that direct jsnapy to connect (using Junos PyEZ and NETCONF) to a single host define the host IP address and credentials within the configuration file, while the configuration files that direct jsnapy to connect to multiple hosts use the include feature of YAML files to read in a list of hosts and credentials from a separate YAML file. The tests to be performed against the hosts are always defined in separate YAML test files whose names are specified within the tests section of the configuration files. Multiple test files can be specified.

For more information regarding test files, see the following:

SQLite configuration is done within the configuration file, while e-mail configuration is done in a separate mail configuration file, the name of which is specified in the configuration file. See <understanding mail config> and <creating mail config> for information about setting up jsnapy to use e-mail.

Comments can be inserted into the file at any location by starting the comment with the pound sign (#).

One Host, One Test

Procedure

Step-by-Step Procedure

Two sections are required for this configuration file: hosts and tests. For this example, use a text editor to create a new file named configuration_one_host_one_test.yml.

  1. Create the hosts section.

  2. Specify the IP address and login credentials.

  3. Create the tests section.

  4. Specify the test file to use.

Results

The resulting configuration file can be shown in the terminal using the cat command.

One Host, Two Tests with E-mail

Procedure

Step-by-Step Procedure

Three sections are required for this configuration file: hosts, tests and mail. For this example, use a text editor to create a new file named configuration_one_host_two_tests_e-mail.yml.

  1. Create the hosts section.

  2. Specify the IP address and login credentials.

  3. Create the tests section.

  4. Specify the test file to use.

  5. Specify the e-mail configuration file.

Results

The resulting configuration file can be shown in the terminal using the cat command.

Multiple Hosts, One Test with SQLite Database Storage

Procedure

Step-by-Step Procedure

Three sections are required for this configuration file: hosts, tests, and sqlite. Use a text editor to create a new file named configuration_multiple_hosts_one_test_sqlite.

  1. Create the hosts section.

  2. Specify the file in which the host IP addresses and login credentials are contained.

  3. Create the tests section.

  4. Specify the test file to use.

  5. Create the sqlite section.

  6. Configure the sqlite parameters.

Results

The resulting configuration file can be shown in the terminal using the cat command.