06-01-2015 03:24 AM
Is it possible for EEM scripting to be used to check that the correct prompt is showing when a particular command is entered?
For example if I am in BGP config mode and I type:
Router(config-router)#address-family ipv4 unicast vrf 1234
I would like to make sure that the prompt changes to:
Router(config-router-af)#
This would prevent someone accidentally mistyping the VRF and end up putting code in the global address family that could cause problems. An alternative might be to detect the % VRF 1234 does not exist. warning instead?
06-12-2015 05:07 PM
Unfortunately, you cannot match the prompt in this manner. However, you can use the CLI event detector to match the address-family ... command and then check to see that the VRF actually exists. If it doesn't you can print a message that might be more visible to the user. I'm not sure if this would be sufficient for your use case, though.
07-17-2015 03:04 AM
Hi Joseph,
We have managed to come up with this to server our purpose:
event manager session cli username eemauto
event manager applet BGP_VRF_CHECK
event cli pattern "address-family ipv4 vrf .*" sync yes
action 10 cli command "enable"
action 20 cli command "configure terminal"
action 30 cli command "router bgp 1234"
action 40 cli command "$_cli_msg"
action 50 string length "$_cli_result"
action 60 if $_string_result lt 50 goto END
action 70 regexp "% VRF (.*) does not exist." "$_cli_result" not_configured vrf
action 80 syslog msg "CATCH_AF_VRF_NOT_EXIST: VRF $vrf is not configured. Networks please investigate."
action END set _exit_status "1"
Not as smooth as I would like as it is dependent on the resulting length of the % VRF (.*) does not exist. message. It will generate a syslog message that we can then detect and send a message out.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide