- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
12-18-2020 01:49 PM
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.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
01-06-2021 10:36 AM
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 clifrom device import apifrom xmclib import loggerfrom xmclib import emc_varsimport 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_linesdef 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 switchvarCMDS = []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_SWvar_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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
01-06-2021 10:36 AM
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 clifrom device import apifrom xmclib import loggerfrom xmclib import emc_varsimport 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_linesdef 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 switchvarCMDS = []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_SWvar_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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
12-28-2020 04:45 PM
Hi Mark.
The VLAN name can be defined in the Site or in the Service. The following API calls will help you:
- get Site ID based on the deviceIP
varQuery = '''query{network {device(ip:"%s") {siteId}}}''' % emc_vars["deviceIP"]varSiteID = emc_nbi.query(varQuery)['network']['device']['siteId']
- Get Service ID
varQuery = '''query{network{sites{siteId,parentId,fabricServiceDefinitionId}}}'''varResult = emc_nbi.query(varQuery)['network']['sites']
- Get VLANs for the Service
varQuery = '''{network{serviceDefinition(id:%s){serviceApplicationConfig{serviceVlanData{name,vlanId}}}}}''' %varServiceIdvarApps = emc_nbi.query(varQuery)['network']['serviceDefinition']['serviceApplicationConfig']
- Get VLANs based on Site where the device is assigned
varQuery='''query{network{device(ip:"%s"){siteData{vlans{name,vid}}}}}''' % emc_vars["deviceIP"]varResult = emc_nbi.query(varQuery)
I guess you can re-use the workflow mentioned above, just delete lines calling functions: AddCommandCreateVlan (lines 105,127), AddCommandDeleteVlan (line 132) …
Good luck!
Z.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
12-28-2020 12:46 PM
Hi
this workflow creates the vlan on the switches as well.
I was looking for a way to only change the name of a “existing” vlan.
the switch is connected via Fabric Attach and vlan’s are created with names like “VLAN #<id>” for troubleshooting a name is better.
so a script running every day with query the vlan id and names from XMC and changing the names on the ERS for the vlan that are there will do the trick.
Is there a way to query the vlan id and name from XMC ?
than i will try to creat the ERS part.
Kind regards
Mark van Strien
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
12-27-2020 03:44 PM
Hi,
you can sync VLANs from XMC (soon to be called XIQ Site Engine) to ERS by Synchronize Vlans on ERS workflow. there very similar workflows for Catalyst, ISW, HPE.
This workflow creates VLANs on the ERS switch based on a combination of Site and Services VLAN configuration. The workflow deletes VLANs from the switch if the VLAN does not exist in the Site nor the Services definition. The workflow renames the VLAN name to match the Site or Services.
Hope it helps.
