def getFullVLANInfo(self, theVLANName=None): """\brief Returns a list of VLAN objects consisting of all of the vlans in the switch. If the theVLANName parameter is set, the function returns a single VLAN object corresponding to the requested vlan \param theVLANName (\c string) The name of the VLAN to retrieve \return (\c list of VLAN objects) A list of VLAN objects with the requested information or a VLAN object if a vlan name is specified """ vlans = [] untaggedPorts = self.getDot1qVlanStaticUntaggedPorts(True) taggedPorts = self.getDot1qVlanStaticEgressPorts(True) pvidPorts = self.getDot1qPvid(True) vlan_names = self.getVLANNames() vlan_ids = self.getDot1qVlanFdbId(True) #log.debug( untaggedPorts ) #log.debug( taggedPorts ) #log.debug( pvidPorts ) vlan_list = {} # key -> (name, untagged list, tagged list, pvid list) for vid in vlan_names: if not vlan_list.has_key(str(vid)): vlan_list[str(vid)] = (None,[],[],[]) vlan_list[str(vid)] = (vlan_names[vid],[],[],[]) #log.debug("initial vlan list "+str(vlan_list[str(vid)])) # put untagged ports into list for up in untaggedPorts: vid = str(up[0][0][len(up[0][0])-1]) if not vlan_list.has_key(vid): vlan_list[vid] = (None,[],[],[]) #log.debug("adding new vlan (untagged) "+str(vlan_list[vid])) vlan_list[vid] = (vlan_list[vid][0],self.__parsePortList(up[0][1],False), vlan_list[vid][2], vlan_list[vid][3]) # put tagged ports into list for tp in taggedPorts: vid = str(tp[0][0][len(tp[0][0])-1]) if not vlan_list.has_key(vid): vlan_list[vid] = (None,[],[],[]) #log.debug("adding new vlan (tagged) "+str(vlan_list[vid])) vlan_list[vid] = (vlan_list[vid][0],vlan_list[vid][1],self.__parsePortList(tp[0][1],True), vlan_list[vid][3]) # Remove PVID support - Adam 18/02/2008 # put pvid ports into list #for pp in pvidPorts: # vid = str(pp[0][1]) # if not vlan_list.has_key(vid): # #log.debug("adding new vlan (vpid) "+str(vlan_list[vid])) # vlan_list[vid] = (None,[],[],[]) # temp_port = Port(pp[0][0][len(pp[0][0])-1], # False, # pp[0][0][len(pp[0][0])-1]) # if (pp[0][0][len(pp[0][0])-1] > self.getNumberofPorts()): # pass # else: # vlan_list[vid][3].append(temp_port) # vlan_list[vid] = (vlan_list[vid][0], # vlan_list[vid][1], # vlan_list[vid][2], # vlan_list[vid][3]) # consider what to do with ports in both tagged and untagged state for v in vlan_list: switches = {} tmp_vlan = VLAN(vlan_list[v][0]) tmp_vlan.setInternalID(v) tmp_vlan.setID(v) tmp_vlan.setTaggedID(v) switches[self.getSwitchName()] = vlan_list[v][1] + vlan_list[v][2] + vlan_list[v][3] tmp_vlan.setSwitches(switches) vlans.append(tmp_vlan) for vlan in vlans: if (vlan.getName() == theVLANName): return [vlan] return vlans
def getFullVLANInfo(self, theVLANName=None): """\brief Returns a list of VLAN objects consisting of all of the vlans in the switch. If the theVLANName parameter is set, the function returns a single VLAN object corresponding to the requested vlan \param theVLANName (\c string) The name of the VLAN to retrieve \return (\c list of VLAN objects) A list of VLAN objects with the requested information or a VLAN object if a vlan name is specified """ vlans = [] untaggedPorts = self.getDot1qVlanStaticUntaggedPorts(True) taggedPorts = self.getDot1qVlanStaticEgressPorts(True) pvidPorts = self.getDot1qPvid(True) vlan_names = self.getVLANNames() vlan_ids = self.getDot1qVlanFdbId(True) #log.debug( untaggedPorts ) #log.debug( taggedPorts ) #log.debug( pvidPorts ) vlan_list = {} # key -> (name, untagged list, tagged list, pvid list) for vid in vlan_names: if not vlan_list.has_key(str(vid)): vlan_list[str(vid)] = (None, [], [], []) vlan_list[str(vid)] = (vlan_names[vid], [], [], []) #log.debug("initial vlan list "+str(vlan_list[str(vid)])) # put untagged ports into list for up in untaggedPorts: vid = str(up[0][0][len(up[0][0]) - 1]) if not vlan_list.has_key(vid): vlan_list[vid] = (None, [], [], []) #log.debug("adding new vlan (untagged) "+str(vlan_list[vid])) vlan_list[vid] = (vlan_list[vid][0], self.__parsePortList(up[0][1], False), vlan_list[vid][2], vlan_list[vid][3]) # put tagged ports into list for tp in taggedPorts: vid = str(tp[0][0][len(tp[0][0]) - 1]) if not vlan_list.has_key(vid): vlan_list[vid] = (None, [], [], []) #log.debug("adding new vlan (tagged) "+str(vlan_list[vid])) vlan_list[vid] = (vlan_list[vid][0], vlan_list[vid][1], self.__parsePortList(tp[0][1], True), vlan_list[vid][3]) # Remove PVID support - Adam 18/02/2008 # put pvid ports into list #for pp in pvidPorts: # vid = str(pp[0][1]) # if not vlan_list.has_key(vid): # #log.debug("adding new vlan (vpid) "+str(vlan_list[vid])) # vlan_list[vid] = (None,[],[],[]) # temp_port = Port(pp[0][0][len(pp[0][0])-1], # False, # pp[0][0][len(pp[0][0])-1]) # if (pp[0][0][len(pp[0][0])-1] > self.getNumberofPorts()): # pass # else: # vlan_list[vid][3].append(temp_port) # vlan_list[vid] = (vlan_list[vid][0], # vlan_list[vid][1], # vlan_list[vid][2], # vlan_list[vid][3]) # consider what to do with ports in both tagged and untagged state for v in vlan_list: switches = {} tmp_vlan = VLAN(vlan_list[v][0]) tmp_vlan.setInternalID(v) tmp_vlan.setID(v) tmp_vlan.setTaggedID(v) switches[self.getSwitchName( )] = vlan_list[v][1] + vlan_list[v][2] + vlan_list[v][3] tmp_vlan.setSwitches(switches) vlans.append(tmp_vlan) for vlan in vlans: if (vlan.getName() == theVLANName): return [vlan] return vlans