Пример #1
0
    def _create_linux_bridge(self, interface):
        # get xml definition of interface
        iface_xml = self._get_interface_desc_xml(interface)

        # interface not defined in libvirt: try to define it
        iface_defined = False
        conn = self.conn.get()
        if iface_xml is None:
            try:
                mac = knetwork.get_dev_macaddr(str(interface))
                iface_xml = get_iface_xml({"type": "ethernet", "name": interface, "mac": mac, "startmode": "onboot"})
                conn.interfaceDefineXML(iface_xml.encode("utf-8"))
                iface_defined = True
            except libvirt.libvirtError, e:
                raise OperationFailed("KCHNET0024E", {"name": interface, "err": e.get_error_message()})
Пример #2
0
    def _create_linux_bridge(self, interface):
        # get xml definition of interface
        iface_xml = self._get_interface_desc_xml(interface)

        # interface not defined in libvirt: try to define it
        iface_defined = False
        conn = self.conn.get()
        if iface_xml is None:
            try:
                mac = knetwork.get_dev_macaddr(str(interface))
                iface_xml = get_iface_xml({'type': 'ethernet',
                                           'name': interface,
                                           'mac': mac,
                                           'startmode': "onboot"})
                conn.interfaceDefineXML(iface_xml.encode("utf-8"))
                iface_defined = True
            except libvirt.libvirtError, e:
                raise OperationFailed("KCHNET0024E", {'name': interface,
                                      'err': e.get_error_message()})
Пример #3
0
    def _create_linux_bridge(self, interface):
        # get xml definition of interface
        iface_xml = self._get_interface_desc_xml(interface)

        # interface not defined in libvirt: try to define it
        iface_defined = False
        conn = self.conn.get()
        if iface_xml is None:
            try:
                mac = netinfo.get_dev_macaddr(str(interface))
                iface_xml = get_iface_xml({'type': 'ethernet',
                                           'name': interface,
                                           'mac': mac,
                                           'startmode': "onboot"})
                conn.interfaceDefineXML(iface_xml.encode("utf-8"))
                iface_defined = True
            except libvirt.libvirtError, e:
                raise OperationFailed("KCHNET0024E", {'name': interface,
                                      'err': e.get_error_message()})
Пример #4
0
    def _create_linux_bridge(self, interface):
        # get xml definition of interface
        iface_xml = self._get_interface_desc_xml(interface)

        # interface not defined in libvirt: try to define it
        iface_defined = False
        conn = self.conn.get()
        if iface_xml is None:
            try:
                mac = netinfo.get_dev_macaddr(str(interface))
                iface_xml = get_iface_xml(
                    {
                        'type': 'ethernet',
                        'name': interface,
                        'mac': mac,
                        'startmode': 'onboot',
                    }
                )
                conn.interfaceDefineXML(iface_xml)
                iface_defined = True
            except libvirt.libvirtError as e:
                raise OperationFailed(
                    'KCHNET0024E', {'name': interface,
                                    'err': e.get_error_message()}
                )

        # Truncate the interface name if it exceeds 13 characters to make sure
        # the length of bridge name is less than 15 (its maximum value).
        br_name = KIMCHI_BRIDGE_PREFIX + interface[-13:]
        br_xml = create_linux_bridge_xml(br_name, interface, iface_xml)

        # drop network config from interface
        iface_defined or self._redefine_iface_no_network(interface, iface_xml)

        # create and start bridge
        self._create_bridge(br_name, br_xml)

        return br_name
Пример #5
0
    def _create_linux_bridge(self, interface):
        # get xml definition of interface
        iface_xml = self._get_interface_desc_xml(interface)

        # interface not defined in libvirt: try to define it
        iface_defined = False
        conn = self.conn.get()
        if iface_xml is None:
            try:
                mac = netinfo.get_dev_macaddr(str(interface))
                iface_xml = get_iface_xml({
                    'type': 'ethernet',
                    'name': interface,
                    'mac': mac,
                    'startmode': 'onboot',
                })
                conn.interfaceDefineXML(iface_xml)
                iface_defined = True
            except libvirt.libvirtError as e:
                raise OperationFailed('KCHNET0024E', {
                    'name': interface,
                    'err': e.get_error_message()
                })

        # Truncate the interface name if it exceeds 13 characters to make sure
        # the length of bridge name is less than 15 (its maximum value).
        br_name = KIMCHI_BRIDGE_PREFIX + interface[-13:]
        br_xml = create_linux_bridge_xml(br_name, interface, iface_xml)

        # drop network config from interface
        iface_defined or self._redefine_iface_no_network(interface, iface_xml)

        # create and start bridge
        self._create_bridge(br_name, br_xml)

        return br_name