Adam Litke has uploaded a new change for review.

Change subject: FakeLVM: Simplify storage of lv metadata
......................................................................

FakeLVM: Simplify storage of lv metadata

Nir pointed out that storing the LV metadata as a dictionary of
dictionaries (first level is vg_name and second level is lv_name) can be
error prone.  Instead, let's store in a single level dictionary using
the tuple (vg_name, lv_name) as the key.

Change-Id: I0e6c0c9af11ecdc88d294848cf244d0d639ec65d
Signed-off-by: Adam Litke <ali...@redhat.com>
---
M tests/storagefakelib.py
1 file changed, 8 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/15/48215/1

diff --git a/tests/storagefakelib.py b/tests/storagefakelib.py
index e6e2d06..263c163 100644
--- a/tests/storagefakelib.py
+++ b/tests/storagefakelib.py
@@ -110,18 +110,17 @@
                      opened=False,
                      active=bool(activate))
 
-        vg_dict = self.lvmd.setdefault(vgName, {})
-        vg_dict[lvName] = lv_md
+        self.lvmd[(vgName, lvName)] = lv_md
         lv_count = int(self.vgmd[vgName]['lv_count']) + 1
         self.vgmd[vgName]['lv_count'] = str(lv_count)
 
     def activateLVs(self, vgName, lvNames):
         for lv in lvNames:
-            self.lvmd[vgName][lv]['active'] = True
-            self.lvmd[vgName][lv]['attr']['state'] = 'a'
+            self.lvmd[(vgName, lv)]['active'] = True
+            self.lvmd[(vgName, lv)]['attr']['state'] = 'a'
 
     def addtag(self, vg, lv, tag):
-        self.lvmd[vg][lv]['tags'] += (tag,)
+        self.lvmd[(vg, lv)]['tags'] += (tag,)
 
     def lvPath(self, vgName, lvName):
         return os.path.join(self.root, "dev", vgName, lvName)
@@ -137,15 +136,15 @@
         return real_lvm.VG(**vg_md)
 
     def _getLV(self, vgName, lvName):
-        lv_md = deepcopy(self.lvmd[vgName][lvName])
+        lv_md = deepcopy(self.lvmd[(vgName, lvName)])
         lv_attr = real_lvm.LV_ATTR(**lv_md['attr'])
         lv_md['attr'] = lv_attr
         return real_lvm.LV(**lv_md)
 
     def getLV(self, vgName, lvName=None):
         if lvName is None:
-            return [self._getLV(vgName, lv_name)
-                    for lv_name in self.lvmd[vgName].keys()]
+            return [self._getLV(vgName, lv)
+                    for (vg, lv) in self.lvmd.keys() if vg == vgName]
         else:
             return self._getLV(vgName, lvName)
 
@@ -153,7 +152,7 @@
         volpath = self.lvPath(vg_name, lv_name)
         os.makedirs(os.path.dirname(volpath))
         with open(volpath, "w") as f:
-            f.truncate(int(self.lvmd[vg_name][lv_name]['size']))
+            f.truncate(int(self.lvmd[(vg_name, lv_name)]['size']))
 
     def _create_pv(self, pv_name, vg_name, size):
         # pe_start is difficult to calculate correctly but since it's not


-- 
To view, visit https://gerrit.ovirt.org/48215
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0e6c0c9af11ecdc88d294848cf244d0d639ec65d
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Adam Litke <ali...@redhat.com>
_______________________________________________
vdsm-patches mailing list
vdsm-patches@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to