1 Reply Latest reply on Jan 18, 2017 5:39 PM by sixmill

    Interface configuration changes with Adtran switches

    sixmill

      I'm working through a task to enable bpduguard on all of the access interfaces of my switches that have portfast enabled (as is standard practice). I've used the included Cisco VLAN modification template that comes standard with NCM to successfully create a script to make the necessary changes on Cisco and Dell devices, but cannot make this script work on Adtran devices. Here is the script in its current form:

       

      /*

      .CHANGE_TEMPLATE_DESCRIPTION

              This change template configures BPDUguard on selected interfaces.

      .CHANGE_TEMPLATE_TAGS

              adtran, aos, spanning-tree, stp, bpduguard, interface

      .PLATFORM_DESCRIPTION

              ADTRAN AOS

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

              Select interface(s)

      .PARAMETER_DESCRIPTION @TargetInterfaces

              Select the interface(s) for which you would like to change bpduguard settings.

      .PARAMETER_LABEL @State

              Enable or disable

      .PARAMETER_DESCRIPTION @State

              Enter 'enable' or 'disable'

      */

       

      script ConfigureBPDUguardCiscoIOS (   

                                                NCM.Nodes @ContextNode,

                                                NCM.Interfaces[] @TargetInterfaces,

                                                string @State )

      {

        // Enter configuration mode

        CLI

        {

         configure terminal

        }

       

        // Loop through selected interfaces

        foreach (@Interface in @TargetInterfaces)

        {

          CLI

          {

            interface @Interface.InterfaceDescription

            spanning-tree bpduguard @State

          }

         }

         // Exit interface configuration mode

        CLI

        {

         exit

        }

         // Exit global configuration mode

        CLI

        {

         exit

        }

      }

       

      The issue that I'm encountering revolves around the Interface.InterfaceDescription portion of the script. For Cisco devices, these translate into 'FastEthernet 0/1, etc.' values that can be directly used to enter configuration mode (e.g. 'interface FastEthernet 0/1' drops you into interface configuration mode for that interface) for these interfaces. With Adtran devices, the results are in the format 'swx 0/1: Fast Ethernet {BCM56xxx vxgs-robo-5.5.3}' which cannot be directly used to enter configuration mode. Using even the 'swx 0/1' identifier is not productive. You must use the form 'interface switchport 0/1' to reach interface configuration mode. None of the other values collected through the inventory job seem to be usable either (e.g. the Name value is 'swx 0/1').

       

      How do I go about modifying the collected value of 'swx 0/1' into 'switchport 0/1'? Is it possible to embed a regular expression within the script to modify these values before putting them into the CLI portions of the script? If so, what regular expression (or other method) should I use to make this happen?

       

      Thank you to everyone in advance.