示例#1
0
def addIscsiDrive(anaconda, bind=False):
    """
    Displays a series of dialogs that walk the user through discovering and
    logging into iscsi nodes.
    
    Returns gtk.RESPONSE_OK if at least one iscsi node has been logged into.
    """

    # make sure the network is up
    if not network.hasActiveNetDev():
        if not anaconda.intf.enableNetwork():
            log.info("addIscsiDrive(): early exit, network disabled.")
            return gtk.RESPONSE_CANCEL
        urlgrabber.grabber.reset_curl_obj()

    # This will modify behaviour of iscsi.discovery() function
    if storage.iscsi.iscsi().mode == "none" and not bind:
        storage.iscsi.iscsi().delete_interfaces()
    elif (storage.iscsi.iscsi().mode == "none" and bind) \
          or storage.iscsi.iscsi().mode == "bind":
        active = set(network.getActiveNetDevs())
        created = set(storage.iscsi.iscsi().ifaces.values())
        storage.iscsi.iscsi().create_interfaces(active - created)

    wizard = iSCSIGuiWizard()
    login_ok_nodes = pih.drive_iscsi_addition(anaconda, wizard)
    if len(login_ok_nodes):
        return gtk.RESPONSE_OK
    log.info("addIscsiDrive(): no new nodes added")
    return gtk.RESPONSE_CANCEL
示例#2
0
    def _editRepo(self, *args):
        repo = None

        # If we were passed an extra argument, it's the repo store and we
        # are editing an existing repo as opposed to adding a new one.
        if len(args) > 1:
            (model, iter) = args[1].get_selection().get_selected()
            if iter:
                repo = model.get_value(iter, 2)
            else:
                return
        else:
            return

        if repo.needsNetwork() and not network.hasActiveNetDev():
            if not self.anaconda.intf.enableNetwork():
                return gtk.RESPONSE_CANCEL

            urlgrabber.grabber.reset_curl_obj()

        dialog = RepoEditor(self.anaconda, repo)
        dialog.createDialog()
        dialog.run()

        model.set_value(iter, 0, dialog.repo.isEnabled())
        model.set_value(iter, 1, gettext.ldgettext("comps", dialog.repo.name))
        model.set_value(iter, 2, dialog.repo)
示例#3
0
def setupRepo(anaconda, repo):
    if repo.needsNetwork() and not network.hasActiveNetDev():
        if not anaconda.intf.enableNetwork():
            return False
        urlgrabber.grabber.reset_curl_obj()
    try:
        anaconda.backend.doRepoSetup(anaconda,
                                     thisrepo=repo.id,
                                     fatalerrors=False)
        anaconda.backend.doSackSetup(anaconda,
                                     thisrepo=repo.id,
                                     fatalerrors=False)
        log.info("added (UI) repository %s with source URL %s, id:%s" %
                 (repo.name, repo.mirrorlist or repo.baseurl, repo.id))
    except (IOError, yum.Errors.RepoError) as e:
        anaconda.intf.messageWindow(
            _("Error"),
            _("Unable to read package metadata from repository.  "
              "This may be due to a missing repodata directory.  "
              "Please ensure that your repository has been "
              "correctly generated.\n\n%s" % str(e)),
            type="ok",
            custom_icon="error")
        repo.disable()
        repo.close()
        anaconda.backend.ayum.repos.delete(repo.id)
        return False

    return True
    def saveExceptionWindow(self, accountManager, signature, *args, **kwargs):
        from meh.ui.text import SaveExceptionWindow
        import urlgrabber

        if not hasActiveNetDev():
            if self.messageWindow(
                    _("Warning"),
                    _("You do not have an active network connection.  This is "
                      "required by some exception saving methods.  Would you "
                      "like to configure your network now?"),
                    type="yesno"):

                if not self.enableNetwork():
                    self.messageWindow(
                        _("No Network Available"),
                        _("Remote exception saving methods will not work."))
                else:
                    urlgrabber.grabber.reset_curl_obj()

        win = SaveExceptionWindow(accountManager,
                                  signature,
                                  screen=self.screen,
                                  *args,
                                  **kwargs)
        win.run()
示例#5
0
    def _editRepo(self, *args):
        repo = None

        # If we were passed an extra argument, it's the repo store and we
        # are editing an existing repo as opposed to adding a new one.
        if len(args) > 1:
            (model, iter) = args[1].get_selection().get_selected()
            if iter:
                repo = model.get_value(iter, 2)
            else:
                return
        else:
            return

        if repo.needsNetwork() and not network.hasActiveNetDev():
            if not self.anaconda.intf.enableNetwork():
                return gtk.RESPONSE_CANCEL

            urlgrabber.grabber.reset_curl_obj()

        dialog = RepoEditor(self.anaconda, repo)
        dialog.createDialog()
        dialog.run()

        model.set_value(iter, 0, dialog.repo.isEnabled())
        model.set_value(iter, 1, dialog.repo.name)
        model.set_value(iter, 2, dialog.repo)
示例#6
0
    def _repoToggled(self, data, row, store):
        i = store.get_iter(int(row))
        val = store.get_value(i, 0)

        if not val and not network.hasActiveNetDev():
            net = NetworkConfigurator(self.anaconda.id.network)
            ret = net.run()
            net.destroy()
            if ret == gtk.RESPONSE_CANCEL:
                return

        store.set_value(i, 0, not val)
    def _repoToggled(self, data, row, store):
        i = store.get_iter(int(row))
        val = store.get_value(i, 0)

        if not val and not network.hasActiveNetDev():
            net = NetworkConfigurator(self.anaconda.id.network)
            ret = net.run()
            net.destroy()
            if ret == gtk.RESPONSE_CANCEL:
                return
        
        store.set_value(i, 0, not val)
示例#8
0
    def addIscsiDriveDialog(self, screen):
        if not network.hasActiveNetDev():
            ButtonChoiceWindow(
                screen, _("Error"), "Must have a network configuration set up "
                "for iSCSI config.  Please boot with "
                "'linux asknetwork'")
            log.info("addIscsiDriveDialog(): early exit, network disabled.")
            return INSTALL_BACK

        wizard = iSCSITextWizard(screen)
        login_ok_nodes = pih.drive_iscsi_addition(self.anaconda, wizard)
        if len(login_ok_nodes):
            return INSTALL_OK
        log.info("addIscsiDriveDialog(): no new nodes added")
        return INSTALL_BACK
示例#9
0
    def saveExceptionWindow(self, accountManager, signature):
        from meh.ui.gui import SaveExceptionWindow
        import urlgrabber

        if not network.hasActiveNetDev():
            if self.messageWindow(_("Warning"),
                   _("You do not have an active network connection.  This is "
                     "required by some exception saving methods.  Would you "
                     "like to configure your network now?"),
                   type = "yesno"):

                if not self.enableNetwork():
                    self.messageWindow(_("No Network Available"),
                                       _("Remote exception saving methods will not work."))
                else:
                    urlgrabber.grabber.reset_curl_obj()

        win = SaveExceptionWindow (accountManager, signature)
        win.run()
示例#10
0
def setupRepo(anaconda, repo):
    if repo.needsNetwork() and not network.hasActiveNetDev():
        if not anaconda.intf.enableNetwork():
            return False
        urlgrabber.grabber.reset_curl_obj()
    try:
        anaconda.backend.doRepoSetup(anaconda, thisrepo=repo.id, fatalerrors=False)
        anaconda.backend.doSackSetup(anaconda, thisrepo=repo.id, fatalerrors=False)
        log.info("added (UI) repository %s with source URL %s, id:%s" % (repo.name, repo.mirrorlist or repo.baseurl, repo.id))
    except (IOError, yum.Errors.RepoError) as e:
        anaconda.intf.messageWindow(_("Error"),
              _("Unable to read package metadata from repository.  "
                "This may be due to a missing repodata directory.  "
                "Please ensure that your repository has been "
                "correctly generated.\n\n%s" % str(e)),
                                type="ok", custom_icon="error")
        return False

    return True
示例#11
0
    def _applyNfs(self, repo):
        server = self.nfsServerEntry.get_text()
        server.strip()

        path = self.nfsPathEntry.get_text()
        path.strip()

        options = self.nfsOptionsEntry.get_text()
        options.strip()

        repo.name = self.nameEntry.get_text()

        if not server or not path:
            self.intf.messageWindow(_("Error"),
                                    _("Please enter an NFS server and path."))
            return False

        if not network.hasActiveNetDev():
            if not self.anaconda.intf.enableNetwork():
                self.intf.messageWindow(
                    _("No Network Available"),
                    _("Some of your software repositories require "
                      "networking, but there was an error enabling the "
                      "network on your system."))
                return False
            urlgrabber.grabber.reset_curl_obj()

        import tempfile
        dest = tempfile.mkdtemp("", repo.name.replace(" ", ""), "/mnt")

        try:
            isys.mount("%s:%s" % (server, path), dest, "nfs", options=options)
        except Exception as e:
            self.intf.messageWindow(
                _("Error Setting Up Repository"),
                _("The following error occurred while setting up the "
                  "repository:\n\n%s") % e)
            return False

        repo.baseurl = "file://%s" % dest
        repo.anacondaBaseURLs = ["nfs:%s:%s:%s" % (options, server, path)]
        return True
示例#12
0
    def _repoToggled(self, button, row, store):
        i = store.get_iter(int(row))
        wasChecked = store.get_value(i, 0)
        repo = store.get_value(i, 2)

        if not wasChecked:
            if repo.needsNetwork() and not network.hasActiveNetDev():
                if not self.anaconda.intf.enableNetwork():
                    return

                urlgrabber.grabber.reset_curl_obj()

            repo.enable()
            if not setupRepo(self.anaconda, repo):
                return
        else:
            repo.disable()
            repo.close()

        store.set_value(i, 0, not wasChecked)
示例#13
0
    def _repoToggled(self, button, row, store):
        i = store.get_iter(int(row))
        wasChecked = store.get_value(i, 0)
        repo = store.get_value(i, 2)

        if not wasChecked:
            if repo.needsNetwork() and not network.hasActiveNetDev():
                if not self.anaconda.intf.enableNetwork():
                    return

                urlgrabber.grabber.reset_curl_obj()

            repo.enable()
            if not setupRepo(self.anaconda, repo):
                return
        else:
            repo.disable()
            repo.close()

        store.set_value(i, 0, not wasChecked)
示例#14
0
    def addIscsiDriveDialog(self, screen):
        if not network.hasActiveNetDev():
            ButtonChoiceWindow(screen, _("Error"),
                               "Must have a network configuration set up "
                               "for iSCSI config.  Please boot with "
                               "'linux asknetwork'")
            return INSTALL_BACK
        
        (button, entries) = EntryWindow(screen,
                                        _("Configure iSCSI Parameters"),
                                        _("To use iSCSI disks, you must provide the address of your iSCSI target and the iSCSI initiator name you've configured for your host."),
                                        prompts = [ _("Target IP Address"),
                                                    _("iSCSI Initiator Name"),
                                                    _("CHAP username"),
                                                    _("CHAP password"),
                                                    _("Reverse CHAP username"),
                                                    _("Reverse CHAP password") ])
        if button == TEXT_CANCEL_CHECK:
            return INSTALL_BACK

        (user, pw, user_in, pw_in) = entries[2:]

        target = entries[0].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, msg:
            raise ValueError, msg
示例#15
0
def addIscsiDrive(anaconda):
    """
    Displays a series of dialogs that walk the user through discovering and
    logging into iscsi nodes.
    
    Returns gtk.RESPONSE_OK if at least one iscsi node has been logged into.
    """

    # make sure the network is up
    if not network.hasActiveNetDev():
        if not anaconda.intf.enableNetwork():
            log.info("addIscsiDrive(): early exit, network disabled.")
            return gtk.RESPONSE_CANCEL
        urlgrabber.grabber.reset_curl_obj()

    wizard = iSCSIGuiWizard()
    login_ok_nodes = pih.drive_iscsi_addition(anaconda, wizard)
    if len(login_ok_nodes):
        return gtk.RESPONSE_OK
    log.info("addIscsiDrive(): no new nodes added")
    return gtk.RESPONSE_CANCEL
示例#16
0
    def _applyNfs(self, repo):
        server = self.nfsServerEntry.get_text()
        server.strip()

        path = self.nfsPathEntry.get_text()
        path.strip()

        options = self.nfsOptionsEntry.get_text()
        options.strip()

        repo.name = self.nameEntry.get_text()

        if not server or not path:
            self.intf.messageWindow(_("Error"),
                                    _("Please enter an NFS server and path."))
            return False

        if not network.hasActiveNetDev():
            if not self.anaconda.intf.enableNetwork():
                self.intf.messageWindow(_("No Network Available"),
                    _("Some of your software repositories require "
                      "networking, but there was an error enabling the "
                      "network on your system."))
                return False
            urlgrabber.grabber.reset_curl_obj()

        import tempfile
        dest = tempfile.mkdtemp("", repo.name.replace(" ", ""), "/mnt")

        try:
            isys.mount("%s:%s" % (server, path), dest, "nfs", options=options)
        except Exception as e:
            self.intf.messageWindow(_("Error Setting Up Repository"),
                _("The following error occurred while setting up the "
                  "repository:\n\n%s") % e)
            return False

        repo.baseurl = "file://%s" % dest
        repo.anacondaBaseURLs = ["nfs:%s:%s:%s" % (options,server,path)]
        return True
    def addIscsiDriveDialog(self, screen, bind=False):
        if not network.hasActiveNetDev():
            ButtonChoiceWindow(
                screen, _("Error"), "Must have a network configuration set up "
                "for iSCSI config.  Please boot with "
                "'linux asknetwork'")
            log.info("addIscsiDriveDialog(): early exit, network disabled.")
            return INSTALL_BACK

        # This will modify behaviour of iscsi.discovery() function
        if storage.iscsi.iscsi().mode == "none" and not bind:
            storage.iscsi.iscsi().delete_interfaces()
        elif (storage.iscsi.iscsi().mode == "none" and bind) \
              or storage.iscsi.iscsi().mode == "bind":
            active = set(network.getActiveNetDevs())
            created = set(storage.iscsi.iscsi().ifaces.values())
            storage.iscsi.iscsi().create_interfaces(active - created)

        wizard = iSCSITextWizard(screen)
        login_ok_nodes = pih.drive_iscsi_addition(self.anaconda, wizard)
        if len(login_ok_nodes):
            return INSTALL_OK
        log.info("addIscsiDriveDialog(): no new nodes added")
        return INSTALL_BACK
示例#18
0
    def addIscsiDriveDialog(self, screen, bind=False):
        if not network.hasActiveNetDev():
            ButtonChoiceWindow(screen, _("Error"),
                               "Must have a network configuration set up "
                               "for iSCSI config.  Please boot with "
                               "'linux asknetwork'")
            log.info("addIscsiDriveDialog(): early exit, network disabled.")
            return INSTALL_BACK

        # This will modify behaviour of iscsi.discovery() function
        if storage.iscsi.iscsi().mode == "none" and not bind:
            storage.iscsi.iscsi().delete_interfaces()
        elif (storage.iscsi.iscsi().mode == "none" and bind) \
              or storage.iscsi.iscsi().mode == "bind":
            active = set(network.getActiveNetDevs())
            created = set(storage.iscsi.iscsi().ifaces.values())
            storage.iscsi.iscsi().create_interfaces(active - created)

        wizard = iSCSITextWizard(screen)
        login_ok_nodes = pih.drive_iscsi_addition(self.anaconda, wizard)
        if len(login_ok_nodes):
            return INSTALL_OK
        log.info("addIscsiDriveDialog(): no new nodes added")
        return INSTALL_BACK
示例#19
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
示例#20
0
def runRescue(anaconda, instClass):
    for file in [ "services", "protocols", "group", "joe", "man.config",
                  "nsswitch.conf", "selinux", "mke2fs.conf" ]:
        try:
            os.symlink('/mnt/runtime/etc/' + file, '/etc/' + file)
        except:
            pass

    # see if they would like networking enabled
    if not network.hasActiveNetDev():
        screen = SnackScreen()

        while True:
            rc = ButtonChoiceWindow(screen, _("Setup Networking"),
                _("Do you want to start the network interfaces on "
                  "this system?"), [_("Yes"), _("No")])

            if rc != string.lower(_("No")):
                anaconda.intf = RescueInterface(screen)

                if not anaconda.intf.enableNetwork(anaconda):
                    anaconda.intf.messageWindow(_("No Network Available"),
                        _("Unable to activate a networking device.  Networking "
                          "will not be available in rescue mode."))
                    break

                startNetworking(anaconda.id.network, anaconda.intf)
                break
            else:
                break

        anaconda.intf = None
        screen.finish()

    # Early shell access with no disk access attempts
    if not anaconda.rescue_mount:
        # the %post should be responsible for mounting all needed file systems
        # NOTE: 1st script must be bash or simple python as nothing else might be available in the rescue image
        if anaconda.isKickstart and anaconda.id.ksdata.scripts:
           from kickstart import runPostScripts
           runPostScripts(anaconda)
        else:
           runShell()

        sys.exit(0)

    screen = SnackScreen()
    anaconda.intf = RescueInterface(screen)

    if anaconda.isKickstart:
        if anaconda.id.ksdata.rescue and anaconda.id.ksdata.rescue.romount:
            readOnly = 1
        else:
            readOnly = 0
    else:
        # prompt to see if we should try and find root filesystem and mount
        # everything in /etc/fstab on that root
        while True:
            rc = ButtonChoiceWindow(screen, _("Rescue"),
                _("The rescue environment will now attempt to find your "
                  "Linux installation and mount it under the directory "
                  "%s.  You can then make any changes required to your "
                  "system.  If you want to proceed with this step choose "
                  "'Continue'.  You can also choose to mount your file systems "
                  "read-only instead of read-write by choosing 'Read-Only'.  "
                  "If you need to activate SAN devices choose 'Advanced'."
                  "\n\n"
                  "If for some reason this process fails you can choose 'Skip' "
                  "and this step will be skipped and you will go directly to a "
                  "command shell.\n\n") % (anaconda.rootPath,),
                  [_("Continue"), _("Read-Only"), _("Skip"), _("Advanced")] )

            if rc == string.lower(_("Skip")):
                runShell(screen)
                sys.exit(0)
            elif rc == string.lower(_("Advanced")):
                addDialog = addDriveDialog(anaconda)
                addDialog.addDriveDialog(screen)
                continue
            elif rc == string.lower(_("Read-Only")):
                readOnly = 1
            else:
                readOnly = 0
            break

    import storage
    storage.storageInitialize(anaconda)

    disks = upgrade.findExistingRoots(anaconda, upgradeany=True)

    if not disks:
        root = None
    elif (len(disks) == 1) or anaconda.isKickstart:
        root = disks[0]
    else:
        height = min (len (disks), 12)
        if height == 12:
            scroll = 1
        else:
            scroll = 0

        devList = []
        for (device, relstr) in disks:
            if getattr(device.format, "label", None):
                devList.append("%s (%s) - %s" % (device.name, device.format.label, relstr))
            else:
                devList.append("%s - %s" % (device.name, relstr))

        (button, choice) = \
            ListboxChoiceWindow(screen, _("System to Rescue"),
                                _("Which device holds the root partition "
                                  "of your installation?"), devList,
                                [ _("OK"), _("Exit") ], width = 30,
                                scroll = scroll, height = height,
                                help = "multipleroot")

        if button == string.lower (_("Exit")):
            root = None
        else:
            root = disks[choice]

    rootmounted = 0

    if root:
        try:
            rc = mountExistingSystem(anaconda, root,
                                     allowDirty = 1, warnDirty = 1,
                                     readOnly = readOnly)

            if rc == -1:
                if anaconda.isKickstart:
                    log.error("System had dirty file systems which you chose not to mount")
                else:
                    ButtonChoiceWindow(screen, _("Rescue"),
                        _("Your system had dirty file systems which you chose not "
                          "to mount.  Press return to get a shell from which "
                          "you can fsck and mount your partitions.  The system "
                          "will reboot automatically when you exit from the "
                          "shell."), [_("OK")], width = 50)
                rootmounted = 0
            else:
                if anaconda.isKickstart:
                    log.info("System has been mounted under: %s" % anaconda.rootPath)
                else:
                    ButtonChoiceWindow(screen, _("Rescue"),
                       _("Your system has been mounted under %(rootPath)s.\n\n"
                         "Press <return> to get a shell. If you would like to "
                         "make your system the root environment, run the command:\n\n"
                         "\tchroot %(rootPath)s\n\nThe system will reboot "
                         "automatically when you exit from the shell.") %
                                       {'rootPath': anaconda.rootPath},
                                       [_("OK")] )
                rootmounted = 1

                # now turn on swap
                if not readOnly:
                    try:
                        anaconda.id.storage.turnOnSwap()
                    except:
                        log.error("Error enabling swap")

                # and /selinux too
                if flags.selinux and os.path.isdir("%s/selinux" %(anaconda.rootPath,)):
                    try:
                        isys.mount("/selinux", "%s/selinux" %(anaconda.rootPath,),
                                   "selinuxfs")
                    except Exception, e:
                        log.error("error mounting selinuxfs: %s" %(e,))

                    fd = open("%s/.autorelabel" % anaconda.rootPath, "w+")
                    fd.close()

                # set a library path to use mounted fs
                libdirs = os.environ["LD_LIBRARY_PATH"].split(":")
                mounted = map(lambda dir: "/mnt/sysimage%s" % dir, libdirs)
                os.environ["LD_LIBRARY_PATH"] = ":".join(libdirs + mounted)

                # find groff data dir
                try:
                    glst = os.listdir("/mnt/sysimage/usr/share/groff")

                    # find a directory which is a numeral, its where
                    # data files are
                    gversion = None
                    for gdir in glst:
                        try:
                            isone = 1
                            for idx in range(0, len(gdir)):
                                if string.find(string.digits + '.', gdir[idx]) == -1:
                                    isone = 0
                                    break
                            if isone:
                                gversion = gdir
                                break
                        except:
                            gversion = None
                            continue
                except:
                    gversion = None

                if gversion is not None:
                    gpath = "/mnt/sysimage/usr/share/groff/"+gversion
                    os.environ["GROFF_FONT_PATH"] = gpath + '/font'
                    os.environ["GROFF_TMAC_PATH"] = "%s:/mnt/sysimage/usr/share/groff/site-tmac" % (gpath + '/tmac',)

                # do we have bash?
                try:
                    if os.access("/usr/bin/bash", os.R_OK):
                        os.symlink ("/usr/bin/bash", "/bin/bash")
                except:
                    pass
        except:
            # This looks horrible, but all it does is catch every exception,
            # and reraise those in the tuple check. This lets programming
            # errors raise exceptions, while any runtime error will
            # still result in a shell
            (exc, val) = sys.exc_info()[0:2]
            log.error(str(exc)+": "+str(val))
            if exc in (IndexError, ValueError, SyntaxError):
                raise exc, val, sys.exc_info()[2]

            if anaconda.isKickstart:
                log.error("An error occurred trying to mount some or all of your system")
            else:
                ButtonChoiceWindow(screen, _("Rescue"),
                    _("An error occurred trying to mount some or all of your "
                      "system. Some of it may be mounted under %s.\n\n"
                      "Press <return> to get a shell. The system will reboot "
                      "automatically when you exit from the shell.") % (anaconda.rootPath,),
                      [_("OK")] )
    else:
        if anaconda.isKickstart and \
               anaconda.id.ksdata.reboot.action in [KS_REBOOT, KS_SHUTDOWN]:
            log.info("No Linux partitions found")
            screen.finish()
            print(_("You don't have any Linux partitions.  Rebooting.\n"))
            sys.exit(0)
        else:
            ButtonChoiceWindow(screen, _("Rescue Mode"),
                               _("You don't have any Linux partitions. Press "
                                 "return to get a shell. The system will reboot "
                                 "automatically when you exit from the shell."),
                               [ _("OK") ], width = 50)

    msgStr = ""

    if rootmounted and not readOnly:
        makeMtab(anaconda.rootPath, anaconda.id.storage)
        try:
            makeResolvConf(anaconda.rootPath)
        except Exception, e:
            log.error("error making a resolv.conf: %s" %(e,))
        msgStr = _("Your system is mounted under the %s directory.") % (anaconda.rootPath,)
        ButtonChoiceWindow(screen, _("Rescue"), msgStr, [_("OK")] )
    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
示例#22
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
示例#23
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
示例#24
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 in [gtk.RESPONSE_CANCEL, gtk.RESPONSE_DELETE_EVENT]:
                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
示例#25
0
 def _setupNetwork(self, *args):
     self.intf.enableNetwork(just_setup=True)
     if network.hasActiveNetDev():
         urlgrabber.grabber.reset_curl_obj()
示例#26
0
def doRescue(anaconda):
    for file in [ "services", "protocols", "group", "joe", "man.config",
                  "nsswitch.conf", "selinux", "mke2fs.conf" ]:
        try:
            os.symlink('/mnt/runtime/etc/' + file, '/etc/' + file)
        except OSError:
            pass

    # see if they would like networking enabled
    if not network.hasActiveNetDev():

        while True:
            rc = ButtonChoiceWindow(anaconda.intf.screen, _("Setup Networking"),
                _("Do you want to start the network interfaces on "
                  "this system?"), [_("Yes"), _("No")])

            if rc != _("No").lower():
                if not anaconda.intf.enableNetwork(anaconda):
                    anaconda.intf.messageWindow(_("No Network Available"),
                        _("Unable to activate a networking device.  Networking "
                          "will not be available in rescue mode."))
                    break

                startNetworking(anaconda.network, anaconda.intf)
                break
            else:
                break

    # shutdown the interface now
    anaconda.intf.shutdown()
    anaconda.intf = None

    # Early shell access with no disk access attempts
    if not anaconda.rescue_mount:
        # the %post should be responsible for mounting all needed file systems
        # NOTE: 1st script must be bash or simple python as nothing else might be available in the rescue image
        if anaconda.ksdata and anaconda.ksdata.scripts:
           from kickstart import runPostScripts
           runPostScripts(anaconda)
        else:
           runShell()

        sys.exit(0)

    anaconda.intf = RescueInterface()

    if anaconda.ksdata:
        if anaconda.ksdata.rescue and anaconda.ksdata.rescue.romount:
            readOnly = 1
        else:
            readOnly = 0
    else:
        # prompt to see if we should try and find root filesystem and mount
        # everything in /etc/fstab on that root
        while True:
            rc = ButtonChoiceWindow(anaconda.intf.screen, _("Rescue"),
                _("The rescue environment will now attempt to find your "
                  "Linux installation and mount it under the directory "
                  "%s.  You can then make any changes required to your "
                  "system.  If you want to proceed with this step choose "
                  "'Continue'.  You can also choose to mount your file systems "
                  "read-only instead of read-write by choosing 'Read-Only'.  "
                  "If you need to activate SAN devices choose 'Advanced'."
                  "\n\n"
                  "If for some reason this process fails you can choose 'Skip' "
                  "and this step will be skipped and you will go directly to a "
                  "command shell.\n\n") % (ROOT_PATH,),
                  [_("Continue"), _("Read-Only"), _("Skip"), _("Advanced")] )

            if rc == _("Skip").lower():
                runShell(anaconda.intf.screen)
                sys.exit(0)
            elif rc == _("Advanced").lower():
                addDialog = addDriveDialog(anaconda)
                addDialog.addDriveDialog(anaconda.intf.screen)
                continue
            elif rc == _("Read-Only").lower():
                readOnly = 1
            else:
                readOnly = 0
            break

    import storage
    storage.storageInitialize(anaconda)

    (disks, notUpgradable) = storage.findExistingRootDevices(anaconda, upgradeany=True)

    if not disks:
        root = None
    elif (len(disks) == 1) or anaconda.ksdata:
        root = disks[0]
    else:
        height = min (len (disks), 12)
        if height == 12:
            scroll = 1
        else:
            scroll = 0

        devList = []
        for (device, relstr) in disks:
            if getattr(device.format, "label", None):
                devList.append("%s (%s) - %s" % (device.name, device.format.label, relstr))
            else:
                devList.append("%s - %s" % (device.name, relstr))

        (button, choice) = \
            ListboxChoiceWindow(anaconda.intf.screen, _("System to Rescue"),
                                _("Which device holds the root partition "
                                  "of your installation?"), devList,
                                [ _("OK"), _("Exit") ], width = 30,
                                scroll = scroll, height = height,
                                help = "multipleroot")

        if button == _("Exit").lower():
            root = None
        else:
            root = disks[choice]

    rootmounted = 0

    if root:
        try:
            rc = mountExistingSystem(anaconda, root,
                                     allowDirty = 1, warnDirty = 1,
                                     readOnly = readOnly)

            if not flags.imageInstall:
                msg = _("The system will reboot automatically when you exit "
                        "from the shell.")
            else:
                msg = _("Run %s to unmount the system "
                        "when you are finished.") % ANACONDA_CLEANUP

            if rc == -1:
                if anaconda.ksdata:
                    log.error("System had dirty file systems which you chose not to mount")
                else:
                    ButtonChoiceWindow(anaconda.intf.screen, _("Rescue"),
                        _("Your system had dirty file systems which you chose not "
                          "to mount.  Press return to get a shell from which "
                          "you can fsck and mount your partitions. %s") % msg,
                        [_("OK")], width = 50)
                rootmounted = 0
            else:
                if anaconda.ksdata:
                    log.info("System has been mounted under: %s" % ROOT_PATH)
                else:
                    ButtonChoiceWindow(anaconda.intf.screen, _("Rescue"),
                       _("Your system has been mounted under %(rootPath)s.\n\n"
                         "Press <return> to get a shell. If you would like to "
                         "make your system the root environment, run the command:\n\n"
                         "\tchroot %(rootPath)s\n\n%(msg)s") %
                                       {'rootPath': ROOT_PATH,
                                        'msg': msg},
                                       [_("OK")] )
                rootmounted = 1

                # now turn on swap
                if not readOnly:
                    try:
                        anaconda.storage.turnOnSwap()
                    except StorageError:
                        log.error("Error enabling swap")

                # and selinux too
                if flags.selinux:
                    # we have to catch the possible exception
                    # because we support read-only mounting
                    try:
                        fd = open("%s/.autorelabel" % ROOT_PATH, "w+")
                        fd.close()
                    except IOError:
                        log.warning("cannot touch /.autorelabel")

                # set a library path to use mounted fs
                libdirs = os.environ.get("LD_LIBRARY_PATH", "").split(":")
                mounted = map(lambda dir: "/mnt/sysimage%s" % dir, libdirs)
                os.environ["LD_LIBRARY_PATH"] = ":".join(libdirs + mounted)

                # find groff data dir
                gversion = None
                try:
                    glst = os.listdir("/mnt/sysimage/usr/share/groff")
                except OSError:
                    pass
                else:
                    # find a directory which is a numeral, its where
                    # data files are
                    for gdir in glst:
                        if re.match(r'\d[.\d]+\d$', gdir):
                            gversion = gdir
                            break

                if gversion is not None:
                    gpath = "/mnt/sysimage/usr/share/groff/"+gversion
                    os.environ["GROFF_FONT_PATH"] = gpath + '/font'
                    os.environ["GROFF_TMAC_PATH"] = "%s:/mnt/sysimage/usr/share/groff/site-tmac" % (gpath + '/tmac',)

                # do we have bash?
                try:
                    if os.access("/usr/bin/bash", os.R_OK):
                        os.symlink ("/usr/bin/bash", "/bin/bash")
                except OSError:
                    pass
        except (ValueError, LookupError, SyntaxError, NameError):
            raise
        except Exception as e:
            log.error("doRescue caught exception: %s" % e)
            if anaconda.ksdata:
                log.error("An error occurred trying to mount some or all of your system")
            else:
                if not flags.imageInstall:
                    msg = _("The system will reboot automatically when you "
                            "exit from the shell.")
                else:
                    msg = _("Run %s to unmount the system "
                            "when you are finished.") % ANACONDA_CLEANUP

                ButtonChoiceWindow(anaconda.intf.screen, _("Rescue"),
                    _("An error occurred trying to mount some or all of your "
                      "system. Some of it may be mounted under %s.\n\n"
                      "Press <return> to get a shell.") % ROOT_PATH + msg,
                      [_("OK")] )
    else:
        if anaconda.ksdata and \
               anaconda.ksdata.reboot.action in [KS_REBOOT, KS_SHUTDOWN]:
            log.info("No Linux partitions found")
            anaconda.intf.screen.finish()
            print(_("You don't have any Linux partitions.  Rebooting.\n"))
            sys.exit(0)
        else:
            if not flags.imageInstall:
                msg = _(" The system will reboot automatically when you exit "
                        "from the shell.")
            else:
                msg = ""
            ButtonChoiceWindow(anaconda.intf.screen, _("Rescue Mode"),
                               _("You don't have any Linux partitions. Press "
                                 "return to get a shell.%s") % msg,
                               [ _("OK") ], width = 50)

    msgStr = ""

    if rootmounted and not readOnly:
        anaconda.storage.makeMtab()
        try:
            makeResolvConf(ROOT_PATH)
        except (OSError, IOError) as e:
            log.error("error making a resolv.conf: %s" %(e,))
        msgStr = _("Your system is mounted under the %s directory.") % (ROOT_PATH,)
        ButtonChoiceWindow(anaconda.intf.screen, _("Rescue"), msgStr, [_("OK")] )

    # we do not need ncurses anymore, shut them down
    anaconda.intf.shutdown()

    #create /etc/fstab in ramdisk, so it is easier to work with RO mounted filesystems
    makeFStab()

    # run %post if we've mounted everything
    if rootmounted and not readOnly and anaconda.ksdata:
        from kickstart import runPostScripts
        runPostScripts(anaconda)

    # start shell if reboot wasn't requested
    if not anaconda.ksdata or \
           not anaconda.ksdata.reboot.action in [KS_REBOOT, KS_SHUTDOWN]:
        runShell(msg=msgStr)

    sys.exit(0)
