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.

Dynamic Vlan Change Template

Attempting to modify the built in "Change Interfaces based on Description Cisco IOS".  The ideal plan for the template to determine the voice vlan configured on the L2 switch, find all ports using our standard access port naming convention, and then generate the switchport voice vlan # cmd for all interfaces matching the description. We have around 1000 L2 switches with around 75 routers. Each router has it's own voice vlan.  We are utilizing mab authentication which up until now when we started going through a network infrastructure upgrade, mab was authenticating voip correctly, with the new equipment voip was not assigning the correct vlan with mab and we need to hardset the voice vlan on standard user access ports.

Below is where I am currently at.

script ChangeVoiceVlanbyIntDesc (

                                        NCM.Nodes @ContextNode,

                                        NCM.VLANs[] @VLANID,

                                        string @ItfDescriptionMatchValue )

                                   

{

  // Enter configuration mode

  CLI

  {

    configure terminal

  }

  int @MatchFound

  @MatchFound = 0

  // Determine VLANID for Voice Vlan

  @VLANID = @VLANID if (@VLANName contains 'VOICE_VLAN1')

  // 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.InterfaceAlias contains @ItfDescriptionMatchValue){

            {

               // Set command

                CLI

                 {

                    interface @interfaceItem.InterfaceDescription

                 }

                    CLI

                     {

                         switchport voice vlan @VLANID.VLANID

                  }

            }

             }else

            {

                  CLI

                 {

                    exit

                 }

            }

        }

             @MatchFound = 1

        }

   }