Macros
Macros, called smartport macros by Cisco, are groups of commands saved with reference names. Macros are useful when you find yourself entering the same group of commands repeatedly. For example, say youâre adding a lot of servers. Every time you add a server, you execute the same configuration commands for the switch interface to be used for that server. You could create a macro that would execute all of the commands automatically and then simply reference this macro every time you add a new server to the switch.
You create macros are created with the macro
command. There are
two types of macros: global and
interface. An interface macro (the default type) is applied to one or
more interfaces. To make a macro global, include the global
keyword when creating it.
The way macros are created is a little strange, because the commands
are not parsed as you enter them. As a result, you can enter invalid
commands without causing errors. First, enter the macro name
macroname
command. Because youâre not including the global
keyword, this will be an interface macro.
Then, enter the commands youâd like to include in the macro, one by one.
These commands are not checked for syntax. When youâre done entering
commands, put an at sign (@
) on a line
by itself.
Here, Iâve created a macro named SetServerPorts. The commands
included are spanning-tree
portfast
, hhhhhh
(an invalid
command), and description <[ Server
]>
:
3750(config)#macro name SetServerPorts
Enter macro commands one per line. ...
Get Network Warrior, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.