Hi,
I looking for the best way to do this. I have NCM and NPM. Which tool is the best for that :
I want to create a script that will search for down/disabled/err-disabled ports on nodes (all cisco switches) and gives me the possibility to shutdown or "no shutdown" it.
I'm trying to do it via Config change templates but i'm not successful.
Can you help me on this or give me a better for to do it ?
Thank you
/*
.CHANGE_TEMPLATE_DESCRIPTION
This template changes status of interfaces base on it's current status.
.CHANGE_TEMPLATE_TAGS
Cisco, status, interface
.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 @ItfStatusMatchType
Match Type
.PARAMETER_DESCRIPTION @ItfStatusMatchType
Status of port you're looking for
.PARAMETER_DISPLAY_TYPE @ItfStatusMatchType
listbox: 1=connected|2=notconnect|3=disabled|4=err-disabled
.PARAMETER_LABEL @ItfCommands
List of commands
.PARAMETER_DESCRIPTION @ItfCommands
Enter a list of commands, separated by a comma, that you want executed with each iteration.
*/
script ChangeInterfacesBasedOnDescription (
NCM.Nodes @ContextNode,
string @ItfStatusMatchType,
string[] @ItfCommands )
{
// Enter configuration mode
CLI
{
configure terminal
}
int @MatchFound
@MatchFound = 0
// Loop through selected interfaces
foreach (@interfaceItem in @ContextNode.Interfaces)
{
if (@interfaceItem.InterfaceDescription contains 'VLAN')
{
// Do nothing if it's not a physical interface
}
else
{
if (@interfaceItem.?????? (how to get port status??) contains @ItfStatusMatchType)
{
// Set command
CLI
{
interface @interfaceItem.InterfaceDescription
}
foreach (@line in @ItfCommands)
{
CLI
{
@line
}
}
CLI
{
exit
}
@MatchFound = 1
}
}
}
if (@MatchFound != 1)
{
CLI
{
NO MATCHES FOUND
}
}
// Exit configuration mode
CLI
{
exit
}
}