CA-372641: fix _expand_size for multipath

From: Mark Syms <mark.syms@citrix.com>

Signed-off-by: Mark Syms <mark.syms@citrix.com>
---
 drivers/LVHDSR.py |    8 ++++----
 drivers/lvutil.py |   16 ++++++++++++++++
 2 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/drivers/LVHDSR.py b/drivers/LVHDSR.py
index 6815669..cfee071 100755
--- a/drivers/LVHDSR.py
+++ b/drivers/LVHDSR.py
@@ -486,10 +486,10 @@ class LVHDSR(SR.SR):
                     # LVHDoHBASR, LVHDoISCSISR might have slaves
                     scsiutil.refresh_lun_size_by_SCSIid_on_slaves(self.session,
                                                        getattr(self, 'SCSIid'))
-                util.SMlog("LVHDSR._expand_size for %s will resize the pv."
-                           % self.uuid)
-                for device in devices:
-                    lvutil.resizePV(device)
+                util.SMlog("LVHDSR._expand_size for %s will resize the pv." %
+                           self.uuid)
+                for pv in lvutil.get_pv_for_vg(self.vgname):
+                    lvutil.resizePV(pv)
             except:
                 util.logException("LVHDSR._expand_size for %s failed to resize"
                                   " the PV" % self.uuid)
diff --git a/drivers/lvutil.py b/drivers/lvutil.py
index 2ba6945..7e2cdaf 100755
--- a/drivers/lvutil.py
+++ b/drivers/lvutil.py
@@ -291,6 +291,22 @@ def _get_sr_uuid(pvname, prefix_list):
     except:
         return ""
 
+
+# Retrieves the names of the Physical Volumes which are used by the specified
+# Volume Group
+# e.g.
+#   PV         VG                          Fmt  Attr PSize   PFree
+#  /dev/sda4  VG_XenStorage-some-hex-value lvm2 a-   224.74G 223.73G
+# will return "/dev/sda4" when given the argument "VG_XenStorage-some-hex-value".
+def get_pv_for_vg(vgname):
+    try:
+        result = cmd_lvm([CMD_PVS, "--noheadings",
+                          '-S', 'vg_name=%s' % vgname, '-o', 'name'])
+        return [x.strip() for x in result.splitlines()]
+    except util.CommandException:
+        return []
+
+
 # Tries to match any prefix contained in prefix_list in s. If matched, the
 # remainder string is returned, else the empty string is returned. E.g. if s is
 # "VG_XenStorage-some-hex-value" and prefix_list contains "VG_XenStorage-",
