0 Replies Latest reply on May 22, 2018 1:16 PM by cslacker

    Possible to iterate through all interfaces without declaring in template?


      Is it possible to iterate through all interfaces on a device without specifying them in "Define Variables"?  The script below is meant to ask the user for a VRF name, then ask what ip addresses to place into the VRF.  I achieve this by matching the IPAddress.InterfaceIndex to the Interface.InterfaceIndex to know which interface to apply the config against.  I don't really need the user to specify which interfaces to inspect.


      If there's a better way to do this I'm happy to hear it!






              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).


          Cisco, interface, VLAN, description, properties


              Cisco IOS


      .PARAMETER_LABEL @ContextNode

              NCM Node


              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.



              VRF names


              Enter a VRF name that you would like on the device(s.



              IP Addresses to place


              Select IP addresses you'd like to plop into this VRF.




      script ChangeInterfacesBasedOnDescription (

                                                  NCM.Nodes @ContextNode,

                                                  string @VRFName, 

                                                  NCM.Interfaces[] @AllPorts,

                                                  NCM.IpAddresses[] @PlaceInVRF



        // Enter configuration mode



          configure terminal

          ip vrf @VRFName


        foreach (@IP in @PlaceInVRF)


          foreach (@Port in @AllPorts)


            if (@IP.InterfaceIndex == @Port.InterfaceIndex)




                int @Port.InterfaceName

                ip vrf forwarding @VRFName

                ip address @IP.IPAddress @IP.SubnetMask