cancel
Showing results for 
Search instead for 
Did you mean: 

Naming FA created VLANs

Naming FA created VLANs

Jay2009
New Contributor

Hello,

Is it possible to somehow choose the name of VLANs that are dynmically assigned by Control? I am using FA and control to assign the VLANs and the VLAN will always be named SYS_VLAN_Number. If I am using different VLANs for voice per stack, I would like those to be named VOICE on the stack, so if push lldp med policy commands, I just have to specificy the vlan name “VOICE”?

 

Thanks.

1 ACCEPTED SOLUTION

Mark_van_Strien
New Contributor III

Hi all,

created a simple script for setting the correct names on FA vlan’s. In the script you can give the ip address of the source/uplink switch. The script queries the local switch and queries the XMC data for the vlans of the uplink switch and changes the name of the vlans if they are not the same as the source/uplink switch.

from xmclib import cli
from device import api
from xmclib import logger
from xmclib import emc_vars
import re

## Script for setting vlan names on ERS FA switches.

def sendConfigCmds(cmds):
for cmd in cmds:
cli_results = emc_cli.send( cmd )
if cli_results.isSuccess() is False:
print 'CLI-ERROR: ' + cli_results.getError()
wf_error("CLI ERROR EXECUTING CLI COMMANDS")
status = emc_results.Status;
emc_results.setStatus( status.ERROR )
cli_lines = cli_results.getOutput()
return cli_lines

def AddCommandChangeVlan (vlanName,vlanID):
global varCMDS
varCMDS.append('vlan name %s "%s"' % (vlanID,vlanName))
return

## Ip of the uplink switch ( core or datacentre )
varUplink_SW = "SET IP OF UPLINK/SOURCE SWITCH"


## Get local vlans of the switch
varCMDS = []
varCMDS.append('enable')
varCMDS.append('sh vlan type port')
varCli_result = sendConfigCmds(varCMDS)

regex = re.compile(r"(\d+) +(.+?)\s+Port +None")
try:
varVlans = regex.findall(varCli_result)
except:
wf_error("Unexpected CLI response.")
else:
varX = range (len(varVlans))
varVlanIDs=[]
varVlanNames=[]
for varI in varX:
varVlanIDs.append(varVlans[varI][0])
varVlanNames.append(varVlans[varI][1])

varCMDS = []
varCMDS.append('configure terminal')

## Get vlans of the uplink switch.

var_query = '''query{network{device(ip: "%s"){deviceData{vlans{name,vid}}}}}''' %varUplink_SW
var_Result = emc_nbi.query(var_query)
vlans_id = var_Result['network']['device']['deviceData']['vlans']

## loop the local vpn and replace name is not correct.

for varVlan in var_Result['network']['device']['deviceData']['vlans']:
if str(varVlan['vid']) in varVlanIDs:
if str(varVlan['name']) in varVlanNames:
varVlanNames.remove(str(varVlan['name']))
varVlanIDs.remove(str(varVlan['vid']))
else:
#vlan name does not match
if str(varVlan['vid']) != "1":
AddCommandChangeVlan (varVlan['name'],varVlan['vid'])
print varCMDS
varChanged=True
del varVlanNames[varVlanIDs.index(str(varVlan['vid']))]
varVlanIDs.remove(str(varVlan['vid']))

## send commands to the switch.
if varChanged:
varCli_result = sendConfigCmds(varCMDS)
emc_results.put("ChangedVlan","true")


print "end"

 

Thought I shared it with you all

 

Planning to run this script two times a day to my switches. Or do you see away to run it after a vlan is added to the switch via fa ?

Kind regards

Mark van Strien

View solution in original post

11 REPLIES 11

Mark_van_Strien
New Contributor III

There was a script on github page for ERS switches that took the vlan names and numbers for xmc and gave the name of the matching id to the switch. I can’t find it at the moment on github but @Zdenek Pala can give as a hint ? 
i was looking for the same but toen for ERS.

 

Jay2009
New Contributor

The use case is when the VLAN is dynaically created through FA that it name it what I want insted of the system generated name.

Miguel-Angel_RO
Valued Contributor II

Jay,

 

I’m not sure of the use case… Tunnel-Private-Group-Id with VLAN name is to assign to a port a VLAN by its name instead of VLAN-Id

If the VLAN doesn’t exists, this has no sense.

 

If the VLAN is specific per switch, you can create it manually and assign an i-sid.

You can then provision it by its name without the need to use FA-xx attributes (just for the voice VLAN)

 

Mig

Jay2009
New Contributor

I have ERS as well, so I can test on both.

a8a9cddba9d2410e86d78af37299e308_5a814e73-1bc3-4d5d-9b12-6065c0241d75.png

So I need this?

Miguel-Angel_RO
Valued Contributor II

You should specify this in the radius attributes to be sent to the switches:

Tunnel-Private-Group-Id=%VLAN_NAME% or this: 

cc1e75e8aa3043738450f48d394ded75_0d3752fd-0ffe-4557-bdce-b24303a49a97.png

I never tested this on EXOS switches but on ERS you can send the name of the VLAN, as it is RFC compliant, it should be ok.

To be checked, what are the attributes you are sending to specify the VLAN?

Could you share a screenshot of the policy mapping entry?

Mig

GTM-P2G8KFN