示例#1
0
    def __init__(self, parent, request, isNew=0):
        QWidget.__init__(self, parent.parent)
        self.setupUi(self)
        self.parent = parent
        self.origrequest = request
        self.isNew = isNew

        if not self.origrequest.exists:
            if self.origrequest.name:
                self.name.setText(self.origrequest.lvname)
            else:
                self.name.setText(self.parent.storage.createSuggestedVolumeGroupName(self.origrequest.vg))
        else:
            self.name.setText(self.origrequest.lvname)

        storageGuiHelpers.fillMountpointMenu(self.mountpointMenu, self.origrequest, excludes=["/boot"])
        self.mountpointMenu.currentIndexChanged[int].connect(self.mountPointChanged)

        # This empty radioButton is hack about enabling autoExclusive formatRadio according to mountpoint.(#16446)
        self.radioButton.hide()

        # Partition Type
        if not self.origrequest.exists:
            storageGuiHelpers.fillFilesystemMenu(self.filesystemMenu, self.origrequest.format,
                                                 ignores=["mdmember", "efi", "lvmpv"])
            self.filesystemMenu.currentIndexChanged[int].connect(self.formatTypeChanged)
            default_format = self.filesystemMenu.findText("ext4")
            self.filesystemMenu.setCurrentIndex(default_format)
            self.resizeRadio.hide()
            self.resizeSlider.hide()
            self.resizeSpin.hide()
            self.formatRadio.hide()
            self.formatCombo.hide()
            self.migrateRadio.hide()
            self.migrateCombo.hide()
        else:
            self.filesystemLabel.hide()
            self.filesystemMenu.hide()
            if self.origrequest.format.formattable or not self.origrequest.format.type:
                storageGuiHelpers.fillFilesystemMenu(self.formatCombo, self.origrequest.format,
                                                     ignores= ["mdmember", "lvmpv", "vfat"])
                self.formatRadio.setChecked(self.origrequest.format.formattable and not self.origrequest.format.exists)
                self.formatRadio.toggled[bool].connect(self.formatRadioToggled)
                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()

            if self.origrequest.resizable and self.origrequest.format.exists:
                if self.origrequest.targetSize is not None:
                    value = self.origrequest.targetSize
                else:
                    value = self.origrequest.size

                reqlower = 1
                requpper = self.origrequest.maxSize
                if self.origrequest.format.exists:
                    reqlower = self.origrequest.minSize

                    if self.origrequest.type == "partition":
                        geomsize = self.origrequest.partedPartition.geometry.getSize(unit="MB")
                        if (geomsize != 0) and (requpper > geomsize):
                            requpper = geomsize

                self.resizeSpin.setMinimum(reqlower)
                self.resizeSpin.setMaximum(requpper)
                self.resizeSpin.setValue(value)
                self.resizeSlider.setMinimum(reqlower)
                self.resizeSlider.setMaximum(requpper)
                self.resizeSlider.setValue(value)
            else:
                self.resizeRadio.hide()
                self.resizeSpin.hide()
                self.resizeSlider.hide()

        #Size and maximum size
        if not self.origrequest.exists:
             maximumGrow = self.origrequest.vg.freeSpace / self.origrequest.stripes
             self.sizeSpin.setMaximum(min(lvm.getMaxLVSize(), self.origrequest.size + maximumGrow))
             self.sizeSpin.setValue(self.origrequest.size)
             self.sizeSlider.setMaximum(min(lvm.getMaxLVSize(), self.origrequest.size + maximumGrow))
             self.sizeSlider.setValue(self.origrequest.size)
        else:
            self.sizeLabel.hide()
            self.sizeSlider.hide()
            self.sizeSpin.hide()


        self.buttonBox.accepted.connect(self.parent.dialog.accept)
        self.buttonBox.rejected.connect(self.parent.dialog.reject)
示例#2
0
    def __init__(self, parent, request, isNew=0):
        QWidget.__init__(self, parent.parent)
        self.setupUi(self)
        self.parent = parent
        self.origrequest = request
        self.isNew = isNew

        if not self.origrequest.exists:
            if self.origrequest.name:
                self.name.setText(self.origrequest.lvname)
            else:
                self.name.setText(self.parent.storage.createSuggestedVolumeGroupName(self.origrequest.vg))
        else:
            self.name.setText(self.origrequest.lvname)

        storageGuiHelpers.fillMountpointMenu(self.mountpointMenu, self.origrequest, excludes=["/boot"])
        QObject.connect(self.mountpointMenu, SIGNAL("currentIndexChanged(int)"), self.mountPointChanged)

        # This empty radioButton is hack about enabling autoExclusive formatRadio according to mountpoint.(#16446)
        self.radioButton.hide()

        # Partition Type
        if not self.origrequest.exists:
            storageGuiHelpers.fillFilesystemMenu(self.filesystemMenu, self.origrequest.format,
                                                 ignores=["mdmember", "efi", "lvmpv"])
            QObject.connect(self.filesystemMenu, SIGNAL("currentIndexChanged(int)"), self.formatTypeChanged)
            default_format = self.filesystemMenu.findText("ext4")
            self.filesystemMenu.setCurrentIndex(default_format)
            self.resizeRadio.hide()
            self.resizeSlider.hide()
            self.resizeSpin.hide()
            self.formatRadio.hide()
            self.formatCombo.hide()
            self.migrateRadio.hide()
            self.migrateCombo.hide()
        else:
            self.filesystemLabel.hide()
            self.filesystemMenu.hide()
            if self.origrequest.format.formattable or not self.origrequest.format.type:
                storageGuiHelpers.fillFilesystemMenu(self.formatCombo, self.origrequest.format,
                                                     ignores= ["mdmember", "lvmpv", "vfat"])
                self.formatRadio.setChecked(self.origrequest.format.formattable and not self.origrequest.format.exists)
                QObject.connect(self.formatRadio, SIGNAL("toggled(bool)"), self.formatRadioToggled)
                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()

            if self.origrequest.resizable and self.origrequest.format.exists:
                if self.origrequest.targetSize is not None:
                    value = self.origrequest.targetSize
                else:
                    value = self.origrequest.size

                reqlower = 1
                requpper = self.origrequest.maxSize
                if self.origrequest.format.exists:
                    reqlower = self.origrequest.minSize

                    if self.origrequest.type == "partition":
                        geomsize = self.origrequest.partedPartition.geometry.getSize(unit="MB")
                        if (geomsize != 0) and (requpper > geomsize):
                            requpper = geomsize

                self.resizeSpin.setMinimum(reqlower)
                self.resizeSpin.setMaximum(requpper)
                self.resizeSpin.setValue(value)
                self.resizeSlider.setMinimum(reqlower)
                self.resizeSlider.setMaximum(requpper)
                self.resizeSlider.setValue(value)
            else:
                self.resizeRadio.hide()
                self.resizeSpin.hide()
                self.resizeSlider.hide()

        #Size and maximum size
        if not self.origrequest.exists:
             maximumGrow = self.origrequest.vg.freeSpace / self.origrequest.stripes
             self.sizeSpin.setMaximum(min(lvm.getMaxLVSize(), self.origrequest.size + maximumGrow))
             self.sizeSpin.setValue(self.origrequest.size)
             self.sizeSlider.setMaximum(min(lvm.getMaxLVSize(), self.origrequest.size + maximumGrow))
             self.sizeSlider.setValue(self.origrequest.size)
        else:
            self.sizeLabel.hide()
            self.sizeSlider.hide()
            self.sizeSpin.hide()


        self.connect(self.buttonBox, SIGNAL("accepted()"), self.parent.dialog.accept)
        self.connect(self.buttonBox, SIGNAL("rejected()"), self.parent.dialog.reject)
示例#3
0
    def __init__(self, parent, request, isNew, restricts=None):
        QtGui.QWidget.__init__(self, parent.parent)
        self.setupUi(self)
        self.parent = parent
        self.origrequest = request
        self.isNew = isNew

        if not self.origrequest.exists:
            if self.parent.partedPartition and self.parent.partedPartition.type & parted.PARTITION_LOGICAL:
                self.primaryCheck.hide()

        # Mount Point entry
        storageGuiHelpers.fillMountpointMenu(self.mountpointMenu,
                                             self.origrequest)
        QObject.connect(self.mountpointMenu,
                        SIGNAL("currentIndexChanged(int)"),
                        self.mountPointChanged)

        # This empty radioButton is hack about enabling autoExclusive formatRadio according to mountpoint.(#16446)
        self.radioButton.hide()
        if not self.origrequest.exists:
            #Nont existing partition filesystem type
            storageGuiHelpers.fillFilesystemMenu(self.filesystemMenu,
                                                 self.origrequest.format,
                                                 availables=restricts)
            QObject.connect(self.filesystemMenu,
                            SIGNAL("currentIndexChanged(int)"),
                            self.formatTypeChanged)
            self.resizeRadio.hide()
            self.resizeSlider.hide()
            self.resizeSpin.hide()
            self.formatRadio.hide()
            self.formatCombo.hide()
            self.migrateRadio.hide()
            self.migrateCombo.hide()
        else:
            self.primaryCheck.hide()
            self.filesystemLabel.hide()
            self.filesystemMenu.hide()
            #To format existing partition
            if self.origrequest.format.formattable or not self.origrequest.format.type:
                storageGuiHelpers.fillFilesystemMenu(self.formatCombo,
                                                     self.origrequest.format)
                self.formatRadio.setChecked(
                    self.origrequest.format.formattable
                    and not self.origrequest.format.exists)
                QObject.connect(self.formatRadio, SIGNAL("toggled(bool)"),
                                self.formatRadioToggled)
                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()

            if self.origrequest.resizable and self.origrequest.format.exists:
                if self.origrequest.targetSize is not None:
                    value = self.origrequest.targetSize
                else:
                    value = self.origrequest.size

                reqlower = 1
                requpper = self.origrequest.maxSize
                if self.origrequest.format.exists:
                    reqlower = self.origrequest.minSize

                    if self.origrequest.type == "partition":
                        geomsize = self.origrequest.partedPartition.geometry.getSize(
                            unit="MB")
                        if (geomsize != 0) and (requpper > geomsize):
                            requpper = geomsize

                self.resizeSpin.setMinimum(reqlower)
                self.resizeSpin.setMaximum(requpper)
                self.resizeSpin.setValue(value)
                self.resizeSlider.setMinimum(reqlower)
                self.resizeSlider.setMaximum(requpper)
                self.resizeSlider.setValue(value)
            else:
                self.resizeRadio.hide()
                self.resizeSpin.hide()
                self.resizeSlider.hide()

        #Size
        if not self.origrequest.exists:
            if self.parent.isNew:
                maxsize = self.parent.partedPartition.getSize(unit="MB")
                self.sizeSpin.setMaximum(maxsize)
                self.sizeSlider.setMaximum(maxsize)
            elif not self.parent.isNew and self.origrequest.req_size:
                self.sizeSpin.setMaximum(self.origrequest.req_size)
                self.sizeSpin.setValue(self.origrequest.req_size)
                self.sizeSlider.setMaximum(self.origrequest.req_size)
                self.sizeSlider.setValue(self.origrequest.req_size)
        else:
            self.sizeLabel.hide()
            self.sizeSpin.hide()
            self.sizeSlider.hide()

        #create only as primary
        if not self.origrequest.exists and \
        self.parent.storage.extendedPartitionsSupported:
            self.primaryCheck.setChecked(False)
            if self.origrequest.req_primary:
                self.primaryCheck.setChecked(True)

        self.connect(self.buttonBox, SIGNAL("accepted()"),
                     self.parent.dialog.accept)
        self.connect(self.buttonBox, SIGNAL("rejected()"),
                     self.parent.dialog.reject)
