예제 #1
0
def addZfcpDrive(anaconda):
    (dxml, dialog) = gui.getGladeWidget("zfcp-config.glade", "zfcpDialog")
    gui.addFrame(dialog)
    dialog.show_all()
    sg = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
    for w in ["devnumEntry", "wwpnEntry", "fcplunEntry"]:
        sg.add_widget(dxml.get_widget(w))

    while True:
        rc = dialog.run()
        if rc != gtk.RESPONSE_APPLY:
            break

        devnum = dxml.get_widget("devnumEntry").get_text().strip()
        wwpn = dxml.get_widget("wwpnEntry").get_text().strip()
        fcplun = dxml.get_widget("fcplunEntry").get_text().strip()

        try:
            anaconda.storage.zfcp.addFCP(devnum, wwpn, fcplun)
        except ValueError as e:
            anaconda.intf.messageWindow(_("Error"), str(e))
            continue

        break

    dialog.destroy()
    return rc
예제 #2
0
    def createDialog(self):

        if self.repo:
            self.nameEntry.set_text(gettext.ldgettext("comps", self.repo.name))
            if self.repo.anacondaBaseURLs:
                url = self.repo.anacondaBaseURLs[0]
            else:
                url = ''
            self.typeComboBox.set_active(self._methodToIndex(url))

            if not url or url.startswith("http") or url.startswith("ftp"):
                if self.repo.mirrorlist:
                    self.baseurlEntry.set_text(self.repo.mirrorlist)
                    self.mirrorlistCheckbox.set_active(True)
                else:
                    self.baseurlEntry.set_text(url)

                    self.mirrorlistCheckbox.set_active(False)

                if self.repo.proxy:
                    self.proxyCheckbox.set_active(True)
                    self.proxyTable.set_sensitive(True)
                    self.proxyEntry.set_text(self.repo.proxy)
                    self.usernameEntry.set_text(self.repo.proxy_username or '')
                    self.passwordEntry.set_text(self.repo.proxy_password or '')
                else:
                    self.proxyCheckbox.set_active(False)
                    self.proxyTable.set_sensitive(False)
            elif url.startswith("nfs"):
                (opts, server, path) = iutil.parseNfsUrl(url)
                self.nfsServerEntry.set_text(server)
                self.nfsPathEntry.set_text(path)
                self.nfsOptionsEntry.set_text(opts)
            elif url.startswith("cdrom:"):
                pass
            elif url.startswith("hd:"):
                m = url[3:]
                if m.count(":") == 1:
                    (device, path) = m.split(":")
                    fstype = "auto"
                else:
                    (device, fstype, path) = m.split(":")

                # find device in self.partitionComboBox and select it
                self.directoryChooser.set_current_folder("%s%s" % (self.anaconda.backend.ayum.isodir, path))
            else:
                self.baseurlEntry.set_text(url)

        else:
            self.typeComboBox.set_active(0)
            self.proxyCheckbox.set_active(False)
            self.proxyTable.set_sensitive(False)

        gui.addFrame(self.dialog)

        lbl = self.dxml.get_widget("descLabel")
        txt = lbl.get_text()
        lbl.set_text(txt)

        self.dialog.show_all()
예제 #3
0
def addZfcpDrive(anaconda):
    (dxml, dialog) = gui.getGladeWidget("zfcp-config.glade", "zfcpDialog")
    gui.addFrame(dialog)
    dialog.show_all()
    sg = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
    for w in ["devnumEntry", "wwpnEntry", "fcplunEntry"]:
        sg.add_widget(dxml.get_widget(w))

    while True:
        dialog.present()
        rc = dialog.run()
        if rc != gtk.RESPONSE_APPLY:
            break

        devnum = dxml.get_widget("devnumEntry").get_text().strip()
        wwpn = dxml.get_widget("wwpnEntry").get_text().strip()
        fcplun = dxml.get_widget("fcplunEntry").get_text().strip()

        try:
            anaconda.id.storage.zfcp.addFCP(devnum, wwpn, fcplun)
        except ValueError as e:
            anaconda.intf.messageWindow(_("Error"), str(e))
            continue

        break

    dialog.destroy()
    return rc
예제 #4
0
    def createDialog(self):

        if self.repo:
            self.nameEntry.set_text(self.repo.name)
            if self.repo.anacondaBaseURLs:
                url = self.repo.anacondaBaseURLs[0]
            else:
                url = ''
            self.typeComboBox.set_active(self._methodToIndex(url))

            if not url or url.startswith("http") or url.startswith("ftp"):
                if self.repo.mirrorlist:
                    self.baseurlEntry.set_text(self.repo.mirrorlist)
                    self.mirrorlistCheckbox.set_active(True)
                else:
                    self.baseurlEntry.set_text(url)

                    self.mirrorlistCheckbox.set_active(False)

                if self.repo.proxy:
                    self.proxyCheckbox.set_active(True)
                    self.proxyTable.set_sensitive(True)
                    self.proxyEntry.set_text(self.repo.proxy)
                    self.usernameEntry.set_text(self.repo.proxy_username or '')
                    self.passwordEntry.set_text(self.repo.proxy_password or '')
                else:
                    self.proxyCheckbox.set_active(False)
                    self.proxyTable.set_sensitive(False)
            elif url.startswith("nfs"):
                (opts, server, path) = iutil.parseNfsUrl(url)
                self.nfsServerEntry.set_text(server)
                self.nfsPathEntry.set_text(path)
                self.nfsOptionsEntry.set_text(opts)
            elif url.startswith("cdrom:"):
                pass
            elif url.startswith("hd:"):
                m = url[3:]
                if m.count(":") == 1:
                    (device, path) = m.split(":")
                    fstype = "auto"
                else:
                    (device, fstype, path) = m.split(":")

                # find device in self.partitionComboBox and select it
                self.directoryChooser.set_current_folder("%s%s" % (self.anaconda.backend.ayum.isodir, path))
            else:
                self.baseurlEntry.set_text(url)

        else:
            self.typeComboBox.set_active(0)
            self.proxyCheckbox.set_active(False)
            self.proxyTable.set_sensitive(False)

        gui.addFrame(self.dialog)

        lbl = self.dxml.get_widget("descLabel")
        txt = lbl.get_text()
        lbl.set_text(txt)

        self.dialog.show_all()
예제 #5
0
def addDrive(anaconda):
    (dxml, dialog) = gui.getGladeWidget("adddrive.glade", "addDriveDialog")
    gui.addFrame(dialog)
    dialog.show_all()
    if not iutil.isS390():
        dxml.get_widget("zfcpRadio").hide()
        dxml.get_widget("zfcpRadio").set_group(None)

    if not storage.iscsi.has_iscsi():
        dxml.get_widget("iscsiRadio").set_sensitive(False)
        dxml.get_widget("iscsiRadio").set_active(False)
        dxml.get_widget("iscsiBindCheck").set_sensitive(False)
    else:
        dxml.get_widget("iscsiBindCheck").set_active(bool(storage.iscsi.iscsi().ifaces))
        dxml.get_widget("iscsiBindCheck").set_sensitive(storage.iscsi.iscsi().mode == "none")

    if not storage.fcoe.has_fcoe():
        dxml.get_widget("fcoeRadio").set_sensitive(False)
        dxml.get_widget("fcoeRadio").set_active(False)

    def update_active_ifaces():
        active_ifaces = network.getActiveNetDevs()
        dxml.get_widget("ifaceLabel").set_text(", ".join(active_ifaces))

    def netconfButton_clicked(*args):
        from network_gui import setupNetwork
        setupNetwork(anaconda.intf)
        update_active_ifaces()

    dxml.get_widget("netconfButton").connect("clicked", netconfButton_clicked)
    update_active_ifaces()

    #figure out what advanced devices we have available and set sensible default
    group = dxml.get_widget("iscsiRadio").get_group()
    for button in group:
        if button is not None and button.get_property("sensitive"):
            button.set_active(True)
            button.grab_focus()
            break

    rc = dialog.run()
    dialog.hide()

    if rc in [gtk.RESPONSE_CANCEL, gtk.RESPONSE_DELETE_EVENT]:
        return False

    if dxml.get_widget("iscsiRadio").get_active() and storage.iscsi.has_iscsi():
        bind = dxml.get_widget("iscsiBindCheck").get_active()
        rc = addIscsiDrive(anaconda, bind)
    elif dxml.get_widget("fcoeRadio").get_active() and storage.fcoe.has_fcoe():
        rc = addFcoeDrive(anaconda)
    elif dxml.get_widget("zfcpRadio") is not None and dxml.get_widget("zfcpRadio").get_active():
        rc = addZfcpDrive(anaconda)

    dialog.destroy()

    if rc in [gtk.RESPONSE_CANCEL, gtk.RESPONSE_DELETE_EVENT]:
        return False
    else:
        return True
예제 #6
0
 def _handleIPMissing(self, field):
     d = gtk.MessageDialog(None, 0, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK,
                      _("A value is required for the field %s.") % (field,))
     d.set_title(_("Error With Data"))
     d.set_position(gtk.WIN_POS_CENTER)
     gui.addFrame(d)
     d.run()
     d.destroy()
예제 #7
0
 def _handleNetworkError(self, field):
     d = gtk.MessageDialog(None, 0, gtk.MESSAGE_ERROR,
                           gtk.BUTTONS_OK,
                           _("An error occurred trying to bring up the "
                             "%s network interface.") % (field,))
     d.set_title(_("Error Configuring Network"))
     d.set_position(gtk.WIN_POS_CENTER)
     gui.addFrame(d)
     d.run()
     d.destroy()
예제 #8
0
 def _handleIPError(self, field, errmsg):
     d = gtk.MessageDialog(None, 0, gtk.MESSAGE_ERROR,
                           gtk.BUTTONS_OK,
                             _("An error occurred converting the value "
                               "entered for \"%(field)s\":\n%(errmsg)s")
                             % {'field': field, 'errmsg': errmsg})
     d.set_title(_("Error With Data"))
     d.set_position(gtk.WIN_POS_CENTER)
     gui.addFrame(d)
     d.run()
     d.destroy()
예제 #9
0
    def __init__(self, storage, intf, parent):
        self.storage = storage
        self.intf = intf
        self.parent = parent

        self.dialog = None
        self.dialog = gtk.Dialog(_("Clone Drive Tool"), self.parent)
        self.dialog.set_default_size(500, 200)
        gui.addFrame(self.dialog)
        self.dialog.add_button('gtk-cancel', 2)
        self.dialog.add_button('gtk-ok', 1)
        self.dialog.set_position(gtk.WIN_POS_CENTER)

        # present list of drives as source
        vbox = gtk.VBox()
        clnmessage = _(
            "This tool clones the layout from a partitioned source "
            "onto other similar sized drives. The source must have "
            "partitions which are restricted to that drive and must "
            "ONLY contain unused software RAID partitions.  "
            "EVERYTHING on the target drive(s) will be destroyed.\n")

        lbl = gui.WrappingLabel(clnmessage)
        vbox.pack_start(lbl)

        box = gtk.HBox()

        lbl = gtk.Label(_("Source Drive:"))
        lbl.set_alignment(0.0, 0.0)
        box.pack_start(lbl, padding=5)
        (sw, self.sourceView) = self.createDriveList(storage.partitioned)
        selection = self.sourceView.get_selection()
        selection.set_mode(gtk.SELECTION_SINGLE)
        box.pack_start(sw, padding=5)

        lbl = gtk.Label(_("Target Drive(s):"))
        lbl.set_alignment(0.0, 0.0)
        box.pack_start(lbl, padding=5)
        (sw, self.targetView) = self.createDriveList(storage.partitioned)
        selection = self.targetView.get_selection()
        selection.set_mode(gtk.SELECTION_MULTIPLE)
        box.pack_start(sw, padding=5)

        frame = gtk.Frame(_("Drives"))
        frame.add(box)
        vbox.pack_start(frame)

        # put contents into dialog
        self.dialog.vbox.pack_start(vbox)

        self.dialog.show_all()

        return
예제 #10
0
    def __init__(self, storage, intf, parent):
	self.storage = storage
	self.intf = intf
	self.parent = parent

	self.dialog = None
	self.dialog = gtk.Dialog(_("Clone Drive Tool"), self.parent)
        self.dialog.set_default_size(500, 200)
	gui.addFrame(self.dialog)
	self.dialog.add_button('gtk-cancel', 2)
	self.dialog.add_button('gtk-ok', 1)
	self.dialog.set_position(gtk.WIN_POS_CENTER)

        # present list of drives as source
        vbox = gtk.VBox()
        clnmessage = _("This tool clones the layout from a partitioned source "
                        "onto other similar sized drives. The source must have "
                        "partitions which are restricted to that drive and must "
                        "ONLY contain unused software RAID partitions.  "
                        "EVERYTHING on the target drive(s) will be destroyed.\n")

        lbl = gui.WrappingLabel(clnmessage)
        vbox.pack_start(lbl)
                                  
        box = gtk.HBox()

        lbl = gtk.Label(_("Source Drive:"))
        lbl.set_alignment(0.0, 0.0)
        box.pack_start(lbl, padding=5)
        (sw, self.sourceView) = self.createDriveList(storage.partitioned)
        selection = self.sourceView.get_selection()
        selection.set_mode(gtk.SELECTION_SINGLE)
        box.pack_start(sw, padding=5)

        lbl = gtk.Label(_("Target Drive(s):"))
        lbl.set_alignment(0.0, 0.0)
        box.pack_start(lbl, padding=5)
        (sw, self.targetView) = self.createDriveList(storage.partitioned)
        selection = self.targetView.get_selection()
        selection.set_mode(gtk.SELECTION_MULTIPLE)
        box.pack_start(sw, padding=5)

        frame = gtk.Frame(_("Drives"))
        frame.add(box)
        vbox.pack_start(frame)

	# put contents into dialog
	self.dialog.vbox.pack_start(vbox)

	self.dialog.show_all()

	return
예제 #11
0
    def changeBootloaderCallback(self, *args):
        dialog = gtk.Dialog(_("Change Boot Loader"), self.parent)
        dialog.add_button('gtk-cancel', 2)
        dialog.add_button('gtk-ok', 1)
        dialog.set_position(gtk.WIN_POS_CENTER)
        gui.addFrame(dialog)
        radio_vbox = self.setupChooseBootloaderRadioBox()

        dialog.vbox.pack_start(radio_vbox)
        dialog.show_all()

        blname = self.blname
        while 1:
            rc = dialog.run()
            if rc == 2:
                break

            if self.none_radio.get_active() == gtk.TRUE:
                newrc = self.intf.messageWindow(_("Warning"),
                                                _("You have selected not to "
                                                  "install a boot loader on "
                                                  "your system.  You will "
                                                  "have to create a boot "
                                                  "disk to boot your system "
                                                  "with this option.\n\n"
                                                  "Would you like to "
                                                  "continue and not install "
                                                  "a boot loader?"),
                                                type="custom",
                                                custom_buttons=[
                                                    _("Cancel"),
                                                    _("C_ontinue with no boot "
                                                      "loader")
                                                ])
                if newrc != 1:
                    continue
                blname = None
            elif ((self.lilo_radio is not None)
                  and (self.lilo_radio.get_active() == gtk.TRUE)):
                blname = "LILO"
            else:
                blname = "GRUB"
            break

        dialog.destroy()

        if rc != 2:
            self.blname = blname
        self.updateBootLoaderLabel()
        if blname is not None:
            self.oslist.changeBootLoader(blname)
        return rc
예제 #12
0
    def editDriveOrder(self, *args):
        # we only support this for grub
        if not self.usingGrub:
            self.intf.messageWindow(_("Unable to Change Drive Order for LILO"),
                                    _("We do not support changing the "
                                      "drive order for use with LILO."),
                                    type="ok")
            return
                                      

            
        dialog = gtk.Dialog(_("Edit Drive Order"), flags = gtk.DIALOG_MODAL)
        gui.addFrame(dialog)
        dialog.set_modal(gtk.TRUE)
        dialog.set_position(gtk.WIN_POS_CENTER)

        label = gui.WrappingLabel(_("Arrange the drives to be in the same "
				    "order as used by the BIOS. Changing "
				    "the drive order may be useful if you "
				    "have multiple SCSI adapters or both SCSI "
				    "and IDE adapters and want to boot from "
				    "the SCSI device.\n\n"
				    "Changing the drive order will change "
				    "where the installation program "
				    "locates the Master Boot Record (MBR)."))
        label.set_alignment(0.0, 0.0)
        dialog.vbox.pack_start(label, padding = 25)

        orderWidget = DriveOrderWidget(self.driveOrder, self.diskset)
        alignment = gtk.Alignment()
        alignment.set(0.5, 0, 0, 0)
        alignment.add(orderWidget.getWidget())
        dialog.vbox.pack_start(alignment)

	dialog.add_button('gtk-cancel', 1)
	dialog.add_button('gtk-ok', 0)
	dialog.show_all()

        while 1:
            rc = dialog.run()
            if rc == 1:
                break

            self.driveOrder = orderWidget.getOrder()
            self.setMbrLabel(self.driveOrder[0])
            break

        dialog.destroy()
        return rc
예제 #13
0
def addDrive(anaconda):
    (dxml, dialog) = gui.getGladeWidget("adddrive.glade", "addDriveDialog")
    gui.addFrame(dialog)
    dialog.show_all()
    if not iutil.isS390():
        dxml.get_widget("zfcpRadio").hide()
        dxml.get_widget("zfcpRadio").set_group(None)

    if not storage.iscsi.has_iscsi():
        dxml.get_widget("iscsiRadio").set_sensitive(False)
        dxml.get_widget("iscsiRadio").set_active(False)

    if not storage.fcoe.has_fcoe():
        dxml.get_widget("fcoeRadio").set_sensitive(False)
        dxml.get_widget("fcoeRadio").set_active(False)

    #figure out what advanced devices we have available and set sensible default
    group = dxml.get_widget("iscsiRadio").get_group()
    for button in group:
        if button is not None and button.get_property("sensitive"):
            button.set_active(True)
            button.grab_focus()
            break

    rc = dialog.run()
    dialog.hide()

    if rc in [gtk.RESPONSE_CANCEL, gtk.RESPONSE_DELETE_EVENT]:
        return False

    if dxml.get_widget(
            "iscsiRadio").get_active() and storage.iscsi.has_iscsi():
        rc = addIscsiDrive(anaconda)
    elif dxml.get_widget("fcoeRadio").get_active() and storage.fcoe.has_fcoe():
        rc = addFcoeDrive(anaconda)
    elif dxml.get_widget("zfcpRadio") is not None and dxml.get_widget(
            "zfcpRadio").get_active():
        rc = addZfcpDrive(anaconda)

    dialog.destroy()

    if rc in [gtk.RESPONSE_CANCEL, gtk.RESPONSE_DELETE_EVENT]:
        return False
    else:
        return True
예제 #14
0
    def run(self):
        gui.addFrame(self.window)
        busycursor = gui.getBusyCursorStatus()
        gui.setCursorToNormal()

        self.window.show()
        while True:
            rc = self.window.run()
            if rc in [gtk.RESPONSE_CANCEL, gtk.RESPONSE_DELETE_EVENT]:
                self._cancel()
                break
            if self._ok():
                break

        # restore busy cursor
        if busycursor:
            gui.setCursorToBusy()
        return self.rc
예제 #15
0
def addDrive(anaconda):
    (dxml, dialog) = gui.getGladeWidget("adddrive.glade", "addDriveDialog")
    gui.addFrame(dialog)
    dialog.show_all()
    if not iutil.isS390():
        dxml.get_widget("zfcpRadio").hide()
        dxml.get_widget("zfcpRadio").set_group(None)

    if not storage.iscsi.has_iscsi():
        dxml.get_widget("iscsiRadio").set_sensitive(False)
        dxml.get_widget("iscsiRadio").set_active(False)

    if not storage.fcoe.has_fcoe():
        dxml.get_widget("fcoeRadio").set_sensitive(False)
        dxml.get_widget("fcoeRadio").set_active(False)

    #figure out what advanced devices we have available and set sensible default
    group = dxml.get_widget("iscsiRadio").get_group()
    for button in group:
        if button is not None and button.get_property("sensitive"):
            button.set_active(True)
            break

    rc = dialog.run()
    dialog.hide()

    if rc in [gtk.RESPONSE_CANCEL, gtk.RESPONSE_DELETE_EVENT]:
        return False

    if dxml.get_widget("iscsiRadio").get_active() and storage.iscsi.has_iscsi():
        rc = addIscsiDrive(anaconda)
    elif dxml.get_widget("fcoeRadio").get_active() and storage.fcoe.has_fcoe():
        rc = addFcoeDrive(anaconda)
    elif dxml.get_widget("zfcpRadio") is not None and dxml.get_widget("zfcpRadio").get_active():
        rc = addZfcpDrive(anaconda)

    dialog.destroy()

    if rc in [gtk.RESPONSE_CANCEL, gtk.RESPONSE_DELETE_EVENT]:
        return False
    else:
        return True
예제 #16
0
    def addDrive(self, button):
        (dxml, dialog) = gui.getGladeWidget("adddrive.glade", "addDriveDialog")
        gui.addFrame(dialog)
        dialog.show_all()
        if rhpl.getArch() not in ("s390", "s390x"):
            dxml.get_widget("zfcpRadio").hide()
            dxml.get_widget("zfcpRadio").set_group(None)

        import iscsi
        if not iscsi.has_iscsi():
            dxml.get_widget("iscsiRadio").set_sensitive(False)
            dxml.get_widget("iscsiRadio").set_active(False)

        #figure out what advanced devices we have available and set sensible default
        group = dxml.get_widget("iscsiRadio").get_group()
        for button in group:
            if button is not None and button.get_property("sensitive"):
                button.set_active(True)
                break
        
        rc = dialog.run()
        dialog.hide()
        if rc == gtk.RESPONSE_CANCEL:
            return
        if dxml.get_widget("iscsiRadio").get_active():
            rc = self.addIscsiDrive()
        elif dxml.get_widget("zfcpRadio") is not None and dxml.get_widget("zfcpRadio").get_active():
            rc = self.addZfcpDrive()
        dialog.destroy()

        if rc != gtk.RESPONSE_CANCEL:
            w = self.intf.waitWindow(_("Rescanning disks"),
                                     _("Rescanning disks"))
            partitioning.partitionObjectsInitialize(self.anaconda)
            createAllowedDrivesStore(self.diskset.disks,
                                     self.partitions.autoClearPartDrives,
                                     self.drivelist,
                                     self.anaconda.updateSrc)
            w.pop()
예제 #17
0
    def editDriveOrder(self, *args):
        dialog = gtk.Dialog(_("Edit Drive Order"), flags = gtk.DIALOG_MODAL)
        gui.addFrame(dialog)
        dialog.set_modal(True)
        dialog.set_position(gtk.WIN_POS_CENTER)

        label = gui.WrappingLabel(_("Arrange the drives to be in the same "
				    "order as used by the BIOS. Changing "
				    "the drive order may be useful if you "
				    "have multiple SCSI adapters or both SCSI "
				    "and IDE adapters and want to boot from "
				    "the SCSI device.\n\n"
				    "Changing the drive order will change "
				    "where the installation program "
				    "locates the Master Boot Record (MBR)."))
        label.set_alignment(0.0, 0.0)
        dialog.vbox.pack_start(label, padding = 25)

        orderWidget = DriveOrderWidget(self.driveOrder, self.diskset)
        alignment = gtk.Alignment()
        alignment.set(0.5, 0, 0, 0)
        alignment.add(orderWidget.getWidget())
        dialog.vbox.pack_start(alignment)

	dialog.add_button('gtk-cancel', 1)
	dialog.add_button('gtk-ok', 0)
	dialog.show_all()

        while 1:
            rc = dialog.run()
            if rc == 1:
                break

            self.driveOrder = orderWidget.getOrder()
            self.setMbrLabel(self.driveOrder[0])
            break

        dialog.destroy()
        return rc
예제 #18
0
    def addDrive(self, button):
        (dxml, dialog) = gui.getGladeWidget("adddrive.glade", "addDriveDialog")
        gui.addFrame(dialog)
        dialog.show_all()
        if rhpl.getArch() not in ("s390", "s390x"):
            dxml.get_widget("zfcpRadio").hide()
            dxml.get_widget("zfcpRadio").set_group(None)

        import iscsi
        if not iscsi.has_iscsi():
            dxml.get_widget("iscsiRadio").set_sensitive(False)
            dxml.get_widget("iscsiRadio").set_active(False)

        #figure out what advanced devices we have available and set sensible default
        group = dxml.get_widget("iscsiRadio").get_group()
        for button in group:
            if button is not None and button.get_property("sensitive"):
                button.set_active(True)
                break

        rc = dialog.run()
        dialog.hide()
        if rc in [gtk.RESPONSE_CANCEL, gtk.RESPONSE_DELETE_EVENT]:
            return
        if dxml.get_widget("iscsiRadio").get_active():
            rc = self.addIscsiDrive()
        elif dxml.get_widget("zfcpRadio") is not None and dxml.get_widget(
                "zfcpRadio").get_active():
            rc = self.addZfcpDrive()
        dialog.destroy()

        if rc not in [gtk.RESPONSE_CANCEL, gtk.RESPONSE_DELETE_EVENT]:
            w = self.intf.waitWindow(_("Rescanning disks"),
                                     _("Rescanning disks"))
            partitioning.partitionObjectsInitialize(self.anaconda)
            createAllowedDrivesStore(self.diskset.disks,
                                     self.partitions.autoClearPartDrives,
                                     self.drivelist, self.anaconda.updateSrc)
            w.pop()
예제 #19
0
    def addZfcpDrive(self):
        (dxml, dialog) = gui.getGladeWidget("zfcp-config.glade", "zfcpDialog")
        gui.addFrame(dialog)
        dialog.show_all()
        sg = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
        map(lambda x: sg.add_widget(dxml.get_widget(x)),
            ("devnumEntry", "wwpnEntry", "fcplunEntry"))

        while 1:
            rc = dialog.run()
            if rc != gtk.RESPONSE_APPLY:
                break

            devnum = dxml.get_widget("devnumEntry").get_text().strip()
            wwpn = dxml.get_widget("wwpnEntry").get_text().strip()
            fcplun = dxml.get_widget("fcplunEntry").get_text().strip()

            try:
                self.anaconda.id.zfcp.addFCP(devnum, wwpn, fcplun)
            except ValueError, e:
                self.intf.messageWindow(_("Error"), "%s" % e)
                continue
            break
예제 #20
0
    def addZfcpDrive(self):
        (dxml, dialog) = gui.getGladeWidget("zfcp-config.glade",
                                            "zfcpDialog")
        gui.addFrame(dialog)
        dialog.show_all()
        sg = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
        map(lambda x: sg.add_widget(dxml.get_widget(x)),
            ("devnumEntry", "wwpnEntry", "fcplunEntry"))

        while 1:
            rc = dialog.run()
            if rc != gtk.RESPONSE_APPLY:
                break

            devnum = dxml.get_widget("devnumEntry").get_text().strip()
            wwpn = dxml.get_widget("wwpnEntry").get_text().strip()
            fcplun = dxml.get_widget("fcplunEntry").get_text().strip()

            try:
                self.anaconda.id.zfcp.addFCP(devnum, wwpn, fcplun)
            except ValueError, e:
                self.intf.messageWindow(_("Error"), "%s" % e)
                continue
            break
예제 #21
0
	def setupWindow(self):
		self.vue.set_document(self.doc)
		self.textWin = gtk.Window()
		self.textWin.connect("delete-event", self.closedCallBack)
		mainbox = gtk.VBox(False, 6)
		self.textWin.add(mainbox)

		table = gtk.Table(3, 3, False)
		mainbox.pack_start(table)

		mainbox.pack_start(gtk.HSeparator(), False, False)
		bb = gtk.HButtonBox()
		bb.set_property("layout-style", gtk.BUTTONBOX_END)

		b = gtk.Button(stock="gtk-close")
		b.connect("clicked", self.closedCallBack)
		bb.pack_start(b)
		mainbox.pack_start(bb, False, False)

		vbox1 = gtk.VBox()
		vbox1.set_border_width(10)
		frame = gtk.Frame("")
		frame.add(vbox1)
		frame.set_label_align(0.5, 0.5)
		frame.set_shadow_type(gtk.SHADOW_NONE)

		self.textWin.set_position(gtk.WIN_POS_NONE)
		self.textWin.set_gravity(gtk.gdk.GRAVITY_NORTH_WEST)

		if self.vue is not None:
			sw = gtk.ScrolledWindow()
			sw.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC)
			sw.set_shadow_type(gtk.SHADOW_IN)
			sw.add(self.vue)
			vbox1.pack_start(sw)

			a = gtk.Alignment(0, 0, 1.0, 1.0)
			a.add(frame)

			self.textWin.set_default_size(self.width, self.height)
			self.textWin.set_size_request(self.width, self.height)

			# we want the release notes dialog to be the same
			# size as the main installer window so it covers it
			# up completely.  this isn't always the same size
			# as the root window, so figure out our northwest
			# origin point and then move the window
			if gtk.gdk.screen_width() == self.width:
				self.textWin.move(0, 0)
			else:
				# the width will always be fixed, but our
				# height changes depending on the installation
				# stage, so do the origin point calculations
				# using what would be the full height
				if self.width == 800:
					fullh = 600
				elif self.width == 640:
					fullh = 480

				left = (gtk.gdk.screen_width() - self.width) / 2
				top = (gtk.gdk.screen_height() - fullh) / 2
				self.textWin.move(left, top)

			table.attach(a, 1, 2, 1, 2, gtk.FILL | gtk.EXPAND, gtk.FILL | gtk.EXPAND, 5, 5)

			self.textWin.set_border_width(0)
			gui.addFrame(self.textWin, _("Release Notes"))
		else:
			self.textWin.set_position(gtk.WIN_POS_CENTER)
			label = gtk.Label(_("Unable to load file!"))

			table.attach(label, 1, 2, 1, 2, gtk.FILL | gtk.EXPAND, gtk.FILL | gtk.EXPAND, 5, 5)

			self.textWin.set_border_width(0)
			gui.addFrame(self.textWin)
예제 #22
0
    def __init__(self, partitions, diskset, intf, parent):
	self.partitions = partitions
	self.diskset = diskset
	self.intf = intf
	self.parent = parent

	self.dialog = None
	self.dialog = gtk.Dialog(_("Make RAID Device"), self.parent)
        self.dialog.set_size_request(500, 400)
	gui.addFrame(self.dialog)
	self.dialog.add_button('gtk-cancel', 2)
	self.dialog.add_button('gtk-ok', 1)
	self.dialog.set_position(gtk.WIN_POS_CENTER)

        # present list of drives as source
        vbox = gtk.VBox()

        lbl = gui.WrappingLabel(_("Clone Drive Tool\n\n"
                                  "This tool allows you to significantly "
                                  "reduce the amount of effort required "
                                  "to setup RAID arrays.  The idea is to "
                                  "take a source drive which has been "
                                  "prepared with the desired partitioning "
                                  "layout, and clone this layout onto other "
                                  "similar sized drives.  Then a RAID device "
                                  "can be created.\n\n"
                                  "NOTE: The source drive must have "
                                  "partitions which are restricted to be on "
                                  "that drive only, and can only contain "
                                  "unused software RAID partitions.  Other "
                                  "partition types are not allowed.\n\n"
                                  "EVERYTHING on the target drive(s) will be "
                                  "destroyed by this process."))
        vbox.pack_start(lbl)
                                  
        box = gtk.HBox()

        lbl = gtk.Label(_("Source Drive:"))
        lbl.set_alignment(0.0, 0.0)
        box.pack_start(lbl, padding=5)
        (sw, self.sourceView) = self.createDriveList(diskset)
        selection = self.sourceView.get_selection()
        selection.set_mode(gtk.SELECTION_SINGLE)
        box.pack_start(sw)

        lbl = gtk.Label(_("Target Drive(s):"))
        lbl.set_alignment(0.0, 0.0)
        box.pack_start(lbl, padding=5)
        (sw, self.targetView) = self.createDriveList(diskset)
        selection = self.targetView.get_selection()
        selection.set_mode(gtk.SELECTION_MULTIPLE)
        box.pack_start(sw)

        frame = gtk.Frame(_("Drives"))
        frame.add(box)
        vbox.pack_start(frame)

	# put contents into dialog
	self.dialog.vbox.pack_start(vbox)

	self.dialog.show_all()

	return
예제 #23
0
def addFcoeDrive(anaconda):
    (dxml, dialog) = gui.getGladeWidget("fcoe-config.glade", "fcoeDialog")
    combo = dxml.get_widget("fcoeNicCombo")
    dcb_cb = dxml.get_widget("dcbCheckbutton")

    # Populate the combo
    cell = gtk.CellRendererText()
    combo.pack_start(cell, True)
    combo.set_attributes(cell, text=0)
    cell.set_property("wrap-width", 525)
    combo.set_size_request(480, -1)
    store = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
    combo.set_model(store)

    netdevs = anaconda.id.network.netdevices
    keys = netdevs.keys()
    keys.sort()
    selected_interface = None
    for dev in keys:
        i = store.append(None)
        desc = netdevs[dev].description
        if desc:
            desc = "%s - %s" % (dev, desc)
        else:
            desc = "%s" % (dev, )

        mac = netdevs[dev].get("HWADDR")
        if mac:
            desc = "%s - %s" % (desc, mac)

        if selected_interface is None:
            selected_interface = i

        store[i] = (desc, dev)

    if selected_interface:
        combo.set_active_iter(selected_interface)
    else:
        combo.set_active(0)

    # Show the dialog
    gui.addFrame(dialog)
    dialog.show_all()
    sg = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
    sg.add_widget(dxml.get_widget("fcoeNicCombo"))

    while True:
        # make sure the dialog pops into foreground in case this is the second
        # time through the loop:
        dialog.present()
        rc = dialog.run()

        if rc in [gtk.RESPONSE_CANCEL, gtk.RESPONSE_DELETE_EVENT]:
            break

        iter = combo.get_active_iter()
        if iter is None:
            anaconda.intf.messageWindow(_("Error"),
                                        _("You must select a NIC to use."),
                                        type="warning",
                                        custom_icon="error")
            continue

        try:
            anaconda.id.storage.fcoe.addSan(store.get_value(iter, 1),
                                            dcb=dcb_cb.get_active(),
                                            intf=anaconda.intf)
        except IOError as e:
            anaconda.intf.messageWindow(_("Error"), str(e))
            rc = gtk.RESPONSE_CANCEL

        break

    dialog.destroy()
    return rc
예제 #24
0
    def editOther(self, oldDevice, oldLabel, isDefault, isRoot = 0):
        dialog = gtk.Dialog(_("Image"), self.parent)
        dialog.add_button('gtk-cancel', 2)
        dialog.add_button('gtk-ok', 1)
        dialog.set_position(gtk.WIN_POS_CENTER)
        gui.addFrame(dialog)

        dialog.vbox.pack_start(gui.WrappingLabel(
            _("Enter a label to be displayed in the boot loader menu. The "
	      "device (or hard drive and partition number) is the device "
	      "from which it boots.")))

        spacer = gtk.Label("")
        spacer.set_size_request(10, 1)
        dialog.vbox.pack_start(spacer, False)

        table = gtk.Table(2, 5)
        table.set_row_spacings(5)
        table.set_col_spacings(5)

        label = gui.MnemonicLabel(_("_Label"))
        table.attach(label, 0, 1, 1, 2, gtk.FILL, 0, 10)
        labelEntry = gtk.Entry(32)
        label.set_mnemonic_widget(labelEntry)
        table.attach(labelEntry, 1, 2, 1, 2, gtk.FILL, 0, 10)
        if oldLabel:
            labelEntry.set_text(oldLabel)

        label = gui.MnemonicLabel(_("_Device"))
        table.attach(label, 0, 1, 2, 3, gtk.FILL, 0, 10)
        if not isRoot:
            # XXX should potentially abstract this out into a function
            pedparts = []
            parts = []
            disks = self.diskset.disks
            for drive in disks.keys():
                pedparts.extend(partedUtils.get_all_partitions(disks[drive]))
            for part in pedparts:
                parts.append(partedUtils.get_partition_name(part))
            del pedparts
            parts.sort()

            deviceCombo = datacombo.DataComboBox()
            defindex = 0
            i = 0
            for part in  parts:
                deviceCombo.append("/dev/%s" %(part,), part)
                if oldDevice and oldDevice == part:
                    defindex = i
                i = i + 1


            deviceCombo.set_active(defindex)
            
            table.attach(deviceCombo, 1, 2, 2, 3, gtk.FILL, 0, 10)
            label.set_mnemonic_widget(deviceCombo)
        else:
            table.attach(gtk.Label(oldDevice), 1, 2, 2, 3, gtk.FILL, 0, 10)

        default = gtk.CheckButton(_("Default Boot _Target"))
        table.attach(default, 0, 2, 3, 4, gtk.FILL, 0, 10)
        if isDefault != 0:
            default.set_active(True)

        if self.numentries == 1 and oldDevice != None:
            default.set_sensitive(False)
        else:
            default.set_sensitive(True)
        
        dialog.vbox.pack_start(table)
        dialog.show_all()

        while 1:
            rc = dialog.run()

            # cancel
            if rc == 2:
                break

            label = labelEntry.get_text()

            if not isRoot:
                dev = deviceCombo.get_active_value()
            else:
                dev = oldDevice

            if not label:
                self.intf.messageWindow(_("Error"),
                                        _("You must specify a label for the "
                                          "entry"),
                                        type="warning")
                continue

            foundBad = 0
            for char in self.illegalChars:
                if char in label:
                    self.intf.messageWindow(_("Error"),
                                            _("Boot label contains illegal "
                                              "characters"),
                                            type="warning")
                    foundBad = 1
                    break
            if foundBad:
                continue

            # verify that the label hasn't been used
            foundBad = 0
            for key in self.imagelist.keys():
                if dev == key:
                    continue
                if self.blname == "GRUB":
                    thisLabel = self.imagelist[key][1]
                else:
                    thisLabel = self.imagelist[key][0]

                # if the label is the same as it used to be, they must
                # have changed the device which is fine
                if thisLabel == oldLabel:
                    continue

                if thisLabel == label:
                    self.intf.messageWindow(_("Duplicate Label"),
                                            _("This label is already in "
                                              "use for another boot entry."),
                                            type="warning")
                    foundBad = 1
                    break
            if foundBad:
                continue

            # XXX need to do some sort of validation of the device?

            # they could be duplicating a device, which we don't handle
            if dev in self.imagelist.keys() and (not oldDevice or
                                                 dev != oldDevice):
                self.intf.messageWindow(_("Duplicate Device"),
                                        _("This device is already being "
                                          "used for another boot entry."),
                                        type="warning")
                continue

            # if we're editing a previous, get what the old info was for
            # labels.  otherwise, make it something safe for grub and the
            # device name for lilo for lack of any better ideas
            if oldDevice:
                (oldshort, oldlong, oldisroot) = self.imagelist[oldDevice]
            else:
                (oldshort, oldlong, oldisroot) = (dev, label, None)
                
            # if we're editing and the device has changed, delete the old
            if oldDevice and dev != oldDevice:
                del self.imagelist[oldDevice]
                
            # go ahead and add it
            if self.blname == "GRUB":
                self.imagelist[dev] = (oldshort, label, isRoot)
            else:
                self.imagelist[dev] = (label, oldlong, isRoot)

            if default.get_active():
                self.defaultDev = dev

            # refill the os list store
            self.fillOSList()
            break
        
        dialog.destroy()
예제 #25
0
    def _deviceChange(self, b, anaconda, *args):
        def __driveChange(combo, dxml, choices):
            if not choices.has_key("mbr"):
                return

            iter = combo.get_active_iter()
            if not iter:
                return

            first = combo.get_model()[iter][1]
            desc = choices["mbr"][1]
            dxml.get_widget("mbrRadio").set_label("%s - /dev/%s" %(_(desc), first))
            dxml.get_widget("mbrRadio").set_data("bootDevice", first)

        def __genStore(combo, disks, active):
            model = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
            combo.set_model(model)
            cell = gtk.CellRendererText()
            combo.pack_start(cell, True)
            combo.set_attributes(cell, text = 0)

            for disk in disks:
                i = model.append(None)
                model[i] = ("%s %8.0f MB %s" %(disk.name, disk.size,
                                               disk.description),
                            "%s" %(disk.name,))
                if disk.name == active:
                    combo.set_active_iter(i)

            return model

        (dxml, dialog) = gui.getGladeWidget("blwhere.glade",
                                            "blwhereDialog")
        gui.addFrame(dialog)
        dialog.set_transient_for(self.parent)
        dialog.show()

        choices = anaconda.platform.bootloaderChoices(self.bl)
        for t in ("mbr", "boot"):
            if not choices.has_key(t):
                continue
            (device, desc) = choices[t]
            w = dxml.get_widget("%sRadio" %(t,))
            w.set_label("%s - /dev/%s" %(_(desc), device))
            w.show()
            if self.bldev == device:
                w.set_active(True)
            else:
                w.set_active(False)
            w.set_data("bootDevice", device)

        for i in range(1, 5):
            if len(self.driveorder) < i:
                break
            combo = dxml.get_widget("bd%dCombo" %(i,))
            lbl = dxml.get_widget("bd%dLabel" %(i,))
            combo.show()
            lbl.show()
            partitioned = anaconda.id.storage.partitioned
            disks = anaconda.id.storage.disks
            bl_disks = [d for d in disks if d in partitioned]
            m = __genStore(combo, bl_disks, self.driveorder[i - 1])

        dxml.get_widget("bd1Combo").connect("changed", __driveChange, dxml, choices)
        __driveChange(dxml.get_widget("bd1Combo"), dxml, choices)

        while 1:
            rc = dialog.run()
            if rc in [gtk.RESPONSE_CANCEL, gtk.RESPONSE_DELETE_EVENT]:
                break

            # set the boot device based on what they chose
            if dxml.get_widget("bootRadio").get_active():
                self.bldev = dxml.get_widget("bootRadio").get_data("bootDevice")
            elif dxml.get_widget("mbrRadio").get_active():
                self.bldev = dxml.get_widget("mbrRadio").get_data("bootDevice")
            else:
                raise RuntimeError, "No radio button selected!"

            # and adjust the boot order
            neworder = []
            for i in range(1, 5):
                if len(self.driveorder) < i:
                    break

                combo = dxml.get_widget("bd%dCombo" %(i,))
                iter = combo.get_active_iter()
                if not iter:
                    continue

                act = combo.get_model()[iter][1]
                if act not in neworder:
                    neworder.append(act)
            for d in self.driveorder:
                if d not in neworder:
                    neworder.append(d)
            self.driveorder = neworder

            break

        dialog.destroy()
        self.grubCB.set_label(_("_Install boot loader on /dev/%s.") %
                              (self.bldev,))
        return rc
예제 #26
0
    def __init__(self, storage, intf, parent, origrequest, isNew = 0):
	self.storage = storage
	self.origrequest = origrequest
	self.isNew = isNew
	self.intf = intf
	self.parent = parent

	self.dialog = None

	#
	# start of editRaidRequest
	#
        availraidparts = self.storage.unusedMDMembers(array=self.origrequest)

	# if no raid partitions exist, raise an error message and return
	if len(availraidparts) < 2:
	    dlg = gtk.MessageDialog(self.parent, 0, gtk.MESSAGE_ERROR,
				    gtk.BUTTONS_OK,
				    _("At least two unused software RAID "
				      "partitions are needed to create "
				      "a RAID device.\n\n"
				      "First create at least two partitions "
				      "of type \"software RAID\", and then "
				      "select the \"RAID\" option again."))
	    gui.addFrame(dlg)
	    dlg.show_all()
	    dlg.set_position(gtk.WIN_POS_CENTER)
	    dlg.run()
	    dlg.destroy()
	    return

	if isNew:
	    tstr = _("Make RAID Device")
	else:
	    if origrequest.minor is not None:
		tstr = _("Edit RAID Device: %s") % (origrequest.path,)
	    else:
		tstr = _("Edit RAID Device")
		
	dialog = gtk.Dialog(tstr, self.parent)
	gui.addFrame(dialog)
	dialog.add_button('gtk-cancel', 2)
	self.ok_button = dialog.add_button('gtk-ok', 1)
	dialog.set_position(gtk.WIN_POS_CENTER)

	maintable = gtk.Table()
	maintable.set_row_spacings(5)
	maintable.set_col_spacings(5)
	row = 0

        # we'll maybe add this further down
        self.lukscb = gtk.CheckButton(_("_Encrypt"))
        self.lukscb.set_data("formatstate", 1)

        if origrequest.format.type == "luks":
            try:
                luksdev = self.storage.devicetree.getChildren(origrequest)[0]
            except IndexError:
                luksdev = None
                usedev = origrequest
                format = origrequest.format
            else:
                usedev = luksdev
                format = usedev.format
        else:
            luksdev = None
            usedev = origrequest
            format = origrequest.format

	# Mount Point entry
	lbl = createAlignedLabel(_("_Mount Point:"))
	maintable.attach(lbl, 0, 1, row, row + 1)
	self.mountCombo = createMountPointCombo(usedev)
	lbl.set_mnemonic_widget(self.mountCombo)
	maintable.attach(self.mountCombo, 1, 2, row, row + 1)
	row = row + 1

	# Filesystem Type
        if not origrequest.exists:
            lbl = createAlignedLabel(_("_File System Type:"))
            maintable.attach(lbl, 0, 1, row, row + 1)
            self.fstypeCombo = createFSTypeMenu(format,
                                                fstypechangeCB,
                                                self.mountCombo,
                                                ignorefs = ["mdmember", "efi", "prepboot", "appleboot"])
	    lbl.set_mnemonic_widget(self.fstypeCombo)
            maintable.attach(self.fstypeCombo, 1, 2, row, row + 1)
            row += 1
        else:
            maintable.attach(createAlignedLabel(_("Original File System Type:")),
                             0, 1, row, row + 1)
            self.fstypeCombo = gtk.Label(usedev.originalFormat.name)
            maintable.attach(self.fstypeCombo, 1, 2, row, row + 1)
            row += 1

            if getattr(usedev.originalFormat, "label", None):
                maintable.attach(createAlignedLabel(_("Original File System "
                                                      "Label:")),
                                 0, 1, row, row + 1)
                maintable.attach(gtk.Label(usedev.originalFormat.label),
                                 1, 2, row, row + 1)
                row += 1

	# raid minors
	lbl = createAlignedLabel(_("RAID _Device:"))	
	maintable.attach(lbl, 0, 1, row, row + 1)

        if not origrequest.exists:
            availminors = self.storage.unusedMDMinors[:16]
            reqminor = origrequest.minor
            if reqminor is not None and reqminor not in availminors:
                availminors.append(reqminor)

            availminors.sort()
            self.minorCombo = self.createRaidMinorMenu(availminors, reqminor)
	    lbl.set_mnemonic_widget(self.minorCombo)
        else:
            self.minorCombo = gtk.Label("%s" %(origrequest.name,))
	maintable.attach(self.minorCombo, 1, 2, row, row + 1)
	row = row + 1

	# raid level
	lbl = createAlignedLabel(_("RAID _Level:"))
	maintable.attach(lbl, 0, 1, row, row + 1)

        if not origrequest.exists:
            # Create here, pack below
            # create the raid level combobox:
            self.levelcombo = self.createRaidLevelMenu(mdraidlib.raid_levels,
                                                       origrequest.level)
            # now the number-of-spares spin button:
            spareAdj = gtk.Adjustment(value=0, upper=0, step_incr=1)
            self.sparesb = gtk.SpinButton(spareAdj)
            # adjust the max number of spares depending on the default raid level
            level_index = self.levelcombo.get_active()
            selected_level = self.levelcombo.get_model()[level_index][0]
            self._adjust_spares_button(selected_level, origrequest.totalDevices)
            # if there's a specific spares number request, set it
            self.sparesb.set_value(origrequest.spares)
	    lbl.set_mnemonic_widget(self.levelcombo)
        else:
            self.sparesb = gtk.Label(str(origrequest.spares))
            self.levelcombo = gtk.Label(origrequest.level)

	maintable.attach(self.levelcombo, 1, 2, row, row + 1)
	row = row + 1

	# raid members
	lbl=createAlignedLabel(_("_RAID Members:"))
	maintable.attach(lbl, 0, 1, row, row + 1)

	# XXX need to pass in currently used partitions for this device
	(self.raidlist, sw) = self.createAllowedRaidPartitionsList(availraidparts,
                                                                   origrequest.devices,
                                                                   origrequest.exists)

	lbl.set_mnemonic_widget(self.raidlist)
	self.raidlist.set_size_request(275, 80)
	maintable.attach(sw, 1, 2, row, row + 1)
	row = row + 1

        if origrequest.exists:
            self.raidlist.set_sensitive(False)

	# number of spares - created widget above
	lbl = createAlignedLabel(_("Number of _spares:"))
	maintable.attach(lbl, 0, 1, row, row + 1)
	maintable.attach(self.sparesb, 1, 2, row, row + 1)
	lbl.set_mnemonic_widget(self.sparesb)
	row = row + 1

	# format or not?
	self.formatButton = None
	self.fsoptionsDict = {}
	if not format.exists and not origrequest.exists:
	    self.formatButton = gtk.CheckButton(_("_Format partition?"))
	    if not format.type:
		self.formatButton.set_active(1)
	    else:
		self.formatButton.set_active(0)
            # it only makes sense to show this for preexisting RAID
            if origrequest.exists:
                maintable.attach(self.formatButton, 0, 2, row, row + 1)
                row = row + 1

            # checkbutton for encryption using dm-crypt/LUKS
            if origrequest.format.type == "luks":
                self.lukscb.set_active(1)
            else:
                self.lukscb.set_active(0)
            maintable.attach(self.lukscb, 0, 2, row, row + 1)
            row = row + 1
	else:
	    (row, self.fsoptionsDict) = createPreExistFSOptionSection(origrequest, maintable, row, self.mountCombo, self.storage, luksdev=luksdev)

	# put main table into dialog
	dialog.vbox.pack_start(maintable)

	dialog.show_all()
	self.dialog = dialog
	return
예제 #27
0
    def editLogicalVolume(self, logrequest, isNew=0):
        if isNew:
            tstr = _("Make Logical Volume")
        else:
            try:
                tstr = _("Edit Logical Volume: %s") % (
                    logrequest.logicalVolumeName, )
            except:
                tstr = _("Edit Logical Volume")

        dialog = gtk.Dialog(tstr, self.parent)
        gui.addFrame(dialog)
        dialog.add_button('gtk-cancel', 2)
        dialog.add_button('gtk-ok', 1)
        dialog.set_position(gtk.WIN_POS_CENTER)

        maintable = gtk.Table()
        maintable.set_row_spacings(5)
        maintable.set_col_spacings(5)
        row = 0

        lbl = createAlignedLabel(_("_Mount Point:"))
        maintable.attach(lbl, 0, 1, row, row + 1)
        mountCombo = createMountPointCombo(logrequest,
                                           excludeMountPoints=["/boot"])
        lbl.set_mnemonic_widget(mountCombo.entry)
        maintable.attach(mountCombo, 1, 2, row, row + 1)
        row = row + 1

        if not logrequest or not logrequest.getPreExisting():
            lbl = createAlignedLabel(_("_File System Type:"))
            maintable.attach(lbl, 0, 1, row, row + 1)
            (newfstype,
             newfstypeMenu) = createFSTypeMenu(logrequest.fstype,
                                               fstypechangeCB,
                                               mountCombo,
                                               ignorefs=[
                                                   "software RAID",
                                                   "physical volume (LVM)",
                                                   "vfat", "PPC PReP Boot"
                                               ])
            lbl.set_mnemonic_widget(newfstype)
        else:
            maintable.attach(
                createAlignedLabel(_("Original File System Type:")), 0, 1, row,
                row + 1)
            if logrequest.origfstype and logrequest.origfstype.getName():
                newfstype = gtk.Label(logrequest.origfstype.getName())
            else:
                newfstype = gtk.Label(_("Unknown"))
        maintable.attach(newfstype, 1, 2, row, row + 1)
        row = row + 1

        if not logrequest or not logrequest.getPreExisting():
            lbl = createAlignedLabel(_("_Logical Volume Name:"))
            lvnameEntry = gtk.Entry(16)
            lbl.set_mnemonic_widget(lvnameEntry)
            if logrequest and logrequest.logicalVolumeName:
                lvnameEntry.set_text(logrequest.logicalVolumeName)
            else:
                lvnameEntry.set_text(lvm.createSuggestedLVName(
                    self.logvolreqs))
        else:
            lbl = createAlignedLabel(_("Logical Volume Name:"))
            lvnameEntry = gtk.Label(logrequest.logicalVolumeName)

        maintable.attach(lbl, 0, 1, row, row + 1)
        maintable.attach(lvnameEntry, 1, 2, row, row + 1)
        row = row + 1

        if not logrequest or not logrequest.getPreExisting():
            lbl = createAlignedLabel(_("_Size (MB):"))
            sizeEntry = gtk.Entry(16)
            lbl.set_mnemonic_widget(sizeEntry)
            if logrequest:
                sizeEntry.set_text("%g" % (logrequest.getActualSize(
                    self.partitions, self.diskset), ))
        else:
            lbl = createAlignedLabel(_("Size (MB):"))
            sizeEntry = gtk.Label(str(logrequest.size))

        maintable.attach(lbl, 0, 1, row, row + 1)
        maintable.attach(sizeEntry, 1, 2, row, row + 1)
        row = row + 1

        if not logrequest or not logrequest.getPreExisting():
            pesize = self.peOptionMenu.get_active().get_data("value")
            (tspace, uspace, fspace) = self.computeSpaceValues(usepe=pesize)
            maxlv = min(lvm.getMaxLVSize(pesize), fspace)

            # add in size of current logical volume if it has a size
            if logrequest and not isNew:
                maxlv = maxlv + logrequest.getActualSize(
                    self.partitions, self.diskset)
            maxlabel = createAlignedLabel(_("(Max size is %s MB)") % (maxlv, ))
            maintable.attach(maxlabel, 1, 2, row, row + 1)

        self.fsoptionsDict = {}
        if logrequest.getPreExisting():
            (row, self.fsoptionsDict) = createPreExistFSOptionSection(
                logrequest,
                maintable,
                row,
                mountCombo,
                showbadblocks=0,
                ignorefs=["software RAID", "physical volume (LVM)", "vfat"])

        dialog.vbox.pack_start(maintable)
        dialog.show_all()

        while 1:
            rc = dialog.run()
            if rc == 2:
                dialog.destroy()
                return

            if not logrequest or not logrequest.getPreExisting():
                fsystem = newfstypeMenu.get_active().get_data("type")
                format = 1
                migrate = 0
            else:
                if self.fsoptionsDict.has_key("formatrb"):
                    formatrb = self.fsoptionsDict["formatrb"]
                else:
                    formatrb = None

                if formatrb:
                    format = formatrb.get_active()
                    if format:
                        fsystem = self.fsoptionsDict["fstypeMenu"].get_active(
                        ).get_data("type")
                else:
                    format = 0

                if self.fsoptionsDict.has_key("migraterb"):
                    migraterb = self.fsoptionsDict["migraterb"]
                else:
                    migraterb = None

                if migraterb:
                    migrate = migraterb.get_active()
                    if migrate:
                        fsystem = self.fsoptionsDict[
                            "migfstypeMenu"].get_active().get_data("type")
                else:
                    migrate = 0

    # set back if we are not formatting or migrating
                origfstype = logrequest.origfstype
                if not format and not migrate:
                    fsystem = origfstype

            mntpt = string.strip(mountCombo.entry.get_text())

            if not logrequest or not logrequest.getPreExisting():
                # check size specification
                badsize = 0
                try:
                    size = long(sizeEntry.get_text())
                except:
                    badsize = 1

                if badsize or size <= 0:
                    self.intf.messageWindow(
                        _("Illegal size"),
                        _("The requested size as entered is "
                          "not a valid number greater "
                          "than 0."),
                        custom_icon="error")
                    continue
            else:
                size = logrequest.size

            # is this an existing logical volume or one we're editting
            if logrequest:
                preexist = logrequest.getPreExisting()
            else:
                preexist = 0

            # test mount point
            # check in pending logical volume requests
            # these may not have been put in master list of requests
            # yet if we have not hit 'OK' for the volume group creation
            if fsystem.isMountable():
                used = 0
                if logrequest:
                    curmntpt = logrequest.mountpoint
                else:
                    curmntpt = None

                for lv in self.logvolreqs:
                    if curmntpt and lv.mountpoint == curmntpt:
                        continue

                    if lv.mountpoint == mntpt:
                        used = 1
                        break

                if used:
                    self.intf.messageWindow(_("Mount point in use"),
                                            _("The mount point \"%s\" is in "
                                              "use, please pick another.") %
                                            (mntpt, ),
                                            custom_icon="error")
                    continue

            # check out logical volumne name
            lvname = string.strip(lvnameEntry.get_text())

            if not logrequest or not logrequest.getPreExisting():
                err = sanityCheckLogicalVolumeName(lvname)
                if err:
                    self.intf.messageWindow(_("Illegal Logical Volume Name"),
                                            err,
                                            custom_icon="error")
                    continue

            # is it in use?
            used = 0
            if logrequest:
                origlvname = logrequest.logicalVolumeName
            else:
                origlvname = None

            for lv in self.logvolreqs:
                if origlvname and lv.logicalVolumeName == origlvname:
                    continue

                if lv.logicalVolumeName == lvname:
                    used = 1
                    break

            if used:
                self.intf.messageWindow(_("Illegal logical volume name"),
                                        _("The logical volume name \"%s\" is "
                                          "already in use. Please pick "
                                          "another.") % (lvname, ),
                                        custom_icon="error")
                continue

            # create potential request
            request = copy.copy(logrequest)
            pesize = self.peOptionMenu.get_active().get_data("value")
            size = lvm.clampLVSizeRequest(size, pesize, roundup=1)

            # do some final tests
            maxlv = lvm.getMaxLVSize(pesize)
            if size > maxlv:
                self.intf.messageWindow(_("Not enough space"),
                                        _("The current requested size "
                                          "(%10.2f MB) is larger than maximum "
                                          "logical volume size (%10.2f MB). "
                                          "To increase this limit you can "
                                          "increase the Physical Extent size "
                                          "for this Volume Group."),
                                        custom_icon="error")
                continue

            request.fstype = fsystem

            if request.fstype.isMountable():
                request.mountpoint = mntpt
            else:
                request.mountpoint = None

            request.preexist = preexist
            request.logicalVolumeName = lvname
            request.size = size
            request.format = format
            request.migrate = migrate
            request.badblock = None

            # this is needed to clear out any cached info about the device
            # only a workaround - need to change way this is handled in
            # partRequest.py really.
            request.dev = None

            # make list of original logvol requests so we can skip them
            # in tests below. We check for mount point name conflicts
            # above within the current volume group, so it is not
            # necessary to do now.
            err = request.sanityCheckRequest(self.partitions,
                                             skipMntPtExistCheck=1)
            if err is None:
                skiplist = []
                for lv in self.origvolreqs:
                    skiplist.append(lv.uniqueID)

                err = request.isMountPointInUse(self.partitions,
                                                requestSkipList=skiplist)

            if err:
                self.intf.messageWindow(_("Error With Request"),
                                        "%s" % (err),
                                        custom_icon="error")
                continue

            if (not request.format and request.mountpoint
                    and request.formatByDefault()):
                if not queryNoFormatPreExisting(self.intf):
                    continue

            # see if there is room for request
            (availSpaceMB, neededSpaceMB,
             fspace) = self.computeSpaceValues(usepe=pesize)

            tmplogreqs = []
            for l in self.logvolreqs:
                if origlvname and l.logicalVolumeName == origlvname:
                    continue

                tmplogreqs.append(l)

            tmplogreqs.append(request)
            neededSpaceMB = self.computeLVSpaceNeeded(tmplogreqs)

            if neededSpaceMB > availSpaceMB:
                self.intf.messageWindow(
                    _("Not enough space"),
                    _("The logical volumes you have "
                      "configured require %g MB, but the "
                      "volume group only has %g MB.  Please "
                      "either make the volume group larger "
                      "or make the logical volume(s) smaller.") %
                    (neededSpaceMB, availSpaceMB),
                    custom_icon="error")
                del tmplogreqs
                continue

            # everything ok
            break

        # now remove the previous request, insert request created above
        if not isNew:
            self.logvolreqs.remove(logrequest)
            iter = self.getCurrentLogicalVolume()
            self.logvolstore.remove(iter)

        self.logvolreqs.append(request)

        iter = self.logvolstore.append()
        self.logvolstore.set_value(iter, 0, lvname)
        if request.fstype and request.fstype.isMountable():
            self.logvolstore.set_value(iter, 1, mntpt)
        else:
            self.logvolstore.set_value(iter, 1, "N/A")

        self.logvolstore.set_value(iter, 2, "%g" % (size, ))

        self.updateVGSpaceLabels()
        dialog.destroy()
예제 #28
0
	def setupWindow(self):
		self.vue.set_document(self.doc)
		self.textWin = gtk.Window()
		self.textWin.connect("delete-event", self.closedCallBack)
		mainbox = gtk.VBox(False, 6)
		self.textWin.add(mainbox)

		table = gtk.Table(3, 3, False)
		mainbox.pack_start(table)

		mainbox.pack_start(gtk.HSeparator(), False, False)
		bb = gtk.HButtonBox()
		bb.set_property("layout-style", gtk.BUTTONBOX_END)

		b = gtk.Button(stock="gtk-close")
		b.connect("clicked", self.closedCallBack)
		bb.pack_start(b)
		mainbox.pack_start(bb, False, False)

		vbox1 = gtk.VBox()
		vbox1.set_border_width(10)
		frame = gtk.Frame("")
		frame.add(vbox1)
		frame.set_label_align(0.5, 0.5)
		frame.set_shadow_type(gtk.SHADOW_NONE)

		self.textWin.set_position(gtk.WIN_POS_NONE)
		self.textWin.set_gravity(gtk.gdk.GRAVITY_NORTH_WEST)

		if self.vue is not None:
			sw = gtk.ScrolledWindow()
			sw.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC)
			sw.set_shadow_type(gtk.SHADOW_IN)
			sw.add(self.vue)
			vbox1.pack_start(sw)

			a = gtk.Alignment(0, 0, 1.0, 1.0)
			a.add(frame)

			self.textWin.set_default_size(self.width, self.height)
			self.textWin.set_size_request(self.width, self.height)

			# we want the release notes dialog to be the same
			# size as the main installer window so it covers it
			# up completely.  this isn't always the same size
			# as the root window, so figure out our northwest
			# origin point and then move the window
			if gtk.gdk.screen_width() == self.width:
				self.textWin.move(0, 0)
			else:
				# the width will always be fixed, but our
				# height changes depending on the installation
				# stage, so do the origin point calculations
				# using what would be the full height
				if self.width == 800:
					fullh = 600
				elif self.width == 640:
					fullh = 480

				left = (gtk.gdk.screen_width() - self.width) / 2
				top = (gtk.gdk.screen_height() - fullh) / 2
				self.textWin.move(left, top)

			table.attach(a, 1, 2, 1, 2, gtk.FILL | gtk.EXPAND, gtk.FILL | gtk.EXPAND, 5, 5)

			self.textWin.set_border_width(0)
			gui.addFrame(self.textWin, _("Release Notes"))
		else:
			self.textWin.set_position(gtk.WIN_POS_CENTER)
			label = gtk.Label(_("Unable to load file!"))

			table.attach(label, 1, 2, 1, 2, gtk.FILL | gtk.EXPAND, gtk.FILL | gtk.EXPAND, 5, 5)

			self.textWin.set_border_width(0)
			gui.addFrame(self.textWin)
예제 #29
0
    def passwordWindow(self, *args):
        dialog = gtk.Dialog(_("Enter Boot Loader Password"), self.parent)
        dialog.add_button('gtk-cancel', 2)
        dialog.add_button('gtk-ok', 1)
        dialog.set_position(gtk.WIN_POS_CENTER)
        gui.addFrame(dialog)
        
        label = gui.WrappingLabel(_("Enter a boot loader password and then confirm it.  (Note that your BIOS keymap may be different than the actual keymap you are used to.)"))
        label.set_alignment(0.0, 0.0)
        dialog.vbox.pack_start(label)

        table = gtk.Table(2, 2)
        table.set_row_spacings(5)
        table.set_col_spacings(5)
        label = gui.MnemonicLabel(_("_Password:"******"Con_firm:"))        
        table.attach(label, 0, 1, 3, 4, gtk.FILL, 0, 10) 
        confirmEntry = gtk.Entry (16)
        confirmEntry.set_visibility (False)
        label.set_mnemonic_widget(confirmEntry)
        table.attach(confirmEntry, 1, 2, 3, 4, gtk.FILL, 0, 10)
        dialog.vbox.pack_start(table)

        # set the default
        if self.password:
            pwEntry.set_text(self.password)
            confirmEntry.set_text(self.password)

        dialog.show_all()

        while 1:
            rc = dialog.run()
            if rc == 2:
                break

            if pwEntry.get_text() != confirmEntry.get_text():
                self.intf.messageWindow(_("Passwords don't match"),
                                        _("Passwords do not match"),
                                        type='warning')
                continue

            thePass = pwEntry.get_text()
            if not thePass:
                continue
            if len(thePass) < 6:
                ret = self.intf.messageWindow(_("Warning"),
                                    _("Your boot loader password is less than "
                                      "six characters.  We recommend a longer "
                                      "boot loader password."
                                      "\n\n"
                                      "Would you like to continue with this "
                                      "password?"),
                                             type = "yesno")
                if ret == 0:
                    continue

            self.password = thePass
            break

        dialog.destroy()
        return rc
예제 #30
0
    def __init__(self, partitions, diskset, intf, parent):
        self.partitions = partitions
        self.diskset = diskset
        self.intf = intf
        self.parent = parent

        self.dialog = None
        self.dialog = gtk.Dialog(_("Make RAID Device"), self.parent)
        self.dialog.set_size_request(500, 400)
        gui.addFrame(self.dialog)
        self.dialog.add_button('gtk-cancel', 2)
        self.dialog.add_button('gtk-ok', 1)
        self.dialog.set_position(gtk.WIN_POS_CENTER)

        # present list of drives as source
        vbox = gtk.VBox()

        lbl = gui.WrappingLabel(
            _("Clone Drive Tool\n\n"
              "This tool allows you to significantly "
              "reduce the amount of effort required "
              "to setup RAID arrays.  The idea is to "
              "take a source drive which has been "
              "prepared with the desired partitioning "
              "layout, and clone this layout onto other "
              "similar sized drives.  Then a RAID device "
              "can be created.\n\n"
              "NOTE: The source drive must have "
              "partitions which are restricted to be on "
              "that drive only, and can only contain "
              "unused software RAID partitions.  Other "
              "partition types are not allowed.\n\n"
              "EVERYTHING on the target drive(s) will be "
              "destroyed by this process."))
        vbox.pack_start(lbl)

        box = gtk.HBox()

        lbl = gtk.Label(_("Source Drive:"))
        lbl.set_alignment(0.0, 0.0)
        box.pack_start(lbl, padding=5)
        (sw, self.sourceView) = self.createDriveList(diskset)
        selection = self.sourceView.get_selection()
        selection.set_mode(gtk.SELECTION_SINGLE)
        box.pack_start(sw)

        lbl = gtk.Label(_("Target Drive(s):"))
        lbl.set_alignment(0.0, 0.0)
        box.pack_start(lbl, padding=5)
        (sw, self.targetView) = self.createDriveList(diskset)
        selection = self.targetView.get_selection()
        selection.set_mode(gtk.SELECTION_MULTIPLE)
        box.pack_start(sw)

        frame = gtk.Frame(_("Drives"))
        frame.add(box)
        vbox.pack_start(frame)

        # put contents into dialog
        self.dialog.vbox.pack_start(vbox)

        self.dialog.show_all()

        return
예제 #31
0
    def editDetails(self, button, data):
	# do all magic for packages and metapackages
	def getDescription(obj, comp):
            if self.grpset.hdrlist.pkgs.has_key(obj):
                obj = self.grpset.hdrlist.pkgs[obj]
            elif self.grpset.groups.has_key(obj):
                obj = self.grpset.groups[obj]
            basedesc = obj.getDescription()

	    if basedesc is not None:
		desc = replace (basedesc, "\n\n", "\x00")
		desc = replace (desc, "\n", " ")
		desc = replace (desc, "\x00", "\n\n")
	    else:
		desc = ""
	    return "%s - %s" % (obj.name, desc)

	# pull out member sorted by name
	def getNextMember(goodpkgs, comp, domandatory = 0):
	    curpkg = None
	    for pkg in goodpkgs:
		if domandatory:
		    (ptype, sel) = comp.packageInfo()[pkg]
		    if ptype != PKGTYPE_MANDATORY:
			continue

		foundone = 1
		if curpkg is not None:
		    if pkg < curpkg:
			curpkg = pkg
		else:
		    curpkg = pkg

	    return curpkg


	#
	# START OF editDetails
	#
	# backup state
	(comp, hdrlbl, countlbl, compcb) = data
	origpkgselection = {}
	for (pkg, val) in comp.packageInfo().items():
	    origpkgselection[pkg] = val
	    
        self.dialog = gtk.Dialog(_("Details for '%s'") % (comp.name,))
        gui.addFrame(self.dialog)
        self.dialog.add_button('gtk-cancel', 2)
        self.dialog.add_button('gtk-ok', 1)
        self.dialog.set_position(gtk.WIN_POS_CENTER)

        mainvbox = self.dialog.vbox

	lblhbox = gtk.HBox(gtk.FALSE)
        lbl = gtk.Label(_("A package group can have both Base and "
                          "Optional package members.  Base packages "
                          "are always selected as long as the package group "
			  "is selected.\n\nSelect the optional packages "
			  "to be installed:"))
        lbl.set_line_wrap(gtk.TRUE)
	lbl.set_size_request(475, -1)
	lbl.set_alignment(0.0, 0.5)
	lblhbox.pack_start(lbl, gtk.TRUE, gtk.TRUE)

	fn = self.ics.findPixmap("package-selection.png")
	if not fn:
	    pix = None
	else:
	    rawpix = gtk.gdk.pixbuf_new_from_file(fn)
	    pix = gtk.Image()
	    pix.set_from_pixbuf(rawpix)

	if pix is not None:
	    al = gtk.Alignment(0.0, 0.0)
	    al.add(pix)
	    lblhbox.pack_start(al, gtk.FALSE, gtk.FALSE)
	    
        mainvbox.pack_start(lblhbox, gtk.FALSE, gtk.FALSE)

        cbvbox = gtk.VBox(gtk.FALSE)
	cbvbox.set_border_width(5)
	
	# will pack this last, need to create it for toggle callback below
        sizeLabel = gtk.Label("")
	self.setDetailSizeLabel(comp, sizeLabel)

        goodpkgs = comp.packageInfo().keys()
        # FIXME
#        goodpkgs = comp.packagesFullInfo().keys() + comp.metapackagesFullInfo().keys()


	# first show default members, if any
	haveBase = 0
	next = getNextMember(goodpkgs, comp, domandatory = 1)
	if next is not None:
	    haveBase = 1
	    lbl = gtk.Label("")
	    lbl.set_markup("<b>%s</b>" % (_("Base Packages"),))
	    lbl.set_alignment(0.0, 0.0)
	    cbvbox.pack_start(lbl, gtk.FALSE, gtk.FALSE);
	    while 1:
		next = getNextMember(goodpkgs, comp, domandatory = 1)
		if next is None:
		    break

		goodpkgs.remove(next)
		desc = getDescription(next, comp)
		lbl = gtk.Label(desc)
		lbl.set_alignment(0.0, 0.0)
		lbl.set_property("use-underline", gtk.FALSE)

		thbox = gtk.HBox(gtk.FALSE)
		chbox = gtk.HBox(gtk.FALSE)
		chbox.set_size_request(10,-1)
		thbox.pack_start(chbox, gtk.FALSE, gtk.FALSE)
		thbox.pack_start(lbl, gtk.TRUE, gtk.TRUE)

		cbvbox.pack_start(thbox, gtk.FALSE, gtk.FALSE)

	# now the optional parts, if any
	next = getNextMember(goodpkgs, comp, domandatory = 0)
	if next is not None:
	    spacer = gtk.Fixed()
	    spacer.set_size_request(-1, 10)
	    cbvbox.pack_start(spacer, gtk.FALSE, gtk.FALSE)
	    
	    lbl = gtk.Label("")
	    lbl.set_markup("<b>%s</b>" % (_("Optional Packages"),))
	    lbl.set_alignment(0.0, 0.0)
	    cbvbox.pack_start(lbl, gtk.FALSE, gtk.FALSE)
	    while 1:
		next = getNextMember(goodpkgs, comp, domandatory = 0)
		if next is None:
		    break

		goodpkgs.remove(next)

		desc = getDescription(next, comp)
		lbl = gtk.Label(desc)
		lbl.set_alignment(0.0, 0.0)
		lbl.set_property("use-underline", gtk.FALSE)
		cb = gtk.CheckButton()
		cb.add(lbl)
		(ptype, sel) = comp.packageInfo()[next]
		cb.set_active((sel in ON_STATES))
		cb.connect("toggled", self.pkgGroupMemberToggled,
			   (comp, sizeLabel, next))

		thbox = gtk.HBox(gtk.FALSE)
		chbox = gtk.HBox(gtk.FALSE)
		chbox.set_size_request(10,-1)
		thbox.pack_start(chbox, gtk.FALSE, gtk.FALSE)
		thbox.pack_start(cb, gtk.TRUE, gtk.TRUE)

		cbvbox.pack_start(thbox, gtk.FALSE, gtk.FALSE)

        sw = gtk.ScrolledWindow()
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)

        wrapper = gtk.VBox (gtk.FALSE, 0)
        wrapper.pack_start (cbvbox, gtk.FALSE)
        
        sw.add_with_viewport (wrapper)
        viewport = sw.get_children()[0]
        viewport.set_shadow_type (gtk.SHADOW_IN)
	viewport.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse ("white"))
        cbvbox.set_focus_hadjustment(sw.get_hadjustment ())
        cbvbox.set_focus_vadjustment(sw.get_vadjustment ())
        
        mainvbox.pack_start(sw, gtk.TRUE, gtk.TRUE, 10)

        mainvbox.pack_start(sizeLabel, gtk.FALSE, gtk.FALSE)
                            
        self.dialog.set_size_request(550, 420)
        self.dialog.show_all()

	while 1:
	    rc = self.dialog.run()

	    # they hit cancel, restore original state and quit
	    if rc == 2:
		allpkgs = comp.packageInfo().keys()
		for pkg in allpkgs:
		    (ptype, sel) = comp.packageInfo()[pkg]
		    (optype, osel) = origpkgselection[pkg]

                    if (osel == sel):
                        pass
                    elif (osel not in OFF_STATES) and (sel not in ON_STATES):
                        comp.selectPackage(pkg)
                    elif (osel not in ON_STATES) and (sel not in OFF_STATES):
                        comp.unselectPackage(pkg)
	    break
	
        self.dialog.destroy()
	self.setSize()

	if countlbl:
	    self.setCompCountLabel(comp, countlbl)

	(selpkg, totpkg) = self.getStats(comp)
	if selpkg < 1:
	    if compcb:
		compcb.set_active(0)
        return
예제 #32
0
    def __init__(self,
                 partitions,
                 diskset,
                 intf,
                 parent,
                 origvgrequest,
                 isNew=0):
        self.partitions = partitions
        self.diskset = diskset
        self.origvgrequest = origvgrequest
        self.isNew = isNew
        self.intf = intf
        self.parent = parent

        self.availlvmparts = self.partitions.getAvailLVMPartitions(
            self.origvgrequest, self.diskset)
        self.logvolreqs = self.partitions.getLVMLVForVG(self.origvgrequest)
        self.origvolreqs = copy.copy(self.logvolreqs)

        # if no PV exist, raise an error message and return
        if len(self.availlvmparts) < 1:
            self.intf.messageWindow(
                _("Not enough physical volumes"),
                _("At least one unused physical "
                  "volume partition is "
                  "needed to create an LVM Volume Group.\n\n"
                  "Create a partition or RAID array "
                  "of type \"physical volume (LVM)\" and then "
                  "select the \"LVM\" option again."),
                custom_icon="error")
            self.dialog = None
            return

        if isNew:
            tstr = _("Make LVM Volume Group")
        else:
            try:
                tstr = _("Edit LVM Volume Group: %s") % (
                    origvgrequest.volumeGroupName, )
            except:
                tstr = _("Edit LVM Volume Group")

        dialog = gtk.Dialog(tstr, self.parent)
        gui.addFrame(dialog)
        dialog.add_button('gtk-cancel', 2)
        dialog.add_button('gtk-ok', 1)

        dialog.set_position(gtk.WIN_POS_CENTER)

        maintable = gtk.Table()
        maintable.set_row_spacings(5)
        maintable.set_col_spacings(5)
        row = 0

        # volume group name
        if not origvgrequest.getPreExisting():
            lbl = createAlignedLabel(_("_Volume Group Name:"))
            self.volnameEntry = gtk.Entry(16)
            lbl.set_mnemonic_widget(self.volnameEntry)
            if not self.isNew:
                self.volnameEntry.set_text(self.origvgrequest.volumeGroupName)
            else:
                self.volnameEntry.set_text(
                    lvm.createSuggestedVGName(self.partitions))
        else:
            lbl = createAlignedLabel(_("Volume Group Name:"))
            self.volnameEntry = gtk.Label(self.origvgrequest.volumeGroupName)

        maintable.attach(lbl, 0, 1, row, row + 1, gtk.EXPAND | gtk.FILL,
                         gtk.SHRINK)
        maintable.attach(self.volnameEntry, 1, 2, row, row + 1,
                         gtk.EXPAND | gtk.FILL, gtk.SHRINK)
        row = row + 1

        if not origvgrequest.getPreExisting():
            lbl = createAlignedLabel(_("_Physical Extent:"))
            (self.peOption, self.peOptionMenu) = self.createPEOptionMenu(
                self.origvgrequest.pesize)
            lbl.set_mnemonic_widget(self.peOption)
        else:
            # FIXME: this is a nice hack -- if we create the option menu, but
            # don't display it, getting the value always returns what we init'd
            # it to
            lbl = createAlignedLabel(_("Physical Extent:"))
            (self.peOption, self.peOptionMenu) = self.createPEOptionMenu(
                self.origvgrequest.pesize)
            self.peOption = gtk.Label(
                self.prettyFormatPESize(origvgrequest.pesize))

        maintable.attach(lbl, 0, 1, row, row + 1, gtk.EXPAND | gtk.FILL,
                         gtk.SHRINK)
        maintable.attach(self.peOption, 1, 2, row, row + 1,
                         gtk.EXPAND | gtk.FILL, gtk.SHRINK)
        row = row + 1

        (self.lvmlist, sw) = self.createAllowedLvmPartitionsList(
            self.availlvmparts, self.origvgrequest.physicalVolumes,
            self.partitions, origvgrequest.getPreExisting())
        if origvgrequest.getPreExisting():
            self.lvmlist.set_sensitive(gtk.FALSE)
        self.lvmlist.set_size_request(275, 80)
        lbl = createAlignedLabel(_("Physical Volumes to _Use:"))
        lbl.set_mnemonic_widget(self.lvmlist)
        maintable.attach(lbl, 0, 1, row, row + 1)
        maintable.attach(sw, 1, 2, row, row + 1)
        row = row + 1

        maintable.attach(createAlignedLabel(_("Used Space:")), 0, 1, row,
                         row + 1, gtk.EXPAND | gtk.FILL, gtk.SHRINK)
        lbox = gtk.HBox()
        self.usedSpaceLabel = gtk.Label("")
        labelalign = gtk.Alignment()
        labelalign.set(1.0, 0.5, 0.0, 0.0)
        labelalign.add(self.usedSpaceLabel)
        lbox.pack_start(labelalign, gtk.FALSE, gtk.FALSE)
        self.usedPercentLabel = gtk.Label("")
        labelalign = gtk.Alignment()
        labelalign.set(1.0, 0.5, 0.0, 0.0)
        labelalign.add(self.usedPercentLabel)
        lbox.pack_start(labelalign, gtk.FALSE, gtk.FALSE, padding=10)
        maintable.attach(lbox, 1, 2, row, row + 1, gtk.EXPAND | gtk.FILL,
                         gtk.SHRINK)
        maintable.set_row_spacing(row, 0)
        row = row + 1

        maintable.attach(createAlignedLabel(_("Free Space:")), 0, 1, row,
                         row + 1, gtk.EXPAND | gtk.FILL, gtk.SHRINK)
        lbox = gtk.HBox()
        self.freeSpaceLabel = gtk.Label("")
        labelalign = gtk.Alignment()
        labelalign.set(1.0, 0.5, 0.0, 0.0)
        labelalign.add(self.freeSpaceLabel)
        lbox.pack_start(labelalign, gtk.FALSE, gtk.FALSE)
        self.freePercentLabel = gtk.Label("")
        labelalign = gtk.Alignment()
        labelalign.set(1.0, 0.5, 0.0, 0.0)
        labelalign.add(self.freePercentLabel)
        lbox.pack_start(labelalign, gtk.FALSE, gtk.FALSE, padding=10)

        maintable.attach(lbox, 1, 2, row, row + 1, gtk.EXPAND | gtk.FILL,
                         gtk.SHRINK)
        maintable.set_row_spacing(row, 0)
        row = row + 1

        maintable.attach(createAlignedLabel(_("Total Space:")), 0, 1, row,
                         row + 1, gtk.EXPAND | gtk.FILL, gtk.SHRINK)
        self.totalSpaceLabel = gtk.Label("")
        labelalign = gtk.Alignment()
        labelalign.set(0.0, 0.5, 0.0, 0.0)
        labelalign.add(self.totalSpaceLabel)
        maintable.attach(labelalign, 1, 2, row, row + 1, gtk.EXPAND | gtk.FILL,
                         gtk.SHRINK)
        maintable.set_row_spacing(row, 5)
        row = row + 1

        # populate list of logical volumes
        lvtable = gtk.Table()
        lvtable.set_row_spacings(5)
        lvtable.set_col_spacings(5)
        self.logvolstore = gtk.ListStore(gobject.TYPE_STRING,
                                         gobject.TYPE_STRING,
                                         gobject.TYPE_STRING)

        if self.logvolreqs:
            for lvrequest in self.logvolreqs:
                iter = self.logvolstore.append()
                self.logvolstore.set_value(iter, 0,
                                           lvrequest.logicalVolumeName)
                if lvrequest.mountpoint is not None:
                    self.logvolstore.set_value(iter, 1, lvrequest.mountpoint)
                else:
                    self.logvolstore.set_value(iter, 1, "")
                self.logvolstore.set_value(
                    iter, 2, "%g" %
                    (lvrequest.getActualSize(self.partitions, self.diskset)))

        self.logvollist = gtk.TreeView(self.logvolstore)
        col = gtk.TreeViewColumn(_("Logical Volume Name"),
                                 gtk.CellRendererText(),
                                 text=0)
        self.logvollist.append_column(col)
        col = gtk.TreeViewColumn(_("Mount Point"),
                                 gtk.CellRendererText(),
                                 text=1)
        self.logvollist.append_column(col)
        col = gtk.TreeViewColumn(_("Size (MB)"),
                                 gtk.CellRendererText(),
                                 text=2)
        self.logvollist.append_column(col)
        self.logvollist.connect('row-activated', self.logvolActivateCb)

        sw = gtk.ScrolledWindow()
        sw.add(self.logvollist)
        sw.set_size_request(100, 100)
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        sw.set_shadow_type(gtk.SHADOW_IN)
        lvtable.attach(sw, 0, 1, 0, 1)

        # button box of options
        lvbbox = gtk.VBox()
        add = gtk.Button(_("_Add"))
        add.connect("clicked", self.addLogicalVolumeCB)
        lvbbox.pack_start(add)
        edit = gtk.Button(_("_Edit"))
        edit.connect("clicked", self.editLogicalVolumeCB)
        lvbbox.pack_start(edit)
        delete = gtk.Button(_("_Delete"))
        delete.connect("clicked", self.delLogicalVolumeCB)
        lvbbox.pack_start(delete)

        lvalign = gtk.Alignment()
        lvalign.set(0.5, 0.0, 0.0, 0.0)
        lvalign.add(lvbbox)
        lvtable.attach(lvalign, 1, 2, 0, 1, gtk.SHRINK, gtk.SHRINK)

        # pack all logical volumne stuff in a frame
        lvtable.set_border_width(12)
        l = gtk.Label()
        l.set_markup("<b>%s</b>" % (_("Logical Volumes"), ))
        frame = gtk.Frame()
        frame.set_label_widget(l)
        frame.add(lvtable)
        frame.set_shadow_type(gtk.SHADOW_NONE)

        #	dialog.vbox.pack_start(frame)
        maintable.attach(frame, 0, 2, row, row + 1)
        row = row + 1

        dialog.vbox.pack_start(maintable)
        dialog.set_size_request(500, 450)
        dialog.show_all()

        # set space labels to correct values
        self.updateVGSpaceLabels()

        self.dialog = dialog
예제 #33
0
    def _addRepo(self, *args):
        if not network.hasActiveNetDev():
            net = NetworkConfigurator(self.anaconda.id.network)
            ret = net.run()
            net.destroy()
            if ret == gtk.RESPONSE_CANCEL:
                return gtk.RESPONSE_CANCEL

        (dxml, dialog) = gui.getGladeWidget("addrepo.glade", "addRepoDialog")
        gui.addFrame(dialog)

        lbl = dxml.get_widget("descLabel")
        txt = lbl.get_text()
        lbl.set_text(txt % (productName, ))

        dialog.show_all()

        while 1:
            rc = dialog.run()
            if rc == gtk.RESPONSE_CANCEL:
                break

            reponame = dxml.get_widget("nameEntry").get_text()
            reponame.strip()
            if len(reponame) == 0:
                self.intf.messageWindow(
                    _("Invalid Repository Name"),
                    _("You must provide a non-zero length "
                      "repository name."))
                continue

            repourl = dxml.get_widget("urlEntry").get_text()
            repourl.strip()
            if (len(repourl) == 0 or not (repourl.startswith("http://")
                                          or repourl.startswith("ftp://"))):
                self.intf.messageWindow(
                    _("Invalid Repository URL"),
                    _("You must provide an HTTP or FTP "
                      "URL to a repository."))
                continue

            # FIXME: this is yum specific
            repo = AnacondaYumRepo(uri=repourl, repoid=reponame)
            repo.name = reponame
            repo.basecachedir = self.backend.ayum.conf.cachedir
            repo.enable()

            try:
                self.backend.ayum.repos.add(repo)
            except yum.Errors.DuplicateRepoError, e:
                self.intf.messageWindow(
                    _("Error"),
                    _("The repository %s has already been added.  Please "
                      "choose a different repository name and "
                      "URL.") % reponame,
                    type="ok",
                    custom_icon="error")
                continue

            if not self._setupRepo(repo):
                continue

            s = self.xml.get_widget("repoList").get_model()
            s.append([repo.isEnabled(), repo.name, repo])
            self.repos[repo.name] = (repo.baseurl[0], None)

            break
예제 #34
0
def addIscsiDrive(anaconda):
    if not network.hasActiveNetDev():
        net = NetworkConfigurator(anaconda.network)
        ret = net.run()
        net.destroy()
        if ret != gtk.RESPONSE_OK:
            return ret

    (dxml, dialog) = gui.getGladeWidget("iscsi-config.glade", "iscsiDialog")
    gui.addFrame(dialog)
    dialog.show_all()
    sg = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
    for w in ["iscsiAddrEntry", "iscsiInitiatorEntry", "userEntry",
              "passEntry", "userinEntry", "passinEntry"]:
        sg.add_widget(dxml.get_widget(w))

    # get the initiator name if it exists and don't allow changing
    # once set
    e = dxml.get_widget("iscsiInitiatorEntry")
    e.set_text(anaconda.storage.iscsi.initiator)
    if anaconda.storage.iscsi.initiatorSet:
        e.set_sensitive(False)

    while True:
        rc = dialog.run()
        if rc in [gtk.RESPONSE_CANCEL, gtk.RESPONSE_DELETE_EVENT]:
            break

        initiator = e.get_text().strip()
        if len(initiator) == 0:
            anaconda.intf.messageWindow(_("Invalid Initiator Name"),
                                        _("You must provide an initiator name."))
            continue

        anaconda.storage.iscsi.initiator = initiator

        target = dxml.get_widget("iscsiAddrEntry").get_text().strip()
        user = dxml.get_widget("userEntry").get_text().strip()
        pw = dxml.get_widget("passEntry").get_text().strip()
        user_in = dxml.get_widget("userinEntry").get_text().strip()
        pw_in = dxml.get_widget("passinEntry").get_text().strip()

        try:
            count = len(target.split(":"))
            idx = target.rfind("]:")
            # Check for IPV6 [IPV6-ip]:port
            if idx != -1:
                ip = target[1:idx]
                port = target[idx+2:]
            # Check for IPV4 aaa.bbb.ccc.ddd:port
            elif count == 2:
                idx = target.rfind(":")
                ip = target[:idx]
                port = target[idx+1:]
            else:
                ip = target
                port = "3260"

            network.sanityCheckIPString(ip)
        except (network.IPMissing, network.IPError) as msg:
            anaconda.intf.messageWindow(_("Error with Data"), msg)
            continue

        try:
            anaconda.storage.iscsi.addTarget(ip, port, user, pw,
                                             user_in, pw_in,
                                             anaconda.intf)
        except ValueError as e:
            anaconda.intf.messageWindow(_("Error"), str(e))
            continue
        except IOError as e:
            anaconda.intf.messageWindow(_("Error"), str(e))
            rc = gtk.RESPONSE_CANCEL

        break

    dialog.destroy()
    return rc
예제 #35
0
    def __init__(self, anaconda, parent, origrequest, isNew = 0,
                 restrictfs = None):
        self.anaconda = anaconda
	self.partitions = self.anaconda.id.partitions
	self.diskset = self.anaconda.id.diskset
	self.intf = self.anaconda.intf
	self.origrequest = origrequest
	self.isNew = isNew
	self.parent = parent

	if isNew:
	    tstr = _("Add Partition")
	else:
	    try:
		tstr = _("Edit Partition: /dev/%s") % (origrequest.device,)
	    except:
		tstr = _("Edit Partition")
	    
        self.dialog = gtk.Dialog(tstr, self.parent)
        gui.addFrame(self.dialog)
        self.dialog.add_button('gtk-cancel', 2)
        self.dialog.add_button('gtk-ok', 1)
        self.dialog.set_position(gtk.WIN_POS_CENTER)
        
        maintable = gtk.Table()
        maintable.set_row_spacings(5)
        maintable.set_col_spacings(5)
        row = 0

        # see if we are creating a floating request or by cylinder
        if self.origrequest.type == REQUEST_NEW:
            self.newbycyl = self.origrequest.start != None

        # Mount Point entry
	lbl = createAlignedLabel(_("_Mount Point:"))
        maintable.attach(lbl, 0, 1, row, row + 1)
        self.mountCombo = createMountPointCombo(origrequest)
	lbl.set_mnemonic_widget(self.mountCombo)
        maintable.attach(self.mountCombo, 1, 2, row, row + 1)
        row = row + 1

        # Partition Type
        if self.origrequest.type == REQUEST_NEW:
	    lbl = createAlignedLabel(_("File System _Type:"))
            maintable.attach(lbl, 0, 1, row, row + 1)
            self.lukscb = gtk.CheckButton(_("_Encrypt"))
            self.newfstypeCombo = createFSTypeMenu(self.origrequest.fstype,
                                                   fstypechangeCB,
                                                   self.mountCombo,
                                                   availablefstypes = restrictfs,
                                                   lukscb = self.lukscb)
	    lbl.set_mnemonic_widget(self.newfstypeCombo)
            maintable.attach(self.newfstypeCombo, 1, 2, row, row + 1)
        else:
            maintable.attach(createAlignedLabel(_("Original File System "
                                                  "Type:")),
                             0, 1, row, row + 1)

            if self.origrequest.origfstype:
                typestr = self.origrequest.origfstype.getName()
                if self.origrequest.origfstype.getName() == "foreign":
                    part = get_partition_by_name(self.diskset.disks,
                                                 self.origrequest.device)
                    typestr = map_foreign_to_fsname(part.native_type)
            else:
                typestr = _("Unknown")

            fstypelabel = gtk.Label(typestr)
            maintable.attach(fstypelabel, 1, 2, row, row + 1)
            self.newfstypeCombo = None
            
        row = row + 1

        # allowable drives
        if self.origrequest.type == REQUEST_NEW:
            if not self.newbycyl:
		lbl = createAlignedLabel(_("Allowable _Drives:"))
                maintable.attach(lbl, 0, 1, row, row + 1)

                self.driveview = createAllowedDrivesList(self.diskset.disks,
                                                         self.origrequest.drive,
                                                         self.anaconda.updateSrc)
		lbl.set_mnemonic_widget(self.driveview)
                sw = gtk.ScrolledWindow()
                sw.add(self.driveview)
                sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
		sw.set_shadow_type(gtk.SHADOW_IN)
                maintable.attach(sw, 1, 2, row, row + 1)
		self.driveview.set_size_request(375, 80)
            else:
                maintable.attach(createAlignedLabel(_("Drive:")),
                                 0, 1, row, row + 1)
                maintable.attach(createAlignedLabel(origrequest.drive[0]),
                                 1, 2, row, row + 1)

            row = row + 1

        # original fs label
        if self.origrequest.type != REQUEST_NEW and self.origrequest.fslabel:
            maintable.attach(createAlignedLabel(_("Original File System "
                                                  "Label:")),
                             0, 1, row, row + 1)
            fslabel = gtk.Label(self.origrequest.fslabel)
            maintable.attach(fslabel, 1, 2, row, row + 1)

            row = row + 1

        # size
        if self.origrequest.type == REQUEST_NEW:
            if not self.newbycyl:
                # Size specification
		lbl = createAlignedLabel(_("_Size (MB):"))
                maintable.attach(lbl, 0, 1, row, row + 1)
                sizeAdj = gtk.Adjustment(value = 1, lower = 1,
                                         upper = MAX_PART_SIZE, step_incr = 1)
                self.sizespin = gtk.SpinButton(sizeAdj, digits = 0)
                self.sizespin.set_property('numeric', True)

                if self.origrequest.size:
                    self.sizespin.set_value(self.origrequest.size)

		lbl.set_mnemonic_widget(self.sizespin)
                maintable.attach(self.sizespin, 1, 2, row, row + 1)
                bycyl_sizelabel = None
            else:
                # XXX need to add partition by size and
                #     wire in limits between start and end
                dev = self.diskset.disks[origrequest.drive[0]].dev
                maintable.attach(createAlignedLabel(_("Size (MB):")),
                                 0, 1, row, row + 1)
                bycyl_sizelabel = createAlignedLabel("")
                maintable.attach(bycyl_sizelabel, 1, 2, row, row + 1)
                row = row + 1

		lbl = createAlignedLabel(_("_Start Cylinder:"))
                maintable.attach(lbl, 0, 1, row, row + 1)

                maxcyl = self.diskset.disks[origrequest.drive[0]].dev.cylinders
                cylAdj = gtk.Adjustment(value=origrequest.start,
                                        lower=origrequest.start,
                                        upper=maxcyl,
                                        step_incr=1)
                self.startcylspin = gtk.SpinButton(cylAdj, digits=0)
                self.startcylspin.set_property('numeric', True)
		lbl.set_mnemonic_widget(self.startcylspin)
                maintable.attach(self.startcylspin, 1, 2, row, row + 1)
                row = row + 1
                
                endcylAdj = gtk.Adjustment(value=origrequest.end,
                                           lower=origrequest.start,
                                           upper=maxcyl,
                                           step_incr=1)
		lbl = createAlignedLabel(_("_End Cylinder:"))		
                maintable.attach(lbl, 0, 1, row, row + 1)
                self.endcylspin = gtk.SpinButton(endcylAdj, digits = 0)
                self.endcylspin.set_property('numeric', True)
		lbl.set_mnemonic_widget(self.endcylspin)
                maintable.attach(self.endcylspin, 1, 2, row, row + 1)

                self.startcylspin.connect("value-changed", self.cylspinchangedCB,
					  (dev, self.startcylspin,
					   self.endcylspin, bycyl_sizelabel))
                self.endcylspin.connect("value-changed", self.cylspinchangedCB,
					(dev, self.startcylspin,
					 self.endcylspin, bycyl_sizelabel))
                
                startsec = start_cyl_to_sector(dev, origrequest.start)
                endsec = end_cyl_to_sector(dev, origrequest.end)
                cursize = (endsec - startsec)/2048
                bycyl_sizelabel.set_text("%s" % (int(cursize)))
        else:
            maintable.attach(createAlignedLabel(_("Size (MB):")),
                             0, 1, row, row + 1)
            sizelabel = gtk.Label("%d" % (origrequest.size))
            maintable.attach(sizelabel, 1, 2, row, row + 1)
            self.sizespin = None
            
        row = row + 1

        # format/migrate options for pre-existing partitions, as long as they
        # aren't protected (we'd still like to be able to mount them, though)
	self.fsoptionsDict = {}
        if self.origrequest.type == REQUEST_PREEXIST and self.origrequest.fstype and not self.origrequest.getProtected():
	    (row, self.fsoptionsDict) = createPreExistFSOptionSection(self.origrequest, maintable, row, self.mountCombo)

        # size options
        if self.origrequest.type == REQUEST_NEW:
            if not self.newbycyl:
                (sizeframe, self.fixedrb, self.fillmaxszrb,
                 self.fillmaxszsb) = self.createSizeOptionsFrame(self.origrequest,
							    self.fillmaxszCB)
                self.sizespin.connect("value-changed", self.sizespinchangedCB,
				      self.fillmaxszsb)

                maintable.attach(sizeframe, 0, 2, row, row + 1)
            else:
                # XXX need new by cyl options (if any)
                pass
            row = row + 1
        else:
            self.sizeoptiontable = None

        # create only as primary
        if self.origrequest.type == REQUEST_NEW:
            self.primonlycheckbutton = gtk.CheckButton(_("Force to be a _primary "
                                                    "partition"))
            self.primonlycheckbutton.set_active(0)
            if self.origrequest.primary:
                self.primonlycheckbutton.set_active(1)

            # only show if we have something other than primary
            if not self.diskset.onlyPrimaryParts():
                maintable.attach(self.primonlycheckbutton, 0, 2, row, row+1)
                row = row + 1

            self.lukscb.set_data("formatstate", 1)

            if self.origrequest.encryption:
                self.lukscb.set_active(1)
            else:
                self.lukscb.set_active(0)
            maintable.attach(self.lukscb, 0, 2, row, row + 1)
            row = row + 1

	    # disable option for badblocks checking
	    self.badblocks = None

	    # uncomment to reenable
            #self.badblocks = gtk.CheckButton(_("Check for _bad blocks"))
            #self.badblocks.set_active(0)
            #maintable.attach(self.badblocks, 0, 1, row, row + 1)
            #row = row + 1
            #if self.origrequest.badblocks:
            #    self.badblocks.set_active(1)
            
        # put main table into dialog
        self.dialog.vbox.pack_start(maintable)
        self.dialog.show_all()
    def _addRepo(self, *args):
        if not network.hasActiveNetDev():
            net = NetworkConfigurator(self.anaconda.id.network)
            ret = net.run()
            net.destroy()
            if ret == gtk.RESPONSE_CANCEL:
                return gtk.RESPONSE_CANCEL
        
        (dxml, dialog) = gui.getGladeWidget("addrepo.glade", "addRepoDialog")
        gui.addFrame(dialog)

        lbl = dxml.get_widget("descLabel")
        txt = lbl.get_text()
        lbl.set_text(txt %(productName,))
        
        dialog.show_all()

        while 1:
            rc = dialog.run()
            if rc == gtk.RESPONSE_CANCEL:
                break
        
            reponame = dxml.get_widget("nameEntry").get_text()
            reponame.strip()
            if len(reponame) == 0:
                self.intf.messageWindow(_("Invalid Repository Name"),
                                        _("You must provide a non-zero length "
                                          "repository name."))
                continue

            repourl = dxml.get_widget("urlEntry").get_text()
            repourl.strip()
            if (len(repourl) == 0 or not
                (repourl.startswith("http://") or
                 repourl.startswith("ftp://"))):
                self.intf.messageWindow(_("Invalid Repository URL"),
                                        _("You must provide an HTTP or FTP "
                                          "URL to a repository."))
                continue

            # FIXME: this is yum specific
            repo = AnacondaYumRepo(uri=repourl, repoid=reponame)
            repo.name = reponame
            repo.basecachedir = self.backend.ayum.conf.cachedir
            repo.enable()

            try:
                self.backend.ayum.repos.add(repo)
            except yum.Errors.DuplicateRepoError, e:
                self.intf.messageWindow(_("Error"),
                      _("The repository %s has already been added.  Please "
                        "choose a different repository name and "
                        "URL.") % reponame, type="ok", custom_icon="error")
                continue

            if not self._setupRepo(repo):
                continue

            s = self.xml.get_widget("repoList").get_model()
            s.append([repo.isEnabled(), repo.name, repo])
            self.repos[repo.name] = (repo.baseurl[0], None)

            break
