def _create_vlan_tagged_bridge(self, interface, vlan_id): # Truncate the interface name if it exceeds 8 characters to make sure # the length of bridge name is less than 15 (its maximum value). br_name = KIMCHI_BRIDGE_PREFIX + interface[-8:] + '-' + vlan_id br_xml = create_vlan_tagged_bridge_xml(br_name, interface, vlan_id) self._create_bridge(br_name, br_xml) return br_name
def _create_vlan_tagged_bridge(self, interface, vlan_id): # Truncate the interface name if it exceeds 8 characters to make sure # the length of bridge name is less than 15 (its maximum value). br_name = KIMCHI_BRIDGE_PREFIX + interface[-8:] + '-' + vlan_id br_xml = create_vlan_tagged_bridge_xml(br_name, interface, vlan_id) self._create_bridge(br_name, br_xml) return br_name
def test_vlan_tagged_bridge_no_ip(self): expected_xml = """ <interface type='bridge' name='br10'> <start mode='onboot'/> <bridge> <interface type='vlan' name='em1.10'> <vlan tag='10'> <interface name='em1'/> </vlan> </interface> </bridge> </interface> """ actual_xml = nxml.create_vlan_tagged_bridge_xml('br10', 'em1', '10') self.assertEquals(actual_xml, normalize_xml(expected_xml))
def test_vlan_tagged_bridge_no_ip(self): expected_xml = """ <interface type='bridge' name='br10'> <start mode='onboot'/> <bridge> <interface type='vlan' name='em1.10'> <vlan tag='10'> <interface name='em1'/> </vlan> </interface> </bridge> </interface> """ actual_xml = nxml.create_vlan_tagged_bridge_xml('br10', 'em1', '10') self.assertEqual(actual_xml, normalize_xml(expected_xml))
def _create_vlan_tagged_bridge(self, interface, vlan_id): # Truncate the interface name if it exceeds 8 characters to make sure # the length of bridge name is less than 15 (its maximum value). br_name = KIMCHI_BRIDGE_PREFIX + interface[-8:] + '-' + vlan_id br_xml = create_vlan_tagged_bridge_xml(br_name, interface, vlan_id) conn = self.conn.get() bridges = [] for net in conn.listAllNetworks(): # Bridged networks do not have a bridge name # So in those cases, libvirt raises an error when trying to get # the bridge name try: bridges.append(net.bridgeName()) except libvirt.libvirtError, e: wok_log.error(e.message)