From e6d7ff592ccb8034ebebd290718b5b87e0733862 Mon Sep 17 00:00:00 2001 From: David Lehman Date: Mon, 21 Dec 2009 19:17:13 -0600 Subject: Dump the initial and final state of the system's storage devices. A timestamp in the keys will allow multiple installs (live media) as well as arbitrary amounts of back and forth, resetting, whatever. --- storage/__init__.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'storage') diff --git a/storage/__init__.py b/storage/__init__.py index 52d25b52d..d50987d07 100644 --- a/storage/__init__.py +++ b/storage/__init__.py @@ -53,6 +53,9 @@ import fcoe import zfcp import dasd +import shelve +import contextlib + import gettext _ = lambda x: gettext.ldgettext("anaconda", x) @@ -258,6 +261,7 @@ class Storage(object): self._nextID = 0 self.defaultFSType = get_default_filesystem_type() self.defaultBootFSType = get_default_filesystem_type(boot=True) + self._dumpFile = "/tmp/storage.state" # these will both be empty until our reset method gets called self.devicetree = DeviceTree(intf=self.anaconda.intf, @@ -308,6 +312,8 @@ class Storage(object): dev.disk.setup() dev.disk.format.commitToDisk() + self.dumpState("final") + @property def nextID(self): id = self._nextID @@ -364,6 +370,7 @@ class Storage(object): self.fsset = FSSet(self.devicetree, self.anaconda.rootPath) self.anaconda.id.rootParts = None self.anaconda.id.upgradeRoot = None + self.dumpState("initial") w.pop() @property @@ -1021,6 +1028,12 @@ class Storage(object): return True return False + def dumpState(self, suffix): + """ Dump the current device list to the storage shelf. """ + key = "devices.%d.%s" % (time.time(), suffix) + with contextlib.closing(shelve.open(self._dumpFile)) as shelf: + shelf[key] = [d.dict for d in self.devices] + def write(self, instPath): self.fsset.write(instPath) self.iscsi.write(instPath, self.anaconda) -- cgit