This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

Custom Change Template Question

Im currently having trouble getting the result I want from a Custom Change Template.

The point is to deploy the template to add on the specified command onto the selected switches if the prompted string matches. But currently, it runs right through with no matches.
For example:
If the string Port-channel is entered, the commans speciifed should be run on each port-channel the switch can find.

Any suggestions as to what should be changed?









/*

.CHANGE_TEMPLATE_DESCRIPTION

        This template configures physical interfaces based on interface description.  It was verified on a Cisco 2950 Catalyst Switch running IOS software version 12.1(12c).

.CHANGE_TEMPLATE_TAGS

  Cisco, interface, VLAN, description, properties

.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 @Interface

        Interface-string

.PARAMETER_DESCRIPTION @Interface

        The string that the interfaces matches on.

.PARAMETER_LABEL @InterfaceMatchType

        Match Type

.PARAMETER_DESCRIPTION @InterfaceMatchType

        Exact match will determine a match on exactly what you enter. 'Contains...' will determine a match on the pattern of what you enter as found anywhere in the description.

.PARAMETER_DISPLAY_TYPE @InterfaceMatchType

        listbox: 1=Contains|2=Exact Match

.PARAMETER_LABEL @InterfaceCommands

        List of commands

.PARAMETER_DESCRIPTION @InterfaceCommands

        Enter a list of commands, separated by a comma, that you want executed with each iteration.       

*/

script ChangeInterfacesBasedOnDescription (

                                            NCM.Nodes @ContextNode,

                                            string @Interface,

                                            string @InterfaceMatchType,

                                            string[] @InterfaceCommands             )

{

  // Enter configuration mode

  CLI

  {

    configure terminal

  }

int @MatchFound

@MatchFound = 0

// Loop through selected interfaces

  foreach (@interfaceItem in @ContextNode.Interfaces)

// Determine if user wants exact or fuzzy match

      if (@InterfaceMatchType == 'Contains') 

      {

         if (@interfaceItem.InterfaceDescription contains @Interface)

         {

             // Set command

             CLI

             {

                interface @interfaceItem.InterfaceDescription

             }

             foreach (@line in @InterfaceCommands)

             {

                CLI

                {

                  @line

                }

             }

             CLI

             {

                exit

             }

             @MatchFound = 1

         }

      }

// Determine if user wants exact or fuzzy match

      if (@InterfaceMatchType == 'Exact Match') 

      {

          if (@interfaceItem.InterfaceDescription contains @Interface)

         {

             // Set command

             CLI

             {

               interface @interfaceItem.InterfaceDescription

             }

             foreach (@line in @InterfaceCommands)

             {

                CLI

                {

                  @line

                }

             }

             CLI

             {

                exit

             }

             @MatchFound = 1

         }

      }

  if (@MatchFound != 1)

  {

     CLI

     {

         NO MATCHES FOUND

     }

  }

  // Exit configuration mode

  CLI

  {

    exit

  }

}