示例#4
0
    def __init__(self, parent, request, isNew, restricts=None):
        QtWidgets.QWidget.__init__(self, parent.parent)
        self.setupUi(self)
        self.parent = parent
        self.origrequest = request
        self.isNew = isNew

        if not self.origrequest.exists:
            if self.parent.partedPartition and self.parent.partedPartition.type & parted.PARTITION_LOGICAL:
                self.primaryCheck.hide()

        # Mount Point entry
        storageGuiHelpers.fillMountpointMenu(self.mountpointMenu, self.origrequest)
        self.mountpointMenu.currentIndexChanged[int].connect(self.mountPointChanged)

        # This empty radioButton is hack about enabling autoExclusive formatRadio according to mountpoint.(#16446)
        self.radioButton.hide()
        if not self.origrequest.exists:
            #Nont existing partition filesystem type
            storageGuiHelpers.fillFilesystemMenu(self.filesystemMenu, self.origrequest.format,
                                                 availables=restricts)
            self.filesystemMenu.currentIndexChanged[int].connect(self.formatTypeChanged)
            self.resizeRadio.hide()
            self.resizeSlider.hide()
            self.resizeSpin.hide()
            self.formatRadio.hide()
            self.formatCombo.hide()
            self.migrateRadio.hide()
            self.migrateCombo.hide()
        else:
            self.primaryCheck.hide()
            self.filesystemLabel.hide()
            self.filesystemMenu.hide()
            #To format existing partition
            if self.origrequest.format.formattable or not self.origrequest.format.type:
                storageGuiHelpers.fillFilesystemMenu(self.formatCombo, self.origrequest.format)
                self.formatRadio.setChecked(self.origrequest.format.formattable and not self.origrequest.format.exists)
                self.formatRadio.toggled[bool].connect(self.formatRadioToggled)
                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()

            if self.origrequest.resizable and self.origrequest.format.exists:
                if self.origrequest.targetSize is not None:
                    value = self.origrequest.targetSize
                else:
                    value = self.origrequest.size

                reqlower = 1
                requpper = self.origrequest.maxSize
                if self.origrequest.format.exists:
                    reqlower = self.origrequest.minSize

                    if self.origrequest.type == "partition":
                        geomsize = self.origrequest.partedPartition.geometry.getSize(unit="MB")
                        if (geomsize != 0) and (requpper > geomsize):
                            requpper = geomsize

                self.resizeSpin.setMinimum(reqlower)
                self.resizeSpin.setMaximum(requpper)
                self.resizeSpin.setValue(value)
                self.resizeSlider.setMinimum(reqlower)
                self.resizeSlider.setMaximum(requpper)
                self.resizeSlider.setValue(value)
            else:
                self.resizeRadio.hide()
                self.resizeSpin.hide()
                self.resizeSlider.hide()

        #Size
        if not self.origrequest.exists:
            if self.parent.isNew:
                maxsize = self.parent.partedPartition.getSize(unit="MB")
                self.sizeSpin.setMaximum(maxsize)
                self.sizeSlider.setMaximum(maxsize)
            elif not self.parent.isNew and self.origrequest.req_size:
                self.sizeSpin.setMaximum(self.origrequest.req_size)
                self.sizeSpin.setValue(self.origrequest.req_size)
                self.sizeSlider.setMaximum(self.origrequest.req_size)
                self.sizeSlider.setValue(self.origrequest.req_size)
        else:
            self.sizeLabel.hide()
            self.sizeSpin.hide()
            self.sizeSlider.hide()

        #create only as primary
        if not self.origrequest.exists and \
        self.parent.storage.extendedPartitionsSupported:
            self.primaryCheck.setChecked(False)
            if self.origrequest.req_primary:
                self.primaryCheck.setChecked(True)

        self.buttonBox.accepted.connect(self.parent.dialog.accept)
        self.buttonBox.rejected.connect(self.parent.dialog.reject)
示例#5
0
    def __init__(self, parent, request, isNew, restricts=None):
        QtGui.QWidget.__init__(self, parent.parent)
        self.setupUi(self)
        self.parent = parent
        self.origrequest = request
        self.isNew = isNew

        # Mount Point entry
        storageGuiHelpers.fillMountpointMenu(self.mountpointMenu, self.origrequest)

        if not self.origrequest.exists:
            #Nont existing partition filesystem type
            storageGuiHelpers.fillFilesystemMenu(self.filesystemMenu, self.origrequest.format,
                                                 availables=restricts)
            QObject.connect(self.filesystemMenu, SIGNAL("currentIndexChanged(int)"), self.formatTypeChanged)
            self.resizeRadio.hide()
            self.resizeSlider.hide()
            self.resizeSpin.hide()
            self.formatRadio.hide()
            self.formatCombo.hide()
            self.migrateRadio.hide()
            self.migrateCombo.hide()
        else:
            self.primaryCheck.hide()
            self.filesystemLabel.hide()
            self.filesystemMenu.hide()
            #To format existing partition
            if self.origrequest.format.formattable or not self.origrequest.format.type:
                storageGuiHelpers.fillFilesystemMenu(self.formatCombo, self.origrequest.format)
                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()

            if self.origrequest.resizable and self.origrequest.format.exists:
                if self.origrequest.targetSize is not None:
                    value = self.origrequest.targetSize
                else:
                    value = self.origrequest.size

                reqlower = 1
                requpper = self.origrequest.maxSize
                if self.origrequest.format.exists:
                    reqlower = self.origrequest.minSize

                    if self.origrequest.type == "partition":
                        geomsize = self.origrequest.partedPartition.geometry.getSize(unit="MB")
                        if (geomsize != 0) and (requpper > geomsize):
                            requpper = geomsize

                self.resizeSpin.setMinimum(reqlower)
                self.resizeSpin.setMaximum(requpper)
                self.resizeSpin.setValue(value)
                self.resizeSlider.setMinimum(reqlower)
                self.resizeSlider.setMaximum(requpper)
                self.resizeSlider.setValue(value)
            else:
                self.resizeRadio.hide()
                self.resizeSpin.hide()
                self.resizeSlider.hide()


        # Allowable Drives
        #if not self.origrequest.exists:
        #    req_disk_names = [d.name for d in self.origrequest.req_disks]
        #    storageGuiHelpers.fillAllowedDrives(self.drives, self.parent.storage.partitioned, req_disk_names)
        #else:
        self.drivesLabel.hide()
        #self.drivesSpacer.hide()
        self.drives.hide()

        #Size
        if not self.origrequest.exists:
            maxsize = self.parent.partedPartition.getSize(unit="MB")
            self.sizeSpin.setMaximum(maxsize)
            self.sizeSlider.setMaximum(maxsize)
            if self.origrequest.req_size:
                self.sizeSpin.setValue(self.origrequest.req_size)
                self.sizeSlider.setValue(self.origrequest.req_size)
        else:
            self.sizeLabel.hide()
            self.sizeSpin.hide()
            self.sizeSlider.hide()

        #create only as primary
        if not self.origrequest.exists and \
        self.parent.storage.extendedPartitionsSupported:
            self.primaryCheck.setChecked(False)
            if self.origrequest.req_primary:
                self.primaryCheck.setChecked(True)

        self.connect(self.buttonBox, SIGNAL("accepted()"), self.parent.dialog.accept)
        self.connect(self.buttonBox, SIGNAL("rejected()"), self.parent.dialog.reject)
