08-30-2017 11:07 AM - edited 09-17-2017 11:32 PM
Objective:
Gracefully divert traffic out of the ASR9K node prior to software upgrade. This can be done by changing the routing protocol configuration e.g:
a. BGP : "Shutdown" the neighbors / neighbor groups
b. ISIS : "Set the overload bit" and "max-link-metric" on per ISIS instance.
Automated Solution:
This document shows how to use EEM script to automate the node isolation / restoration by parsing the node configuration. This script is agnostic of node specific configuration.
The script reads the 'running-config' and creates the new intended configuration. The diff of the two configs is shown to the user. The user has to explicitly provide an intent to commit the configuration.
Setup Pre-requisites:
a. Linux / Mac host (Python 2.7)
b. Telnet access to the node (for python script to do initial router setup)
c . SCP access to the IOS-XR node (to copy the EEM script)
Files:
Download GIR_v3.zip and unzip it. The folder should have following two files
a. EEM Script: GIR_TCL_v3.tcl
b. Initial Router Setup Script: gir_node_env_cfg_v3.py
Note: These scripts have been tried mainly on 6.1.3 release.
Initial Router Setup:
The initial setup is done by running the python script: python gir_node_env_cfg_v3.py
Following initial configuration is done automatically by running the EEM script. Please refer to the section 'Running the Initial Setup script' for detailed steps.
a. Create the EEM policy file location
config t
event manager directory user policy disk0:
commit
exit
b. Copy the script to the Node Active RSP
c. Create EEM user, AAA authorization local and Enable the policy
config t
username event_manager_user
group root-system
group cisco-support
aaa authorization eventmanager default local
aaa authorization commands eem-method none
vty-pool eem 100 105 line-template eem-template
line template eem-template
authorization commands eem-method
!
commit
event manager policy GIR_TCL_v3.tcl username event_manager_user
commit
Note: The current version of Initial router setup script copies the EEM script to active RP only. If there are redundant RP's, please copy the script to the standby RP.
Running the Initial Router Setup script:
The initial setup script arguments: list of target IOS-XR nodes IP addresses
python gir_node_env_cfg_v3.py <ip_address_node_1> <ip_address_node_2>
Sample run:
python gir_node_env_cfg_v3.py 172.15.0.100 172.15.0.109
Note: The initial router setup script will prompt for telnet and ssh credentials for each node.
Initial Router Setup Script Logs:
The script saves the initial and final config of the nodes.
The script logs are saved in file: ASR9K_<node_ip_address>_date_time
How to determine if the EEM policy was successfully registered?
Run the IOS-XR command: "show event manager policy registered" and confirm that the policy is registered.
RP/0/RSP0/CPU0:AGG-0908-ASR9K#show event manager policy registered
Fri Aug 4 16:48:12.706 PDT
No. Class Type Event Type Trap Time Registered Name
1 script user none Off Fri Aug 4 15:48:10 2017 GIR_TCL_v3.tcl
policyname {GIR_TCL_v3.tcl} sync {yes}
nice 0 queue-priority normal maxrun 20.000 scheduler rp_primary Secu none
persist_time: 3600 seconds, username: event_manager_user
Optionally, check the 'show logging | i GIr_TCL_v3.tcl'
RP/0/RSP0/CPU0:ASR9K#show logging | i GIR_TCL_v3.tcl
Fri Aug 4 15:48:16.307 PDT
RP/0/RSP0/CPU0:Aug 4 15:48:10.503 : eem_policy_dir[207]: %HA-HA_EM-6-FMPD_POLICY_REG_SUCC : fh_reg_unreg_policy: Policy 'GIR_TCL_v3.tcl' registered successfully, by user event_manager_user, with persist time 3600 and type 2
Running the GIR EEM Script:
The GIR EEM script can be invoked on the IOS-XR active RP by invoking the command:
event manager run GIR_TCL_v3.tcl <GIR-Mode> <optional commit>
The two parameters are:
The GIR mode (mandatory): "insert" / "remove"
User intention to commit the configuration (optional) : commit
Note: The initial reference configuration is the current 'running configuration'.
Sample CLI's:
Audit / Get Diff of config changes to remove the node:
event manager run GIR_TCL_v3.tcl remove
Remove the node:
event manager run GIR_TCL_v3.tcl remove commit
GIR EEM Script Logs:
The script saves the node SW version and node initial config on the node's harddisk with filename gir-eem-script-log-<date>.txt file
Sample script run output:
RP/0/RSP0/CPU0:ASR9K#event manager run GIR_TCL_v3.tcl remove commit
Tue Aug 1 18:38:39.103 PDT
GIR Action is :
remove
ISIS Instances are :
{router isis ring9} {router isis ring10} {router isis ring30}
BGP AS is:
router bgp 100
Neighbor List is:
{ neighbor 100.9.5.0} { neighbor 100.9.6.0} { neighbor 100.0.12.0} { neighbor 100.0.22.0} { neighbor 100.10.3.0} { neighbor 100.10.4.0}
Neighbor Group List is:
{ neighbor-group SvRR} { neighbor-group RR-Ring9} { neighbor-group RRC-Ring10}
-------------------------------------------------------------
show commit changes diff
Tue Aug 1 18:38:51.392 PDT
Building configuration...
!! IOS XR Configuration 6.1.3
router isis ring9
<- set-overload-bit on-startup 360
+> set-overload-bit
+ max-link-metric
!
router isis ring10
<- set-overload-bit on-startup 360
+> set-overload-bit
+ max-link-metric
!
router isis ring30
<- set-overload-bit on-startup 360
+> set-overload-bit
+ max-link-metric
!
router bgp 100
neighbor-group SvRR
+ shutdown
!
neighbor-group RR-Ring9
+ shutdown
!
neighbor-group RRC-Ring10
+ shutdown
!
+ neighbor 100.9.5.0
+ shutdown
!
+ neighbor 100.9.6.0
+ shutdown
!
+ neighbor 100.0.12.0
+ shutdown
!
+ neighbor 100.0.22.0
+ shutdown
!
+ neighbor 100.10.3.0
+ shutdown
!
+ neighbor 100.10.4.0
+ shutdown
!
!
end
RP/0/RSP0/CPU0:AGG-0908-ASR9K(config-bgp-nbrgrp)#
-------------------------------------------------------------
Proceeding with Commit
show config commit changes la$
Tue Aug 1 18:38:52.483 PDT
Building configuration...
!! IOS XR Configuration 6.1.3
router isis ring9
set-overload-bit
max-link-metric
!
router isis ring10
set-overload-bit
max-link-metric
!
router isis ring30
set-overload-bit
max-link-metric
!
router bgp 100
neighbor-group SvRR
shutdown
!
neighbor-group RR-Ring9
shutdown
!
neighbor-group RRC-Ring10
shutdown
!
neighbor 100.9.5.0
shutdown
!
neighbor 100.9.6.0
shutdown
!
neighbor 100.0.12.0
shutdown
!
neighbor 100.0.22.0
shutdown
!
neighbor 100.10.3.0
shutdown
!
neighbor 100.10.4.0
shutdown
!
!
end
Caveat :
At times, the EEM script fails to register. Try again and if it still does't work, please re-start the eem server.
Here is sample error seen while running EEM script on IOS-XR 6.1.3
RP/0/RSP0/CPU0:ASR9K#show logging | i GIR_TCL_v3.tcl
Fri Aug 4 15:48:16.307 PDT
RP/0/RSP0/CPU0:Aug 4 15:41:14.934 : eem_policy_dir[207]: %HA-HA_EM-4-FMPD_POLICY_APPLY : Could not apply policy 'GIR_TCL_v3.tcl': 'Embedded Event Manager' detected the 'fatal' condition 'Embedded Event Manager configuration'
Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: