summaryrefslogtreecommitdiffstats
path: root/pyanaconda/rescue.py
diff options
context:
space:
mode:
authorChris Lumens <clumens@redhat.com>2012-08-01 16:53:07 -0400
committerChris Lumens <clumens@redhat.com>2012-08-01 17:03:37 -0400
commit53844893e72a7643f7b3ec4ceca7307473eaa870 (patch)
treed1422b3b2609682f1ea19b4589b010ebe8851700 /pyanaconda/rescue.py
parent3c0f70e65c93190d8362b6329f3e7cb80a91c397 (diff)
downloadanaconda-53844893e72a7643f7b3ec4ceca7307473eaa870.tar.gz
anaconda-53844893e72a7643f7b3ec4ceca7307473eaa870.tar.xz
anaconda-53844893e72a7643f7b3ec4ceca7307473eaa870.zip
Update rescue mode to continue working in the newui world.
This is still just the existing newt rescue mode interface, but with adding advanced devices removed (requires other code that no longer exists). Of course, this all needs to be removed and replaced by something that does not use newt in the future but for now, it's enough of a stop-gap to fulfill release requirements.
Diffstat (limited to 'pyanaconda/rescue.py')
-rw-r--r--pyanaconda/rescue.py148
1 files changed, 60 insertions, 88 deletions
diff --git a/pyanaconda/rescue.py b/pyanaconda/rescue.py
index 284077bbc..be84c1a2e 100644
--- a/pyanaconda/rescue.py
+++ b/pyanaconda/rescue.py
@@ -23,7 +23,6 @@
from snack import *
from constants import *
from textw.constants_text import *
-from textw.add_drive_text import addDriveDialog
from text import WaitWindow, OkCancelWindow, ProgressWindow, PassphraseEntryWindow, stepToClasses
from flags import flags
import sys
@@ -92,11 +91,11 @@ class RescueInterface(InstallInterfaceBase):
else:
return OkCancelWindow(self.screen, title, text)
- def enableNetwork(self, anaconda):
+ def enableNetwork(self):
if len(network.getDevices()) == 0:
return False
from textw.netconfig_text import NetworkConfiguratorText
- w = NetworkConfiguratorText(self.screen, anaconda)
+ w = NetworkConfiguratorText(self.screen, self)
ret = w.run()
return ret != INSTALL_BACK
@@ -115,9 +114,6 @@ class RescueInterface(InstallInterfaceBase):
def resume(self):
pass
- def run(self, anaconda):
- self.anaconda = anaconda
-
def __init__(self):
InstallInterfaceBase.__init__(self)
self.screen = SnackScreen()
@@ -192,7 +188,7 @@ def runShell(screen = None, msg=""):
if os.path.exists("/usr/bin/firstaidkit-qs"):
proc = subprocess.Popen(["/usr/bin/firstaidkit-qs"])
proc.wait()
-
+
if proc is None or proc.returncode!=0:
if os.path.exists("/bin/bash"):
iutil.execConsole()
@@ -203,7 +199,9 @@ def runShell(screen = None, msg=""):
if screen:
screen.finish()
-def doRescue(anaconda):
+def doRescue(rescue_mount, ksdata, platform):
+ import storage
+
for file in [ "services", "protocols", "group", "joe", "man.config",
"nsswitch.conf", "selinux", "mke2fs.conf" ]:
try:
@@ -211,106 +209,82 @@ def doRescue(anaconda):
except OSError:
pass
+ intf = RescueInterface()
+
# see if they would like networking enabled
if not network.hasActiveNetDev():
+ rc = ButtonChoiceWindow(intf.screen, _("Setup Networking"),
+ _("Do you want to start the network interfaces on "
+ "this system?"), [_("Yes"), _("No")])
- 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
-
- break
- else:
- break
-
- # shutdown the interface now
- anaconda.intf.shutdown()
- anaconda.intf = None
+ if rc != _("No").lower():
+ if not intf.enableNetwork():
+ intf.messageWindow(_("No Network Available"),
+ _("Unable to activate a networking device. Networking "
+ "will not be available in rescue mode."))
# Early shell access with no disk access attempts
- if not anaconda.rescue_mount:
+ if not 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:
+ if flags.automatedInstall and ksdata.scripts:
from kickstart import runPostScripts
- runPostScripts(anaconda.ksdata.scripts)
+ runPostScripts(ksdata.scripts)
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
+ if flags.automatedInstall:
+ readOnly = ksdata.rescue.romount
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"),
+ rc = ButtonChoiceWindow(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")] )
+ [_("Continue"), _("Read-Only"), _("Skip")] )
if rc == _("Skip").lower():
- runShell(anaconda.intf.screen)
+ runShell(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
+ readOnly = rc == _("Read-Only").lower()
- import storage
- storage.storageInitialize(anaconda)
+ break
- (disks, notUpgradable) = storage.findExistingRootDevices(anaconda, upgradeany=True)
+ sto = storage.Storage(ksdata, platform)
+ storage.storageInitialize(sto, ksdata, [])
+ roots = storage.findExistingInstallations(sto.devicetree)
- if not disks:
+ if not roots:
root = None
- elif (len(disks) == 1) or anaconda.ksdata:
- root = disks[0]
+ elif len(roots) == 1 or ksdata.upgrade.upgrade:
+ root = roots[0]
else:
- height = min (len (disks), 12)
+ height = min (len (roots), 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))
+ lst = []
+ for root in roots:
+ lst.append("%s" % root.name)
(button, choice) = \
- ListboxChoiceWindow(anaconda.intf.screen, _("System to Rescue"),
+ ListboxChoiceWindow(intf.screen, _("System to Rescue"),
_("Which device holds the root partition "
- "of your installation?"), devList,
+ "of your installation?"), lst,
[ _("OK"), _("Exit") ], width = 30,
scroll = scroll, height = height,
help = "multipleroot")
@@ -318,15 +292,15 @@ def doRescue(anaconda):
if button == _("Exit").lower():
root = None
else:
- root = disks[choice]
+ root = roots[choice]
- rootmounted = 0
+ rootmounted = False
if root:
try:
# TODO: add a callback to warn about dirty filesystems
- rc = mountExistingSystem(anaconda.storage.fsset, root,
- allowDirty = 1,
+ rc = mountExistingSystem(sto.fsset, root.device,
+ allowDirty = True,
readOnly = readOnly)
if not flags.imageInstall:
@@ -337,20 +311,20 @@ def doRescue(anaconda):
"when you are finished.") % ANACONDA_CLEANUP
if rc == -1:
- if anaconda.ksdata:
+ if flags.automatedInstall:
log.error("System had dirty file systems which you chose not to mount")
else:
- ButtonChoiceWindow(anaconda.intf.screen, _("Rescue"),
+ ButtonChoiceWindow(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
+ rootmounted = False
else:
- if anaconda.ksdata:
+ if flags.automatedInstall:
log.info("System has been mounted under: %s" % ROOT_PATH)
else:
- ButtonChoiceWindow(anaconda.intf.screen, _("Rescue"),
+ ButtonChoiceWindow(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"
@@ -358,12 +332,12 @@ def doRescue(anaconda):
{'rootPath': ROOT_PATH,
'msg': msg},
[_("OK")] )
- rootmounted = 1
+ rootmounted = True
# now turn on swap
if not readOnly:
try:
- anaconda.storage.turnOnSwap()
+ sto.turnOnSwap()
except StorageError:
log.error("Error enabling swap")
@@ -411,7 +385,7 @@ def doRescue(anaconda):
raise
except Exception as e:
log.error("doRescue caught exception: %s" % e)
- if anaconda.ksdata:
+ if flags.automatedInstall:
log.error("An error occurred trying to mount some or all of your system")
else:
if not flags.imageInstall:
@@ -421,16 +395,15 @@ def doRescue(anaconda):
msg = _("Run %s to unmount the system "
"when you are finished.") % ANACONDA_CLEANUP
- ButtonChoiceWindow(anaconda.intf.screen, _("Rescue"),
+ ButtonChoiceWindow(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]:
+ if flags.automatedInstall and ksdata.reboot.action in [KS_REBOOT, KS_SHUTDOWN]:
log.info("No Linux partitions found")
- anaconda.intf.screen.finish()
+ intf.screen.finish()
print(_("You don't have any Linux partitions. Rebooting.\n"))
sys.exit(0)
else:
@@ -439,7 +412,7 @@ def doRescue(anaconda):
"from the shell.")
else:
msg = ""
- ButtonChoiceWindow(anaconda.intf.screen, _("Rescue Mode"),
+ ButtonChoiceWindow(intf.screen, _("Rescue Mode"),
_("You don't have any Linux partitions. Press "
"return to get a shell.%s") % msg,
[ _("OK") ], width = 50)
@@ -447,28 +420,27 @@ def doRescue(anaconda):
msgStr = ""
if rootmounted and not readOnly:
- anaconda.storage.makeMtab()
+ sto.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")] )
+ ButtonChoiceWindow(intf.screen, _("Rescue"), msgStr, [_("OK")] )
# we do not need ncurses anymore, shut them down
- anaconda.intf.shutdown()
+ 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:
+ if rootmounted and not readOnly and flags.automatedInstall:
from kickstart import runPostScripts
- runPostScripts(anaconda.ksdata.scripts)
+ runPostScripts(ksdata.scripts)
# start shell if reboot wasn't requested
- if not anaconda.ksdata or \
- not anaconda.ksdata.reboot.action in [KS_REBOOT, KS_SHUTDOWN]:
+ if not flags.automatedInstall or not ksdata.reboot.action in [KS_REBOOT, KS_SHUTDOWN]:
runShell(msg=msgStr)
sys.exit(0)