def _get_original_devices_info(self):
        clonelist = []
        retdisks = []

        for disk in self._guest.get_devices("disk"):
            if self._do_we_clone_device(disk):
                clonelist.append(disk)
                continue

        # Set up virtual disk to encapsulate all relevant path info
        for disk in clonelist:
            validate = not self.preserve_dest_disks

            try:
                if (disk.path and validate and
                    not VirtualDisk.path_exists(self._hyper_conn, disk.path)):
                    raise ValueError(_("Disk '%s' does not exist.") %
                                     disk.path)

                device = VirtualDisk.DEVICE_DISK
                if not disk.path:
                    # Tell VirtualDisk we are a cdrom to allow empty media
                    device = VirtualDisk.DEVICE_CDROM

                d = VirtualDisk(disk.path, conn=self._hyper_conn,
                                device=device, driverType=disk.driver_type,
                                validate=validate)
                d.target = disk.target
            except Exception, e:
                logging.debug("", exc_info=True)
                raise ValueError(_("Could not determine original disk "
                                   "information: %s" % str(e)))
            retdisks.append(d)
Exemple #2
0
    def _make_disks(self):
        for drive in self.boot_caps.drives:
            path = self._abspath(drive.disk.file)
            size = None
            if drive.disk.size is not None:
                size = float(drive.disk.size) / 1024

            # FIXME: This is awkward; the image should be able to express
            # whether the disk is expected to be there or not independently
            # of its classification, especially for user disks
            # FIXME: We ignore the target for the mapping in m.target
            if (drive.disk.use == ImageParser.Disk.USE_SYSTEM
                    and not os.path.exists(path)):
                raise ImageInstallerException(
                    _("System disk %s does not exist") % path)

            device = VirtualDisk.DEVICE_DISK
            if drive.disk.format == ImageParser.Disk.FORMAT_ISO:
                device = VirtualDisk.DEVICE_CDROM

            disk = VirtualDisk(conn=self.conn,
                               path=path,
                               size=size,
                               device=device,
                               format=drive.disk.format)
            disk.target = drive.target

            self.install_devices.append(disk)
    def _make_disks(self):
        for drive in self.boot_caps.drives:
            path = self._abspath(drive.disk.file)
            size = None
            if drive.disk.size is not None:
                size = float(drive.disk.size) / 1024

            # FIXME: This is awkward; the image should be able to express
            # whether the disk is expected to be there or not independently
            # of its classification, especially for user disks
            # FIXME: We ignore the target for the mapping in m.target
            if (drive.disk.use == ImageParser.Disk.USE_SYSTEM and
                not os.path.exists(path)):
                raise ImageInstallerException(_("System disk %s does not exist")
                                              % path)

            device = VirtualDisk.DEVICE_DISK
            if drive.disk.format == ImageParser.Disk.FORMAT_ISO:
                device = VirtualDisk.DEVICE_CDROM


            disk = VirtualDisk(conn=self.conn,
                               path=path,
                               size=size,
                               device=device,
                               format=drive.disk.format)
            disk.target = drive.target

            self.install_devices.append(disk)
Exemple #4
0
    def _make_disks(self):
        for m in self.boot_caps.drives:
            p = self._abspath(m.disk.file)
            s = None
            if m.disk.size is not None:
                s = float(m.disk.size) / 1024

            # FIXME: This is awkward; the image should be able to express
            # whether the disk is expected to be there or not independently
            # of its classification, especially for user disks
            # FIXME: We ignore the target for the mapping in m.target
            if (m.disk.use == ImageParser.Disk.USE_SYSTEM
                    and not os.path.exists(p)):
                raise ImageInstallerException(
                    _("System disk %s does not exist") % p)
            device = VirtualDisk.DEVICE_DISK
            if m.disk.format == ImageParser.Disk.FORMAT_ISO:
                device = VirtualDisk.DEVICE_CDROM
            d = VirtualDisk(p, s, device=device, type=VirtualDisk.TYPE_FILE)
            d.target = m.target

            self.install_devices.append(d)
Exemple #5
0
    def _get_original_devices_info(self, xml):

        disks = []
        lst = []

        count = _util.get_xml_path(xml, "count(/domain/devices/disk)")
        for i in range(1, int(count + 1)):
            # Check if the disk needs cloning
            (path, target) = self._do_we_clone_device(xml, i)
            if target == None:
                continue
            lst.append((path, target))

        # Set up virtual disk to encapsulate all relevant path info
        for path, target in lst:
            d = None
            validate = not self.preserve_dest_disks
            try:
                if (path and validate and
                        not VirtualDisk.path_exists(self._hyper_conn, path)):
                    raise ValueError(_("Disk '%s' does not exist.") % path)

                device = VirtualDisk.DEVICE_DISK
                if not path:
                    # Tell VirtualDisk we are a cdrom to allow empty media
                    device = VirtualDisk.DEVICE_CDROM

                d = VirtualDisk(path,
                                conn=self._hyper_conn,
                                device=device,
                                validate=validate)
                d.target = target
            except Exception, e:
                _util.log_exception(e)
                raise ValueError(
                    _("Could not determine original disk "
                      "information: %s" % str(e)))
            disks.append(d)
    def _make_disks(self):
        for m in self.boot_caps.drives:
            p = self._abspath(m.disk.file)
            s = None
            if m.disk.size is not None:
                s = float(m.disk.size)/1024

            # FIXME: This is awkward; the image should be able to express
            # whether the disk is expected to be there or not independently
            # of its classification, especially for user disks
            # FIXME: We ignore the target for the mapping in m.target
            if (m.disk.use == ImageParser.Disk.USE_SYSTEM and
                not os.path.exists(p)):
                raise ImageInstallerException(_("System disk %s does not exist")
                                              % p)
            device = VirtualDisk.DEVICE_DISK
            if m.disk.format == ImageParser.Disk.FORMAT_ISO:
                device = VirtualDisk.DEVICE_CDROM
            d = VirtualDisk(p, s,
                            device = device,
                            type = VirtualDisk.TYPE_FILE)
            d.target = m.target

            self.install_devices.append(d)
    def _get_original_devices_info(self, xml):

        disks   = []
        lst     = []

        count = _util.get_xml_path(xml, "count(/domain/devices/disk)")
        for i in range(1, int(count + 1)):
            # Check if the disk needs cloning
            (path, target) = self._do_we_clone_device(xml, i)
            if target == None:
                continue
            lst.append((path, target))

        # Set up virtual disk to encapsulate all relevant path info
        for path, target in lst:
            d = None
            validate = not self.preserve_dest_disks
            try:
                if (path and validate and
                    not VirtualDisk.path_exists(self._hyper_conn, path)):
                    raise ValueError(_("Disk '%s' does not exist.") %
                                     path)

                device = VirtualDisk.DEVICE_DISK
                if not path:
                    # Tell VirtualDisk we are a cdrom to allow empty media
                    device = VirtualDisk.DEVICE_CDROM

                d = VirtualDisk(path, conn=self._hyper_conn, device=device,
                                validate=validate)
                d.target = target
            except Exception, e:
                _util.log_exception(e)
                raise ValueError(_("Could not determine original disk "
                                   "information: %s" % str(e)))
            disks.append(d)