Re: [PATCH 3/3] Dump the initial and final state of the system's storage devices.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On 12/22/2009 02:26 AM, David Lehman wrote:
---
  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)
+


storageInitialize() gets called (again) when manually adding iscsi/zfcp/fcoe
disks, it would be good to have dumps of the initial device tree, and of the
re-scanned one after activating the additional drives in this case, would it
be possible to add some sort of counter here, so that we can get
multiple initial dumps ?


  # 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


Other then that ack.

Regards,

Hans

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux