def populate_storage_volumes(self): pool = self.current_pool() model = self.widget("vol-list").get_model() model.clear() vols = pool.get_volumes() for key in vols.keys(): vol = vols[key] try: path = vol.get_target_path() name = vol.get_name() cap = vol.get_pretty_capacity() fmt = vol.get_format() or "" except: logging.debug("Error getting volume info for '%s', " "hiding it", key, exc_info=True) continue namestr = None try: if path: names = VirtualDisk.path_in_use_by(self.conn.vmm, path) namestr = ", ".join(names) if not namestr: namestr = None except: logging.exception("Failed to determine if storage volume in " "use.") model.append([key, name, cap, fmt, namestr])
def ok(self, ignore1=None, ignore2=None): if self.widget("iso-image").get_active(): path = self.widget("iso-path").get_text() else: path = self.mediacombo.get_path() if path == "" or path is None: return self.err.val_err(_("Invalid Media Path"), _("A media path must be specified.")) names = VirtualDisk.path_in_use_by(self.disk.conn, path) if names: res = self.err.yes_no( _('Disk "%s" is already in use by other guests %s') % (path, names), _("Do you really want to use the disk?")) if not res: return False vmmAddStorage.check_path_search(self, self.conn, path) try: self.disk.path = path except Exception as e: return self.err.val_err(_("Invalid Media Path"), e) self.emit("cdrom-chosen", self.disk, path) self.close()
def populate_storage_volumes(self): pool = self.current_pool() model = self.widget("vol-list").get_model() model.clear() vols = pool.get_volumes() for key in vols.keys(): vol = vols[key] try: path = vol.get_target_path() name = vol.get_name() cap = vol.get_pretty_capacity() fmt = vol.get_format() or "" except: logging.debug( "Error getting volume info for '%s', " "hiding it", key, exc_info=True) continue namestr = None try: if path: names = VirtualDisk.path_in_use_by(self.conn.vmm, path) namestr = ", ".join(names) if not namestr: namestr = None except: logging.exception("Failed to determine if storage volume in " "use.") model.append([key, name, cap, fmt, namestr])
def populate_storage_volumes(list_widget, pool, sensitive_cb): vols = pool and pool.get_volumes() or {} model = list_widget.get_model() model.clear() for key in vols.keys(): vol = vols[key] try: path = vol.get_target_path() name = vol.get_pretty_name(pool.get_type()) cap = vol.get_pretty_capacity() fmt = vol.get_format() or "" except: logging.debug("Error getting volume info for '%s', " "hiding it", key, exc_info=True) continue namestr = None try: if path: names = VirtualDisk.path_in_use_by(vol.conn.get_backend(), path) namestr = ", ".join(names) if not namestr: namestr = None except: logging.exception("Failed to determine if storage volume in " "use.") row = [key, name, cap, fmt, namestr] if sensitive_cb: row.append(sensitive_cb(fmt)) model.append(row)
def _populate_vols(self): list_widget = self.widget("vol-list") pool = self._current_pool() vols = pool and pool.get_volumes() or [] model = list_widget.get_model() list_widget.get_selection().unselect_all() model.clear() vadj = self.widget("vol-scroll").get_vadjustment() vscroll_percent = vadj.get_value() / max(vadj.get_upper(), 1) for vol in vols: key = vol.get_connkey() try: path = vol.get_target_path() name = vol.get_pretty_name(pool.get_type()) cap = str(vol.get_capacity()) sizestr = vol.get_pretty_capacity() fmt = vol.get_format() or "" except: logging.debug( "Error getting volume info for '%s', " "hiding it", key, exc_info=True) continue namestr = None try: if path: names = VirtualDisk.path_in_use_by(vol.conn.get_backend(), path) namestr = ", ".join(names) if not namestr: namestr = None except: logging.exception("Failed to determine if storage volume in " "use.") sensitive = True if self._vol_sensitive_cb: sensitive = self._vol_sensitive_cb(fmt) row = [None] * VOL_NUM_COLUMNS row[VOL_COLUMN_KEY] = key row[VOL_COLUMN_NAME] = name row[VOL_COLUMN_SIZESTR] = sizestr row[VOL_COLUMN_CAPACITY] = cap row[VOL_COLUMN_FORMAT] = fmt row[VOL_COLUMN_INUSEBY] = namestr row[VOL_COLUMN_SENSITIVE] = sensitive model.append(row) def _reset_vscroll_position(): vadj.set_value(vadj.get_upper() * vscroll_percent) self.idle_add(_reset_vscroll_position)
def _populate_vols(self): list_widget = self.widget("vol-list") pool = self._current_pool() vols = pool and pool.get_volumes() or [] model = list_widget.get_model() list_widget.get_selection().unselect_all() model.clear() vadj = self.widget("vol-scroll").get_vadjustment() vscroll_percent = vadj.get_value() / max(vadj.get_upper(), 1) for vol in vols: key = vol.get_connkey() try: path = vol.get_target_path() name = vol.get_pretty_name(pool.get_type()) cap = str(vol.get_capacity()) sizestr = vol.get_pretty_capacity() fmt = vol.get_format() or "" except: logging.debug("Error getting volume info for '%s', " "hiding it", key, exc_info=True) continue namestr = None try: if path: names = VirtualDisk.path_in_use_by(vol.conn.get_backend(), path) namestr = ", ".join(names) if not namestr: namestr = None except: logging.exception("Failed to determine if storage volume in " "use.") sensitive = True if self._vol_sensitive_cb: sensitive = self._vol_sensitive_cb(fmt) row = [None] * VOL_NUM_COLUMNS row[VOL_COLUMN_KEY] = key row[VOL_COLUMN_NAME] = name row[VOL_COLUMN_SIZESTR] = sizestr row[VOL_COLUMN_CAPACITY] = cap row[VOL_COLUMN_FORMAT] = fmt row[VOL_COLUMN_INUSEBY] = namestr row[VOL_COLUMN_SENSITIVE] = sensitive model.append(row) def _reset_vscroll_position(): vadj.set_value(vadj.get_upper() * vscroll_percent) self.idle_add(_reset_vscroll_position)
def populate_storage_volumes(self): model = self.widget("vol-list").get_model() model.clear() dironly = self.browse_reason == self.config.CONFIG_DIR_FS pool = self.current_pool() if not pool: return vols = pool.get_volumes() for key in vols.keys(): vol = vols[key] sensitive = True try: path = vol.get_target_path() fmt = vol.get_format() or "" except Exception: logging.exception("Failed to determine volume parameters, " "skipping volume %s", key) continue namestr = None try: if path: names = VirtualDisk.path_in_use_by(self.conn.get_backend(), path) namestr = ", ".join(names) if not namestr: namestr = None except: logging.exception("Failed to determine if storage volume in " "use.") if dironly and fmt != 'dir': sensitive = False elif not self.rhel6_defaults: if fmt == "vmdk": sensitive = False model.append([key, vol.get_name(), vol.get_pretty_capacity(), fmt, namestr, sensitive])