Hey all,
first time posting here. Was wondering whether the knowledgeable programmers / scripters could assist me with a Network Configuration Manager Script. I'm neither a SQL nor a scripting expert. I hack (dabble) away at both systems to try and get an outcome, so please forgive my knowledge and terminology if it somewhat lacks.
What I'm trying to achieve is as follows
1) Check all physical interfaces for all NCM Cisco nodes for the presence of 'ip address%' (this would dictate that it's a routable / layer 3 interface)
2) perform Cisco CLI Commands on given identified interface
From a SQL perspective I can see that there are two tables that would need to be linked in the query [dbo].[Interfaces] and [dbo].[IPAddresses] and that they would need to be linked on field [InterfaceID].
So if [dbo].[IPAddresses].[IPAddress] is present / populated (not blank), using a link from [dbo].[IPAddresses].[InterfaceID] to [dbo].[Interfaces].[InterfaceID], perform actions Cisco CLI configuration on [dbo].[Interfaces].[InterfaceName]. I hope this makes sense.
I've been looking through the 'out of the box' NCM 7.2.2 scripts to see if there is something applicable. I believe the "Edit Configure Interfaces Based on Description Cisco IOS" could be changed to accommodate, but that's where I get completely lost =) From what I can ascertain this script is based on SQL [dbo].[Interfaces] table using @ContextNode.Interfaces
I guess the first question is what programming language are the NCM scripts in ? So I can Google the relevant syntax etc ?
This was my n00b attempt at the task. I fully realise is it probably not the correct approach and would appreciate some feedback on Syntax etc.
==================================
Code sample
==================================
/*
.CHANGE_TEMPLATE_DESCRIPTION
This change template configures Cisco L3 routable interfaces with specific CLI Configuration
.CHANGE_TEMPLATE_TAGS
Cisco, IOS, Routable, L3
.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 @CLICommands
List of commands
.PARAMETER_DESCRIPTION @CLICommands
Enter a list of commands, separated by a comma, that you want executed with each iteration.
*/
script ConfigureL3InterfacesCiscoIOS (
NCM.Nodes @ContextNode,
string[] @CLICommands
string[] @intItem
string[] @intItemID
int @MatchFound
{
// Enter configuration mode
CLI
{
configure terminal
}
@MatchFound = 0
// Loop through selected interfaces
foreach (@intItem in @ContextNode.IPAddresses)
{
if (@interfaceItem.IPAddress != null )
{
@intItemID == @ContextNode.IPAddresses.InterfaceID
foreach (@intItemID in @ContextNode.Interfaces)
{
if (@intItemID == InterfaceID )
{
// Set command
CLI
{
interface @interfaceItem.InterfaceDescription
}
foreach (@line in @CLICommands)
{
CLI
{
@line
}
}
CLI
{
exit
}
@MatchFound = 1
}
}
}
}
// Does not contain IP address statement
if (@MatchFound != 1)
{
CLI
{
NO MATCHES FOUND
}
}
// Exit configuration mode
CLI
{
exit
}
}