Manage Common Script Actions Using YANG RPCs
Feature Name |
Release Information |
Description |
---|---|---|
Manage Common Script Actions Using YANG RPCs |
Release 7.5.1 |
This feature enables you to use YANG remote procedure calls (RPCs) on |
This section provides information about YANG RPC messages for common actions on automation scripts. The Cisco-IOS-XR-infra-script-mgmt-act.yang
action YANG model is enhanced to perform the actions such as adding or removing a script from the repository, and also include
output responses. The output response provides a description about the action and displays the status as True
for a successful action, and False
for a failed action.
The YANG RPC supports these scripts:
-
Config
-
Exec
-
Process
-
EEM
The following section shows the various script actions, sample RPC request, and RPC response.
Add Script
You can add up to a maximum of 10 scripts to the script repository. You can set the script type to config, exec, process, or eem. The following example shows the RPC to add the exec script to the repository:
<add xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-infra-script-mgmt-act">
<script-type>exec</script-type>
<vrf></vrf>
<source>/harddisk:/</source>
<script-name>sample.py</script-name>
</add>
You can add more than one script to the repository simultaneously:
<add xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-infra-script-mgmt-act">
<script-type>exec</script-type>
<source>/harddisk:/</source>
<script-name>sample2.py</script-name>
<script-name>sample3.py</script-name>
</add>
To add a checksum value to the script, use the following RPC request:
<add-checksum xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-infra-script-mgmt-act">
<script-type>exec</script-type>
<source>/harddisk:/</source>
<script-checksums>
<script-name>sample.py</script-name>
<checksum>e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855</checksum>
</script-checksums>
</add-checksum>
You can add more than one script with their checksum values:
<add-checksum xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-infra-script-mgmt-act">
<script-type>exec</script-type>
<source>/harddisk:/</source>
<script-checksums>
<script-name>sample.py</script-name>
<checksum>e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855</checksum>
</script-checksums>
<script-checksums>
<script-name>sample2.py</script-name>
<checksum>e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855</checksum>
</script-checksums>
</add-checksum>
Remove Script
To remove script from the repository, provide the script type and the script name. You can send an RPC request to remove up to 10 scripts.
<remove xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-infra-script-mgmt-act">
<script-type>exec</script-type>
<script-name>sample.py</script-name>
</remove>
You can remove more than one script simultaneously:
<remove xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-infra-script-mgmt-act">
<script-type>exec</script-type>
<script-name>sample2.py</script-name>
<script-name>sample3.py</script-name>
</remove>
The following example shows a sample RPC response indicating that the script sample1.py
is removed from the repository:
<responses>
<script-name>sample.py<script-name>
<response>sample.py has been removed from the script repository</response>
<status>True</status>
<responses>
Stop Script
You must provide the request ID for the script instance to be stopped.
<stop xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-infra-script-mgmt-act">
<request-id>1622058854</request-id>
<description></description>
</stop>
The following example shows that the script has stopped:
<script-stop-response>
<response></response>
<status>True</status>
</script-stop-response>
Run Script
You must provide the script name to run the script. You can also configure the log levels to one of these values—Critical, Debug, Error, Info, or Warning.
<run xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-infra-script-mgmt-act">
<script-name>sample.py</script-name>
<argument-list></ argument-list>
<description></description>
<log-level></log-level>
<log-path></log-path>
<max-runtime></max-runtime>
</run>
The following example shows a sample RPC response where the script with the request ID 1622058854
is run:
<script-run-response>
<response>Script run scheduled</response>
<request-id>1622058854</request-id>
<status>True</status>
</script-run-response>