11-24-2011 01:53 AM
Hi
Does anyone know if its possible to make a template that gets data and uses it to make commands, example:
Say i want the description field on all trunks to include the hostname of the next-hop.
Could i use something like "show cdp nei" as preceding/parrent and then somehow refer to that data with my + [#description something #] command? Or maybe do it without a preceding command?
Any help would be much appreciated.
Thanks.
11-25-2011 05:55 PM
Unfortunately not. Operational data like this is something we have asked for, and we will likely see it in a future release. You could use embedded scripting such as the Embedded Event Manager on the device to detect CDP neighbor changes on an interface and update the description. You could use an EEM applet like the following on switches running recent code:
event manager applet cdp-descr
event neigh cdp add interface regexp .*Ethernet.*
action 1.0 cli command "enable"
action 2.0 cli command "config t"
action 3.0 cli command "int $_nd_local_intf_name"
action 4.0 cli command "description Connection to $_nd_cdp_entry_name"
action 5.0 cli command "end"
11-28-2011 01:08 AM
Thanks for the answer.
It looks like it would be a perfect solution, but i need it on 2000+ switches which doesnt have the ip service image. So is there an alternative?
Also what i actually need in the description field is hostname and port name of next hop. How would you get the next-hop port in an EEM aplet.
Thanks.
11-28-2011 08:17 AM
IP SERVICES should not be a prereq if the switches are running new enough code. However, if they are 29XX switches, EEM will not work. Auto Smart Ports macros will, though. You can use LMS to push macro configurations down to your switches.
For the next-hop port, you could use:
event manager applet cdp-descr
_nd_port_id
event neigh cdp add interface regexp .*Ethernet.*
action 1.0 cli command "enable"
action 2.0 cli command "config t"
action 3.0 cli command "int $_nd_local_intf_name"
action 4.0 cli command "description Connection to $_nd_cdp_entry_name : $"
action 5.0 cli command "end"
11-29-2011 01:13 PM
Thanks for the answers.
I think i might be able to do it with Auto smart ports. But how would you write the macro? I dont know how to refer to a value from cdp.
Thanks.
12-01-2011 11:04 PM
Check out the command "show shell functions". This will show you the built-in ASP macros, which are great ways of getting started. While I haven't tried this, ASP is built on top of EEM, so you should be able to use something like:
$_nd_cdp_entry_name
and
$
_nd_port_id
Within your macro.
12-02-2011 12:20 AM
Ok im with you this far, but do you then know how to add a variable to a description field. So it will be used as the value of the variable instead of regular text.
I can see that "macro description" accepts commands like $trigger - - but the regular description doesnt seem to accept variables that easy.
Thanks.
12-02-2011 01:36 AM
Have a look at http://www.cisco.com/en/US/partner/docs/switches/lan/auto_smartports/12.2_58_se/configuration/guide/configure.html#wp1053766. In particular, you will likely be configuring a CISCO_ROUTER_EVENT, CISCO_SWITCH_EVENT, and/or CISCO_WIRELESS_AP_EVENT.
12-02-2011 12:04 PM
I get "Forbidden File or Application" when i try to log in.
Do you have another link?
Thanks.
12-03-2011 11:34 AM
Sorry, I forgot to yank out the parnter piece. Try:
12-06-2011 03:44 AM
First off all, thanks for all your help.
I've tried to read through the document, but i cant find what im seeking. Maybe im reading it wrong.
I do understant that im making an event that causes some commands to be executed on all or a specific interface, depending on how i configure it.
My problem is that i dont know the command/commands to tell the switch that what i write in the description field is not just text but a variable. Ive tried $_nd_cdp_entry_name and {$_nd_cdp_entry_name} and [$_nd_cdp_entry_name]... the list could go on. Do you have an idea of how to tell the description field that "its" a variable instead of just text.
Thanks.
12-06-2011 08:03 AM
Your first try was right. Something like:
if [[ $LINKUP -eq YES ]]; then
config t
interface $INTERFACE
description $_nd_cdp_entry_name ...
end
fi
06-08-2013 09:27 PM
Very nice input.
Do you know if there is any reason why this works:
macro auto execute AIRONET_3502I ACCESS_VLAN=m-net {
if [[ $LINKUP == YES ]]
then conf t
interface $INTERFACE
macro description $TRIGGER
desc m-net
switchport access vlan $ACCESS_VLAN
switchport mode access
exit
end
fi
if [[ $LINKUP == NO ]]
then conf t
interface $INTERFACE
no macro description
no desc m-net
no switchport access vlan $ACCESS_VLAN
no switchport mode access
exit
end
fi
}
But this doesnt:
macro auto execute CISCO_CUSTOM_EVENT ACCESS_VLAN=P-net {
if [[ $LINKUP == YES ]]
then conf t
interface $INTERFACE
exit
end
fi
if [[ $LINKUP == NO ]]
then conf t
interface $INTERFACE
desc P-net
switchport access vlan $ACCESS_VLAN
switchport mode access
exit
end
fi
}
Thanks for your help
Isaac
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