I was wondering whether anyone has some information on how to execute an EEM script on a switch reload before the ports can start forwarding. Effectively the problem is the host ports start forwarding before the bgp session is established and I would like the script to shut down the ports immediately before then can start forwarding. Only when the BGP session is established the host ports can be unshut.
Any advise on this please?
event manager applet interface_Shutdown
event timer cron cron-entry "@reboot"
action 1.0 cli command "config t"
action 2.0 cli command "interface eth1/1-10"
action 3.0 cli command "shutdown"
action 4.0 cli command "end"
The above script is inconsistent and looking at the actin-cli-logs 9/10 times it says system unable to parse commands.
Is there a bug on the 9k running i 7.0.3.i7(6)
Solved! Go to Solution.
Likely you're seeing a race condition. Ultimately, there may not be a reliable way to do what you want and do it soon enough in the boot process. But you could try looking for a syslog message that occurs after boot that would give the switch enough time to allow config changes, and use this instead of the cron timer. Alternatively, you could try executing a Python script that can call "time.sleep(N)" where N is a number of seconds to sleep before trying to execute the same config commands. Something like:
cli.clip('config t ; int e1/1-10 ; shut')
thanks @Joe Clarke
I've ended up using
event manager applet track-up
event syslog pattern "%ASCII-CFG-2-CONF_CONTROL: System ready"
action 1.0 cli conf
action 2 cli event manager applet track-timer
action 3 cli event timer countdown time 10
action 4 cli action 1.0 cli config
action 5 cli action 2.0 cli int eth1/1-10
action 6 cli action 3.0 cli shut
action 7 cli action 4.0 cli end
seems to do the job and 10 seconds is enough to trigger the disable.. still gotta burn test this but looks like i have a way forward. Please let me know if this can be improved or if there's any flaws in the above.
Would there be any harm if it was written to the startup config. I don't see what would trigger it to execute.
Ah i just got what you meant on this.
Yes, I'll do so and thanks again for your help with this.