示例#27
0
def runRescue(anaconda):
    for file in [ "services", "protocols", "group", "joe", "man.config",
                  "nsswitch.conf", "selinux", "mke2fs.conf" ]:
        try:
            os.symlink('/mnt/runtime/etc/' + file, '/etc/' + file)
        except:
            pass

    # see if they would like networking enabled
    if not network.hasActiveNetDev():
        screen = SnackScreen()

        while True:
            rc = ButtonChoiceWindow(screen, _("Setup Networking"),
                _("Do you want to start the network interfaces on "
                  "this system?"), [_("Yes"), _("No")])

            if rc != string.lower(_("No")):
                anaconda.intf = RescueInterface(screen)

                if not anaconda.intf.enableNetwork(anaconda):
                    anaconda.intf.messageWindow(_("No Network Available"),
                        _("Unable to activate a networking device.  Networking "
                          "will not be available in rescue mode."))
                    break

                startNetworking(anaconda.network, anaconda.intf)
                break
            else:
                break

        anaconda.intf = None
        screen.finish()

    # Early shell access with no disk access attempts
    if not anaconda.rescue_mount:
        # the %post should be responsible for mounting all needed file systems
        # NOTE: 1st script must be bash or simple python as nothing else might be available in the rescue image
        if anaconda.ksdata and anaconda.ksdata.scripts:
           from kickstart import runPostScripts
           runPostScripts(anaconda)
        else:
           runShell()

        sys.exit(0)

    screen = SnackScreen()
    anaconda.intf = RescueInterface(screen)

    if anaconda.ksdata:
        if anaconda.ksdata.rescue and anaconda.ksdata.rescue.romount:
            readOnly = 1
        else:
            readOnly = 0
    else:
        # prompt to see if we should try and find root filesystem and mount
        # everything in /etc/fstab on that root
        while True:
            rc = ButtonChoiceWindow(screen, _("Rescue"),
                _("The rescue environment will now attempt to find your "
                  "Linux installation and mount it under the directory "
                  "%s.  You can then make any changes required to your "
                  "system.  If you want to proceed with this step choose "
                  "'Continue'.  You can also choose to mount your file systems "
                  "read-only instead of read-write by choosing 'Read-Only'.  "
                  "If you need to activate SAN devices choose 'Advanced'."
                  "\n\n"
                  "If for some reason this process fails you can choose 'Skip' "
                  "and this step will be skipped and you will go directly to a "
                  "command shell.\n\n") % (anaconda.rootPath,),
                  [_("Continue"), _("Read-Only"), _("Skip"), _("Advanced")] )

            if rc == string.lower(_("Skip")):
                runShell(screen)
                sys.exit(0)
            elif rc == string.lower(_("Advanced")):
                addDialog = addDriveDialog(anaconda)
                addDialog.addDriveDialog(screen)
                continue
            elif rc == string.lower(_("Read-Only")):
                readOnly = 1
            else:
                readOnly = 0
            break

    import storage
    storage.storageInitialize(anaconda)

    (disks, notUpgradable) = upgrade.findExistingRoots(anaconda, upgradeany=True)

    if not disks:
        root = None
    elif (len(disks) == 1) or anaconda.ksdata:
        root = disks[0]
    else:
        height = min (len (disks), 12)
        if height == 12:
            scroll = 1
        else:
            scroll = 0

        devList = []
        for (device, relstr) in disks:
            if getattr(device.format, "label", None):
                devList.append("%s (%s) - %s" % (device.name, device.format.label, relstr))
            else:
                devList.append("%s - %s" % (device.name, relstr))

        (button, choice) = \
            ListboxChoiceWindow(screen, _("System to Rescue"),
                                _("Which device holds the root partition "
                                  "of your installation?"), devList,
                                [ _("OK"), _("Exit") ], width = 30,
                                scroll = scroll, height = height,
                                help = "multipleroot")

        if button == string.lower (_("Exit")):
            root = None
        else:
            root = disks[choice]

    rootmounted = 0

    if root:
        try:
            rc = mountExistingSystem(anaconda, root,
                                     allowDirty = 1, warnDirty = 1,
                                     readOnly = readOnly)

            if rc == -1:
                if anaconda.ksdata:
                    log.error("System had dirty file systems which you chose not to mount")
                else:
                    ButtonChoiceWindow(screen, _("Rescue"),
                        _("Your system had dirty file systems which you chose not "
                          "to mount.  Press return to get a shell from which "
                          "you can fsck and mount your partitions.  The system "
                          "will reboot automatically when you exit from the "
                          "shell."), [_("OK")], width = 50)
                rootmounted = 0
            else:
                if anaconda.ksdata:
                    log.info("System has been mounted under: %s" % anaconda.rootPath)
                else:
                    ButtonChoiceWindow(screen, _("Rescue"),
                       _("Your system has been mounted under %(rootPath)s.\n\n"
                         "Press <return> to get a shell. If you would like to "
                         "make your system the root environment, run the command:\n\n"
                         "\tchroot %(rootPath)s\n\nThe system will reboot "
                         "automatically when you exit from the shell.") %
                                       {'rootPath': anaconda.rootPath},
                                       [_("OK")] )
                rootmounted = 1

                # now turn on swap
                if not readOnly:
                    try:
                        anaconda.storage.turnOnSwap()
                    except:
                        log.error("Error enabling swap")

                # and /sys/fs/selinux too
                if flags.selinux and os.path.isdir("%s/sys/fs/selinux" %(anaconda.rootPath,)):
                    try:
                        isys.mount("/sys/fs/selinux", "%s/sys/fs/selinux" %(anaconda.rootPath,),
                                   "selinuxfs")
                    except Exception, e:
                        log.error("error mounting selinuxfs: %s" %(e,))

                    # we have to catch the possible exception
                    # because we support read-only mounting
                    try:
                        fd = open("%s/.autorelabel" % anaconda.rootPath, "w+")
                        fd.close()
                    except Exception, e:
                        log.warning("cannot touch /.autorelabel")

                # set a library path to use mounted fs
                libdirs = os.environ["LD_LIBRARY_PATH"].split(":")
                mounted = map(lambda dir: "/mnt/sysimage%s" % dir, libdirs)
                os.environ["LD_LIBRARY_PATH"] = ":".join(libdirs + mounted)

                # find groff data dir
                try:
                    glst = os.listdir("/mnt/sysimage/usr/share/groff")

                    # find a directory which is a numeral, its where
                    # data files are
                    gversion = None
                    for gdir in glst:
                        try:
                            isone = 1
                            for idx in range(0, len(gdir)):
                                if string.find(string.digits + '.', gdir[idx]) == -1:
                                    isone = 0
                                    break
                            if isone:
                                gversion = gdir
                                break
                        except:
                            gversion = None
                            continue
                except:
                    gversion = None

                if gversion is not None:
                    gpath = "/mnt/sysimage/usr/share/groff/"+gversion
                    os.environ["GROFF_FONT_PATH"] = gpath + '/font'
                    os.environ["GROFF_TMAC_PATH"] = "%s:/mnt/sysimage/usr/share/groff/site-tmac" % (gpath + '/tmac',)

                # do we have bash?
                try:
                    if os.access("/usr/bin/bash", os.R_OK):
                        os.symlink ("/usr/bin/bash", "/bin/bash")
                except:
                    pass
