Examples of NCM config change templates
A config change template consists of two parts: parameters and commands. The following sections describe the parameters and commands in the example templates:
- Change VLAN Membership on Ports Cisco IOS example
- Enable NetFlow on Cisco ASA example
- Include a custom property
For more information, see:
Change VLAN Membership on Ports Cisco IOS example
A config change template named Change VLAN Membership on Ports Cisco IOS is installed with NCM. Its purpose is to change VLAN membership on Cisco IOS device ports.
The following sections explain the specific components of a config change template by demonstrating how to use the Change VLAN Membership on Ports Cisco IOS template to make VLAN membership config changes on hypothetical Cisco device interfaces.
This section assumes that you know how to make VLAN membership changes to device interfaces from the Cisco IOS command line. This section also assumes that you are familiar with using variables, data arrays, foreach loops, if/else conditional statements, and logical operators in creating system administration scripts.
The following sections show the reference template broken up into parameter, command, and output sections.
Parameters
These are the parameters for the Change VLAN Membership on Ports Cisco IOS template. Notice that the parameters already have values associated with them, which are either a string or a variable.
/* .CHANGE_TEMPLATE_DESCRIPTION This change template configures VLAN membership on Cisco IOS devices. The template was verified on Cisco 2950 Catalyst Switch running IOS software version 12.1(12c). .CHANGE_TEMPLATE_TAGS Cisco, IOS, VLAN Membership .PLATFORM_DESCRIPTION Cisco IOS .PARAMETER_LABEL @ContextNode NCM Node .PARAMETER_DESCRIPTION @ContextNode The node the template will operate on. All templates require this by default. The target node is selected during the first part of the wizard so it will not be available for selection when defining values of variables. .PARAMETER_LABEL @TargetPorts Select Port(s) .PARAMETER_DESCRIPTION @TargetPorts Select the port(s) for which you would like to change VLAN membership. .PARAMETER_LABEL @VlansToRemove VLAN(s) to remove .PARAMETER_DESCRIPTION @VlansToRemove Select the VLAN(s) to remove. Selecting VLANs irrelevant to interfaces results in no actions taken for those interfaces. .PARAMETER_LABEL @VlanToAssign VLAN to assign .PARAMETER_DESCRIPTION @VlanToAssign Select the VLAN you would like to assign. */
Commands
There is one instance of the script command and multiple instances of the CLI{ }
command, and all variables have declarations.
script ConfigureVLANmembershipCiscoIOS ( NCM.Nodes @ContextNode, NCM.Interfaces[] @TargetPorts, NCM.VLANs[] @VlansToRemove, NCM.VLANs @VlanToAssign ) { // Enter configuration mode CLI { configure terminal } // Loop through selected ports foreach (@portItem in @TargetPorts) { CLI { interface @portItem.InterfaceDescription } // Loop through list of vlans to remove foreach (@vlanRemove in @VlansToRemove) { CLI { no switchport access vlan @vlanRemove.VLANID } } CLI { switchport access vlan @VlanToAssign.VLANID } CLI { exit } } // Exit configuration mode CLI { exit } }
Output commands
These are the commands that NCM executes after logging on to the NCM device(s) selected as the target for this config change template. We are changing VLAN membership on one interface of two different Cisco switches.
bgp-2651-03
configure terminal interface FastEthernet0/0 no switchport access vlan 1004 switchport access vlan 1002 exit exit
cur-3725
configure terminal interface FastEthernet0/1 no switchport access vlan 1004 switchport access vlan 1002 exit exit
Enable NetFlow on Cisco ASA example
A config change template named Enable NetFlow on CiscoASA is installed with NCM. It configures a Cisco ASA for NetFlow export.
Here are the commands that this template executes on the command line of the targeted devices selected in the template's run-time setup wizard. For this example, we are including values as if the user entered them in the wizard interface.
configure terminal flow-export destination inside 10.10.18.157 2055 flow-export template timeout-rate 1 flow-export delay flow-create 60 logging flow-export syslogs disable access-list netflow-export extended permit ip any class-map netflow-export-class match access-list netflow-export policy-map netflow-policy class netflow-export-class flow-export event-type all destination 10.10.18.157 service-policy netflow-policy global flow-export enable exit end
You could execute this set of CLI commands on your target device and the result would be config changes in the status of NetFlow data processing by the device.
The config change template that produces this output of CLI commands is:
/* .CHANGE_TEMPLATE_DESCRIPTION This change template configures your Cisco ASA for NetFlow export. This was verified on an ASA 5505 running ASA software version 8.2(1)12. .CHANGE_TEMPLATE_TAGS Cisco, ASA, NetFlow .PLATFORM_DESCRIPTION Cisco ASA .PARAMETER_LABEL @ContextNode NCM Node .PARAMETER_DESCRIPTION @ContextNode The node the template will operate on. All templates require this by default. The target node is selected during the first part of the wizard so it will not be available for selection when defining values of variables. .PARAMETER_LABEL @NetFlowCollectorIPAddress NetFlow Collector IP Address .PARAMETER_DESCRIPTION @NetFlowCollectorIPAddress Enter the IP address of the server running the NetFlow traffic analysis solution (for example: SolarWinds NetFlow Traffic Analyzer). .PARAMETER_LABEL @NetFlowExportPort NetFlow Export Port .PARAMETER_DESCRIPTION @NetFlowExportPort Enter the NetFlow export port The default for SolarWinds NTA is 2055. */ script EnableNetflowOnCiscoASA ( NCM.Nodes @ContextNode, string @NetFlowCollectorIPAddress, int @NetFlowExportPort ) { // Enter configuration mode and generate NetFlow commands CLI { configure terminal flow-export destination inside @NetFlowCollectorIPAddress @NetFlowExportPort flow-export template timeout-rate 1 flow-export delay flow-create 60 logging flow-export-syslogs disable access-list netflow-export extended permit ip any any class-map netflow-export-class match access-list netflow-export policy-map netflow-policy class netflow-export-class flow-export event-type all destination @NetFlowCollectorIPAddress service-policy netflow-policy global flow-export enable exit } }
Parameters
The parameters defined at the beginning of this script create an interface in which the user types the IP address and port of the NetFlow receiver.
.PARAMETER_LABEL @NetFlowCollectorIPAddress NetFlow Collector IP Address .PARAMETER_DESCRIPTION @NetFlowCollectorIPAddress Enter the IP address of the server running the NetFlow traffic analysis solution (e.g. SolarWinds NetFlow Traffic Analyzer--NTA). .PARAMETER_LABEL @NetFlowExportPort NetFlow Export Port .PARAMETER_DESCRIPTION @NetFlowExportPort Enter the NetFlow export port (default for SolarWinds NTA is 2055).
The first line defines the parameter or variable name (in this case, @NetFlowCollectorIPAddress
) for which the user enters a value in the wizard interface text box at run time. The second line defines the label (in this case, NetFlow Collector IP Address) that appears in the wizard interface to prompt the user to enter the IP address. The third and fourth lines define the description that appears below the wizard interface text box.
The parameters for NetFlow Export Port (in lines 5-12) function exactly the same way as the first four. The parameter variables, labels, and descriptions guide the config change template's run-time execution by receiving specific user input.
Command declarations (script)
The script declarations include all the variables for which the template prompts the user to provide input. In this case, three variables and their data types are declared:
script EnableNetflowOnCiscoASA ( NCM.Nodes @ContextNode, string @NetFlowCollectorIPAddress, int @NetFlowExportPort ) {
NCM.Nodes is applied to the @ContextNode
variable. NCM.Nodes refers to the Nodes entity in the SolarWinds Information Service (SWIS). In the interface wizard, the user enters a string value for the NetFlow Collector IP Address and an integer value for the NetFlow Export Port on the device.
For a complete list of entities and properties, see SWIS entities used in config change templates.
CLI commands
The majority of config change template code outputs original CLI commands with only a few parsed variables. Any time a variable is referenced, a value is used in its place. For example, since the user typed 10.10.18.157
as the IP address and 2055
as the collector port number, @NetFlowCollectorIPAddress
is replaced with 10.10.18.157
and @NetFlowExportPort
is replaced with 2055
when the script runs.
flow-export destination inside @NetFlowCollectorIPAddress @NetFlowExportPort
The previous line of code generates the following output:
flow-export destination inside 10.10.18.157 2055
Include a custom property
The following example updates the SNMP location to a defined custom property called City
.
script ScriptToChangeSomething (NCM.Nodes @ContextNode)
{
//Reference Node Custom Property
CLI
{
configure terminal
snmp-server location @ContextNode.City
}
CLI {exit}
}