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.

Change interface description depending on old descriptions

Hi! Im working on this piece of a pussle... We are going to change the configuration on 200+ switches to have the same standard conf, and one part of this is to rename all the interfaces accordingly.

The menu alternatives 1 to 3 works fine. Alternative 4 (change interface description) Im having abit of trouble with. At the moment "access port" and "client port" are the choices to see if it works on a lab switch.

The idea is that the switch makes the changes it self depending on whats previously configured /or not configured. Without me having to add labels for manual input the description on the interfaces.

This is what I have so far:

/*

.CHANGE_TEMPLATE_DESCRIPTION

  This change template configures some stuff.

.CHANGE_TEMPLATE_TAGS

  Cisco, IOS, QoS, Service Policy, storm-control, error recovery

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

        Select port(s)

.PARAMETER_DESCRIPTION @TargetPorts

        Select the port(s) for which you would like to configure port-security.

     

.PARAMETER_LABEL @MenuAlternative

     

.PARAMETER_DESCRIPTION @MenuAlternative

        Select the alternatives to Apply to these devices interfaces

.PARAMETER_DISPLAY_TYPE @MenuAlternative

        Listbox:1=Remove QoS|2=Set __________ NTP servers, timezone and summer-time|3=Error recovery|4=Switch port-Secuirty, Max 9 mac-addresses and Storm-control

*/

script ConfigureCiscoIOS (

  NCM.Nodes @ContextNode,

  string @MenuAlternative )

{

 

    CLI

  {

   configure terminal

  }

  if ( @MenuAlternative == 'Remove QoS' )

  {

  CLI

  {

    no mls qos

  }

  }

  if ( @MenuAlternative == 'Set __________ NTP servers, timezone and summer-time' )

  {

   CLI

      {

    clock timezone CET 1

    ntp server x.x.x.x

       

       }

    }

  if ( @MenuAlternative == 'Error recovery' )

  {

  CLI

  {

  errdisable recovery cause udld

  errdisable recovery cause bpduguard

  errdisable recovery cause security-violation

  errdisable recovery cause channel-misconfig (STP)

  errdisable recovery cause pagp-flap

  errdisable recovery cause dtp-flap

  errdisable recovery cause link-flap

  errdisable recovery cause sfp-config-mismatch

  errdisable recovery cause gbic-invalid

  errdisable recovery cause l2ptguard

  errdisable recovery cause psecure-violation

  errdisable recovery cause port-mode-failure

  errdisable recovery cause dhcp-rate-limit

  errdisable recovery cause pppoe-ia-rate-limit

  errdisable recovery cause mac-limitv

  errdisable recovery cause vmps

  errdisable recovery cause storm-control

  errdisable recovery cause inline-power

  errdisable recovery cause arp-inspection

  errdisable recovery cause loopback

  errdisable recovery cause small-frame

  errdisable recovery interval 10

  }

  }

  if ( @MenuAlternative == 'Switch port-Secuirty, Max 9 mac-addresses and Storm-control' )

    {

   foreach (@interfaceItem in @ContextNode.Interfaces)

   {

  if (@interfaceItem.InterfaceDescription contains 'Client port')

  {

  CLI

   {

  description Client Port

  switch port-security

  switch port-security maximum 9

  storm-control broadcast level 10.00 5.00

  storm-control multicast level 10.00 5.00

  storm-control action shutdown

  storm-control action trap

   } 

{

 

  if (@interfaceItem.InterfaceDescription contains 'Access port')

  {

  CLI

   {

  description Client Port

  switch port-security

  switch port-security maximum 9

  storm-control broadcast level 10.00 5.00

  storm-control multicast level 10.00 5.00

  storm-control action shutdown

  storm-control action trap

   }  

}

  // Exit configuration mode

  CLI

  {

   exit

  }

}

Not sure if this is possible or not, so would like to hear your thoughts emoticons_happy.png

  • I actually think this would be much easier to do with Compliance checking and config blocks...

    Have it search for a config block that looks for something that starts with "^interface (Fast|Gig)Ethernet .*" and ends with "^!".  Look for the description you don't want to be there (ie: "description Access Port") and have it re-mediate with the commands you had above.

    You could create another compliance rule that looks for the description you do want to be there (ie: "description Client Port") and then checks for the config lines you have listed above and if it sees a discrepancy in what is on the port vs. what should be on the port, you can once again have it re-mediate with the commands you had above...

    I'd give it a try and if you have any problems with it, post here and we can try and flesh out the idea a bit better for you...