def raidLevelChanged(self, index): raidlevel = int(self.raidLevels.currentText()) availraidparts = self.parent.storage.unusedRaidMembers(array=self.origrequest) maxspares = raid.get_raid_max_spares(raidlevel, numparts) if maxspares > 0 and not raid.isRaid(raid.RAID0, raidlevel): value = self.spareSpin.value() if value > maxspares: value = maxspares self.spareSpin.setRange(0, maxspares) self.spareSpin.setValue(value) else: self.spareSpin.setValue(0) self.spareSpin.setEnabled(False)
def raidLevelChanged(self, index): raidlevel = int(self.raidLevels.itemData(index)) availraidparts = self.parent.storage.unusedRaidMembers( array=self.origrequest) maxspares = raid.get_raid_max_spares(raidlevel, len(availraidparts)) if maxspares > 0 and not raid.isRaid(raid.RAID0, raidlevel): value = self.spareSpin.value() if value > maxspares: value = maxspares self.spareSpin.setRange(0, maxspares) self.spareSpin.setValue(value) else: self.spareSpin.setValue(0) self.spareSpin.setEnabled(False)
def __init__(self, parent, request, isNew): QtGui.QWidget.__init__(self, parent.parent) self.setupUi(self) self.parent = parent self.origrequest = request self.isNew = isNew if self.origrequest.exists: self.filesystemLabel.hide() self.filesystemMenu.hide() else: self.formatRadio.hide() self.formatCombo.hide() self.migrateRadio.hide() self.migrateCombo.hide() # Mountpoints storageGuiHelpers.fillMountpointMenu(self.mountpointMenu, self.origrequest) # Format options filesystems if not self.origrequest.exists: storageGuiHelpers.fillFilesystemMenu(self.filesystemMenu, self.origrequest.format, ignores=["mdmember", "efi", "prepboot", "appleboot"]) QObject.connect(self.filesystemMenu, SIGNAL("currentIndexChanged(int)"), self.formatTypeChanged) else: if self.origrequest.format.formattable or not self.origrequest.format.type: storageGuiHelpers.fillFilesystemMenu(self.formatCombo, self.origrequest.format, ignores=["mdmember", "efi", "prepboot", "appleboot"]) self.formatRadio.setChecked(self.origrequest.format.formattable and not self.origrequest.format.exists) QObject.connect(self.formatCombo, SIGNAL("currentIndexChanged(int)"), self.formatTypeChanged) else: self.formatRadio.hide() self.formatCombo.hide() if self.origrequest.format.migratable and self.origrequest.format.exists: storageGuiHelpers.fillFilesystemMenu(self.migrateCombo, self.origrequest.format, availables=[self.origrequest.format.migrationTarget]) self.migrateRadio.setChecked(self.origrequest.format.migrate and not self.formatRadio.isChecked()) QObject.connect(self.migrateCombo, SIGNAL("currentIndexChanged(int)"), self.formatTypeChanged) else: self.migrateRadio.hide() self.migrateCombo.hide() # Raid Members availraidparts = self.parent.storage.unusedRaidMembers(array=self.origrequest) storageGuiHelpers.fillRaidMembers(self.raidMembers, availraidparts, self.origrequest.devices, self.origrequest.format) if self.origrequest.exists: self.raidMembers.setEnabled(False) # Raid Minors if not self.origrequest.exists: availminors = self.parent.storage.unusedRaidMinors[:16] if self.origrequest.minor is not None and self.origrequest.minor not in availminors: availminors.append(self.origrequest.minor) availminors.sort() storageGuiHelpers.fillRaidMinors(self.raidMinors, availminors, self.origrequest.minor) else: self.raidMinors.addItem(self.origrequest.name) self.raidMinors.setEnabled(0) # Raid Level if not self.origrequest.exists: storageGuiHelpers.fillRaidLevels(self.raidLevels, raid.raid_levels, self.origrequest.level) else: self.raidLevels.addItem(str(self.origrequest.level)) self.raidLevels.setEnabled(0) QObject.connect(self.raidLevels, SIGNAL("currentIndexChanged(int)"), self.raidLevelChanged) # Raid Spares if not self.origrequest.exists: numparts = len(availraidparts) if self.origrequest.spares: spares = origrequest.spares else: spares = 0 if self.origrequest.level: maxspares = raid.get_raid_max_spares(self.origrequest.level, numparts) else: maxspares = 0 self.spareSpin.setRange(0,maxspares) self.spareSpin.setValue(spares) if maxspares > 0: self.spareSpin.setEnabled(True) else: self.spareSpin.setEnabled(False) self.spareSpin.setValue(0) else: self.spareSpin.setValue(self.origrequest.spares) self.spareSpin.setEnabled(0) if self.origrequest.level is not None and self.origrequest.level == raid.RAID0: self.spareSpin.setEnabled(False) self.connect(self.buttonBox, SIGNAL("accepted()"), self.parent.dialog.accept) self.connect(self.buttonBox, SIGNAL("rejected()"), self.parent.dialog.reject)
def __init__(self, parent, request, isNew): QWidget.__init__(self, parent.parent) self.setupUi(self) self.parent = parent self.origrequest = request self.isNew = isNew if self.origrequest.exists: self.filesystemLabel.hide() self.filesystemMenu.hide() else: self.formatRadio.hide() self.formatCombo.hide() self.migrateRadio.hide() self.migrateCombo.hide() # Mountpoints storageGuiHelpers.fillMountpointMenu(self.mountpointMenu, self.origrequest) # Format options filesystems if not self.origrequest.exists: storageGuiHelpers.fillFilesystemMenu( self.filesystemMenu, self.origrequest.format, ignores=["mdmember", "efi", "prepboot", "appleboot"]) self.filesystemMenu.currentIndexChanged[int].connect( self.formatTypeChanged) else: if self.origrequest.format.formattable or not self.origrequest.format.type: storageGuiHelpers.fillFilesystemMenu( self.formatCombo, self.origrequest.format, ignores=["mdmember", "efi", "prepboot", "appleboot"]) self.formatRadio.setChecked( self.origrequest.format.formattable and not self.origrequest.format.exists) self.formatCombo.currentIndexChanged[int].connect( self.formatTypeChanged) else: self.formatRadio.hide() self.formatCombo.hide() if self.origrequest.format.migratable and self.origrequest.format.exists: storageGuiHelpers.fillFilesystemMenu( self.migrateCombo, self.origrequest.format, availables=[self.origrequest.format.migrationTarget]) self.migrateRadio.setChecked( self.origrequest.format.migrate and not self.formatRadio.isChecked()) self.migrateCombo.currentIndexChanged[int].connect( self.formatTypeChanged) else: self.migrateRadio.hide() self.migrateCombo.hide() # Raid Members availraidparts = self.parent.storage.unusedRaidMembers( array=self.origrequest) storageGuiHelpers.fillRaidMembers(self.raidMembers, availraidparts, self.origrequest.devices, self.origrequest.format) if self.origrequest.exists: self.raidMembers.setEnabled(False) # Raid Minors if not self.origrequest.exists: availminors = self.parent.storage.unusedRaidMinors[:16] if self.origrequest.minor is not None and self.origrequest.minor not in availminors: availminors.append(self.origrequest.minor) availminors.sort() storageGuiHelpers.fillRaidMinors(self.raidMinors, availminors, self.origrequest.minor) else: self.raidMinors.addItem(self.origrequest.name) self.raidMinors.setEnabled(0) # Raid Level if not self.origrequest.exists: storageGuiHelpers.fillRaidLevels(self.raidLevels, raid.raid_levels, self.origrequest.level) else: self.raidLevels.addItem(str(self.origrequest.level)) self.raidLevels.setEnabled(0) self.raidLevels.currentIndexChanged[int].connect(self.raidLevelChanged) # Raid Spares if not self.origrequest.exists: numparts = len(availraidparts) if self.origrequest.spares: spares = self.origrequest.spares else: spares = 0 if self.origrequest.level: maxspares = raid.get_raid_max_spares(self.origrequest.level, numparts) else: maxspares = 0 self.spareSpin.setRange(0, maxspares) self.spareSpin.setValue(spares) if maxspares > 0: self.spareSpin.setEnabled(True) else: self.spareSpin.setEnabled(False) self.spareSpin.setValue(0) else: self.spareSpin.setValue(self.origrequest.spares) self.spareSpin.setEnabled(0) if self.origrequest.level is not None and self.origrequest.level == raid.RAID0: self.spareSpin.setEnabled(False) self.buttonBox.accepted.connect(self.parent.dialog.accept) self.buttonBox.rejected.connect(self.parent.dialog.reject)