Quantcast
Channel: THWACK: Popular Discussions - Network Configuration Manager
Viewing all articles
Browse latest Browse all 4266

Config Change Template question

$
0
0

I'm trying my hand at a CCT and I've run into a small roadblock.  I am not a programmer, so I am bumbling my way through this as best I can.  I've got a template configured that will accept some variables and configure an interface - simple enough.  I've got that part working.  The part I don't have quite right is, for lack of better terminology, I need to be able to do an 'if / if / else' type of configuration.

 

In the script below, there's a variable that defines a list of several options the user can input (@Bandwidth).  If the user chooses one specific option, the output should be 'XXXX'.  If the user chooses another specific option, the output should be 'YYYY' and if the user chooses any one of the rest of the options, the output should be the option they chose.  As it is now, if the user chooses the '100M-GE' option, it works fine, but if they choose the '100M-FE' option, then the output shows that the 'service-policy' configuration is applied twice, but the second iteration of it is slightly wrong, shown here:

 

interface Gi0/8

service-policy input 100M-ingress-FE

service-policy output 100M-egress-FE

interface Gi0/8

service-policy input 100M-ingress-FE

service-policy output 100M-ingress-FE


/*
.CHANGE_TEMPLATE_DESCRIPTION    This script will configure a customer port on an ME3600 switch.
.PLATFORM_DESCRIPTION    Cisco ME3600X

.PARAMETER_LABEL @ContextNode
    NCM Node
.PARAMETER_DESCRIPTION @ContextNode    Select the node to run on

.PARAMETER_LABEL @CustomerPort
    Customer Port
.PARAMETER_DESCRIPTION @CustomerPort    This is the port to build the customer on (ie. Gi0/3).

.PARAMETER_LABEL @DataVLANID
    Data VLAN ID
.PARAMETER_DESCRIPTION @DataVLANID    This is the customer's data VLAN.

.PARAMETER_LABEL @VoiceVLANID
    Voice VLAN ID (Optional)
.PARAMETER_DESCRIPTION @VoiceVLANID    This is the switch's voice VLAN ID. It is usually '8', but sometimes not.  If voice is not needed, just type 'None'.

.PARAMETER_LABEL @CustomerID
    Customer ID
.PARAMETER_DESCRIPTION @CustomerID    Enter the customer ID.      
.PARAMETER_LABEL @WANGatewayIP    WAN Gateway IP Address
.PARAMETER_DESCRIPTION @WANGatewayIP    This is our end of the WAN subnet.

.PARAMETER_LABEL @WANCustomerIP
    Customer WAN IP Address
.PARAMETER_DESCRIPTION @WANCustomerIP    This is the customer's end of the WAN subnet.

.PARAMETER_LABEL @WANNetmask
    WAN Subnet Mask
.PARAMETER_DESCRIPTION @WANNetmask    This the WAN Subnet Mask, which is almost always 255.255.255.252
.PARAMETER_DISPLAY_TYPE @WANNetmask    Listbox:1=255.255.255.252|2=255.255.255.248|3=255.255.255.240|4=255.255.255.224|5=255.255.255.192|6=255.255.255.128|7=255.255.255.0

.PARAMETER_LABEL @LANSubnet
    LAN Subnet
.PARAMETER_DESCRIPTION @LANSubnet    This is the customer's LAN subnet.  If there is no LAN subnet, just type 'None'.

.PARAMETER_LABEL @LANNetmask
    LAN Subnet Mask
.PARAMETER_DESCRIPTION @LANNetmask    This the LAN subnet mask.
.PARAMETER_DISPLAY_TYPE @LANNetmask    Listbox:1=255.255.255.252|2=255.255.255.248|3=255.255.255.240|4=255.255.255.224|5=255.255.255.192|6=255.255.255.128|7=255.255.255.0      
.PARAMETER_LABEL @Bandwidth    Bandwidth Option
.PARAMETER_DESCRIPTION @Bandwidth    This the bandwidth option the customer has chosen.
.PARAMETER_DISPLAY_TYPE @Bandwidth    Listbox:1=5M|2=10M|3=25M|4=50M|5=100M-FE|6=100M-GE|7=1G

*/

script ConfigureVoicePort(                              NCM.Nodes @ContextNode,                            string @CustomerPort,                            string @CustomerID,                            string @DataVLANID,                            string @VoiceVLANID,                            string @WANGatewayIP,                            string @WANCustomerIP,                            string @WANNetmask,                            string @LANSubnet,                            string @LANNetmask,                            string @Bandwidth )
{
string @AddVLANs = @VoiceVLANID + ',' + @DataVLANID
string @BandwidthIn = @Bandwidth + '-ingress'
string @BandwidthOut = @Bandwidth + '-ingress'

/* Configure VLAN */
    CLI {        configure terminal        vlan @DataVLANID        name @CustomerID    }
/* Configure switchport */    CLI {        interface @CustomerPort        mtu 9800        description @CustomerID        switchport mode trunk        load-interval 30        no shutdown        no lldp transmit        no lldp receive        spanning-tree bpdufilter enable        spanning-tree bpduguard enable       }
/* Configure Voice VLAN and Data VLAN on switchport*/    if (@VoiceVLANID contains 'one') {        CLI {            switchport trunk allowed vlan @DataVLANID        }    }    else {        CLI {            switchport trunk allowed vlan @AddVLANs        }    }
/* Configure SVI */    CLI {        interface Vlan@DataVLANID        description @CustomerID        ip address @WANGatewayIP @WANNetmask        ip access-group cust-ingress in       }
/* Configure IP route statement */    if (@LANSubnet contains 'one') {        /* Do nothing */    }    else {        CLI {        ip route @LANSubnet @LANNetmask @WANCustomerIP        }    }    if (@Bandwidth == '100M-FE') {        CLI {            interface @CustomerPort            service-policy input 100M-ingress-FE            service-policy output 100M-egress-FE        }    }     if (@Bandwidth == '100M-GE') {        CLI {            interface @CustomerPort            service-policy input 100M-ingress-GE            service-policy output 100M-egress-GE        }    }    else {        CLI {            interface @CustomerPort            service-policy input @BandwidthIn            service-policy output @BandwidthOut        }    }     
/* Write memory and exit */    CLI {        end        write memory    }
}

Viewing all articles
Browse latest Browse all 4266

Trending Articles