예제 #37
0
    def __init__(self,
                 partitions,
                 diskset,
                 intf,
                 parent,
                 origrequest,
                 isNew=0):
        self.partitions = partitions
        self.diskset = diskset
        self.origrequest = origrequest
        self.isNew = isNew
        self.intf = intf
        self.parent = parent

        self.dialog = None

        #
        # start of editRaidRequest
        #
        availraidparts = self.partitions.getAvailRaidPartitions(
            origrequest, self.diskset)
        # if no raid partitions exist, raise an error message and return
        if len(availraidparts) < 2:
            dlg = gtk.MessageDialog(
                self.parent, 0, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK,
                _("At least two unused software RAID "
                  "partitions are needed to create "
                  "a RAID device.\n\n"
                  "First create at least two partitions "
                  "of type \"software RAID\", and then "
                  "select the \"RAID\" option again."))
            gui.addFrame(dlg)
            dlg.show_all()
            dlg.set_position(gtk.WIN_POS_CENTER)
            dlg.run()
            dlg.destroy()
            return

        if isNew:
            tstr = _("Make RAID Device")
        else:
            try:
                tstr = _("Edit RAID Device: /dev/md%s") % (
                    origrequest.raidminor, )
            except:
                tstr = _("Edit RAID Device")

        dialog = gtk.Dialog(tstr, self.parent)
        gui.addFrame(dialog)
        dialog.add_button('gtk-cancel', 2)
        dialog.add_button('gtk-ok', 1)
        dialog.set_position(gtk.WIN_POS_CENTER)

        maintable = gtk.Table()
        maintable.set_row_spacings(5)
        maintable.set_col_spacings(5)
        row = 0

        # Mount Point entry
        lbl = createAlignedLabel(_("_Mount Point:"))
        maintable.attach(lbl, 0, 1, row, row + 1)
        self.mountCombo = createMountPointCombo(origrequest)
        lbl.set_mnemonic_widget(self.mountCombo)
        maintable.attach(self.mountCombo, 1, 2, row, row + 1)
        row = row + 1

        # we'll maybe add this further down
        self.lukscb = gtk.CheckButton(_("_Encrypt"))
        self.lukscb.set_data("formatstate", 1)

        # Filesystem Type
        if not origrequest.getPreExisting():
            lbl = createAlignedLabel(_("_File System Type:"))
            maintable.attach(lbl, 0, 1, row, row + 1)
            self.fstypeCombo = createFSTypeMenu(
                origrequest.fstype,
                fstypechangeCB,
                self.mountCombo,
                ignorefs=["software RAID", "PPC PReP Boot", "Apple Bootstrap"])
            lbl.set_mnemonic_widget(self.fstypeCombo)
            maintable.attach(self.fstypeCombo, 1, 2, row, row + 1)
            row += 1
        else:
            maintable.attach(
                createAlignedLabel(_("Original File System Type:")), 0, 1, row,
                row + 1)
            if origrequest.fstype.getName():
                self.fstypeCombo = gtk.Label(origrequest.fstype.getName())
            else:
                self.fstypeCombo = gtk.Label(_("Unknown"))

            maintable.attach(self.fstypeCombo, 1, 2, row, row + 1)
            row += 1

            if origrequest.fslabel:
                maintable.attach(
                    createAlignedLabel(_("Original File System "
                                         "Label:")), 0, 1, row, row + 1)
                maintable.attach(gtk.Label(origrequest.fslabel), 1, 2, row,
                                 row + 1)
                row += 1

        # raid minors
        lbl = createAlignedLabel(_("RAID _Device:"))
        maintable.attach(lbl, 0, 1, row, row + 1)

        if not origrequest.getPreExisting():
            availminors = self.partitions.getAvailableRaidMinors()[:16]
            reqminor = origrequest.raidminor
            if reqminor is not None:
                availminors.append(reqminor)

            availminors.sort()
            self.minorCombo = self.createRaidMinorMenu(availminors, reqminor)
            lbl.set_mnemonic_widget(self.minorCombo)
        else:
            self.minorCombo = gtk.Label("md%s" % (origrequest.raidminor, ))
        maintable.attach(self.minorCombo, 1, 2, row, row + 1)
        row = row + 1

        # raid level
        lbl = createAlignedLabel(_("RAID _Level:"))
        maintable.attach(lbl, 0, 1, row, row + 1)

        if not origrequest.getPreExisting():
            # Create here, pack below
            numparts = len(availraidparts)
            if origrequest.raidspares:
                nspares = origrequest.raidspares
            else:
                nspares = 0

            if origrequest.raidlevel:
                maxspares = raid.get_raid_max_spares(origrequest.raidlevel,
                                                     numparts)
            else:
                maxspares = 0

            spareAdj = gtk.Adjustment(value=nspares,
                                      lower=0,
                                      upper=maxspares,
                                      step_incr=1)
            self.sparesb = gtk.SpinButton(spareAdj, digits=0)
            self.sparesb.set_data("numparts", numparts)

            if maxspares > 0:
                self.sparesb.set_sensitive(1)
            else:
                self.sparesb.set_value(0)
                self.sparesb.set_sensitive(0)
        else:
            self.sparesb = gtk.Label(str(origrequest.raidspares))

        if not origrequest.getPreExisting():
            self.levelcombo = self.createRaidLevelMenu(availRaidLevels,
                                                       origrequest.raidlevel)
            lbl.set_mnemonic_widget(self.levelcombo)
        else:
            self.levelcombo = gtk.Label(origrequest.raidlevel)

        maintable.attach(self.levelcombo, 1, 2, row, row + 1)
        row = row + 1

        # raid members
        lbl = createAlignedLabel(_("_RAID Members:"))
        maintable.attach(lbl, 0, 1, row, row + 1)

        # XXX need to pass in currently used partitions for this device
        (self.raidlist, sw) = self.createAllowedRaidPartitionsList(
            availraidparts, origrequest.raidmembers,
            origrequest.getPreExisting())

        lbl.set_mnemonic_widget(self.raidlist)
        self.raidlist.set_size_request(275, 80)
        maintable.attach(sw, 1, 2, row, row + 1)
        row = row + 1

        if origrequest.getPreExisting():
            self.raidlist.set_sensitive(False)

        # number of spares - created widget above
        lbl = createAlignedLabel(_("Number of _spares:"))
        maintable.attach(lbl, 0, 1, row, row + 1)
        maintable.attach(self.sparesb, 1, 2, row, row + 1)
        lbl.set_mnemonic_widget(self.sparesb)
        row = row + 1

        # format or not?
        self.formatButton = None
        self.fsoptionsDict = {}
        if (origrequest.fstype and origrequest.fstype.isFormattable()
            ) and not origrequest.getPreExisting():
            self.formatButton = gtk.CheckButton(_("_Format partition?"))
            if origrequest.format == None or origrequest.format != 0:
                self.formatButton.set_active(1)
            else:
                self.formatButton.set_active(0)
    # it only makes sense to show this for preexisting RAID
            if origrequest.getPreExisting():
                maintable.attach(self.formatButton, 0, 2, row, row + 1)
                row = row + 1

    # checkbutton for encryption using dm-crypt/LUKS
            if self.origrequest.encryption:
                self.lukscb.set_active(1)
            else:
                self.lukscb.set_active(0)
            maintable.attach(self.lukscb, 0, 2, row, row + 1)
            row = row + 1
        else:
            (row, self.fsoptionsDict) = createPreExistFSOptionSection(
                self.origrequest,
                maintable,
                row,
                self.mountCombo,
                showbadblocks=0)

        # put main table into dialog
        dialog.vbox.pack_start(maintable)

        dialog.show_all()
        self.dialog = dialog
        return
예제 #38
0
def addFcoeDrive(anaconda):
    (dxml, dialog) = gui.getGladeWidget("fcoe-config.glade", "fcoeDialog")
    combo = dxml.get_widget("fcoeNicCombo")
    dcb_cb = dxml.get_widget("dcbCheckbutton")

    # Populate the combo
    cell = gtk.CellRendererText()
    combo.pack_start(cell, True)
    combo.set_attributes(cell, text = 0)
    cell.set_property("wrap-width", 525)
    combo.set_size_request(480, -1)
    store = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
    combo.set_model(store)

    netdevs = anaconda.network.available()
    keys = netdevs.keys()
    keys.sort()
    selected_interface = None
    for dev in keys:
        # Skip NICs which are connected (iow in use for a net install)
        if dev in network.getActiveNetDevs():
            continue

        i = store.append(None)
        desc = netdevs[dev].get("DESC")
        if desc:
            desc = "%s - %s" %(dev, desc)
        else:
            desc = "%s" %(dev,)

        mac = netdevs[dev].get("HWADDR")
        if mac:
            desc = "%s - %s" %(desc, mac)

        if selected_interface is None:
            selected_interface = i

        store[i] = (desc, dev)

    if selected_interface:
        combo.set_active_iter(selected_interface)
    else:
        combo.set_active(0)

    # Show the dialog
    gui.addFrame(dialog)
    dialog.show_all()
    sg = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
    sg.add_widget(dxml.get_widget("fcoeNicCombo"))

    while True:
        rc = dialog.run()

        if rc in [gtk.RESPONSE_CANCEL, gtk.RESPONSE_DELETE_EVENT]:
            break

        iter = combo.get_active_iter()
        if iter is None:
            anaconda.intf.messageWindow(_("Error"),
                                        _("You must select a NIC to use."),
                                        type="warning", custom_icon="error")
            continue

        try:
            anaconda.storage.fcoe.addSan(store.get_value(iter, 1),
                                         dcb=dcb_cb.get_active(),
                                         intf=anaconda.intf)
        except IOError as e:
            anaconda.intf.messageWindow(_("Error"), str(e))
            rc = gtk.RESPONSE_CANCEL

        break

    dialog.destroy()
    return rc
예제 #39
0
        sw.set_shadow_type(gtk.SHADOW_IN)
        sw.add(text)
        vbox1.pack_start(sw)

        a = gtk.Alignment(0, 0, 1.0, 1.0)
        a.add(frame)

        textWin.set_default_size(635, 393)
        textWin.set_size_request(635, 393)
        textWin.set_position(gtk.WIN_POS_CENTER)

        table.attach(a, 1, 2, 1, 2, gtk.FILL | gtk.EXPAND,
                     gtk.FILL | gtk.EXPAND, 5, 5)

        textWin.set_border_width(0)
        addFrame(textWin, _("Release Notes"))
        textWin.show_all()
    else:
        textWin.set_position(gtk.WIN_POS_CENTER)
        label = gtk.Label(_("Unable to load file!"))

        table.attach(label, 1, 2, 1, 2, gtk.FILL | gtk.EXPAND,
                     gtk.FILL | gtk.EXPAND, 5, 5)

        textWin.set_border_width(0)
        addFrame(textWin)
        textWin.show_all()

    # set cursor to normal (assuming that anaconda set it to busy when
    # it exec'd this viewer app to give progress indicator to user).
    root = gtk.gdk.get_default_root_window()
예제 #40
0
    def addIscsiDrive(self):
        if not network.hasActiveNetDev():
            net = NetworkConfigurator(self.anaconda.id.network)
            ret = net.run()
            net.destroy()

        (dxml, dialog) = gui.getGladeWidget("iscsi-config.glade",
                                            "iscsiDialog")
        gui.addFrame(dialog)
        dialog.show_all()
        sg = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
        map(lambda x: sg.add_widget(dxml.get_widget(x)),
            ("iscsiAddrEntry", "iscsiInitiatorEntry", "userEntry", "passEntry",
             "userinEntry", "passinEntry"))

        # get the initiator name if it exists and don't allow changing
        # once set
        e = dxml.get_widget("iscsiInitiatorEntry")
        e.set_text(self.anaconda.id.iscsi.initiator)
        if self.anaconda.id.iscsi.initiatorSet: # this is uglyyyy....
            e.set_sensitive(False)

        while 1:
            rc = dialog.run()
            if rc == gtk.RESPONSE_CANCEL:
                break

            initiator = dxml.get_widget("iscsiInitiatorEntry").get_text()
            initiator.strip()
            if len(initiator) == 0:
                self.intf.messageWindow(_("Invalid Initiator Name"),
                                        _("You must provide a non-zero length "
                                          "initiator name."))
                continue

            self.anaconda.id.iscsi.initiator = initiator

            target = dxml.get_widget("iscsiAddrEntry").get_text().strip()
            user = dxml.get_widget("userEntry").get_text().strip()
            pw = dxml.get_widget("passEntry").get_text().strip()
            user_in = dxml.get_widget("userinEntry").get_text().strip()
            pw_in = dxml.get_widget("passinEntry").get_text().strip()

            err = None
            try:
                count = len(target.split(":"))
                idx = target.rfind("]:")
                # Check for IPV6 [IPV6-ip]:port
                if idx != -1:
                    ip = target[1:idx]
                    port = target[idx+2:]
                # Check for IPV4 aaa.bbb.ccc.ddd:port
                elif count == 2:
                    idx = target.rfind(":")
                    ip = target[:idx]
                    port = target[idx+1:]
                else:
                    ip = target
                    port = "3260"
                network.sanityCheckIPString(ip)
            except network.IPMissing, msg:
                err = msg
            except network.IPError, msg:
                err = msg
예제 #41
0
    def passwordWindow(self, *args):
        dialog = gtk.Dialog(_("Enter Boot Loader Password"), self.parent)
        dialog.add_button('gtk-cancel', 2)
        dialog.add_button('gtk-ok', 1)
        dialog.set_position(gtk.WIN_POS_CENTER)
        gui.addFrame(dialog)
        
        label = gui.WrappingLabel(_("Enter a boot loader password and then confirm it.  (Note that your BIOS keymap may be different than the actual keymap you are used to.)"))
        label.set_alignment(0.0, 0.0)
        dialog.vbox.pack_start(label)

        table = gtk.Table(2, 2)
        table.set_row_spacings(5)
        table.set_col_spacings(5)
        label = gui.MnemonicLabel(_("_Password:"******"Con_firm:"))        
        table.attach(label, 0, 1, 3, 4, gtk.FILL, 0, 10) 
        confirmEntry = gtk.Entry (16)
        confirmEntry.set_visibility (False)
        label.set_mnemonic_widget(confirmEntry)
        table.attach(confirmEntry, 1, 2, 3, 4, gtk.FILL, 0, 10)
        dialog.vbox.pack_start(table)

        # set the default
        if self.password:
            pwEntry.set_text(self.password)
            confirmEntry.set_text(self.password)

        dialog.show_all()

        while 1:
            rc = dialog.run()
            if rc in [2, gtk.RESPONSE_DELETE_EVENT]:
                break

            if pwEntry.get_text() != confirmEntry.get_text():
                self.intf.messageWindow(_("Passwords don't match"),
                                        _("Passwords do not match"),
                                        type='warning')
                continue

            thePass = pwEntry.get_text()
            if not thePass:
                continue
            if len(thePass) < 6:
                ret = self.intf.messageWindow(_("Warning"),
                                    _("Your boot loader password is shorter than "
                                      "six characters.  We recommend a longer "
                                      "boot loader password."
                                      "\n\n"
                                      "Would you like to continue with this "
                                      "password?"),
                                             type = "yesno")
                if ret == 0:
                    continue

            self.password = thePass
            break

        dialog.destroy()
        return rc
예제 #42
0
def selectInstallNetDeviceDialog(network, devices=None):

    devs = devices or network.netdevices.keys()
    if not devs:
        return None
    devs.sort()

    dialog = gtk.Dialog(_("Select network interface"))
    dialog.add_button('gtk-cancel', gtk.RESPONSE_CANCEL)
    dialog.add_button('gtk-ok', 1)
    dialog.set_position(gtk.WIN_POS_CENTER)
    gui.addFrame(dialog)

    dialog.vbox.pack_start(
        gui.WrappingLabel(
            _("This requires that you have an active "
              "network connection during the installation "
              "process.  Please configure a network interface.")))

    combo = gtk.ComboBox()
    cell = gtk.CellRendererText()
    combo.pack_start(cell, True)
    combo.set_attributes(cell, text=0)
    cell.set_property("wrap-width", 525)
    combo.set_size_request(480, -1)
    store = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
    combo.set_model(store)

    ksdevice = network.getKSDevice()
    if ksdevice:
        ksdevice = ksdevice.get('DEVICE')
    preselected = None

    for dev in devices:
        i = store.append(None)
        if not preselected:
            preselected = i

        desc = network.netdevices[dev].description
        if desc:
            desc = "%s - %s" % (dev, desc)
        else:
            desc = "%s" % (dev, )

        hwaddr = network.netdevices[dev].get("HWADDR")

        if hwaddr:
            desc = "%s - %s" % (
                desc,
                hwaddr,
            )

        if ksdevice and ksdevice == dev:
            preselected = i

        store[i] = (desc, dev)

    combo.set_active_iter(preselected)
    dialog.vbox.pack_start(combo)

    dialog.show_all()

    rc = dialog.run()

    if rc in [gtk.RESPONSE_CANCEL, gtk.RESPONSE_DELETE_EVENT]:
        install_device = None
    else:
        active = combo.get_active_iter()
        install_device = combo.get_model().get_value(active, 1)

    dialog.destroy()
    return install_device
예제 #43
0
    def __init__(self, anaconda, parent, origrequest, isNew = 0,
                 restrictfs = None):
        self.anaconda = anaconda
	self.storage = self.anaconda.storage
	self.intf = self.anaconda.intf
	self.origrequest = origrequest
	self.isNew = isNew
	self.parent = parent

	if isNew:
	    tstr = _("Add Partition")
	else:
	    tstr = _("Edit Partition: %s") % (origrequest.path,)
	    
        self.dialog = gtk.Dialog(tstr, self.parent)
        gui.addFrame(self.dialog)
        self.dialog.add_button('gtk-cancel', 2)
        self.dialog.add_button('gtk-ok', 1)
        self.dialog.set_position(gtk.WIN_POS_CENTER)
        
        maintable = gtk.Table()
        maintable.set_row_spacings(5)
        maintable.set_col_spacings(5)
        row = 0

        # if this is a luks device we need to grab info from two devices
        # to make it seem like one device. wee!
        if self.origrequest.format.type == "luks":
            try:
                luksdev = self.storage.devicetree.getChildren(self.origrequest)[0]
            except IndexError:
                usereq = self.origrequest
                luksdev = None
            else:
                usereq = luksdev
        else:
            luksdev = None
            usereq = self.origrequest

        # Mount Point entry
	lbl = createAlignedLabel(_("_Mount Point:"))
        maintable.attach(lbl, 0, 1, row, row + 1)
        self.mountCombo = createMountPointCombo(usereq)
	lbl.set_mnemonic_widget(self.mountCombo)
        maintable.attach(self.mountCombo, 1, 2, row, row + 1)
        row = row + 1

        # Partition Type
        if not self.origrequest.exists:
	    lbl = createAlignedLabel(_("File System _Type:"))
            maintable.attach(lbl, 0, 1, row, row + 1)

            self.newfstypeCombo = createFSTypeMenu(usereq.format,
                                                   fstypechangeCB,
                                                   self.mountCombo,
                                                   availablefstypes = restrictfs)
	    lbl.set_mnemonic_widget(self.newfstypeCombo)
            maintable.attach(self.newfstypeCombo, 1, 2, row, row + 1)
        else:
            self.newfstypeCombo = None
            
        row = row + 1

        # allowable drives
        if not self.origrequest.exists:
            lbl = createAlignedLabel(_("Allowable _Drives:"))
            maintable.attach(lbl, 0, 1, row, row + 1)

            req_disk_names = [d.name for d in self.origrequest.req_disks]
            self.driveview = createAllowedDrivesList(self.storage.partitioned,
                                                     req_disk_names,
                                                     disallowDrives=[self.anaconda.updateSrc])
            lbl.set_mnemonic_widget(self.driveview)
            sw = gtk.ScrolledWindow()
            sw.add(self.driveview)
            sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
            sw.set_shadow_type(gtk.SHADOW_IN)
            maintable.attach(sw, 1, 2, row, row + 1)
            self.driveview.set_size_request(375, 80)

            row = row + 1

        # original fs type and label
        if self.origrequest.exists:
            maintable.attach(createAlignedLabel(_("Original File System Type:")),
                             0, 1, row, row + 1)
            self.fstypeCombo = gtk.Label(usereq.originalFormat.name)

            maintable.attach(self.fstypeCombo, 1, 2, row, row + 1)
            row += 1

            if getattr(usereq.originalFormat, "label", None):
                maintable.attach(createAlignedLabel(_("Original File System "
                                                      "Label:")),
                                 0, 1, row, row + 1)
                fslabel = gtk.Label(usereq.originalFormat.label)
                maintable.attach(fslabel, 1, 2, row, row + 1)
                row = row + 1

        # size
        if not self.origrequest.exists:
            # Size specification
            lbl = createAlignedLabel(_("_Size (MB):"))
            maintable.attach(lbl, 0, 1, row, row + 1)
            sizeAdj = gtk.Adjustment(value = 1, lower = 1,
                                     upper = MAX_PART_SIZE, step_incr = 1)
            self.sizespin = gtk.SpinButton(sizeAdj, digits = 0)
            self.sizespin.set_property('numeric', True)

            if self.origrequest.req_size:
                self.sizespin.set_value(self.origrequest.req_size)

            lbl.set_mnemonic_widget(self.sizespin)
            maintable.attach(self.sizespin, 1, 2, row, row + 1)
        else:
            self.sizespin = None
            
        row = row + 1

        # format/migrate options for pre-existing partitions, as long as they
        # aren't protected (we'd still like to be able to mount them, though)
	self.fsoptionsDict = {}
        if self.origrequest.exists and \
           not self.origrequest.protected:
	    (row, self.fsoptionsDict) = createPreExistFSOptionSection(self.origrequest, maintable, row, self.mountCombo, self.storage, luksdev=luksdev)

        # size options
        if not self.origrequest.exists:
            (sizeframe, self.fixedrb, self.fillmaxszrb,
             self.fillmaxszsb) = self.createSizeOptionsFrame(self.origrequest,
                                                        self.fillmaxszCB)
            self.sizespin.connect("value-changed", self.sizespinchangedCB,
                                  self.fillmaxszsb)

            maintable.attach(sizeframe, 0, 2, row, row + 1)
            row = row + 1
        else:
            self.sizeoptiontable = None

        # create only as primary
        if not self.origrequest.exists:
            self.primonlycheckbutton = gtk.CheckButton(_("Force to be a _primary "
                                                    "partition"))
            self.primonlycheckbutton.set_active(0)
            if self.origrequest.req_primary:
                self.primonlycheckbutton.set_active(1)

            # only show if we have something other than primary
            if self.storage.extendedPartitionsSupported():
                maintable.attach(self.primonlycheckbutton, 0, 2, row, row+1)
                row = row + 1

        # checkbutton for encryption using dm-crypt/LUKS
        if not self.origrequest.exists:
            self.lukscb = gtk.CheckButton(_("_Encrypt"))
            self.lukscb.set_data("formatstate", 1)

            if self.origrequest.format.type == "luks":
                self.lukscb.set_active(1)
            else:
                self.lukscb.set_active(0)
            maintable.attach(self.lukscb, 0, 2, row, row + 1)
            row = row + 1

        # put main table into dialog
        self.dialog.vbox.pack_start(maintable)
        self.dialog.show_all()
