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

Use EEM script to create another EEM Script?

emory.clayton
Level 1
Level 1

The switch accepts all commands until action 11.0. I believe it's because of the additional quotes. Is there a way around this?

event manager applet CODE_DOWNLOAD
event syslog pattern "IOSD_INFRA-6-IFS_DEVICE_OIR: Device usbflash"
action 1.0 cli command "term len 0"
action 1.5 puts "EEM Script CODE_DOWNLOAD Executing"
action 2.0 cli command "enable"
action 2.5 puts "Copying cat9k_iosxe.17.06.04.SPA.bin..."
action 3.0 cli command "copy usbflash0:cat9k_iosxe.17.06.04.SPA.bin flash:" pattern "cat9k_iosxe.17.06.04.SPA.bin"
action 3.5 cli command "cat9k_iosxe.17.06.04.SPA.bin"
Action 4.0 wait 90
action 4.5 puts "Code downloaded, removing configuration from SVI 1"
action 5.0 cli command "conf t"
action 5.5 cli command "int vlan 1"
action 6.0 cli command "no IP address"
action 6.5 cli command "shut"
action 7.0 puts "Setting boot parameters..."
action 7.5 cli command "no boot system"
action 8.0 cli command "boot system bootflash:packages.conf"
action 8.5 cli command "wr mem"
Action 9.0 wait 10
action 10.0 puts "REMOVE_EEM_CODE_DOWNLOAD"
action 10.5 cli command "event manager applet REMOVE_EEM_CODE_DOWNLOAD"
action 11.0 cli command "event syslog pattern "IOSD_INFRA-6-IFS_DEVICE_OIR: Device usbflash"
action 11.5 cli command "action 1.1 puts "Deleting EEM script""
action 12.0 cli command "action 1.2 cli command "enable""
action 12.5 cli command "action 1.2 cli command "conf t""
action 13.0 cli command "action 1.3 cli command "no event manager applet CODE_DOWNLOAD"
action 13.5 cli command
action 14.0 cli command "action 1.4 cli command "install add file bootflash:cat9k_iosxe.17.06.04.SPA.bin activate commit" pattern "Press Yes(y) to save the configuration and proceed."
Action 14.5 cli command "action 1.5 cli command "n"
Action 15.0 cli command "action 1.6 wait 60"
Action 15.5 cli command "action 1.7 cli command pattern "Action 5.5 This operation may require a reload of the system."
Action 16.0 cli command "y"



I have tried using this also, but again the cli doesn't accept the command. I added an additional " to the end, thinking the quotes needed to be closed, 
action 11.0 cli command "event syslog pattern "IOSD_INFRA-6-IFS_DEVICE_OIR: Device usbflash""

1 Reply 1

Casey B
Level 1
Level 1

Hi, You can solve this problem by creating an environment variable for "

event manager environment Q "

event manager applet PortChannel1-Up
event syslog pattern "%LINEPROTO-5-UPDOWN: Line protocol on Interface Port-channel1, changed state to up"
action 0010 syslog msg "Port-channel1 is back up, configuring EEM script to wait 90 seconds before moving VLAN 14 back to Port-channel1"
action 0020 cli command "enable"
action 0030 cli command "configure terminal"
action 0040 cli command "event manager applet Delayed_Vlan14_move"
action 0050 cli command "event timer countdown time $_PortChannel1_UP_TIMER"
action 0060 cli command "action 1.0 syslog msg $Q Port-channel1 has been up for 90 seconds$Q"
action 0070 cli command "action 2.0 cli command $Q enable$Q"
action 0080 cli command "action 3.0 cli command $Q configure terminal$Q"
action 0110 cli command "action 4.0 cli command $Q interface Gi0/1$Q"
action 0120 cli command "action 5.0 cli command $Q switchport trunk allowed vlan none$Q"
action 0090 cli command "action 6.0 cli command $Q interface Port-channel1$Q"
action 0100 cli command "action 7.0 cli command $Q switchport trunk allowed vlan 14$Q"
action 0130 cli command "action 8.0 cli command $Q end$Q"
action 0140 cli command "exit" ;# Exit from EEM applet configuration
action 0150 cli command "exit" ;# Exit from the global configuration mode

Debug:

*Oct 24 05:16:32.049: %HA_EM-6-LOG: PortChannel1-Up : DEBUG(cli_lib) : : OUT : South_DS>
*Oct 24 05:16:32.049: %HA_EM-6-LOG: PortChannel1-Up : DEBUG(cli_lib) : : IN : South_DS>enable
*Oct 24 05:16:32.059: %HA_EM-6-LOG: PortChannel1-Up : DEBUG(cli_lib) : : OUT : South_DS#
*Oct 24 05:16:32.059: %HA_EM-6-LOG: PortChannel1-Up : DEBUG(cli_lib) : : IN : South_DS#configure terminal
*Oct 24 05:16:32.170: %HA_EM-6-LOG: PortChannel1-Up : DEBUG(cli_lib) : : OUT : Enter configuration commands, one per line. End with CNTL/Z.
*Oct 24 05:16:32.170: %HA_EM-6-LOG: PortChannel1-Up : DEBUG(cli_lib) : : OUT : South_DS(config)#
*Oct 24 05:16:32.170: %HA_EM-6-LOG: PortChannel1-Up : DEBUG(cli_lib) : : IN : South_DS(config)#event manager applet Delayed_Vlan14_move
*Oct 24 05:16:32.280: %HA_EM-6-LOG: PortChannel1-Up : DEBUG(cli_lib) : : OUT : South_DS(config-applet)#
*Oct 24 05:16:32.280: %HA_EM-6-LOG: PortChannel1-Up : DEBUG(cli_lib) : : IN : South_DS(config-applet)#event timer countdown time 90
*Oct 24 05:16:32.390: %HA_EM-6-LOG: PortChannel1-Up : DEBUG(cli_lib) : : OUT : South_DS(config-applet)#
*Oct 24 05:16:32.390: %HA_EM-6-LOG: PortChannel1-Up : DEBUG(cli_lib) : : IN : South_DS(config-applet)#action 1.0 syslog msg " Port-channel1 has been up for 90 seconds"
*Oct 24 05:16:32.500: %HA_EM-6-LOG: PortChannel1-Up : DEBUG(cli_lib) : : OUT : South_DS(config-applet)#
*Oct 24 05:16:32.500: %HA_EM-6-LOG: PortChannel1-Up : DEBUG(cli_lib) : : IN : South_DS(config-applet)#action 2.0 cli command " enable"
*Oct 24 05:16:32.610: %HA_EM-6-LOG: PortChannel1-Up : DEBUG(cli_lib) : : OUT : South_DS(config-applet)#
*Oct 24 05:16:32.610: %HA_EM-6-LOG: PortChannel1-Up : DEBUG(cli_lib) : : IN : South_DS(config-applet)#action 3.0 cli command " configure terminal"
*Oct 24 05:16:32.720: %HA_EM-6-LOG: PortChannel1-Up : DEBUG(cli_lib) : : OUT : South_DS(config-applet)#
*Oct 24 05:16:32.720: %HA_EM-6-LOG: PortChannel1-Up : DEBUG(cli_lib) : : IN : South_DS(config-applet)#action 6.0 cli command " interface Port-channel1"
*Oct 24 05:16:32.830: %HA_EM-6-LOG: PortChannel1-Up : DEBUG(cli_lib) : : OUT : South_DS(config-applet)#
*Oct 24 05:16:32.830: %HA_EM-6-LOG: PortChannel1-Up : DEBUG(cli_lib) : : IN : South_DS(config-applet)#action 7.0 cli command " switchport trunk allowed vlan 14"
*Oct 24 05:16:32.940: %HA_EM-6-LOG: PortChannel1-Up : DEBUG(cli_lib) : : OUT : South_DS(config-applet)#
*Oct 24 05:16:32.940: %HA_EM-6-LOG: PortChannel1-Up : DEBUG(cli_lib) : : IN : South_DS(config-applet)#action 4.0 cli command " interface Gi0/1"
*Oct 24 05:16:33.050: %HA_EM-6-LOG: PortChannel1-Up : DEBUG(cli_lib) : : OUT : South_DS(config-applet)#
*Oct 24 05:16:33.050: %HA_EM-6-LOG: PortChannel1-Up : DEBUG(cli_lib) : : IN : South_DS(config-applet)#action 5.0 cli command " switchport trunk allowed vlan none"
*Oct 24 05:16:33.160: %HA_EM-6-LOG: PortChannel1-Up : DEBUG(cli_lib) : : OUT : South_DS(config-applet)#
*Oct 24 05:16:33.160: %HA_EM-6-LOG: PortChannel1-Up : DEBUG(cli_lib) : : IN : South_DS(config-applet)#action 8.0 cli command " end"
*Oct 24 05:16:33.270: %HA_EM-6-LOG: PortChannel1-Up : DEBUG(cli_lib) : : OUT : South_DS(config-applet)#
*Oct 24 05:16:33.270: %HA_EM-6-LOG: PortChannel1-Up : DEBUG(cli_lib) : : IN : South_DS(config-applet)#exit
*Oct 24 05:16:33.280: %HA_EM-6-LOG: PortChannel1-Up : DEBUG(cli_lib) : : OUT : South_DS(config)#
*Oct 24 05:16:33.280: %HA_EM-6-LOG: PortChannel1-Up : DEBUG(cli_lib) : : IN : South_DS(config)#exit


Review Cisco Networking for a $25 gift card