def _populate_raid(self): """ Set up the raid-specific portion of the device details. Hide the RAID level menu if this device type does not support RAID. Choose a default RAID level. """ if not containerRaidLevelsSupported(self.device_type): for widget in [self._raidLevelLabel, self._raidLevelCombo]: really_hide(widget) return raid_level = self.raid_level or defaultContainerRaidLevel( self.device_type) raid_level_name = raidLevelSelection(raid_level) # Set a default RAID level in the combo. for (i, row) in enumerate(self._raidLevelCombo.get_model()): log.debug("container dialog: raid level %s", row[1]) if row[1] == raid_level_name: self._raidLevelCombo.set_active(i) break for widget in [self._raidLevelLabel, self._raidLevelCombo]: really_show(widget) fancy_set_sensitive(self._raidLevelCombo, not self.exists)
def on_enable_kdump_toggled(self, checkbutton, user_data=None): status = checkbutton.get_active() # If disabling, set everything to insensitve. Otherwise, only set the radio # button and currently reserved widgets to sensitive and then fake a # toggle event on the radio button to set the state on the reserve # amount spin button and total/usable mem display. if KdumpSpoke.OS == "redhat": self._autoButton.set_sensitive(status) self._manualButton.set_sensitive(status) self._reservationTypeLabel.set_sensitive(status) if not status: fancy_set_sensitive(self._toBeReservedSpin, status) self._totalMemLabel.set_sensitive(status) self._totalMemMB.set_sensitive(status) self._usableMemLabel.set_sensitive(status) self._usableMemMB.set_sensitive(status) elif KdumpSpoke.OS == "redhat": self._autoButton.emit("toggled") else: fancy_set_sensitive(self._toBeReservedSpin, True) self._totalMemLabel.set_sensitive(True) self._totalMemMB.set_sensitive(True) self._usableMemLabel.set_sensitive(True) self._usableMemMB.set_sensitive(True)
def _populate_raid(self): """Set up the raid-specific portion of the device details. Hide the RAID level menu if this device type does not support RAID. Choose a default RAID level. """ self._raidStoreFilter.set_visible_func(self._raid_level_visible) self._raidStoreFilter.refilter() if not self._supported_raid_levels: for widget in [self._raidLevelLabel, self._raidLevelCombo]: really_hide(widget) return raid_level = self._request.container_raid_level for (i, row) in enumerate(self._raidLevelCombo.get_model()): if row[1] == raid_level: self._raidLevelCombo.set_active(i) break for widget in [self._raidLevelLabel, self._raidLevelCombo]: really_show(widget) fancy_set_sensitive(self._raidLevelCombo, self._permissions.container_raid_level)
def on_reservation_toggled(self, radiobutton, user_data=None): status = self._manualButton.get_active() # If setting to auto, disable the manual config spinner and # the total/usable memory labels fancy_set_sensitive(self._toBeReservedSpin, status) self._totalMemLabel.set_sensitive(status) self._totalMemMB.set_sensitive(status) self._usableMemLabel.set_sensitive(status) self._usableMemMB.set_sensitive(status)
def on_enable_kdump_toggled(self, checkbutton, user_data=None): status = checkbutton.get_active() # If disabling, set everything to insensitve. Otherwise, only set the radio # button and currently reserved widgets to sensitive and then fake a # toggle event on the radio button to set the state on the reserve # amount spin button and total/usable mem display. fancy_set_sensitive(self._toBeReservedSpin, status) self._totalMemLabel.set_sensitive(status) self._totalMemMB.set_sensitive(status) self._usableMemLabel.set_sensitive(status) self._usableMemMB.set_sensitive(status) self._fadumpButton.set_sensitive(status) if not status: self._fadumpButton.set_active(False)
def _set_size(self): if self._request.container_size_policy == SIZE_POLICY_AUTO: self._sizeCombo.set_active(0) self._sizeEntry.set_text("") elif self._request.container_size_policy == SIZE_POLICY_MAX: self._sizeCombo.set_active(1) self._sizeEntry.set_text("") else: self._sizeCombo.set_active(2) size = Size(self._request.container_size_policy) self._sizeEntry.set_text(size.human_readable(max_places=2)) if not self._permissions.container_size_policy: fancy_set_sensitive(self._sizeCombo, False) self._sizeEntry.set_sensitive(False)
def _populate_raid(self): """ Set up the raid-specific portion of the device details. """ if self.device_type not in [DEVICE_TYPE_LVM, DEVICE_TYPE_BTRFS, DEVICE_TYPE_LVM_THINP]: map(really_hide, [self._raidLevelLabel, self._raidLevelCombo]) return raid_level = self.raid_level if not raid_level or raid_level == "single": raid_level = _("None") # Set a default RAID level in the combo. for (i, row) in enumerate(self._raidLevelCombo.get_model()): log.debug("container dialog: raid level %s", row[0]) if row[0].upper().startswith(raid_level.upper()): self._raidLevelCombo.set_active(i) break map(really_show, [self._raidLevelLabel, self._raidLevelCombo]) fancy_set_sensitive(self._raidLevelCombo, not self.exists)
def _populate_raid(self): """ Set up the raid-specific portion of the device details. """ if self.device_type not in [ DEVICE_TYPE_LVM, DEVICE_TYPE_BTRFS, DEVICE_TYPE_LVM_THINP ]: map(really_hide, [self._raidLevelLabel, self._raidLevelCombo]) return raid_level = self.raid_level if not raid_level or raid_level == "single": raid_level = _("None") # Set a default RAID level in the combo. for (i, row) in enumerate(self._raidLevelCombo.get_model()): log.debug("container dialog: raid level %s", row[0]) if row[0].upper().startswith(raid_level.upper()): self._raidLevelCombo.set_active(i) break map(really_show, [self._raidLevelLabel, self._raidLevelCombo]) fancy_set_sensitive(self._raidLevelCombo, not self.exists)
def _populate_raid(self): """ Set up the raid-specific portion of the device details. Hide the RAID level menu if this device type does not support RAID. Choose a default RAID level. """ if not containerRaidLevelsSupported(self.device_type): map(really_hide, [self._raidLevelLabel, self._raidLevelCombo]) return raid_level = self.raid_level or defaultContainerRaidLevel(self.device_type) raid_level_name = raidLevelSelection(raid_level) # Set a default RAID level in the combo. for (i, row) in enumerate(self._raidLevelCombo.get_model()): log.debug("container dialog: raid level %s", row[1]) if row[1] == raid_level_name: self._raidLevelCombo.set_active(i) break map(really_show, [self._raidLevelLabel, self._raidLevelCombo]) fancy_set_sensitive(self._raidLevelCombo, not self.exists)
def __init__(self, *args, **kwargs): # these are all absolutely required. not getting them is fatal. self._disks = kwargs.pop("disks") free = kwargs.pop("free") self.selected = kwargs.pop("selected")[:] self.name = kwargs.pop("name") or "" # make sure it's a string self.device_type = kwargs.pop("device_type") self.storage = kwargs.pop("storage") # these are less critical self.raid_level = kwargs.pop("raid_level", None) or None # not "" self.encrypted = kwargs.pop("encrypted", False) self.exists = kwargs.pop("exists", False) self.size_policy = kwargs.pop("size_policy", SIZE_POLICY_AUTO) self.size = kwargs.pop("size", Size(0)) self._error = None GUIObject.__init__(self, *args, **kwargs) self._grabObjects() GUIDialogInputCheckHandler.__init__(self, self._save_button) # set up the dialog labels with device-type-specific text container_type = get_container_type(self.device_type) title_text = _(CONTAINER_DIALOG_TITLE) % { "container_type": _(container_type.name).upper() } self._title_label.set_text(title_text) dialog_text = _(CONTAINER_DIALOG_TEXT) % { "container_type": _(container_type.name).lower() } self._dialog_label.set_text(dialog_text) # populate the dialog widgets self._name_entry.set_text(self.name) # populate the store for disk in self._disks: self._store.append([ disk.description, str(disk.size), str(free[disk.name][0]), disk.name, disk.id ]) model = self._treeview.get_model() itr = model.get_iter_first() selected_ids = [d.id for d in self.selected] selection = self._treeview.get_selection() while itr: disk_id = model.get_value(itr, 4) if disk_id in selected_ids: selection.select_iter(itr) itr = model.iter_next(itr) # XXX how will this be related to the device encryption setting? self._encryptCheckbutton.set_active(self.encrypted) # set up the raid level combo # XXX how will this be related to the device raid level setting? self._raidStoreFilter.set_visible_func(self._raid_level_visible) self._raidStoreFilter.refilter() self._populate_raid() self._original_size = self.size self._original_size_text = self.size.human_readable(max_places=2) self._sizeEntry.set_text(self._original_size_text) if self.size_policy == SIZE_POLICY_AUTO: self._sizeCombo.set_active(0) elif self.size_policy == SIZE_POLICY_MAX: self._sizeCombo.set_active(1) else: self._sizeCombo.set_active(2) if self.exists: fancy_set_sensitive(self._name_entry, False) self._treeview.set_sensitive(False) fancy_set_sensitive(self._encryptCheckbutton, False) fancy_set_sensitive(self._sizeCombo, False) self._sizeEntry.set_sensitive(False) # Check that the container name configured is valid self.add_check(self._name_entry, self._checkNameEntry)
def __init__(self, *args, **kwargs): GUIDialogInputCheckHandler.__init__(self) # these are all absolutely required. not getting them is fatal. self._disks = kwargs.pop("disks") free = kwargs.pop("free") self.selected = kwargs.pop("selected")[:] self.name = kwargs.pop("name") or "" # make sure it's a string self.device_type = kwargs.pop("device_type") self.storage = kwargs.pop("storage") # these are less critical self.raid_level = kwargs.pop("raid_level", None) or None # not "" self.encrypted = kwargs.pop("encrypted", False) self.exists = kwargs.pop("exists", False) self.size_policy = kwargs.pop("size_policy", SIZE_POLICY_AUTO) self.size = kwargs.pop("size", Size(0)) self._error = None GUIObject.__init__(self, *args, **kwargs) self._grabObjects() # set up the dialog labels with device-type-specific text container_type = get_container_type(self.device_type) title_text = _(CONTAINER_DIALOG_TITLE) % {"container_type": container_type.name.upper()} self._title_label.set_text(title_text) dialog_text = _(CONTAINER_DIALOG_TEXT) % {"container_type": container_type.name.lower()} self._dialog_label.set_text(dialog_text) # populate the dialog widgets self._name_entry.set_text(self.name) # populate the store for disk in self._disks: self._store.append([disk.description, str(disk.size), str(free[disk.name][0]), disk.serial, disk.id]) model = self._treeview.get_model() itr = model.get_iter_first() selected_ids = [d.id for d in self.selected] selection = self._treeview.get_selection() while itr: disk_id = model.get_value(itr, 4) if disk_id in selected_ids: selection.select_iter(itr) itr = model.iter_next(itr) # XXX how will this be related to the device encryption setting? self._encryptCheckbutton.set_active(self.encrypted) # set up the raid level combo # XXX how will this be related to the device raid level setting? self._raidStoreFilter.set_visible_func(self._raid_level_visible) self._raidStoreFilter.refilter() self._populate_raid() self._original_size = self.size self._original_size_text = self.size.humanReadable(max_places=2) self._sizeEntry.set_text(self._original_size_text) if self.size_policy == SIZE_POLICY_AUTO: self._sizeCombo.set_active(0) elif self.size_policy == SIZE_POLICY_MAX: self._sizeCombo.set_active(1) else: self._sizeCombo.set_active(2) if self.exists: fancy_set_sensitive(self._name_entry, False) self._treeview.set_sensitive(False) fancy_set_sensitive(self._encryptCheckbutton, False) fancy_set_sensitive(self._sizeCombo, False) self._sizeEntry.set_sensitive(False) # Check that the container name configured is valid self.add_check(self._name_entry, self._checkNameEntry)
def _set_encryption(self): self._encryptCheckbutton.set_active(self._request.container_encrypted) if not self._permissions.container_encrypted: fancy_set_sensitive(self._encryptCheckbutton, False)
def _set_name(self): self._name_entry.set_text(self._request.container_name) self.add_check(self._name_entry, self._check_name_entry) if not self._permissions.container_name: fancy_set_sensitive(self._name_entry, False)