cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1082
Views
0
Helpful
1
Replies

Using EEM / TCL to run commands using parsed output from show commands?

Sam Brynes
Level 1
Level 1

I'm trying to use EEM / TCL to run a command in response to a Tunnel interface going up, but it requires the use of a parameter that I need to parse from a show command.

 

When interface Tunnel1 goes up, I'd like to run these commands:

 

1. Remove configuration with "no" command

2. Add configuration "ipv6 local pool MY-POOL <PARSED-PARAMETER-FROM-SHOW-COMMAND> 56"

 

For command 1, I need to do a 

 

"show run | i ipv6[ ]local"

 

... and remove the corresponding config that's returned:

 

ipv6 local pool MY-POOL 1:2:9B00:FD00::/56 56

 

"no ipv6 local pool MY-POOL 1:2:9B00:FD00::/56 56"

 

For command 2, I need to grab the "General Prefix", including the /56 netmask.

 

"show tunnel 6rd"

 

... which gives me the following output:

 

R1#show tunnel 6rd

Interface Tunnel1:

  Tunnel Source: 114.63.91.184

  6RD: Operational, V6 Prefix: 2602::/24

       V4 Prefix, Length: 0, Value: 0.0.0.0

       V4 Suffix, Length: 0, Value: 0.0.0.0

       Border Relay address: 199.238.1.96

  General Prefix: 2602:BD5C:2B16:F100::/56

R1#

 

For command 2, I'd need EEM to run "ipv6 local pool MY-POOL 2602:BD5C:2B16:F100::/56 56" when Tunnel1 comes up.

 

Any ideas on how to accomplish this? Thanks in advance :)

1 Reply 1

Dan Frey
Cisco Employee
Cisco Employee

 

Give this one a try.

 

event manager applet ipv6pool
event syslog pattern "Line protocol on Interface Tunnel1, changed state to up"
action 010 cli command "enable"
action 020 cli command "show run | i ipv6[ ]local"
action 030 cli command "no $_cli_result"
action 040 cli command "show tunnel 6rd"
action 050 regexp "General Prefix: ([0-9A-F:\/]+)" "$_cli_result" mymatch v6subnet
action 060 cli command "conf t"

action 070 cli command "ipv6 local pool MY-POOL $v6subnet 56"