Configuration Guide for Cisco NCS 1001, IOS XR Release 25.x.x

PDF

Configuration Guide for Cisco NCS 1001, IOS XR Release 25.x.x

Automated deployment of third party Python scripts

Want to summarize with AI?

Log in

This section explains how automated deployment runs third-party Python scripts on the router by using App Manager to activate xr_script_scheduler.py and execute scripts delivered in third-party RPMs.


Efficient network automation is pivotal in handling extensive cloud-computing networks. The Cisco IOS XR infrastructure plays a crucial role by enabling automation through the initiation of API calls and execution of scripts. Traditionally, an external controller is used for this purpose, utilizing interfaces like NETCONF, SNMP, and SSH to communicate with NCS 1001.

This feature streamlines the operational structure by executing automation scripts directly on the router, thus eliminating the need for an external controller. It allows scripts to leverage Python libraries and access underlying router information. This approach not only accelerates the execution of various types of scripts but also enhances reliability by removing dependencies on the speed and network reachability of an external controller.

The third party script is automatically executed by the xr_script_scheduler.py script upon the installation of third-party RPMs. App manager configuration is required to activate the xr_script_scheduler.py script and run the third party scripts after installation.

Note

If you use the autorun configuration, the xr_script_scheduler.py script activates automatically.


Automatically deploy and activate third party script

NCS 1001 provides CLI commands to perform configurations and operations on the optical devices. If you want to automate the NCS 1001 node operations, you can run third party scripts through App manager.

Follow these steps to deploy and activate third party script.

Procedure

1.

Use the show script status command to check the list of the OPS scripts that are in-built in XR.

Example:

This command lists the status of xr_script_scheduler script. Ready status in the output means that the script checksum is verified and is ready to run.

RP/0/RP0/CPU0:ios#show script status        
Tue Oct 24 18:03:09.220 UTC
======================================================================================================
 Name                            | Type   | Status           | Last Action | Action Time               
------------------------------------------------------------------------------------------------------
 show_interfaces_counters_ecn.py | exec   | Ready            | NEW         | Tue Oct 24 07:10:36 2025  
 xr_data_collector.py            | exec   | Ready            | NEW         | Tue Oct 24 07:10:36 2025  
 xr_script_scheduler.py          | process| Ready            | NEW         | Tue Oct 24 07:10:36 2025  
======================================================================================================
RP/0/RP0/CPU0:ios#
2.

Use the appmgr to automatically run the XR scheduler script.

Activate the scheduler script automatically using the "autorun" option with the configuration.

Example:

RP/0/RP0/CPU0:ios#configure
RP/0/RP0/CPU0:ios(config)#appmgr
RP/0/RP0/CPU0:ios(config-appmgr)#process-script xr_script_scheduler
RP/0/RP0/CPU0:ios(config-process-script)#executable xr_script_scheduler.py
RP/0/RP0/CPU0:ios(config-process-script)#autorun
RP/0/RP0/CPU0:ios(config-process-script)#commit

The 'autorun' configuration has been added to enable automatic activation of the process script. If you prefer manual activation/deactivation using CLI, skip the 'autorun' configuration line. See Manually deploy and activate third party script.

3.

Verify the scheduler script is running.

  1. Run the show script execution command to verify the functioning of the debug and monitoring scripts.

    Example:

    This command displays a list of OPS scripts currently running.

    RP/0/RP0/CPU0:ios# show script execution 
    Tue Oct 24 19:41:15.882 UTC
    ====================================================================================================================
     Req. ID   | Name (type)                               | Start                    | Duration   | Return | Status   
    --------------------------------------------------------------------------------------------------------------------
     1698176223| xr_script_scheduler.py (process)          | Tue Oct 24 19:37:02 2025 | 253.32s    | None   | Started  
     ====================================================================================================================
    RP/0/RP0/CPU0:ios#
  2. Use the show script execution details command to verify if the scheduler script is running.

    Example:

    This command displays a list of OPS scripts currently running. If the scheduler script is correctly configured and activated, the scheduler script execution detail appears in the output.

    RP/0/RP0/CPU0:ios#show script execution details 
    Tue Oct 25 18:01:56.590 UTC
    ====================================================================================================================
     Req. ID   | Name (type)                               | Start                    | Duration   | Return | Status   
    --------------------------------------------------------------------------------------------------------------------
     1698170509| xr_script_scheduler.py (process)          | Tue Oct 25 18:01:49 2023 | 7.68s      | None   | Started  
    --------------------------------------------------------------------------------------------------------------------
     Execution Details:
     ------------------
     Script Name  : xr_script_scheduler.py
     Version      : 25.3.1.14Iv1.0.0
     Log location : /harddisk:/mirror/script-mgmt/logs/xr_script_scheduler.py_process_xr_script_scheduler
     Arguments    : 
     Run Options  : Logging level - INFO, Max. Runtime - 0s, Mode - Background
     Events:
     -------
     1.   Event        : New
          Time         : Tue Oct 25 18:01:49 2025
          Time Elapsed : 0.00s Seconds
          Description  : Started by Appmgr
     2.   Event        : Started
          Time         : Tue Oct 25 18:01:49 2025
          Time Elapsed : 0.11s Seconds
          Description  : Script execution started. PID (15985)
    ====================================================================================================================
    RP/0/RP0/CPU0:ios#
4.

Copy the third party RPM files to the NCS 1001 node.

  1. Use any of the file transfer mechanisms to copy third-party RPM.

    Example:

    This example shows copying the RPM to the harddisk of the NCS 1001 node using scp.

    RP/0/RP0/CPU0:ios#scp user@171.xx.xxx.xxx:/users/user/rpm-factory/RPMS/x86_64/nms-1.1-25.3.1.x86_64.rpm /harddisk:
    Tue Oct 24 18:02:42.400 UTC 
    <snip>
    Password:
    nms-1.1-24.1.1.x86_64.rpm                                           100% 9664   881.5KB/s   00:00    
    RP/0/RP0/CPU0:ios#
    
  2. (Optional) Verify the RPM files using dir <filepath> .

    Example:

    RP/0/RP0/CPU0:ios#dir harddisk:/nms-1.1-24.1.1.x86_64.rpm
    Wed Oct  24 19:53:54.041 UTC
    
5.

Install the third party RPM files to use the required debug and monitoring python scripts.

The third party RPM files have the customized scripts to be executed. The third-party RPM contains two types of files:

Example:

This is an example xr_script_scheduler.json file. Customize this file as per your requirements.

[
    {
        "name": "__template_entry__.py",
        "description": ["**This is a template entry for documentation purpose. This entry will be ignored**",
                        "name : Name of the python script to be executed",
                        "       [string][mandatory]",
                        "description:  Description of the script",
                        "              [string or list of strings][optional: default empty string]",
                        "cmd_line_parameters: Script command line parameters" ,
                        "                     [list of strings][optional: default Null][Example: ",
                        "env_variables: Enviromental variables to be set in script run shell",
                        "               [list of key value pairs][optional: default Null][Example: [['INT_NAME': 'hu0/1/0/1']]",
                        "run_policy: Script restart policy when script exits",
                        "            [string: one of always/once/stop][optional: default 'always']",
                        "            always: restart the script every time it exits",
                        "            once:  do not restart the script if it exits",
                        "            stop:  stop an existing script run "
                        ],
        "cmd_line_parameters": [],
        "env_variables": [],
        "run_policy": "always"
    },
    {
        "name": "monitor_int_rx_cntr.py",
        "description": "Monitoring mgmt interface for Rx threshold of 100 ",
        "cmd_line_parameters": ["MgmtEth0/RP0/CPU0/0", "200", "-log", "debug"],
        "env_variables": [["INT_NAME", "FourHundredGigE0/9/0/0"], ["INT_NAME2", "FourHundredGigE0/10/0/0"]],
        "run_policy": "always"
    },
    {
        "name": "monitor_int_rx_cntr.py",
        "description": "Monitoring Fo0/0/0/0 interface for Rx threshold of 1000000 ",
        "cmd_line_parameters": ["FourHundredGigE0/0/0/0", "1000000"],
        "run_policy": "once"
    },
    {
        "name": "monitor_int_rx_cntr2.py",
        "description": "Monitoring Fo0/0/0/1 interface for Rx threshold of 5000000 ",
        "cmd_line_parameters": ["FourHundredGigE0/0/0/1", "5000000"],
        "run_policy": "always"
    },
    {
        "name": "monitor_int_rx_cntr2.py",
        "description": "Monitoring Fo0/0/0/2 interface for Rx threshold of 5000000 ",
        "cmd_line_parameters": ["FourHundredGigE0/0/0/2", "8000000"],
        "run_policy": "stop"
    }
]

Example:

Use the appmgr package install rpm <full RPM file path> command to install the third-party RPMs.
RP/0/RP0/CPU0:ios#appmgr package install rpm /harddisk:/nms-1.1-25.3.1.x86_64.rpm
Tue Oct 24 18:03:26.685 UTC
RP/0/RP0/CPU0:ios#
RP/0/RP0/CPU0:ios#show appmgr packages installed 
Tue Oct 24 19:42:07.967 UTC
Sno Package                                                     
--- ------------------------------------------------------------
1   nms-1.1-25.3.1.x86_64                                       
RP/0/RP0/CPU0:ios#

After the scripts and the run parameters file become ready, build the RPM and configure the RPM to install files at <default exr appmgr rpm install path>/ops-script-repo/exec/<rpm name>/. RPM build tool for TPA is available at RPM Build Tool.

Note

Install the scripts in directories named after the RPM for smoother execution.

6.

Use the show script status command to verify that the scripts and the run parameter files contained in the RPM are all installed successfully and added to the script management repository.

Example:

This output shows the status that two scripts (monitor_int_xr_cntr.py and monitor_int_rx_cntr2.py) and a run parameter file (xr_script_scheduler.json) file were installed in the third-party RPM named “nms”.

RP/0/RP0/CPU0:ios#show script status                                                                                      
Tue Oct 24 19:41:10.696 UTC
======================================================================================================
 Name                            | Type   | Status           | Last Action | Action Time               
------------------------------------------------------------------------------------------------------
 nms/monitor_int_rx_cntr.py      | exec   | Ready            | NEW         | Tue Oct 24 19:38:41 2023  
 nms/monitor_int_rx_cntr2.py     | exec   | Ready            | NEW         | Tue Oct 24 19:38:41 2023  
 nms/xr_script_scheduler.json    | exec   | Ready            | NEW         | Tue Oct 24 19:38:41 2023  
 show_interfaces_counters_ecn.py | exec   | Ready            | NEW         | Tue Oct 24 19:33:52 2023  
 xr_data_collector.py            | exec   | Ready            | NEW         | Tue Oct 24 19:33:52 2023  
 xr_script_scheduler.py          | process| Ready            | NEW         | Tue Oct 24 19:33:52 2023  
======================================================================================================
RP/0/RP0/CPU0:ios#

After the scripts are installed, the scheduler script starts reading the run parameter JSON file and executes the required debug and monitoring scripts.

The logs generated by the scripts are available in the directory /harddisk\:/mirror/script-mgmt/logs/.

7.

Verify that the debug and monitoring scripts are running.

Example:

Use the show script execution command to verify that the scripts are running.

RP/0/RP0/CPU0:ios#show script execution 
Tue Oct 24 19:41:15.882 UTC
====================================================================================================================
 Req. ID   | Name (type)                               | Start                    | Duration   | Return | Status   
--------------------------------------------------------------------------------------------------------------------
 1698176223| xr_script_scheduler.py (process)          | Tue Oct 24 19:37:02 2023 | 253.32s    | None   | Started  
 1698176224| nms/monitor_int_rx_cntr.py (exec)         | Tue Oct 24 19:38:43 2023 | 152.46s    | None   | Started  
 1698176225| nms/monitor_int_rx_cntr.py (exec)         | Tue Oct 24 19:38:44 2023 | 152.03s    | None   | Started  
 1698176226| nms/monitor_int_rx_cntr2.py (exec)        | Tue Oct 24 19:38:44 2023 | 151.63s    | None   | Started  
====================================================================================================================
RP/0/RP0/CPU0:ios#

(Optional) Use the show script execution[ name script-name detail [output] [error]]