示例#28
0
def setupNetwork(intf):
    intf.enableNetwork(just_setup=True)
    if network.hasActiveNetDev():
        urlgrabber.grabber.reset_curl_obj()
def askVncWindow(title=None, message=None):
    if not os.access('/usr/bin/Xvnc', os.X_OK):
        return -1

    if not network.hasActiveNetDev():
        return -1

    if not title:
        title = _("Unable to Start X")
    if not message:
        message = _("X was unable to start on your "
                    "machine.  Would you like to "
                    "start VNC to connect to "
                    "this computer from another "
                    "computer and perform a "
                    "graphical install or continue "
                    "with a text mode install?")

    screen = SnackScreen()
    vncpass = None
    vncconnect = 0

    STEP_MESSAGE = 0
    STEP_PASS = 1
    STEP_DONE = 3
    step = 0
    while step < STEP_DONE:
        if step == STEP_MESSAGE:
            button = ButtonChoiceWindow(
                screen,
                title,
                message,
                buttons=[_("Start VNC"), _("Use text mode")])

            if button == string.lower(_("Use text mode")):
                screen.finish()
                return -1
            else:
                step = STEP_PASS
                continue

        if step == STEP_PASS:
            grid = GridFormHelp(screen, _("VNC Configuration"), "vnc", 1, 10)

            bb = ButtonBar(screen,
                           (TEXT_OK_BUTTON,
                            (_("No password"), "nopass"), TEXT_BACK_BUTTON))

            text = _("A password will prevent unauthorized listeners "
                     "connecting and monitoring your installation progress.  "
                     "Please enter a password to be used for the installation")
            grid.add(TextboxReflowed(40, text), 0, 0, (0, 0, 0, 1))

            entry1 = Entry(16, password=1)
            entry2 = Entry(16, password=1)
            passgrid = Grid(2, 2)
            passgrid.setField(Label(_("Password:"******"Password (confirm):")),
                              0,
                              1, (0, 0, 1, 0),
                              anchorLeft=1)
            passgrid.setField(entry1, 1, 0)
            passgrid.setField(entry2, 1, 1)
            grid.add(passgrid, 0, 1, (0, 0, 0, 1))

            grid.add(bb, 0, 8, (0, 1, 1, 0), growx=1)

            while 1:
                res = grid.run()
                rc = bb.buttonPressed(res)

                if rc == TEXT_BACK_CHECK:
                    screen.popWindow()
                    step = STEP_MESSAGE
                    break
                elif rc == "nopass":
                    screen.finish()
                    return None
                else:
                    pw = entry1.value()
                    cf = entry2.value()
                    if pw != cf:
                        ButtonChoiceWindow(screen,
                                           _("Password Mismatch"),
                                           _("The passwords you entered were "
                                             "different. Please try again."),
                                           buttons=[TEXT_OK_BUTTON],
                                           width=50)
                    elif len(pw) < 6:
                        ButtonChoiceWindow(screen,
                                           _("Password Length"),
                                           _("The password must be at least "
                                             "six characters long."),
                                           buttons=[TEXT_OK_BUTTON],
                                           width=50)
                    else:
                        screen.finish()
                        return pw

                    entry1.set("")
                    entry2.set("")
                    continue
                continue

    screen.finish()
    return -1
