Change in vdsm[master]: Make lvm.listPVNames() be based on vgs information.

ewarszaw at redhat.com ewarszaw at redhat.com
Fri May 10 02:13:50 UTC 2013


Eduardo has uploaded a new change for review.

Change subject: Make lvm.listPVNames() be based on vgs information.
......................................................................

Make lvm.listPVNames() be based on vgs information.

Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=955993
Change-Id: I1e04a73476cab53e9a0a6c74eab2e747380f25c4
Signed-off-by: Eduardo <ewarszaw at redhat.com>
---
M vdsm/storage/blockSD.py
M vdsm/storage/lvm.py
2 files changed, 23 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/31/14631/1

diff --git a/vdsm/storage/blockSD.py b/vdsm/storage/blockSD.py
index 86ffb66..a94c47e 100644
--- a/vdsm/storage/blockSD.py
+++ b/vdsm/storage/blockSD.py
@@ -641,7 +641,7 @@
             raise se.MetaDataMappingError("vg %s: metadata extent is not the "
                                           "first extent" % vgName)
 
-        pvlist = lvm.listPVNames(vgName)
+        pvlist = list(lvm.listPVNames(vgName))
 
         pvlist.remove(firstDev)
         pvlist.insert(0, firstDev)
diff --git a/vdsm/storage/lvm.py b/vdsm/storage/lvm.py
index 97fe38a..533c205 100644
--- a/vdsm/storage/lvm.py
+++ b/vdsm/storage/lvm.py
@@ -51,7 +51,7 @@
 PV_FIELDS = ("uuid,name,size,vg_name,vg_uuid,pe_start,pe_count,"
              "pe_alloc_count,mda_count,dev_size")
 VG_FIELDS = ("uuid,name,attr,size,free,extent_size,extent_count,free_count,"
-             "tags,vg_mda_size,vg_mda_free")
+             "tags,vg_mda_size,vg_mda_free,lv_count,pv_count,pv_name")
 LV_FIELDS = "uuid,name,vg_name,attr,size,seg_start_pe,devices,tags"
 
 VG_ATTR_BITS = ("permission", "resizeable", "exported",
@@ -228,6 +228,9 @@
     attrs = _attr2NamedTuple(args[VG._fields.index("attr")], VG_ATTR_BITS,
                              "VG_ATTR")
     args[VG._fields.index("attr")] = attrs
+    # Convert pv_names list to tuple.
+    args[VG._fields.index("pv_name")] = \
+        tuple(args[VG._fields.index("pv_name")])
     # Add properties. Should be ordered as VG_PROPERTIES.
     args.append(attrs.permission == "w")  # Writable
     args.append(VG_OK if attrs.partial == "-" else VG_PARTIAL)  # Partial
@@ -385,9 +388,22 @@
                 return dict(self._vgs)
 
             updatedVGs = {}
+            vgsFields = {}
             for line in out:
                 fields = [field.strip() for field in line.split(SEPARATOR)]
+                uuid = fields[VG._fields.index("uuid")]
+                pvNameIdx = VG._fields.index("pv_name")
+                pv_name = fields[pvNameIdx]
+                if uuid not in vgsFields:
+                    fields[pvNameIdx] = [pv_name]  # Make a pv_names list
+                    vgsFields[uuid] = fields
+                else:
+                    vgsFields[uuid][pvNameIdx].append(pv_name)
+            for fields in vgsFields.itervalues():
                 vg = makeVG(*fields)
+                if vg.pv_count != len(vg.pv_name):
+                    log.error("vg %s has pv_count %d but pv_names %s",
+                              vg.name, vg.pv_count, vg.pv_name)
                 self._vgs[vg.name] = vg
                 updatedVGs[vg.name] = vg
             # If we updated all the VGs drop stale flag
@@ -1258,8 +1274,11 @@
 
 
 def listPVNames(vgName):
-    pvs = getAllPVs()
-    return [pv.name for pv in pvs if pv.vg_name == vgName]
+    try:
+        pvNames = _lvminfo.vgs[vgName].pv_name
+    except KeyError:
+        pvNames = getVG(vgName).pv_name
+    return pvNames
 
 
 def setrwLV(vg, lv, rw=True):


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1e04a73476cab53e9a0a6c74eab2e747380f25c4
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Eduardo <ewarszaw at redhat.com>


More information about the vdsm-patches mailing list