Workflow to Run an Exec Script
Complete the following tasks to provision exec scripts:
-
Download the script—Add the script to the appropriate exec script directory on the router. using the script add exec command.
-
Configure checksum—Check script integrity and authenticity using the script exec <script.py> checksum command.
-
Run the script—Trigger changes to the router configuration. Include arguments, set the maximum time for the script to run, setup log levels using the script run command.
-
View the script execution details—Validate the script and retrieve the operational data using the show script execution command.
The following image shows a workflow diagram representing the steps involved in using an exec script:
Download the Script to the Router
To manage the scripts, you must add the scripts to the script management repository on the router. A subdirectory is created for each script type. By default, this repository stores the downloaded scripts in the appropriate subdirectory based on script type.
Script Type | Download Location |
---|---|
config |
harddisk:/mirror/script-mgmt/config |
exec |
harddisk:/mirror/script-mgmt/exec |
process |
harddisk:/mirror/script-mgmt/process |
eem |
harddisk:/mirror/script-mgmt/eem |
-
Method 1: Add script from a server
-
Method 2: Copy script from external repository to harddisk using scp or copy command
In this section, you learn how to add exec-script.py
script to the script management repository.
Procedure
Step 1 |
Add the script to the script management repository on the router using one of the two options:
|
||
Step 2 |
Verify that the scripts are downloaded to the script management repository on the router. Example:
exec-script.py is copied to harddisk:/mirror/script-mgmt/exec directory on the router.
|
Configure Checksum for Exec Script
Every script is associated with a checksum value. The checksum ensures the integrity of the script that is downloaded from the server or external repository is intact, and that the script is not tampered. The checksum is a string of numbers and letters that act as a fingerprint for script. The checksum of the script is compared with the configured checksum. If the values do not match, the script is not run and a syslog warning message is displayed.
It is mandatory to configure the checksum to run the script.
Note |
Exec scripts support SHA256 checksum. |
Before you begin
Procedure
Step 1 |
Retrieve the SHA256 checksum hash value for the script. Ideally this action would be performed on a trusted device, such as the system on which the script was created. This minimizes the possibility that the script is tampered with. Example:
Make note of the checksum value. |
Step 2 |
View the status of the script. Example:
The |
Step 3 |
Enter global configuration mode. Example:
|
Step 4 |
Configure the checksum. Example:
|
Step 5 |
Verify the status of the script. Example:
The status |
Run the Exec Script
To run an exec script, use the script run command. After the script is run, a request ID is generated. Each script run is associated with a unique request ID.
Before you begin
Procedure
Run the exec script. Example:
Scripts can be run with more options. The following table lists the various options that you can provide at run time:
The script run is complete. |
View the Script Execution Details
View the status of the script execution.
Before you begin
Procedure
Step 1 |
View the status of the script execution. Example:
You can view detailed or filtered data for every script run. |
||||||||||||||
Step 2 |
Filter the script execution status to view the detailed output of a specific script run via request ID. Example:
|