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

EEM Script to format flash & copy new IOS from USB

davhickm
Cisco Employee
Cisco Employee

Trying to create an EEM script to reset lab gear to a default configuration and/or new version.  I want to format the flash then copy over a new IOS and set the boot statement.  The script works through the formating of the flash then stops.

 

!

event manager applet prep4_day0
event none sync yes
action 1.0 syslog msg "Start: 'prep4_day0' EEM applet."
action 1.5 puts "Preparing device to be factory reset - This script will reboot the device."
action 2.10 puts "Starting flash preparation"
action 2.15 cli command "enable"
action 2.20 cli command "format flash:" pattern "confirm"
action 2.25 cli command "y"
action 2.30 wait 30
action 3.0 puts "Starting copy process"
action 3.5 cli command "copy usbflash0:IOS/cat9k_iosxe.16.09.03s.SPA.bin flash:" pattern "cat9k_iosxe.16.09.03s.SPA.bin"
action 3.10 cli command "\n"
action 3.15 wait 300
action 4.0 puts "Starting set boot file"
action 4.5 cli command "boot system switch all flash:cat9k_iosxe.16.09.03s.SPA.bin"
action 4.10 cli command "write"
action 5.0 puts "Erasing startup-config."
action 5.5 cli command "wr er" pattern "confirm"
action 5.10 cli command "y"

action 9.0 puts "Device has been prepped. Rebooting."
action 9.5 syslog msg "Stop: 'prep4_day0' EEM applet."
action 9.10 reload
!

 

 

1 Reply 1

Dan Frey
Cisco Employee
Cisco Employee

EEM has a default time maxrun time of 20 seconds.    Increase max time to something more than all the wait timers in the script.

 

Try changing this line to include maxrun parameter. 

event none sync yes maxrun 360

Review Cisco Networking for a $25 gift card