Ejemplo n.º 1
0
    def pool_list_from_sources(conn, name, pool_type, host=None):
        """
        Return a list of StoragePool instances built from libvirt's pool
        source enumeration (if supported).

        @param conn: Libvirt connection
        @param name: Name for the new pool
        @param pool_type: Pool type string from I{Types}
        @param host: Option host string to poll for sources
        """
        if not support.check_conn_support(conn,
                                     support.SUPPORT_CONN_FINDPOOLSOURCES):
            return []

        pool_class = StoragePool.get_pool_class(pool_type)
        pool_inst = pool_class(conn=conn, name=name)

        if host:
            source_xml = "<source><host name='%s'/></source>" % host
        else:
            source_xml = "<source/>"

        try:
            xml = conn.findStoragePoolSources(pool_type, source_xml, 0)
        except libvirt.libvirtError, e:
            if support.is_error_nosupport(e):
                return []
            raise
Ejemplo n.º 2
0
    def setup(self, conn=None):
        """
        DEPRECATED: Please use setup_dev instead
        """
        if not conn:
            conn = self.conn

        if not NodeDeviceParser.is_pci_detach_capable(conn):
            return

        try:
            try:
                # Do this as a sanity check, so that we don't fail at domain
                # start time. This is independent of the 'managed' state, since
                # this should work regardless.
                node = conn.nodeDeviceLookupByName(self._nodedev.name)
                node.dettach()
                node.reset()
            except libvirt.libvirtError, e:
                if not support.is_error_nosupport(e):
                    raise
        except Exception, e:
            raise RuntimeError(_("Could not detach PCI device: %s" % str(e)))
Ejemplo n.º 3
0
    def setup(self, conn = None):
        """
        DEPRECATED: Please use setup_dev instead
        """
        if not conn:
            conn = self.conn

        if not NodeDeviceParser.is_pci_detach_capable(conn):
            return

        try:
            try:
                # Do this as a sanity check, so that we don't fail at domain
                # start time. This is independent of the 'managed' state, since
                # this should work regardless.
                node = conn.nodeDeviceLookupByName(self._nodedev.name)
                node.dettach()
                node.reset()
            except libvirt.libvirtError, e:
                if not support.is_error_nosupport(e):
                    raise
        except Exception, e:
            raise RuntimeError(_("Could not detach PCI device: %s" % str(e)))
Ejemplo n.º 4
0
    def install(self, meter=None):
        """
        Build and install storage volume from xml
        """
        xml = self.get_xml_config()
        logging.debug("Creating storage volume '%s' with xml:\n%s",
                      self.name, xml)

        t = threading.Thread(target=self._progress_thread,
                             name="Checking storage allocation",
                             args=(meter,))
        t.setDaemon(True)

        if not meter:
            meter = urlgrabber.progress.BaseMeter()

        try:
            self._install_finished = False
            t.start()
            meter.start(size=self.capacity,
                        text=_("Allocating '%s'") % self.name)

            if self.input_vol:
                vol = self.pool.createXMLFrom(xml, self.input_vol, 0)
            else:
                vol = self.pool.createXML(xml, 0)

            meter.end(self.capacity)
            logging.debug("Storage volume '%s' install complete.",
                          self.name)
            return vol
        except libvirt.libvirtError, e:
            if support.is_error_nosupport(e):
                raise RuntimeError("Libvirt version does not support "
                                   "storage cloning.")
            raise