Showing results for 
Search instead for 
Did you mean: 

EEM Configure interface based on description

Level 1
Level 1

I am trying to create a script that configures an interface based on what description you have configured it as. For example if I set "description PRINT" on a interface I want the interface to get configured as a trunk interface. I have managed to complete both the EEM applet and the python script but it is not working as I want it to. The python script need to know the interface to be able to configure, I have done this by writing %s as you can see below. But when I write the action for the EEM applet where it says "guestshell run python /flash/" I need to write a interface, for example GigabitEthernet1/0/1. I can for example write GigabitEthernet1/0/1 instead of GigabitEthernet* and it works to configure that interface. However I want it to be able to configure any interface and not just one specific. Is there any simple way to do this?



event manager applet AUTO_CONFIGURE
event cli pattern "description ADM" sync no skip yes
action 0.0 cli command "enable"
action 1.0 cli command "guestshell run python /flash/ GigabitEthernet*"


Python script

import sys
from cli import cli,clip,execute,executep,configure,configurep

intf= sys.argv[1:]
intf = ''.join(intf[0])

print ('This script is going configure interface %s'%intf)

if intf != 'Fo1/1/2':
cmd='int %s,switchport mode trunk, switchport trunk allowed vlan 540,end' % intf


executep('show ip interface brief')


Thanks in advance!

0 Replies 0