0 Replies Latest reply on Dec 15, 2017 11:37 AM by brbrewer71

    NCM - Add multiple VLAN's w/ Names and subnets.

    brbrewer71

      We have created the following script for adding one VLAN with a VLAN name and a subnet to our environment.

      I want to extend this functionality to be able to add multiple VLAN's , VLAN names and subnets.

      So the user input would be similar to

      VLAN Number: 10,20,30

      VLAN Name: Test10,Test20,Test30

      IP Subnet: 192.168.10.0, 192.168.20.0,192.168.30.0

      IP Subnet Mask: 255.255.255.0,255.255.255.0,255.255.255.0

       

      See our script below that is working for a single VLAN, need advice on how to achieve multiple VLAN's

      It would be better if I could separate the user input above by asking how many VLAN would you like to create and dynamically generate boxes for input but this may be getting to advanced .

       

      /*

      .CHANGE_TEMPLATE_DESCRIPTION

              This change template creates a new VLAN and Network on the INT.  It is based off of the CHGx-FORM-Create-New-VLAN-INT-Tier.docx Method of Procedure.

             

      .CHANGE_TEMPLATE_TAGS

              Cisco, IOS, NXOS, VLAN, Fabric Path, INT

             

      .PLATFORM_DESCRIPTION

              Cisco IOS, NXOS

       

      .PARAMETER_LABEL @ContextNode

              NCM Nodes

             

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

              INT VLAN Number

             

      .PARAMETER_DESCRIPTION @VlanNumber1

              Please assign a VLAN Number for the INT Tier

       

      .PARAMETER_LABEL @VlanName1

              INT VLAN Name

             

      .PARAMETER_DESCRIPTION @VlanName1

              Please assign a VLAN Name for the INT Tier

       

      .PARAMETER_LABEL @IpSubnet1

              INT IP Subnet

             

      .PARAMETER_DESCRIPTION @IpSubnet1

              Please assign an IP Subnet for the INT Tier

       

      .PARAMETER_LABEL @SubnetMask1

              INT Subnet Mask

             

      .PARAMETER_DESCRIPTION @SubnetMask1

              Please assign an IP Subnet Mask for the INT Tier, which has to be in long form e.g. 255.255.255.224

      */

       

      script BaseChangeTemplate(  

                                   NCM.Nodes @ContextNode,

                                   string @VlanNumber1,

                                   string @VlanName1,

                                   string @IpSubnet1,

                                   string @SubnetMask1    )

      {

        //This template creates a new INT vlan in the datacenter

       

        //Assign VLANs to Fabric Path 5Ks

        if (@ContextNode.SysName contains 'clmb0005sw')

        CLI

        {

          configure terminal

          !

          vlan @VlanNumber1

          name @VlanName1

          mode fabricpath

          !

          end

          !

          show vlan id @VlanNumber1

          !

        }

       

       

        //Assign VLANs to Fabric Path CORE

        if (@ContextNode.SysName contains 'clmb0005cs')

        CLI

        {

          configure terminal

          !

          vlan @VlanNumber1

          name @VlanName1

          mode fabricpath

          !

          end

          !

          show vlan id @VlanNumber1

          !

        }

       

       

        //Sets STP priority on OITNDC2b

        if (@ContextNode.SysName contains 'OITNDC2b')

        CLI

        {

          configure terminal

          !

          spanning-tree vlan @VlanNumber1 priority 20480

          !

        }

       

        //Sets STP priority on OITNDC2a

        if (@ContextNode.SysName contains 'OITNDC2a')

        CLI

        {

          configure terminal

          !

          spanning-tree vlan @VlanNumber1 priority 16384

          !

        }

       

       

        //Assigns vlan, trunks to the FW and SPINE, and routing to the INT FW on OITNDC2(a/b)

        if (@ContextNode.SysName contains 'OITNDC2')

        CLI

        {

          vlan @VlanNumber1

          name @VlanName1

          !

          interface TenGigabitEthernet10/8

          switchport trunk allowed vlan add @VlanNumber1

          !

          interface TenGigabitEthernet10/6

          switchport trunk allowed vlan add @VlanNumber1

          !

          ip route @IpSubnet1 @SubnetMask1 156.63.62.84

          !

          end

          !

          !Verify that the VLAN is on both Te10/6 & Te10/8

          !

          show vlan id @VlanNumber1

          !

          show spanning-tree vlan @VlanNumber1 bridge

          !

          show ip route @IpSubnet1

          !

        }

       

       

        //Assign VLANs to Fabric Path SPINE and trunk to the OITNDC2(a/b)

        if (@ContextNode.SysName contains 'CLMB0005DS')

        CLI

        {

          configure terminal

          !

          vlan @VlanNumber1

          name @VlanName1

          mode fabricpath

          !

          interface Ethernet2/46

          switchport trunk allowed vlan add @VlanNumber1

          !

          end

          !

          !Verify that the VLAN is on Eth2/46

          !

          show vlan id @VlanNumber1

          !

        }

       

       

        //Configure routing for the BBSOC(a/b) devices pointing the the FW

        if (@ContextNode.SysName contains 'BBSOC')

        CLI

        {

          configure terminal

          !

          ip route @IpSubnet1 @SubnetMask1 156.63.217.132

          !

          end

          !

          show ip route @IpSubnet1

          !

        }

       

      }