Less thread work than take 2, better completed/ready handling. Also handle invalid bootDrive (a test case I used when seeing how we handle kickstart errors).
--jlk
This is necessary for doing installs via kickstart where we've got the data even though we haven't gone through the spoke.
Also handle the case where the account could be locked. --- pyanaconda/ui/tui/spokes/password.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/pyanaconda/ui/tui/spokes/password.py b/pyanaconda/ui/tui/spokes/password.py index 98da8ac..b556af2 100644 --- a/pyanaconda/ui/tui/spokes/password.py +++ b/pyanaconda/ui/tui/spokes/password.py @@ -21,6 +21,7 @@
from pyanaconda.ui.tui.spokes import NormalTUISpoke from pyanaconda.ui.tui.simpleline import TextWidget +from pyanaconda.flags import flags import getpass
import gettext @@ -37,14 +38,16 @@ class PasswordSpoke(NormalTUISpoke):
@property def completed(self): - return True + return bool(self.data.rootpw.password or self.data.rootpw.lock)
@property def status(self): - if not self.data.rootpw.password: - return _("Root account disabled.") - else: + if self.data.rootpw.password: return _("Password is set.") + elif self.data.rootpw.lock: + return _("Root account is disabled.") + else: + return _("Password is not set.")
def refresh(self, args = None): NormalTUISpoke.refresh(self, args)
This brings things more in-line with the GUI spoke. Also it imports the thread stuff only once rather than multiple times. --- pyanaconda/ui/tui/spokes/storage.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/pyanaconda/ui/tui/spokes/storage.py b/pyanaconda/ui/tui/spokes/storage.py index d1b85c3..db63750 100644 --- a/pyanaconda/ui/tui/spokes/storage.py +++ b/pyanaconda/ui/tui/spokes/storage.py @@ -28,6 +28,7 @@ from pyanaconda.ui.tui.simpleline import TextWidget, CheckboxWidget from pyanaconda.storage.size import Size from pyanaconda.flags import flags from pyanaconda.kickstart import doKickstartStorage +from pyanaconda.threads import threadMgr, AnacondaThread
from pykickstart.constants import *
@@ -93,6 +94,8 @@ class StorageSpoke(NormalTUISpoke): NormalTUISpoke.__init__(self, app, data, storage, payload, instclass) self.selected_disks = self.data.ignoredisk.onlyuse[:]
+ self._ready = False + # This list gets set up once in initialize and should not be modified # except perhaps to add advanced devices. It will remain the full list # of disks that can be included in the install. @@ -101,7 +104,13 @@ class StorageSpoke(NormalTUISpoke):
@property def completed(self): - return bool(self.selected_disks and not self.errors) + return bool(self.storage.rootDevice and not self.errors) + + @property + def ready(self): + # By default, the storage spoke is not ready. We have to wait until + # storageInitialize is done. + return self._ready and not threadMgr.get("AnaStorageWatcher")
@property def status(self): @@ -162,8 +171,6 @@ class StorageSpoke(NormalTUISpoke): NormalTUISpoke.refresh(self, args)
# Join the initialization thread to block on it - from pyanaconda.threads import threadMgr - initThread = threadMgr.get("AnaStorageWatcher") if initThread: # This print is foul. Need a better message display @@ -262,8 +269,6 @@ class StorageSpoke(NormalTUISpoke): log.warn(w)
def initialize(self): - from pyanaconda.threads import threadMgr, AnacondaThread - NormalTUISpoke.initialize(self)
threadMgr.add(AnacondaThread(name="AnaStorageWatcher", @@ -276,8 +281,6 @@ class StorageSpoke(NormalTUISpoke): # Secondary initialize so wait for the storage thread # to complete before populating our disk list
- from pyanaconda.threads import threadMgr - storageThread = threadMgr.get("AnaStorageThread") if storageThread: storageThread.join()
We were just eating all errors, which is not correct. This will accept errors that might be fixable, but lets other errors bubble up and end the install. It also manipulates the ready status correctly. --- pyanaconda/ui/tui/spokes/storage.py | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-)
diff --git a/pyanaconda/ui/tui/spokes/storage.py b/pyanaconda/ui/tui/spokes/storage.py index db63750..afa2855 100644 --- a/pyanaconda/ui/tui/spokes/storage.py +++ b/pyanaconda/ui/tui/spokes/storage.py @@ -26,6 +26,7 @@ from pyanaconda.ui.tui.spokes import NormalTUISpoke from pyanaconda.ui.tui.simpleline import TextWidget, CheckboxWidget
from pyanaconda.storage.size import Size +from pyanaconda.storage.errors import StorageError from pyanaconda.flags import flags from pyanaconda.kickstart import doKickstartStorage from pyanaconda.threads import threadMgr, AnacondaThread @@ -255,18 +256,24 @@ class StorageSpoke(NormalTUISpoke): def execute(self): print(_("Generating updated storage configuration")) try: - # Try to do the storage, absorb any tracebacks for now - # We will catch any failures when checking the sanity doKickstartStorage(self.storage, self.data, self.instclass) - except: - pass - # Doing this in foreground now, candidate for background thread - print(_("Checking storage configuration...")) - (self.errors, warnings) = self.storage.sanityCheck() - for e in self.errors: - log.error(e) - for w in warnings: - log.warn(w) + except StorageError as e: + log.error("storage configuration failed: %s" % e) + self.errors = e + self.data.clearpart.type = CLEARPART_TYPE_ALL + self.data.clearpart.initAll = False + self.storage.config.update(self.data) + self.storage.autoPartType = self.data.clearpart.type + self.storage.reset() + self._ready = True + else: + print(_("Checking storage configuration...")) + (self.errors, warnings) = self.storage.sanityCheck() + self._ready = True + for e in self.errors: + log.error(e) + for w in warnings: + log.warn(w)
def initialize(self): NormalTUISpoke.initialize(self)
This follows the same design as GUI. If the install is automated, and all the spokes are complete, proceed into the installation phase. However if there are incomplete spokes, let the user finish those spokes. As soon as all spokes are complete jump straight to the install phase.
Note that any new spoke that has a background process that could make it not be "ready" immediately is going to have to be accounted for here, which is ugly. Perhaps a object attribute that is a list of potential threads to join would work? --- pyanaconda/ui/tui/hubs/summary.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
diff --git a/pyanaconda/ui/tui/hubs/summary.py b/pyanaconda/ui/tui/hubs/summary.py index 8c2f4cc..19d2a53 100644 --- a/pyanaconda/ui/tui/hubs/summary.py +++ b/pyanaconda/ui/tui/hubs/summary.py @@ -17,9 +17,13 @@ # Red Hat, Inc. # # Red Hat Author(s): Martin Sivak msivak@redhat.com +# Jesse Keating jkeating@redhat.com #
from pyanaconda.ui.tui.hubs import TUIHub +from pyanaconda.flags import flags +import sys +import time
import gettext _ = lambda x: gettext.ldgettext("anaconda", x) @@ -27,3 +31,27 @@ _ = lambda x: gettext.ldgettext("anaconda", x) class SummaryHub(TUIHub): title = _("Install hub") categories = ["source", "localization", "destination", "password"] + + def __init__(self, app, data, storage, payload, instclass): + TUIHub.__init__(self, app, data, storage, payload, instclass) + if flags.automatedInstall: + sys.stdout.write(_("Starting automated install")) + sys.stdout.flush() + spokes = self._keys.values() + while not all(spoke.ready for spoke in spokes): + sys.stdout.write('.') + sys.stdout.flush() + time.sleep(1) + + print('') + for spoke in spokes: + spoke.execute() + + # override the prompt so that we can skip user input on kickstarts + # where all the data is in hand. If not in hand, do the actual prompt. + def prompt(self, args=None): + if flags.automatedInstall and \ + all(spoke.completed for spoke in self._keys.values()): + self.close() + return None + return TUIHub.prompt(self, args) \ No newline at end of file
--- pyanaconda/kickstart.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/pyanaconda/kickstart.py b/pyanaconda/kickstart.py index fff0ff2..57b26f1 100644 --- a/pyanaconda/kickstart.py +++ b/pyanaconda/kickstart.py @@ -311,7 +311,11 @@ class Bootloader(commands.bootloader.F18_Bootloader):
storage.bootloader.disk_order = self.driveorder
- if not self.bootDrive: + if self.bootDrive: + if not self.bootDrive in disk_names: + raise KickstartValueError, formatErrorMsg(self.lineno, + msg="Requested boot drive %s doesn't exist" % self.bootDrive) + else: self.bootDrive = disk_names[0]
spec = udev_resolve_devspec(self.bootDrive)
Looks good to me.
On Mon, 2012-09-24 at 15:47 -0700, Jesse Keating wrote:
Less thread work than take 2, better completed/ready handling. Also handle invalid bootDrive (a test case I used when seeing how we handle kickstart errors).
--jlk
anaconda-patches mailing list anaconda-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/anaconda-patches
anaconda-patches@lists.fedorahosted.org