Esempio n. 1
0
 def browse_target_path(self, ignore1=None):
     startfolder = StoragePool.get_default_dir(self.conn.get_backend())
     target = self._browse_file(_("Choose target directory"),
                                startfolder=startfolder,
                                foldermode=True)
     if target:
         self.widget("pool-target-path").get_child().set_text(target)
Esempio n. 2
0
 def browse_target_path(self, ignore1=None):
     startfolder = StoragePool.get_default_dir(self.conn.get_backend())
     target = self._browse_file(_("Choose target directory"),
                                startfolder=startfolder,
                                foldermode=True)
     if target:
         self.widget("pool-target-path").get_child().set_text(target)
Esempio n. 3
0
    def convert_disks(self, disk_format, destdir=None, dry=False):
        """
        Convert a disk into the requested format if possible, in the
        given output directory.  Raises RuntimeError or other failures.
        """
        if disk_format == "none":
            disk_format = None

        if destdir is None:
            destdir = StoragePool.get_default_dir(self.conn, build=not dry)

        guest = self.get_guest()
        for disk in guest.get_devices("disk"):
            if disk.device != "disk":
                continue

            if disk_format and disk.driver_type == disk_format:
                logging.debug("path=%s is already in requested format=%s", disk.path, disk_format)
                disk_format = None

            basepath = os.path.splitext(os.path.basename(disk.path))[0]
            newpath = re.sub(r"\s", "_", basepath)
            if disk_format:
                newpath += "." + disk_format
            newpath = os.path.join(destdir, newpath)
            if os.path.exists(newpath):
                raise RuntimeError(_("New path name '%s' already exists") % newpath)

            if not disk_format or disk_format == "none":
                self._copy_file(disk.path, newpath, dry)
            else:
                self._qemu_convert(disk.path, newpath, disk_format, dry)
            disk.driver_type = disk_format
            disk.path = newpath
            self._err_clean.append(newpath)
Esempio n. 4
0
 def _browse_target_cb(self, src):
     startfolder = StoragePool.get_default_dir(self.conn.get_backend())
     target = self.err.browse_local(
         self.conn,
         _("Choose target directory"),
         dialog_type=Gtk.FileChooserAction.SELECT_FOLDER,
         start_folder=startfolder)
     if target:
         self.widget("pool-target-path").get_child().set_text(target)
Esempio n. 5
0
    def convert_disks(self, disk_format, destdir=None, dry=False):
        """
        Convert a disk into the requested format if possible, in the
        given output directory.  Raises RuntimeError or other failures.
        """
        if disk_format == "none":
            disk_format = None

        if destdir is None:
            destdir = StoragePool.get_default_dir(self.conn, build=not dry)

        guest = self.get_guest()
        for disk in guest.devices.disk:
            if disk.device != "disk":
                continue

            if disk_format and disk.driver_type == disk_format:
                logging.debug("path=%s is already in requested format=%s",
                              disk.path, disk_format)
                disk_format = None

            basepath = os.path.splitext(os.path.basename(disk.path))[0]
            newpath = re.sub(r'\s', '_', basepath)
            if disk_format:
                newpath += ("." + disk_format)
            newpath = os.path.join(destdir, newpath)
            if os.path.exists(newpath) and not _is_test():
                raise RuntimeError(
                    _("New path name '%s' already exists") % newpath)

            if not disk_format or disk_format == "none":
                self._copy_file(disk.path, newpath, dry)
            else:
                self._qemu_convert(disk.path, newpath, disk_format, dry)
            disk.driver_type = disk_format
            disk.path = newpath
            self._err_clean.append(newpath)