示例#6
0
文件: lvm_gui.py 项目: Tayyib/uludag
    def __init__(self, parent, request, isNew=0):
        QtGui.QWidget.__init__(self, parent.parent)
        self.setupUi(self)
        self.parent = parent
        self.origrequest = request
        self.isNew = isNew

        if not self.origrequest.exists:
            if self.origrequest.name:
                self.name.setText(self.origrequest.lvname)
            else:
                self.name.setText(self.parent.storage.createSuggestedVolumeGroupName(self.origrequest.vg))
        else:
            self.name.setText(self.origrequest.lvname)
        storageGuiHelpers.fillMountpointMenu(self.mountpointMenu, self.origrequest, excludes=["/boot"])

        # Partition Type
        if not self.origrequest.exists:
            storageGuiHelpers.fillFilesystemMenu(self.filesystemMenu, self.origrequest.format,
                                                 ignores=["mdmember", "efi", "lvmpv"])
            QObject.connect(self.filesystemMenu, SIGNAL("currentIndexChanged(int)"), self.formatTypeChanged)
            self.resizeRadio.hide()
            self.resizeSlider.hide()
            self.resizeSpin.hide()
            self.formatRadio.hide()
            self.formatCombo.hide()
            self.migrateRadio.hide()
            self.migrateCombo.hide()
        else:
            self.filesystemLabel.hide()
            self.filesystemMenu.hide()
            if self.origrequest.format.formattable or not self.origrequest.format.type:
                storageGuiHelpers.fillFilesystemMenu(self.formatCombo, self.origrequest.format,
                                                     ignores= ["software RAID", "physical volume (LVM)","vfat"])
                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()

            if self.origrequest.resizable and self.origrequest.format.exists:
                if self.origrequest.targetSize is not None:
                    value = self.origrequest.targetSize
                else:
                    value = self.origrequest.size

                reqlower = 1
                requpper = self.origrequest.maxSize
                if self.origrequest.format.exists:
                    reqlower = self.origrequest.minSize

                    if self.origrequest.type == "partition":
                        geomsize = self.origrequest.partedPartition.geometry.getSize(unit="MB")
                        if (geomsize != 0) and (requpper > geomsize):
                            requpper = geomsize

                self.resizeSpin.setMinimum(reqlower)
                self.resizeSpin.setMaximum(requpper)
                self.resizeSpin.setValue(value)
                self.resizeSlider.setMinimum(reqlower)
                self.resizeSlider.setMaximum(requpper)
                self.resizeSlider.setValue(value)
            else:
                self.resizeRadio.hide()
                self.resizeSpin.hide()
                self.resizeSlider.hide()

        #Size and maximum size
        if not self.origrequest.exists:
             maximumGrow = self.origrequest.vg.freeSpace / self.origrequest.stripes
             self.sizeSpin.setMaximum(min(lvm.getMaxLVSize(), self.origrequest.size + maximumGrow))
             self.sizeSpin.setValue(self.origrequest.size)
             self.sizeSlider.setMaximum(min(lvm.getMaxLVSize(), self.origrequest.size + maximumGrow))
             self.sizeSlider.setValue(self.origrequest.size)
        else:
            self.sizeLabel.hide()
            self.sizeSlider.hide()
            self.sizeSpin.hide()


        self.connect(self.buttonBox, SIGNAL("accepted()"), self.parent.dialog.accept)
        self.connect(self.buttonBox, SIGNAL("rejected()"), self.parent.dialog.reject)
示例#7
0
文件: raid_gui.py 项目: Tayyib/uludag
    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)
示例#8
0
    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)