def bridgemem_details(self): """ :return: list vlans or bridge names of various stp states MODIFY """ if not self.iface.is_bridgemem(): return None # check if port is in STP _str = '' _stpstate = self.iface.stp.state # get the list of states by grabbing all the keys if self.iface.vlan_filtering: _vlanlist = self.iface.vlan_list _header = [_("all vlans on l2 port")] _table = [[', '.join(linux_common.create_range('', _vlanlist))]] _str += tabulate(_table, _header, numalign='left') + self.new_line() _header = [_("untagged vlans")] _table = [[', '.join(self.iface.native_vlan)]] _str += tabulate(_table, _header, numalign='left') + self.new_line() for _state, _bridgelist in _stpstate.items(): if _bridgelist: _header = [_("vlans in %s state") % (inflection.titleize(_state))] # if vlan aware and bridgelist is not empty, then assume # all vlans have that stp state if self.iface.vlan_filtering: _table = [[', '.join(linux_common.create_range( '', _vlanlist))]] else: _table = [self._pretty_vlanlist(_bridgelist)] _str += tabulate(_table, _header, numalign='left') + self.new_line() return _str
def trunk_summary_vlan_aware(self): """ :return list of vlan trunk info for vlan aware bridge """ _strlist = [] _strlist.append(_('vlans') + ': ' + ','.join( linux_common.create_range('', self.iface.vlan_list))) _strlist.append(_('native') + ': ' + ','.join( linux_common.create_range('', self.iface.native_vlan))) return _strlist
def update_bridge_vlan_list(self): """ take all the vlans defined on all the members and make sure that is assigned to the bridge interface """ vlan_list = [] bridgemems = self.vlan_aware_bridge.members.values() for _member in bridgemems: vlan_list += (_member.vlan_list) self.bridge_vids = create_range('', set(vlan_list))
def update_port_vlan_list(self): """ removes or adds vlans to the vlan aware bridge member vlans """ port_vlan_list = netshowlib.iface(self.port).vlan_list if self.delete_vlan: try: port_vlan_list.remove(self.vlan) except ValueError: pass else: port_vlan_list.append(self.vlan) self.port_vids = create_range('', set(port_vlan_list))
def test_group_ports_just_numbers(): a = ['1', '2', '3', '4', '5', '10'] assert_equals(common.create_range('', a), ['1-5', '10'])