Ejemplo n.º 1
0
 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, utils.normalize_xml(expected_xml))
Ejemplo n.º 2
0
    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:
                kimchi_log.error(e.message)
Ejemplo n.º 3
0
    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:
                kimchi_log.error(e.message)
Ejemplo n.º 4
0
    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()

        if br_name in [net.bridgeName() for net in conn.listAllNetworks()]:
            raise InvalidOperation("KCHNET0010E", {'iface': br_name})

        with RollbackContext() as rollback:
            try:
                vlan_tagged_br = conn.interfaceDefineXML(br_xml, 0)
                rollback.prependDefer(vlan_tagged_br.destroy)
                vlan_tagged_br.create(0)
            except libvirt.libvirtError as e:
                raise OperationFailed(e.message)
            else:
                return br_name
Ejemplo n.º 5
0
    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()

        if br_name in [net.bridgeName() for net in conn.listAllNetworks()]:
            error_msg = 'The interface %s already exist' % br_name
            raise InvalidOperation("KCHNET0010E", {'iface': br_name,
                                                   'err': error_msg})

        with RollbackContext() as rollback:
            try:
                vlan_tagged_br = conn.interfaceDefineXML(br_xml, 0)
                rollback.prependDefer(vlan_tagged_br.destroy)
                vlan_tagged_br.create(0)
            except libvirt.libvirtError as e:
                raise OperationFailed(e.message)
            else:
                return br_name