示例#30
0
def setupNetwork(intf):
    intf.enableNetwork(just_setup=True)
    if network.hasActiveNetDev():
        urlgrabber.grabber.reset_curl_obj()
示例#31
0
def askVncWindow(title = None, message = None):
    if not os.access('/usr/bin/Xvnc', os.X_OK):
        return -1

    if not network.hasActiveNetDev():
        return -1

    if not title:
        title = _("Unable to Start X")
    if not message:
        message = _("X was unable to start on your "
                    "machine.  Would you like to "
                    "start VNC to connect to "
                    "this computer from another "
                    "computer and perform a "
                    "graphical install or continue "
                    "with a text mode install?")

    screen = SnackScreen()
    vncpass = None
    vncconnect = 0

    STEP_MESSAGE = 0
    STEP_PASS = 1
    STEP_DONE = 3
    step = 0
    while step < STEP_DONE:
        if step == STEP_MESSAGE:
            button = ButtonChoiceWindow(screen, title, message,
                                        buttons = [ _("Start VNC"),
                                                    _("Use text mode") ])

	    if button == string.lower (_("Use text mode")):
                screen.finish()
                return -1
            else:
                step = STEP_PASS
                continue

        if step == STEP_PASS:
            grid = GridFormHelp(screen, _("VNC Configuration"),
                                "vnc", 1, 10)

            bb = ButtonBar(screen, (TEXT_OK_BUTTON,
                                    (_("No password"), "nopass"),
                                    TEXT_BACK_BUTTON))

            text = _("A password will prevent unauthorized listeners "
                     "connecting and monitoring your installation progress.  "
                     "Please enter a password to be used for the installation")
            grid.add(TextboxReflowed(40, text), 0, 0, (0, 0, 0, 1))

            entry1 = Entry (16, password = 1)
            entry2 = Entry (16, password = 1)
            passgrid = Grid (2, 2)
            passgrid.setField (Label (_("Password:"******"Password (confirm):")), 0, 1, (0, 0, 1, 0), anchorLeft = 1)
            passgrid.setField (entry1, 1, 0)
            passgrid.setField (entry2, 1, 1)
            grid.add (passgrid, 0, 1, (0, 0, 0, 1))

            grid.add(bb, 0, 8, (0, 1, 1, 0), growx = 1)

            while 1:
                res = grid.run()
                rc = bb.buttonPressed(res)

                if rc == TEXT_BACK_CHECK:
                    screen.popWindow()
                    step = STEP_MESSAGE
                    break
                elif rc == "nopass":
                    screen.finish()
                    return None
                else:
                    pw = entry1.value()
                    cf = entry2.value()
                    if pw != cf:
                        ButtonChoiceWindow(screen, _("Password Mismatch"),
                                           _("The passwords you entered were "
                                             "different. Please try again."),
                                           buttons = [ TEXT_OK_BUTTON ],
                                           width = 50)
                    elif len(pw) < 6:
                        ButtonChoiceWindow(screen, _("Password Length"),
                                           _("The password must be at least "
                                             "six characters long."),
                                           buttons = [ TEXT_OK_BUTTON ],
                                           width = 50)
                    else:
                        screen.finish()
                        return pw

                    entry1.set("")
                    entry2.set("")
                    continue
                continue

    screen.finish()
    return -1
示例#32
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