def run(self): if self.dialog is None: return None while 1: rc = self.dialog.exec_() if not rc: if self.isNew: if self.parent.parent.lvs.has_key(self.origrequest.lvname): del self.parent.parent.lvs[self.origrequest.lvname] self.destroy() return None format = None widget = self.dialog.content format = self.origrequest.format mountpoint = unicode(widget.mountpointMenu.currentText()) if mountpoint and widget.mountpointMenu.isEditable(): msg = sanityCheckMountPoint(mountpoint) if msg: self.intf.messageWindow(_("Mount Point Error"), msg, type="error") continue if not self.origrequest.exists: format_type = str(widget.filesystemMenu.currentText()) else: format_type = str(widget.formatCombo.currentText()) format_class = formats.getFormat(format_type) if mountpoint and format_class.mountable: used = False current_mountpoint = getattr(format, "mountpoint", None) for lv in self.parent.parent.lvs.values(): format = lv["format"] if not format.mountable or current_mountpoint and \ format.mountpoint == current_mountpoint: continue if format.mountpoint == mountpoint: used = True break for (mp, dev) in self.parent.parent.storage.mountpoints.iteritems(): if (dev.type != "lvmlv" or dev.vg.id != self.origrequest.vg.id) and mp == mountpoint: used = True break if used: self.intf.messageWindow(_("Mount point in use"), _("The mount point \"%s\" is in " "use. Please pick another.") % (mountpoint,), type="warning") continue name = str(widget.name.text()) if not self.origrequest.exists: msg = sanityCheckLogicalVolumeName(name) if msg: self.intf.messageWindow(_("Illegal Logical Volume Name"), msg, type="warning") continue # check that the name is not already in use used = 0 for lv in self.parent.parent.lvs.values(): if self.origrequest.lvname != name and lv['name'] == name: used = 1 break if used: self.intf.messageWindow(_("Illegal logical volume name"), _("The logical volume name \"%s\" is " "already in use. Please pick another.") % (name,), type="warning") continue if not self.origrequest.exists: badsize = 0 try: size = long(widget.sizeSpin.value()) except: size = 1 if badsize or size <= 0: self.intf.messageWindow(_("Illegal size"), _("The requested size as entered is " "not a valid number greater than 0."), type="warning") continue else: size = self.origrequest.size # check that size specification is within limits peSize = int(self.parent.physicalExtends.itemData(self.parent.physicalExtends.currentIndex())) / 1024 size = lvm.clampSize(size, peSize, roundup=True) maximumVolumeSize = lvm.getMaxLVSize() if size > maximumVolumeSize: self.intf.messageWindow(_("Not enough space"), _("The current requested size " "(%(size)10.2f MB) is larger than " "the maximum logical volume size " "(%(maxlv)10.2f MB). " "To increase this limit you can " "create more Physical Volumes from " "unpartitioned disk space and " "add them to this Volume Group.") % {'size': size, 'maxlv': maximumVolumeSize}, type="warning") continue # Get format origname = self.origrequest.lvname if not self.origrequest.exists: formatType = str(widget.filesystemMenu.currentText()) format = formats.getFormat(formatType, mountpoint=mountpoint) self.origrequest._name = name try: self.origrequest.size = size except ValueError, msg: self.intf.messageWindow(_("Not enough space"), _("The size entered for this " "logical volume (%(size)d MB) " "combined with the size of the " "other logical volume(s) " "exceeds the size of the " "volume group (%(tmpvgsize)d " "MB). Please make the volume " "group larger or make the " "logical volume smaller.") % {'size': size, 'tmpvgsize': self.origrequest.vg.size}, type="warning") continue else: self.origrequest.format = format else: if widget.formatRadio.isChecked(): formatType = str(widget.formatCombo.currentText()) format = formats.getFormat(formatType, mountpoint=mountpoint, device=self.origrequest.path) self.origrequest.format = format else: self.origrequest.format = self.origrequest.originalFormat if widget.migrateRadio.isChecked(): self.origrequest.format.migrate = True if widget.resizeRadio.isChecked(): self.origrequest.targetSize = widget.resizeSpin.value() if self.origrequest.format.mountable: self.origrequest.format.mountpoint = mountpoint if self.origrequest.format.exists and \ self.origrequest.format.mountable and \ self.origrequest.format.mountpoint: if self.storage.formatByDefault(self.origrequest) and \ not queryNoFormatPreExisting(self.intf): continue # everything ok break
def run(self): if self.dialog is None: return [] while 1: rc = self.dialog.exec_() operations = [] if not rc: self.destroy() return [] widget = self.dialog.content mountpoint = unicode(widget.mountpointMenu.currentText()) active = widget.mountpointMenu.isEnabled() if active and mountpoint: msg = sanityCheckMountPoint(mountpoint) if msg: ctx.interface.messageWindow(_("Mount Point Error"), msg, type="warning") continue used = False for (mp, dev) in self.storage.mountpoints.iteritems(): if mp == mountpoint and \ dev.id != self.origrequest.id and \ not (self.origrequest.format.type == "luks" and self.origrequest in dev.parents): used = True break if used: ctx.interface.messageWindow( _("Mount point in use"), _("The mount point \"%s\" is in " "use. Please pick another.") % (mountpoint, ), type="warning") continue if not self.origrequest.exists: if widget.primaryCheck.isChecked(): primary = True else: primary = None size = widget.sizeSpin.value() formatType = str(widget.filesystemMenu.currentText()) format = formats.getFormat(formatType, mountpoint=mountpoint) if self.isNew: disk = self.storage.devicetree.getDeviceByPath( self.partedPartition.disk.device.path) else: disk = self.origrequest.disk err = doUIRAIDLVMChecks(format, [disk.name], self.storage) if err: self.intf.messageWindow(_("Error With Request"), err, type="error") continue weight = partitioning.weight(mountpoint=mountpoint, fstype=format.type) if self.isNew: request = self.storage.newPartition(size=size, grow=None, maxsize=0, primary=primary, format=format, parents=disk) else: request = self.origrequest request.weight = weight usedev = request if self.isNew: operations.append(OperationCreateDevice(request)) else: request.req_size = size request.req_base_size = size request.req_grow = None request.req_max_size = 0 request.req_primary = primary request.req_disks = [disk] operations.append(OperationCreateFormat(usedev, format)) else: # preexisting partition request = self.origrequest usedev = request origformat = usedev.format devicetree = self.storage.devicetree if widget.formatRadio.isChecked(): formatType = str(widget.formatCombo.currentText()) format = formats.getFormat(formatType, mountpoint=mountpoint, device=usedev.path) operations.append(OperationCreateFormat(usedev, format)) else: cancel = [] cancel.extend( devicetree.findOperations(type="destroy", object="format", devid=request.id)) cancel.extend( devicetree.findOperations(type="create", object="format", devid=request.id)) cancel.reverse() for operation in cancel: devicetree.removeOperation(operation) request.format = request.originalFormat usedev = request if usedev.format.mountable: usedev.format.mountpoint = mountpoint if self.origrequest.protected and usedev.format.mountable: # users can set a mountpoint for protected partitions usedev.format.mountpoint = mountpoint request.weight = partitioning.weight( mountpoint=mountpoint, fstype=request.format.type) if widget.migrateRadio.isChecked(): operations.append(OperationMigrateFormat(usedev)) if widget.resizeRadio.isChecked(): size = widget.resizeSpin.value() try: operations.append(OperationResizeDevice(request, size)) if request.format.type and request.format.exists: operations.append( OperationResizeFormat(request, size)) except ValueError: pass if request.format.exists and \ getattr(request, "mountpoint", None) and \ self.storage.formatByDefault(request): if not queryNoFormatPreExisting(self.intf): continue # everything ok, fall out of loop break return operations
def run(self): if self.dialog is None: return None while 1: rc = self.dialog.exec_() if not rc: if self.isNew: if self.parent.parent.lvs.has_key(self.origrequest.lvname): del self.parent.parent.lvs[self.origrequest.lvname] self.destroy() return None format = None widget = self.dialog.content format = self.origrequest.format mountpoint = unicode(widget.mountpointMenu.currentText()) if mountpoint and widget.mountpointMenu.isEditable(): msg = sanityCheckMountPoint(mountpoint) if msg: self.intf.messageWindow(_("Mount Point Error"), msg, type="error") continue if not self.origrequest.exists: format_type = str(widget.filesystemMenu.currentText()) else: format_type = str(widget.formatCombo.currentText()) format_class = formats.getFormat(format_type) if mountpoint and format_class.mountable: used = False current_mountpoint = getattr(format, "mountpoint", None) for lv in self.parent.parent.lvs.values(): format = lv["format"] if not format.mountable or current_mountpoint and \ format.mountpoint == current_mountpoint: continue if format.mountpoint == mountpoint: used = True break for (mp, dev) in self.parent.parent.storage.mountpoints.iteritems(): if (dev.type != "lvmlv" or dev.vg.id != self.origrequest.vg.id) and mp == mountpoint: used = True break if used: self.intf.messageWindow(_("Mount point in use"), _("The mount point \"%s\" is in " "use. Please pick another.") % (mountpoint,), type="warning") continue name = str(widget.name.text()) if not self.origrequest.exists: msg = sanityCheckLogicalVolumeName(name) if msg: self.intf.messageWindow(_("Illegal Logical Volume Name"), msg, type="warning") continue # check that the name is not already in use used = 0 for lv in self.parent.parent.lvs.values(): if self.origrequest.lvname != name and lv['name'] == name: used = 1 break if used: self.intf.messageWindow(_("Illegal logical volume name"), _("The logical volume name \"%s\" is " "already in use. Please pick another.") % (name,), type="warning") continue if not self.origrequest.exists: badsize = 0 try: size = long(widget.sizeSpin.value()) except: size = 1 if badsize or size <= 0: self.intf.messageWindow(_("Illegal size"), _("The requested size as entered is " "not a valid number greater than 0."), type="warning") continue else: size = self.origrequest.size # check that size specification is within limits peSize = self.parent.physicalExtends.itemData(self.parent.physicalExtends.currentIndex()).toInt()[0] / 1024 size = lvm.clampSize(size, peSize, roundup=True) maximumVolumeSize = lvm.getMaxLVSize() if size > maximumVolumeSize: self.intf.messageWindow(_("Not enough space"), _("The current requested size " "(%(size)10.2f MB) is larger than " "the maximum logical volume size " "(%(maxlv)10.2f MB). " "To increase this limit you can " "create more Physical Volumes from " "unpartitioned disk space and " "add them to this Volume Group.") % {'size': size, 'maxlv': maximumVolumeSize}, type="warning") continue # Get format origname = self.origrequest.lvname if not self.origrequest.exists: formatType = str(widget.filesystemMenu.currentText()) format = formats.getFormat(formatType, mountpoint=mountpoint) self.origrequest._name = name try: self.origrequest.size = size except ValueError, msg: self.intf.messageWindow(_("Not enough space"), _("The size entered for this " "logical volume (%(size)d MB) " "combined with the size of the " "other logical volume(s) " "exceeds the size of the " "volume group (%(tmpvgsize)d " "MB). Please make the volume " "group larger or make the " "logical volume smaller.") % {'size': size, 'tmpvgsize': self.origrequest.vg.size}, type="warning") continue else: self.origrequest.format = format else: if widget.formatRadio.isChecked(): formatType = str(widget.formatCombo.currentText()) format = formats.getFormat(formatType, mountpoint=mountpoint, device=self.origrequest.path) self.origrequest.format = format else: self.origrequest.format = self.origrequest.originalFormat if widget.migrateRadio.isChecked(): self.origrequest.format.migrate = True if widget.resizeRadio.isChecked(): self.origrequest.targetSize = widget.resizeSpin.value() if self.origrequest.format.mountable: self.origrequest.format.mountpoint = mountpoint if self.origrequest.format.exists and \ self.origrequest.format.mountable and \ self.origrequest.format.mountpoint: if self.storage.formatByDefault(self.origrequest) and \ not queryNoFormatPreExisting(self.intf): continue # everything ok break
def run(self): if self.dialog is None: return [] while 1: rc = self.dialog.exec_() operations = [] if not rc: self.destroy() return [] widget = self.dialog.content mountpoint = unicode(widget.mountpointMenu.currentText()) active = widget.mountpointMenu.isEnabled() if active and mountpoint: msg = sanityCheckMountPoint(mountpoint) if msg: ctx.interface.messageWindow(_("Mount Point Error"), msg, type="warning") continue used = False for (mp, dev) in self.storage.mountpoints.iteritems(): if mp == mountpoint and \ dev.id != self.origrequest.id and \ not (self.origrequest.format.type == "luks" and self.origrequest in dev.parents): used = True break if used: ctx.interface.messageWindow(_("Mount point in use"), _("The mount point \"%s\" is in " "use. Please pick another.") % (mountpoint,), type="warning") continue if not self.origrequest.exists: if widget.primaryCheck.isChecked(): primary = True else: primary = None size = widget.sizeSpin.value() formatType = str(widget.filesystemMenu.currentText()) format = formats.getFormat(formatType, mountpoint=mountpoint) if self.isNew: disk = self.storage.devicetree.getDeviceByPath(self.partedPartition.disk.device.path) else: disk = self.origrequest.disk err = doUIRAIDLVMChecks(format, [disk.name], self.storage) if err: self.intf.messageWindow(_("Error With Request"), err, type="error") continue weight = partitioning.weight(mountpoint=mountpoint, fstype=format.type) if self.isNew: request = self.storage.newPartition(size=size, grow=None, maxsize=0, primary=primary, format=format, parents=disk) else: request = self.origrequest request.weight = weight usedev = request if self.isNew: operations.append(OperationCreateDevice(request)) else: request.req_size = size request.req_base_size = size request.req_grow = None request.req_max_size = 0 request.req_primary = primary request.req_disks = [disk] operations.append(OperationCreateFormat(usedev, format)) else: # preexisting partition request = self.origrequest usedev = request origformat = usedev.format devicetree = self.storage.devicetree if widget.formatRadio.isChecked(): formatType = str(widget.formatCombo.currentText()) format = formats.getFormat(formatType, mountpoint=mountpoint, device=usedev.path) operations.append(OperationCreateFormat(usedev, format)) else: cancel = [] cancel.extend(devicetree.findOperations(type="destroy", object="format", devid=request.id)) cancel.extend(devicetree.findOperations(type="create", object="format", devid=request.id)) cancel.reverse() for operation in cancel: devicetree.removeOperation(operation) request.format = request.originalFormat usedev = request if usedev.format.mountable: usedev.format.mountpoint = mountpoint if self.origrequest.protected and usedev.format.mountable: # users can set a mountpoint for protected partitions usedev.format.mountpoint = mountpoint request.weight = partitioning.weight(mountpoint=mountpoint, fstype=request.format.type) if widget.migrateRadio.isChecked(): operations.append(OperationMigrateFormat(usedev)) if widget.resizeRadio.isChecked(): size = widget.resizeSpin.value() try: operations.append(OperationResizeDevice(request, size)) if request.format.type and request.format.exists: operations.append(OperationResizeFormat(request, size)) except ValueError: pass if request.format.exists and \ getattr(request, "mountpoint", None) and \ self.storage.formatByDefault(request): if not queryNoFormatPreExisting(self.intf): continue # everything ok, fall out of loop break return operations
def run(self): if self.dialog is None: return [] while 1: rc = self.dialog.exec_() operations = [] raidmembers = [] if not rc: self.destroy() return [] widget = self.dialog.content for index in range(widget.raidMembers.count()): if widget.raidMembers.item(index).checkState() == Qt.Checked: raidmembers.append(widget.raidMembers.item(index).partition) # The user has to select some devices to be part of the array. if not raidmembers: continue mountpoint = str(widget.mountpointMenu.currentText()) active = widget.mountpointMenu.isEnabled() if active and mountpoint: msg = sanityCheckMountPoint(mountpoint) if msg: self.intf.messageWindow(_("Mount Point Error"), msg, customIcon="error") continue used = False for (mp, dev) in self.storage.mountpoints.iteritems(): if mp == mountpoint and \ dev.id != self.origrequest.id and \ not (self.origrequest.format.type == "luks" and self.origrequest in dev.parents): used = True break if used: self.intf.messageWindow(_("Mount point in use"), _("The mount point \"%s\" is in " "use. Please pick another.") % (mountpoint,), customIcon="error") continue if not self.origrequest.exists: formatType = str(widget.filesystemMenu.currentText()) raidminor = widget.raidMinors.itemData(widget.raidMinors.currentIndex()).toInt()[0] raidlevel = widget.raidMinors.itemData(widget.raidLevels.currentIndex()).toInt()[0] if not raid.isRaid(raid.RAID0, raidlevel): spares = widget.spareSpin.value() else: spares = 0 format = formats.getFormat(formatType, mountpoint=mountpoint) members = len(raidmembers) - spares try: request = self.storage.newRaidArray(minor=raidminor, level=raidlevel, format=format, parents=raidmembers, totalDevices=len(raidmembers), memberDevices=members) except ValueError, e: self.intf.messageWindow(_("Error"), str(e), customIcon="error") continue if not self.isNew: # This may be handled in devicetree.registerAction, # but not in case when we change minor and thus # device name/path (at least with current md) operations.append(OperationDestroyDevice(self.origrequest)) operations.append(OperationCreateDevice(request)) operations.append(OperationCreateFormat(request)) else: format = None if widget.formatRadio.isChecked(): formatType = str(widget.formatCombo.currentText()) format = formats.getFormat(formatType, mountpoint=mountpoint, device=self.origrequest.path) operations.append(OperationCreateFormat(self.origrequest, format)) else: cancel = [] cancel.extend(self.storage.devicetree.findOperations(type="destroy", object="format", devid=self.origrequest.id)) cancel.extend(self.storage.devicetree.findOperations(type="create", object="format", devid=self.origrequest.id)) for operation in cancel: devicetree.removeOperation(operation) self.origrequest.format = self.origrequest.originalFormat if self.origrequest.format.mountable: self.origrequest.format.mountpoint = mountpoint if widget.migrateRadio.isChecked(): operations.append(OperationMigrateFormat(self.origrequest)) if self.origrequest.format.exists and not format and \ self.storage.formatByDefault(self.origrequest): if not queryNoFormatPreExisting(self.intf): continue # everything ok, fall out of loop break
def run(self): if self.dialog is None: return [] while 1: rc = self.dialog.exec_() operations = [] raidmembers = [] if not rc: self.destroy() return [] widget = self.dialog.content mountpoint = unicode(widget.mountpointMenu.currentText()) active = widget.mountpointMenu.isEnabled() if active and mountpoint: msg = sanityCheckMountPoint(mountpoint) if msg: self.intf.messageWindow(_("Mount Point Error"), msg, type="error") continue used = False for (mp, dev) in self.storage.mountpoints.iteritems(): if mp == mountpoint and \ dev.id != self.origrequest.id and \ not (self.origrequest.format.type == "luks" and self.origrequest in dev.parents): used = True break if used: self.intf.messageWindow(_("Mount point in use"), _("The mount point \"%s\" is in " "use. Please pick another.") % (mountpoint, ), type="warning") continue for index in range(widget.raidMembers.count()): if widget.raidMembers.item(index).checkState() == Qt.Checked: raidmembers.append( widget.raidMembers.item(index).partition) # The user has to select some devices to be part of the array. if not raidmembers: raidlevel = int( widget.raidLevels.itemData( widget.raidLevels.currentIndex())) self.intf.messageWindow( _("Invalid Raid Members"), _("A RAID%(level)d set requires at least %(min_member)d member" ) % { "level": raidlevel, "min_member": raid.get_raid_min_members(raidlevel) }, type="warning") continue if not self.origrequest.exists: formatType = str(widget.filesystemMenu.currentText()) raidminor = int( widget.raidMinors.itemData( widget.raidMinors.currentIndex())) raidlevel = int( widget.raidLevels.itemData( widget.raidLevels.currentIndex())) if not raid.isRaid(raid.RAID0, raidlevel): spares = widget.spareSpin.value() else: spares = 0 format = formats.getFormat(formatType, mountpoint=mountpoint) members = len(raidmembers) - spares try: request = self.storage.newRaidArray( minor=raidminor, level=raidlevel, format=format, parents=raidmembers, totalDevices=len(raidmembers), memberDevices=members) except ValueError, msg: self.intf.messageWindow(_("Invalid Raid Members"), unicode(msg), type="warning") continue if not self.isNew: # This may be handled in devicetree.registerAction, # but not in case when we change minor and thus # device name/path (at least with current md) operations.append(OperationDestroyDevice(self.origrequest)) operations.append(OperationCreateDevice(request)) operations.append(OperationCreateFormat(request)) else: format = None if widget.formatRadio.isChecked(): formatType = str(widget.formatCombo.currentText()) format = formats.getFormat(formatType, mountpoint=mountpoint, device=self.origrequest.path) operations.append( OperationCreateFormat(self.origrequest, format)) else: cancel = [] cancel.extend( self.storage.devicetree.findOperations( type="destroy", object="format", devid=self.origrequest.id)) cancel.extend( self.storage.devicetree.findOperations( type="create", object="format", devid=self.origrequest.id)) for operation in cancel: self.storage.devicetree.removeOperation(operation) self.origrequest.format = self.origrequest.originalFormat if self.origrequest.format.mountable: self.origrequest.format.mountpoint = mountpoint if widget.migrateRadio.isChecked(): operations.append(OperationMigrateFormat(self.origrequest)) if self.origrequest.format.exists and not format and \ self.storage.formatByDefault(self.origrequest): if not queryNoFormatPreExisting(self.intf): continue # everything ok, fall out of loop break