예제 #44
0
 def _run_dialog(self, dialog):
     gui.addFrame(dialog)
     dialog.show()
     rc = dialog.run()
     dialog.hide()
     return self._normalize_dialog_response(rc)
예제 #45
0
def addFcoeDrive(anaconda):
    (dxml, dialog) = gui.getGladeWidget("fcoe-config.glade", "fcoeDialog")
    combo = dxml.get_widget("fcoeNicCombo")
    dcb_cb = dxml.get_widget("dcbCheckbutton")
    auto_vlan_cb = dxml.get_widget("autovlanCheckbutton")

    # Populate the combo
    cell = gtk.CellRendererText()
    combo.pack_start(cell, True)
    combo.set_attributes(cell, text = 0)
    cell.set_property("wrap-width", 525)
    combo.set_size_request(480, -1)
    store = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
    combo.set_model(store)

    netdevs = anaconda.id.network.netdevices
    keys = netdevs.keys()
    keys.sort()
    selected_interface = None
    for dev in keys:
        i = store.append(None)
        desc = netdevs[dev].description
        if desc:
            desc = "%s - %s" %(dev, desc)
        else:
            desc = "%s" %(dev,)

        mac = netdevs[dev].get("HWADDR")
        if mac:
            desc = "%s - %s" %(desc, mac)

        if selected_interface is None:
            selected_interface = i

        store[i] = (desc, dev)

    if selected_interface:
        combo.set_active_iter(selected_interface)
    else:
        combo.set_active(0)

    # Show the dialog
    gui.addFrame(dialog)
    dialog.show_all()
    sg = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
    sg.add_widget(dxml.get_widget("fcoeNicCombo"))

    while True:
        # make sure the dialog pops into foreground in case this is the second
        # time through the loop:
        dialog.present()
        rc = dialog.run()

        if rc in [gtk.RESPONSE_CANCEL, gtk.RESPONSE_DELETE_EVENT]:
            break

        iter = combo.get_active_iter()
        if iter is None:
            anaconda.intf.messageWindow(_("Error"),
                                        _("You must select a NIC to use."),
                                        type="warning", custom_icon="error")
            continue

        try:
            nic = store.get_value(iter, 1)
            anaconda.id.storage.fcoe.addSan(nic,
                                            dcb=dcb_cb.get_active(),
                                            auto_vlan=auto_vlan_cb.get_active(),
                                            intf=anaconda.intf)
            anaconda.id.storage.fcoe.ksnics.append(nic)
        except IOError as e:
            anaconda.intf.messageWindow(_("Error"), str(e))
            rc = gtk.RESPONSE_CANCEL

        break

    dialog.destroy()
    return rc
예제 #46
0
def addDrive(anaconda):
    (dxml, dialog) = gui.getGladeWidget("adddrive.glade", "addDriveDialog")
    gui.addFrame(dialog)
    dialog.show_all()
    if not iutil.isS390():
        dxml.get_widget("zfcpRadio").hide()
        dxml.get_widget("zfcpRadio").set_group(None)

    if not storage.iscsi.has_iscsi():
        dxml.get_widget("iscsiRadio").set_sensitive(False)
        dxml.get_widget("iscsiRadio").set_active(False)

    if not storage.fcoe.has_fcoe():
        dxml.get_widget("fcoeRadio").set_sensitive(False)
        dxml.get_widget("fcoeRadio").set_active(False)
    # liuweifeng
    elif storage.iscsi.has_iscsi():
        dxml.get_widget("fcoeRadio").set_active(False)
        dxml.get_widget("iscsiRadio").set_sensitive(True)
        dxml.get_widget("iscsiRadio").set_active(True)
    #figure out what advanced devices we have available and set sensible default
    group = dxml.get_widget("iscsiRadio").get_group()
    for button in group:
        if button is not None and button.get_property("sensitive"):
            button.set_active(True)
            button.grab_focus()
            break
        
    # 
    for button in group:
        if button is not None and button.get_property("sensitive"):
            label = button.get_property("label")
            if "_" in label:
                nl = ""
                for s in label.split('_'):
                    nl = nl+s
                button.set_property("label",nl)
                
    cancelButton = dxml.get_widget("cancelButton")
    cancelButton.set_property("label",_("Cancel"))
    
    okButtonl = dxml.get_widget("label2")
    label = okButtonl.get_property("label")
    if '(_A)' in label:
        i = label.index('(_A)')
        nl = label[0:i]+label[i+4:]
        okButtonl.set_property("label",_(nl))
    
    #liuweifeng
    dxml.get_widget("fcoeRadio").set_active(False)
    #dxml.get_widget("fcoeRadio").set_property("focus_on_click",False)
    dxml.get_widget("iscsiRadio").set_sensitive(True)
    dxml.get_widget("iscsiRadio").set_active(True)
    dxml.get_widget("iscsiRadio").grab_focus()
    
    rc = dialog.run()
    dialog.hide()

    if rc in [gtk.RESPONSE_CANCEL, gtk.RESPONSE_DELETE_EVENT]:
        return False

    if dxml.get_widget("iscsiRadio").get_active() and storage.iscsi.has_iscsi():
        rc = addIscsiDrive(anaconda)
    elif dxml.get_widget("fcoeRadio").get_active() and storage.fcoe.has_fcoe():
        rc = addFcoeDrive(anaconda)
    elif dxml.get_widget("zfcpRadio") is not None and dxml.get_widget("zfcpRadio").get_active():
        rc = addZfcpDrive(anaconda)

    dialog.destroy()

    if rc in [gtk.RESPONSE_CANCEL, gtk.RESPONSE_DELETE_EVENT]:
        return False
    else:
        return True
예제 #47
0
    def __init__(self, partitions, diskset, intf, parent, origrequest, isNew = 0):
	self.partitions = partitions
	self.diskset = diskset
	self.origrequest = origrequest
	self.isNew = isNew
	self.intf = intf
	self.parent = parent

	self.dialog = None

	#
	# start of editRaidRequest
	#
	availraidparts = self.partitions.getAvailRaidPartitions(origrequest,
								self.diskset)
	# if no raid partitions exist, raise an error message and return
	if len(availraidparts) < 2:
	    dlg = gtk.MessageDialog(self.parent, 0, gtk.MESSAGE_ERROR,
				    gtk.BUTTONS_OK,
				    _("At least two unused software RAID "
				      "partitions are needed to create "
				      "a RAID device.\n\n"
				      "First create at least two partitions "
				      "of type \"software RAID\", and then "
				      "select the \"RAID\" option again."))
	    gui.addFrame(dlg)
	    dlg.show_all()
	    dlg.set_position(gtk.WIN_POS_CENTER)
	    dlg.run()
	    dlg.destroy()
	    return

	if isNew:
	    tstr = _("Make RAID Device")
	else:
	    try:
		tstr = _("Edit RAID Device: /dev/md%s") % (origrequest.raidminor,)
	    except:
		tstr = _("Edit RAID Device")
		
	dialog = gtk.Dialog(tstr, self.parent)
	gui.addFrame(dialog)
	dialog.add_button('gtk-cancel', 2)
	dialog.add_button('gtk-ok', 1)
	dialog.set_position(gtk.WIN_POS_CENTER)

	maintable = gtk.Table()
	maintable.set_row_spacings(5)
	maintable.set_col_spacings(5)
	row = 0

	# Mount Point entry
	lbl = createAlignedLabel(_("_Mount Point:"))
	maintable.attach(lbl, 0, 1, row, row + 1)
	self.mountCombo = createMountPointCombo(origrequest)
	lbl.set_mnemonic_widget(self.mountCombo)
	maintable.attach(self.mountCombo, 1, 2, row, row + 1)
	row = row + 1

        # we'll maybe add this further down
        self.lukscb = gtk.CheckButton(_("_Encrypt"))
        self.lukscb.set_data("formatstate", 1)

	# Filesystem Type
        if not origrequest.getPreExisting():
            lbl = createAlignedLabel(_("_File System Type:"))
            maintable.attach(lbl, 0, 1, row, row + 1)
            self.fstypeCombo = createFSTypeMenu(origrequest.fstype,
                                                fstypechangeCB,
                                                self.mountCombo,
                                                ignorefs = ["software RAID", "PPC PReP Boot", "Apple Bootstrap"])
	    lbl.set_mnemonic_widget(self.fstypeCombo)
            maintable.attach(self.fstypeCombo, 1, 2, row, row + 1)
            row += 1
        else:
            maintable.attach(createAlignedLabel(_("Original File System Type:")),
                             0, 1, row, row + 1)
            if origrequest.fstype.getName():
                self.fstypeCombo = gtk.Label(origrequest.fstype.getName())
            else:
                self.fstypeCombo = gtk.Label(_("Unknown"))

            maintable.attach(self.fstypeCombo, 1, 2, row, row + 1)
            row += 1

            if origrequest.fslabel:
                maintable.attach(createAlignedLabel(_("Original File System "
                                                      "Label:")),
                                 0, 1, row, row + 1)
                maintable.attach(gtk.Label(origrequest.fslabel), 1, 2, row,
                                 row + 1)
                row += 1

	# raid minors
	lbl = createAlignedLabel(_("RAID _Device:"))	
	maintable.attach(lbl, 0, 1, row, row + 1)

        if not origrequest.getPreExisting():
            availminors = self.partitions.getAvailableRaidMinors()[:16]
            reqminor = origrequest.raidminor
            if reqminor is not None:
                availminors.append(reqminor)

            availminors.sort()
            self.minorCombo = self.createRaidMinorMenu(availminors, reqminor)
	    lbl.set_mnemonic_widget(self.minorCombo)
        else:
            self.minorCombo = gtk.Label("md%s" %(origrequest.raidminor,))
	maintable.attach(self.minorCombo, 1, 2, row, row + 1)
	row = row + 1

	# raid level
	lbl = createAlignedLabel(_("RAID _Level:"))
	maintable.attach(lbl, 0, 1, row, row + 1)

        if not origrequest.getPreExisting():
            # Create here, pack below
            numparts =  len(availraidparts)
            if origrequest.raidspares:
                nspares = origrequest.raidspares
            else:
                nspares = 0

            if origrequest.raidlevel:
                maxspares = raid.get_raid_max_spares(origrequest.raidlevel, numparts)
            else:
                maxspares = 0

            spareAdj = gtk.Adjustment(value = nspares, lower = 0,
                                      upper = maxspares, step_incr = 1)
            self.sparesb = gtk.SpinButton(spareAdj, digits = 0)
            self.sparesb.set_data("numparts", numparts)

            if maxspares > 0:
                self.sparesb.set_sensitive(1)
            else:
                self.sparesb.set_value(0)
                self.sparesb.set_sensitive(0)
        else:
            self.sparesb = gtk.Label(str(origrequest.raidspares))


        if not origrequest.getPreExisting():
            self.levelcombo = self.createRaidLevelMenu(availRaidLevels,
                                                       origrequest.raidlevel)
	    lbl.set_mnemonic_widget(self.levelcombo)
        else:
            self.levelcombo = gtk.Label(origrequest.raidlevel)

	maintable.attach(self.levelcombo, 1, 2, row, row + 1)
	row = row + 1

	# raid members
	lbl=createAlignedLabel(_("_RAID Members:"))
	maintable.attach(lbl, 0, 1, row, row + 1)

	# XXX need to pass in currently used partitions for this device
	(self.raidlist, sw) = self.createAllowedRaidPartitionsList(availraidparts,
                                                                   origrequest.raidmembers,
                                                                   origrequest.getPreExisting())

	lbl.set_mnemonic_widget(self.raidlist)
	self.raidlist.set_size_request(275, 80)
	maintable.attach(sw, 1, 2, row, row + 1)
	row = row + 1

        if origrequest.getPreExisting():
            self.raidlist.set_sensitive(False)

	# number of spares - created widget above
	lbl = createAlignedLabel(_("Number of _spares:"))
	maintable.attach(lbl, 0, 1, row, row + 1)
	maintable.attach(self.sparesb, 1, 2, row, row + 1)
	lbl.set_mnemonic_widget(self.sparesb)
	row = row + 1

	# format or not?
	self.formatButton = None
	self.fsoptionsDict = {}
	if (origrequest.fstype and origrequest.fstype.isFormattable()) and not origrequest.getPreExisting():
	    self.formatButton = gtk.CheckButton(_("_Format partition?"))
	    if origrequest.format == None or origrequest.format != 0:
		self.formatButton.set_active(1)
	    else:
		self.formatButton.set_active(0)
            # it only makes sense to show this for preexisting RAID
            if origrequest.getPreExisting():
                maintable.attach(self.formatButton, 0, 2, row, row + 1)
                row = row + 1

            # checkbutton for encryption using dm-crypt/LUKS
            if self.origrequest.encryption:
                self.lukscb.set_active(1)
            else:
                self.lukscb.set_active(0)
            maintable.attach(self.lukscb, 0, 2, row, row + 1)
            row = row + 1
	else:
	    (row, self.fsoptionsDict) = createPreExistFSOptionSection(self.origrequest, maintable, row, self.mountCombo, showbadblocks=0)

	# put main table into dialog
	dialog.vbox.pack_start(maintable)

	dialog.show_all()
	self.dialog = dialog
	return
예제 #48
0
 def run(self):
     gui.addFrame(self.window)
     self.window.show()
     gtk.main()
     return self.rc
예제 #49
0
    def __init__(self,
                 anaconda,
                 parent,
                 origrequest,
                 isNew=0,
                 restrictfs=None):
        self.anaconda = anaconda
        self.partitions = self.anaconda.id.partitions
        self.diskset = self.anaconda.id.diskset
        self.intf = self.anaconda.intf
        self.origrequest = origrequest
        self.isNew = isNew
        self.parent = parent

        if isNew:
            tstr = _("Add Partition")
        else:
            try:
                tstr = _("Edit Partition: /dev/%s") % (origrequest.device, )
            except:
                tstr = _("Edit Partition")

        self.dialog = gtk.Dialog(tstr, self.parent)
        gui.addFrame(self.dialog)
        self.dialog.add_button('gtk-cancel', 2)
        self.dialog.add_button('gtk-ok', 1)
        self.dialog.set_position(gtk.WIN_POS_CENTER)

        maintable = gtk.Table()
        maintable.set_row_spacings(5)
        maintable.set_col_spacings(5)
        row = 0

        # see if we are creating a floating request or by cylinder
        if self.origrequest.type == REQUEST_NEW:
            self.newbycyl = self.origrequest.start != None

        # Mount Point entry
        lbl = createAlignedLabel(_("_Mount Point:"))
        maintable.attach(lbl, 0, 1, row, row + 1)
        self.mountCombo = createMountPointCombo(origrequest)
        lbl.set_mnemonic_widget(self.mountCombo)
        maintable.attach(self.mountCombo, 1, 2, row, row + 1)
        row = row + 1

        # Partition Type
        if self.origrequest.type == REQUEST_NEW:
            lbl = createAlignedLabel(_("File System _Type:"))
            maintable.attach(lbl, 0, 1, row, row + 1)
            self.lukscb = gtk.CheckButton(_("_Encrypt"))
            self.newfstypeCombo = createFSTypeMenu(self.origrequest.fstype,
                                                   fstypechangeCB,
                                                   self.mountCombo,
                                                   availablefstypes=restrictfs,
                                                   lukscb=self.lukscb)
            lbl.set_mnemonic_widget(self.newfstypeCombo)
            maintable.attach(self.newfstypeCombo, 1, 2, row, row + 1)
        else:
            maintable.attach(
                createAlignedLabel(_("Original File System "
                                     "Type:")), 0, 1, row, row + 1)

            if self.origrequest.origfstype:
                typestr = self.origrequest.origfstype.getName()
                if self.origrequest.origfstype.getName() == "foreign":
                    part = get_partition_by_name(self.diskset.disks,
                                                 self.origrequest.device)
                    typestr = map_foreign_to_fsname(part.native_type)
            else:
                typestr = _("Unknown")

            fstypelabel = gtk.Label(typestr)
            maintable.attach(fstypelabel, 1, 2, row, row + 1)
            self.newfstypeCombo = None

        row = row + 1

        # allowable drives
        if self.origrequest.type == REQUEST_NEW:
            if not self.newbycyl:
                lbl = createAlignedLabel(_("Allowable _Drives:"))
                maintable.attach(lbl, 0, 1, row, row + 1)

                self.driveview = createAllowedDrivesList(
                    self.diskset.disks, self.origrequest.drive,
                    self.anaconda.updateSrc)
                lbl.set_mnemonic_widget(self.driveview)
                sw = gtk.ScrolledWindow()
                sw.add(self.driveview)
                sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
                sw.set_shadow_type(gtk.SHADOW_IN)
                maintable.attach(sw, 1, 2, row, row + 1)
                self.driveview.set_size_request(375, 80)
            else:
                maintable.attach(createAlignedLabel(_("Drive:")), 0, 1, row,
                                 row + 1)
                maintable.attach(createAlignedLabel(origrequest.drive[0]), 1,
                                 2, row, row + 1)

            row = row + 1

        # original fs label
        if self.origrequest.type != REQUEST_NEW and self.origrequest.fslabel:
            maintable.attach(
                createAlignedLabel(_("Original File System "
                                     "Label:")), 0, 1, row, row + 1)
            fslabel = gtk.Label(self.origrequest.fslabel)
            maintable.attach(fslabel, 1, 2, row, row + 1)

            row = row + 1

        # size
        if self.origrequest.type == REQUEST_NEW:
            if not self.newbycyl:
                # Size specification
                lbl = createAlignedLabel(_("_Size (MB):"))
                maintable.attach(lbl, 0, 1, row, row + 1)
                sizeAdj = gtk.Adjustment(value=1,
                                         lower=1,
                                         upper=MAX_PART_SIZE,
                                         step_incr=1)
                self.sizespin = gtk.SpinButton(sizeAdj, digits=0)
                self.sizespin.set_property('numeric', True)

                if self.origrequest.size:
                    self.sizespin.set_value(self.origrequest.size)

                lbl.set_mnemonic_widget(self.sizespin)
                maintable.attach(self.sizespin, 1, 2, row, row + 1)
                bycyl_sizelabel = None
            else:
                # XXX need to add partition by size and
                #     wire in limits between start and end
                dev = self.diskset.disks[origrequest.drive[0]].dev
                maintable.attach(createAlignedLabel(_("Size (MB):")), 0, 1,
                                 row, row + 1)
                bycyl_sizelabel = createAlignedLabel("")
                maintable.attach(bycyl_sizelabel, 1, 2, row, row + 1)
                row = row + 1

                lbl = createAlignedLabel(_("_Start Cylinder:"))
                maintable.attach(lbl, 0, 1, row, row + 1)

                maxcyl = self.diskset.disks[origrequest.drive[0]].dev.cylinders
                cylAdj = gtk.Adjustment(value=origrequest.start,
                                        lower=origrequest.start,
                                        upper=maxcyl,
                                        step_incr=1)
                self.startcylspin = gtk.SpinButton(cylAdj, digits=0)
                self.startcylspin.set_property('numeric', True)
                lbl.set_mnemonic_widget(self.startcylspin)
                maintable.attach(self.startcylspin, 1, 2, row, row + 1)
                row = row + 1

                endcylAdj = gtk.Adjustment(value=origrequest.end,
                                           lower=origrequest.start,
                                           upper=maxcyl,
                                           step_incr=1)
                lbl = createAlignedLabel(_("_End Cylinder:"))
                maintable.attach(lbl, 0, 1, row, row + 1)
                self.endcylspin = gtk.SpinButton(endcylAdj, digits=0)
                self.endcylspin.set_property('numeric', True)
                lbl.set_mnemonic_widget(self.endcylspin)
                maintable.attach(self.endcylspin, 1, 2, row, row + 1)

                self.startcylspin.connect(
                    "value-changed", self.cylspinchangedCB,
                    (dev, self.startcylspin, self.endcylspin, bycyl_sizelabel))
                self.endcylspin.connect(
                    "value-changed", self.cylspinchangedCB,
                    (dev, self.startcylspin, self.endcylspin, bycyl_sizelabel))

                startsec = start_cyl_to_sector(dev, origrequest.start)
                endsec = end_cyl_to_sector(dev, origrequest.end)
                cursize = (endsec - startsec) / 2048
                bycyl_sizelabel.set_text("%s" % (int(cursize)))
        else:
            maintable.attach(createAlignedLabel(_("Size (MB):")), 0, 1, row,
                             row + 1)
            sizelabel = gtk.Label("%d" % (origrequest.size))
            maintable.attach(sizelabel, 1, 2, row, row + 1)
            self.sizespin = None

        row = row + 1

        # format/migrate options for pre-existing partitions, as long as they
        # aren't protected (we'd still like to be able to mount them, though)
        self.fsoptionsDict = {}
        if self.origrequest.type == REQUEST_PREEXIST and self.origrequest.fstype and not self.origrequest.getProtected(
        ):
            (row, self.fsoptionsDict) = createPreExistFSOptionSection(
                self.origrequest, maintable, row, self.mountCombo)

        # size options
        if self.origrequest.type == REQUEST_NEW:
            if not self.newbycyl:
                (sizeframe, self.fixedrb, self.fillmaxszrb,
                 self.fillmaxszsb) = self.createSizeOptionsFrame(
                     self.origrequest, self.fillmaxszCB)
                self.sizespin.connect("value-changed", self.sizespinchangedCB,
                                      self.fillmaxszsb)

                maintable.attach(sizeframe, 0, 2, row, row + 1)
            else:
                # XXX need new by cyl options (if any)
                pass
            row = row + 1
        else:
            self.sizeoptiontable = None

        # create only as primary
        if self.origrequest.type == REQUEST_NEW:
            self.primonlycheckbutton = gtk.CheckButton(
                _("Force to be a _primary "
                  "partition"))
            self.primonlycheckbutton.set_active(0)
            if self.origrequest.primary:
                self.primonlycheckbutton.set_active(1)

            # only show if we have something other than primary
            if not self.diskset.onlyPrimaryParts():
                maintable.attach(self.primonlycheckbutton, 0, 2, row, row + 1)
                row = row + 1

            self.lukscb.set_data("formatstate", 1)

            if self.origrequest.encryption:
                self.lukscb.set_active(1)
            else:
                self.lukscb.set_active(0)
            maintable.attach(self.lukscb, 0, 2, row, row + 1)
            row = row + 1

            # disable option for badblocks checking
            self.badblocks = None

# uncomment to reenable
#self.badblocks = gtk.CheckButton(_("Check for _bad blocks"))
#self.badblocks.set_active(0)
#maintable.attach(self.badblocks, 0, 1, row, row + 1)
#row = row + 1
#if self.origrequest.badblocks:
#    self.badblocks.set_active(1)

# put main table into dialog
        self.dialog.vbox.pack_start(maintable)
        self.dialog.show_all()
예제 #50
0
def selectInstallNetDeviceDialog(network, devices = None):

    devs = devices or network.netdevices.keys()
    if not devs:
        return None
    devs.sort()

    dialog = gtk.Dialog(_("Select network interface"))
    dialog.add_button('gtk-cancel', gtk.RESPONSE_CANCEL)
    dialog.add_button('gtk-ok', 1)
    dialog.set_position(gtk.WIN_POS_CENTER)
    gui.addFrame(dialog)

    dialog.vbox.pack_start(gui.WrappingLabel(
        _("This requires that you have an active "
          "network connection during the installation "
          "process.  Please configure a network interface.")))

    combo = gtk.ComboBox()
    cell = gtk.CellRendererText()
    combo.pack_start(cell, True)
    combo.set_attributes(cell, text = 0)
    cell.set_property("wrap-width", 525)
    combo.set_size_request(480, -1)
    store = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
    combo.set_model(store)

    ksdevice = network.getKSDevice()
    if ksdevice:
        ksdevice = ksdevice.get('DEVICE')
    preselected = None

    for dev in devices:
        i = store.append(None)
        if not preselected:
            preselected = i

        desc = network.netdevices[dev].description
        if desc:
            desc = "%s - %s" %(dev, desc)
        else:
            desc = "%s" %(dev,)

        hwaddr = network.netdevices[dev].get("HWADDR")

        if hwaddr:
            desc = "%s - %s" %(desc, hwaddr,)

        if ksdevice and ksdevice == dev:
            preselected = i

        store[i] = (desc, dev)

    combo.set_active_iter(preselected)
    dialog.vbox.pack_start(combo)

    dialog.show_all()

    rc = dialog.run()

    if rc in [gtk.RESPONSE_CANCEL, gtk.RESPONSE_DELETE_EVENT]:
        install_device = None
    else:
        active = combo.get_active_iter()
        install_device = combo.get_model().get_value(active, 1)

    dialog.destroy()
    return install_device
def whichToShrink(storage, intf):
    def getActive(combo):
        act = combo.get_active_iter()
        return combo.get_model().get_value(act, 1)

    def comboCB(combo, shrinkSB):
        # partition to resize changed, let's update our spinbutton
        newSize = shrinkSB.get_value_as_int()

        part = getActive(combo)
        (reqlower, requpper) = getResizeMinMax(part)

        adj = shrinkSB.get_adjustment()
        adj.lower = max(1, reqlower)
        adj.upper = requpper
        adj.set_value(reqlower)

    (dxml, dialog) = gui.getGladeWidget("autopart.glade", "shrinkDialog")

    store = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_PYOBJECT)
    combo = dxml.get_widget("shrinkPartCombo")
    combo.set_model(store)
    crt = gtk.CellRendererText()
    combo.pack_start(crt, True)
    combo.set_attributes(crt, text=0)
    combo.connect("changed", comboCB, dxml.get_widget("shrinkSB"))

    biggest = -1
    for part in storage.partitions:
        if not part.exists:
            continue

        entry = None
        if part.resizable and part.format.resizable:
            entry = (
                "%s (%s, %d MB)" %
                (part.name, part.format.name, math.floor(part.format.size)),
                part)

        if entry:
            i = store.append(None)
            store[i] = entry
            combo.set_active_iter(i)

            if biggest == -1:
                biggest = i
            else:
                current = store.get_value(biggest, 1)
                if part.format.targetSize > current.format.targetSize:
                    biggest = i

    if biggest > -1:
        combo.set_active_iter(biggest)

    if len(store) == 0:
        dialog.destroy()
        intf.messageWindow(_("Error"),
                           _("No partitions are available to resize.  Only "
                             "physical partitions with specific filesystems "
                             "can be resized."),
                           type="warning",
                           custom_icon="error")
        return (gtk.RESPONSE_CANCEL, [])

    gui.addFrame(dialog)
    dialog.show_all()
    runResize = True

    while runResize:
        rc = dialog.run()
        if rc != gtk.RESPONSE_OK:
            dialog.destroy()
            return (rc, [])

        request = getActive(combo)
        sb = dxml.get_widget("shrinkSB")
        sb.update()
        newSize = sb.get_value_as_int()
        actions = []

        try:
            actions.append(ActionResizeFormat(request, newSize))
        except ValueError as e:
            intf.messageWindow(_("Resize FileSystem Error"),
                               _("%(device)s: %(msg)s") % {
                                   'device': request.format.device,
                                   'msg': e.message
                               },
                               type="warning",
                               custom_icon="error")
            continue

        try:
            actions.append(ActionResizeDevice(request, newSize))
        except ValueError as e:
            intf.messageWindow(_("Resize Device Error"),
                               _("%(name)s: %(msg)s") % {
                                   'name': request.name,
                                   'msg': e.message
                               },
                               type="warning",
                               custom_icon="error")
            continue

        runResize = False

    dialog.destroy()
    return (rc, actions)
예제 #52
0
    def __init__(self,
                 anaconda,
                 parent,
                 origrequest,
                 isNew=0,
                 restrictfs=None):
        self.anaconda = anaconda
        self.storage = self.anaconda.storage
        self.intf = self.anaconda.intf
        self.origrequest = origrequest
        self.isNew = isNew
        self.parent = parent

        if isNew:
            tstr = _("Add Partition")
        else:
            tstr = _("Edit Partition: %s") % (origrequest.path, )

        self.dialog = gtk.Dialog(tstr, self.parent)
        gui.addFrame(self.dialog)
        self.dialog.add_button('gtk-cancel', 2)
        self.dialog.add_button('gtk-ok', 1)
        self.dialog.set_position(gtk.WIN_POS_CENTER)

        maintable = gtk.Table()
        maintable.set_row_spacings(5)
        maintable.set_col_spacings(5)
        row = 0

        # if this is a luks device we need to grab info from two devices
        # to make it seem like one device. wee!
        if self.origrequest.format.type == "luks":
            try:
                luksdev = self.storage.devicetree.getChildren(
                    self.origrequest)[0]
            except IndexError:
                usereq = self.origrequest
                luksdev = None
            else:
                usereq = luksdev
        else:
            luksdev = None
            usereq = self.origrequest

        # Mount Point entry
        lbl = createAlignedLabel(_("_Mount Point:"))
        maintable.attach(lbl, 0, 1, row, row + 1)
        self.mountCombo = createMountPointCombo(usereq)
        lbl.set_mnemonic_widget(self.mountCombo)
        maintable.attach(self.mountCombo, 1, 2, row, row + 1)
        row = row + 1

        # Partition Type
        if not self.origrequest.exists:
            lbl = createAlignedLabel(_("File System _Type:"))
            maintable.attach(lbl, 0, 1, row, row + 1)

            self.newfstypeCombo = createFSTypeMenu(usereq.format,
                                                   fstypechangeCB,
                                                   self.mountCombo,
                                                   availablefstypes=restrictfs)
            lbl.set_mnemonic_widget(self.newfstypeCombo)
            maintable.attach(self.newfstypeCombo, 1, 2, row, row + 1)
        else:
            self.newfstypeCombo = None

        row = row + 1

        # allowable drives
        if not self.origrequest.exists:
            lbl = createAlignedLabel(_("Allowable _Drives:"))
            maintable.attach(lbl, 0, 1, row, row + 1)

            req_disk_names = [d.name for d in self.origrequest.req_disks]
            self.driveview = createAllowedDrivesList(
                self.storage.partitioned,
                req_disk_names,
                disallowDrives=[self.anaconda.updateSrc])
            lbl.set_mnemonic_widget(self.driveview)
            sw = gtk.ScrolledWindow()
            sw.add(self.driveview)
            sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
            sw.set_shadow_type(gtk.SHADOW_IN)
            maintable.attach(sw, 1, 2, row, row + 1)
            self.driveview.set_size_request(375, 80)

            row = row + 1

        # original fs type and label
        if self.origrequest.exists:
            maintable.attach(
                createAlignedLabel(_("Original File System Type:")), 0, 1, row,
                row + 1)
            self.fstypeCombo = gtk.Label(usereq.originalFormat.name)

            maintable.attach(self.fstypeCombo, 1, 2, row, row + 1)
            row += 1

            if getattr(usereq.originalFormat, "label", None):
                maintable.attach(
                    createAlignedLabel(_("Original File System "
                                         "Label:")), 0, 1, row, row + 1)
                fslabel = gtk.Label(usereq.originalFormat.label)
                maintable.attach(fslabel, 1, 2, row, row + 1)
                row = row + 1

        # size
        if not self.origrequest.exists:
            # Size specification
            lbl = createAlignedLabel(_("_Size (MB):"))
            maintable.attach(lbl, 0, 1, row, row + 1)
            sizeAdj = gtk.Adjustment(value=1,
                                     lower=1,
                                     upper=MAX_PART_SIZE,
                                     step_incr=1)
            self.sizespin = gtk.SpinButton(sizeAdj, digits=0)
            self.sizespin.set_property('numeric', True)

            if self.origrequest.req_size:
                self.sizespin.set_value(self.origrequest.req_size)

            lbl.set_mnemonic_widget(self.sizespin)
            maintable.attach(self.sizespin, 1, 2, row, row + 1)
        else:
            self.sizespin = None

        row = row + 1

        # format/migrate options for pre-existing partitions, as long as they
        # aren't protected (we'd still like to be able to mount them, though)
        self.fsoptionsDict = {}
        if self.origrequest.exists and \
           not self.origrequest.protected:
            (row, self.fsoptionsDict) = createPreExistFSOptionSection(
                self.origrequest,
                maintable,
                row,
                self.mountCombo,
                self.storage,
                luksdev=luksdev)

        # size options
        if not self.origrequest.exists:
            (sizeframe, self.fixedrb, self.fillmaxszrb,
             self.fillmaxszsb) = self.createSizeOptionsFrame(
                 self.origrequest, self.fillmaxszCB)
            self.sizespin.connect("value-changed", self.sizespinchangedCB,
                                  self.fillmaxszsb)

            maintable.attach(sizeframe, 0, 2, row, row + 1)
            row = row + 1
        else:
            self.sizeoptiontable = None

        # create only as primary
        if not self.origrequest.exists:
            self.primonlycheckbutton = gtk.CheckButton(
                _("Force to be a _primary "
                  "partition"))
            self.primonlycheckbutton.set_active(0)
            if self.origrequest.req_primary:
                self.primonlycheckbutton.set_active(1)

            # only show if we have something other than primary
            if self.storage.extendedPartitionsSupported():
                maintable.attach(self.primonlycheckbutton, 0, 2, row, row + 1)
                row = row + 1

        # checkbutton for encryption using dm-crypt/LUKS
        if not self.origrequest.exists:
            self.lukscb = gtk.CheckButton(_("_Encrypt"))
            self.lukscb.set_data("formatstate", 1)

            if self.origrequest.format.type == "luks":
                self.lukscb.set_active(1)
            else:
                self.lukscb.set_active(0)
            maintable.attach(self.lukscb, 0, 2, row, row + 1)
            row = row + 1

        # put main table into dialog
        self.dialog.vbox.pack_start(maintable)
        self.dialog.show_all()
예제 #53
0
    def _deviceChange(self, b, anaconda, *args):
        def __driveChange(combo, dxml, choices):
            if not choices.has_key("mbr"):
                return

            iter = combo.get_active_iter()
            if not iter:
                return

            first = combo.get_model()[iter][1]
            desc = choices["mbr"][1]
            dxml.get_widget("mbrRadio").set_label("%s - /dev/%s" %
                                                  (_(desc), first))
            dxml.get_widget("mbrRadio").set_data("bootDevice", first)

        def __genStore(combo, disks, active):
            model = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
            combo.set_model(model)
            cell = gtk.CellRendererText()
            combo.pack_start(cell, True)
            combo.set_attributes(cell, text=0)

            for disk in disks:
                i = model.append(None)
                model[i] = ("%s %8.0f MB %s" %
                            (disk.name, disk.size, disk.description),
                            "%s" % (disk.name, ))
                if disk.name == active:
                    combo.set_active_iter(i)

            return model

        (dxml, dialog) = gui.getGladeWidget("blwhere.glade", "blwhereDialog")
        gui.addFrame(dialog)
        dialog.set_transient_for(self.parent)
        dialog.show()

        choices = anaconda.platform.bootloaderChoices(self.bl)
        for t in ("mbr", "boot"):
            if not choices.has_key(t):
                continue
            (device, desc) = choices[t]
            w = dxml.get_widget("%sRadio" % (t, ))
            w.set_label("%s - /dev/%s" % (_(desc), device))
            w.show()
            if self.bldev == device:
                w.set_active(True)
            else:
                w.set_active(False)
            w.set_data("bootDevice", device)

        for i in range(1, 5):
            if len(self.driveorder) < i:
                break
            combo = dxml.get_widget("bd%dCombo" % (i, ))
            lbl = dxml.get_widget("bd%dLabel" % (i, ))
            combo.show()
            lbl.show()
            partitioned = anaconda.storage.partitioned
            disks = anaconda.storage.disks
            bl_disks = [d for d in disks if d in partitioned]
            m = __genStore(combo, bl_disks, self.driveorder[i - 1])

        dxml.get_widget("bd1Combo").connect("changed", __driveChange, dxml,
                                            choices)
        __driveChange(dxml.get_widget("bd1Combo"), dxml, choices)

        while 1:
            rc = dialog.run()
            if rc in [gtk.RESPONSE_CANCEL, gtk.RESPONSE_DELETE_EVENT]:
                break

            # set the boot device based on what they chose
            if dxml.get_widget("bootRadio").get_active():
                self.bldev = dxml.get_widget("bootRadio").get_data(
                    "bootDevice")
            elif dxml.get_widget("mbrRadio").get_active():
                self.bldev = dxml.get_widget("mbrRadio").get_data("bootDevice")
            else:
                raise RuntimeError, "No radio button selected!"

            # and adjust the boot order
            neworder = []
            for i in range(1, 5):
                if len(self.driveorder) < i:
                    break

                combo = dxml.get_widget("bd%dCombo" % (i, ))
                iter = combo.get_active_iter()
                if not iter:
                    continue

                act = combo.get_model()[iter][1]
                if act not in neworder:
                    neworder.append(act)
            for d in self.driveorder:
                if d not in neworder:
                    neworder.append(d)
            self.driveorder = neworder

            break

        dialog.destroy()
        self.grubCB.set_label(
            _("_Install boot loader on /dev/%s.") % (self.bldev, ))
        return rc
예제 #54
0
def whichToShrink(storage, intf):
    def getActive(combo):
        act = combo.get_active_iter()
        return combo.get_model().get_value(act, 1)

    def comboCB(combo, shrinkSB):
        # partition to resize changed, let's update our spinbutton
        newSize = shrinkSB.get_value_as_int()

        part = getActive(combo)
        (reqlower, requpper) = getResizeMinMax(part)

        adj = shrinkSB.get_adjustment()
        adj.lower = max(1,reqlower)
        adj.upper = requpper
        adj.set_value(reqlower)


    (dxml, dialog) = gui.getGladeWidget("autopart.glade", "shrinkDialog")

    store = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_PYOBJECT)
    combo = dxml.get_widget("shrinkPartCombo")
    combo.set_model(store)
    crt = gtk.CellRendererText()
    combo.pack_start(crt, True)
    combo.set_attributes(crt, text = 0)
    combo.connect("changed", comboCB, dxml.get_widget("shrinkSB"))

    biggest = -1
    for part in storage.partitions:
        if not part.exists:
            continue

        entry = None
        if part.resizable and part.format.resizable:
            entry = ("%s (%s, %d MB)" % (part.name,
                                         part.format.name,
                                         math.floor(part.format.size)),
                     part)

        if entry:
            i = store.append(None)
            store[i] = entry
            combo.set_active_iter(i)

            if biggest == -1:
                biggest = i
            else:
                current = store.get_value(biggest, 1)
                if part.format.targetSize > current.format.targetSize:
                    biggest = i

    if biggest > -1:
        combo.set_active_iter(biggest)

    if len(store) == 0:
        dialog.destroy()
        intf.messageWindow(_("Error"),
                           _("No partitions are available to resize.  Only "
                             "physical partitions with specific filesystems "
                             "can be resized."),
                             type="warning", custom_icon="error")
        return (gtk.RESPONSE_CANCEL, [])

    gui.addFrame(dialog)
    dialog.show_all()
    runResize = True

    while runResize:
        rc = dialog.run()
        if rc != gtk.RESPONSE_OK:
            dialog.destroy()
            return (rc, [])

        request = getActive(combo)
        sb = dxml.get_widget("shrinkSB")
        sb.update()
        newSize = sb.get_value_as_int()
        actions = []

        try:
            actions.append(ActionResizeFormat(request, newSize))
        except ValueError as e:
            intf.messageWindow(_("Resize FileSystem Error"),
                               _("%(device)s: %(msg)s")
                                 % {'device': request.format.device,
                                    'msg': e.message},
                               type="warning", custom_icon="error")
            continue

        try:
            actions.append(ActionResizeDevice(request, newSize))
        except ValueError as e:
            intf.messageWindow(_("Resize Device Error"),
                               _("%(name)s: %(msg)s")
                                 % {'name': request.name, 'msg': e.message},
                               type="warning", custom_icon="error")
            continue

        runResize = False

    dialog.destroy()
    return (rc, actions)
예제 #55
0
 def _run_dialog(self, dialog):
     gui.addFrame(dialog)
     dialog.show()
     rc = dialog.run()
     dialog.hide()
     return self._normalize_dialog_response(rc)