--- storage/__init__.py | 21 +++++++++++++++++++++ 1 files changed, 21 insertions(+), 0 deletions(-) diff --git a/storage/__init__.py b/storage/__init__.py index bc63e43..cbd72a2 100644 --- a/storage/__init__.py +++ b/storage/__init__.py @@ -53,12 +53,29 @@ import fcoe import zfcp import dasd +import shelve +import contextlib + import gettext _ = lambda x: gettext.ldgettext("anaconda", x) import logging log = logging.getLogger("storage") +def dump_state(dump_list, key, force=False): + """ Dump the list (under the given key) to the storage shelf. + + Each item in the list should have a "dict" attribute which contains + only data of built-in types (int, float, str, list, dict, &c). + """ + with contextlib.closing(shelve.open("/tmp/storage.state")) as shelf: + if shelf.has_key(key): + log.info("storage shelf already has key '%s'" % key) + if not force: + return + + shelf[key] = [d.dict for d in dump_list] + def storageInitialize(anaconda): storage = anaconda.id.storage @@ -100,6 +117,8 @@ def storageInitialize(anaconda): else: storage.reset() + dump_state(storage.devices, "devices.initial", force=True) + # dispatch.py helper function def storageComplete(anaconda): if anaconda.dir == DISPATCH_BACK: @@ -308,6 +327,8 @@ class Storage(object): dev.disk.setup() dev.disk.format.commitToDisk() + dump_state(self.devices, "devices.final", force=True) + @property def nextID(self): id = self._nextID -- 1.6.5.2 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list