Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. And see here for current known issues.

New Member

EEM to apply Smart Port Macro

Hi,

I use macros to configure access ports and voice ports, here is a sample of how it is called.

interface range GigabitEthernet1/0/20 - 24

macro apply cisco-voice $access_vlan 10 $voice_vlan 20

I am trying to call this in an EEM script but am getting the error below.  

000954: .Jun 29 16:16:24.937 CEST: %HA_EM-3-FMPD_UNKNOWN_ENV: fh_parse_var: could not find environment variable: access_vlan
000955: .Jun 29 16:16:24.937 CEST: %HA_EM-3-FMPD_ERROR: Error executing applet POST_PNP statement 1.7

I have messed around with a set variable but am not sure I am going in the right direction.

conf t
no event manager applet POST_PNP
event manager applet POST_PNP
 event timer countdown time 5
 action 1.0 cli command "enable"
 action 1.1 cli command "config t"
 action 1.2 cli command "default interface range GigabitEthernet1/0/20 - 24"
 action 1.5 cli command "interface range GigabitEthernet1/0/20 - 24"
 action 1.6 set ???
 action 1.7 cli command "macro apply cisco-voice $access_vlan 10 $voice_vlan 20"
 action 2.0 cli command "exit"
 action 2.1 cli command "no event manager applet POST_PNP"
 action 2.2 cli command "end"
 action 2.3 cli command "exit"
exit
end

Here is the full macro

test#show parser macro name cisco-phone
Macro name : cisco-phone
Macro type : default interface
# Cisco IP phone + desktop template

# macro keywords $access_vlan $voice_vlan

# VoIP enabled interface - Enable data VLAN
# and voice VLAN
# Recommended value for access vlan should not be 1
switchport access vlan $access_vlan
switchport mode access

# Update the Voice VLAN value which should be
# different from data VLAN
# Recommended value for voice vlan should not be 1
switchport voice vlan $voice_vlan

# Enable port security limiting port to a 2 MAC
# addressess -- One for desktop on data vlan and
# one for phone on voice vlan
switchport port-security
switchport port-security maximum 2

# Ensure port-security age is greater than one minute
# and use inactivity timer
switchport port-security violation restrict
switchport port-security aging time 2
switchport port-security aging type inactivity

# Enable auto-qos to extend trust to attached Cisco phone
auto qos voip cisco-phone

# Configure port as an edge network port
spanning-tree portfast
spanning-tree bpduguard enable

1 ACCEPTED SOLUTION

Accepted Solutions
Cisco Employee

I don't mix EEM and macros. 

I don't mix EEM and macros.  They both use '$' to denote variables, and in this case EEM is winning and complaining it cannot find those variables (and you don't want it to).

What I would recommend is to copy your whole macro into EEM and use EEM (if you want to) to apply the whole config.  This is similar to what I do in https://supportforums.cisco.com/document/100791/automatically-set-port-descriptions .

If you do not want to do that, you'll need to create a variable to stand for the variables:

event manager environment av $access_vlan

event manager environment vv $voice_vlan

Then:

macro apply cisco-voice $av 10 $vv 20

1 REPLY
Cisco Employee

I don't mix EEM and macros. 

I don't mix EEM and macros.  They both use '$' to denote variables, and in this case EEM is winning and complaining it cannot find those variables (and you don't want it to).

What I would recommend is to copy your whole macro into EEM and use EEM (if you want to) to apply the whole config.  This is similar to what I do in https://supportforums.cisco.com/document/100791/automatically-set-port-descriptions .

If you do not want to do that, you'll need to create a variable to stand for the variables:

event manager environment av $access_vlan

event manager environment vv $voice_vlan

Then:

macro apply cisco-voice $av 10 $vv 20

139
Views
0
Helpful
1
Replies
CreatePlease login to create content