Change in vdsm[master]: volume: move metadata dict creation to volume.py

laravot at redhat.com laravot at redhat.com
Mon Jun 9 11:24:33 UTC 2014


Liron Ar has uploaded a new change for review.

Change subject: volume: move metadata dict creation to volume.py
......................................................................

volume: move metadata dict creation to volume.py

Change-Id: I26c495d437fe327a4029fe1dae087d182ba6611b
Signed-off-by: Liron Aravot <laravot at redhat.com>
---
M vdsm/storage/blockVolume.py
M vdsm/storage/fileVolume.py
M vdsm/storage/volume.py
3 files changed, 16 insertions(+), 19 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/92/28492/1

diff --git a/vdsm/storage/blockVolume.py b/vdsm/storage/blockVolume.py
index 81331fa..d448e00 100644
--- a/vdsm/storage/blockVolume.py
+++ b/vdsm/storage/blockVolume.py
@@ -574,20 +574,12 @@
         try:
             meta = misc.readblock(lvm.lvPath(vgname, sd.METADATA),
                                   offs * VOLUME_METASIZE, VOLUME_METASIZE)
-            out = {}
-            for l in meta:
-                if l.startswith("EOF"):
-                    return out
-                if l.find("=") < 0:
-                    continue
-                key, value = l.split("=")
-                out[key.strip()] = value.strip()
+            return self.metadata2dict(meta)
 
         except Exception as e:
             self.log.error(e, exc_info=True)
             raise se.VolumeMetadataReadError("%s: %s" % (metaId, e))
 
-        return out
 
     def setMetadata(self, meta, metaId=None):
         """
diff --git a/vdsm/storage/fileVolume.py b/vdsm/storage/fileVolume.py
index 654818e..6b655b8 100644
--- a/vdsm/storage/fileVolume.py
+++ b/vdsm/storage/fileVolume.py
@@ -294,20 +294,11 @@
 
         try:
             f = self.oop.directReadLines(metaPath)
-            out = {}
-            for l in f:
-                if l.startswith("EOF"):
-                    return out
-                if l.find("=") < 0:
-                    continue
-                key, value = l.split("=")
-                out[key.strip()] = value.strip()
+            return self.metadata2dict(f)
 
         except Exception as e:
             self.log.error(e, exc_info=True)
             raise se.VolumeMetadataReadError("%s: %s" % (metaId, e))
-
-        return out
 
     @classmethod
     def __putMetadata(cls, metaId, meta):
diff --git a/vdsm/storage/volume.py b/vdsm/storage/volume.py
index 3a5ed8e..aed932e 100644
--- a/vdsm/storage/volume.py
+++ b/vdsm/storage/volume.py
@@ -814,6 +814,20 @@
         """
         pass
 
+
+    def metadata2dict(self, meta):
+        out = {}
+        for l in meta:
+            if l.startswith("EOF"):
+                return out
+            if l.find("=") < 0:
+                continue
+            key, value = l.split("=")
+            out[key.strip()] = value.strip()
+
+        return out
+
+
     def metadata2info(self, meta):
         return {
             "uuid": self.volUUID,


-- 
To view, visit http://gerrit.ovirt.org/28492
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I26c495d437fe327a4029fe1dae087d182ba6611b
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Liron Ar <laravot at redhat.com>


More information about the vdsm-patches mailing list