]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Changed pvs separator from ':' to '|' to support names with ':'.
authorJoe D'Andrea <jdandrea@research.att.com>
Fri, 16 Jan 2015 21:26:09 +0000 (21:26 +0000)
committerJoe D'Andrea <jdandrea@research.att.com>
Mon, 26 Jan 2015 18:35:00 +0000 (18:35 +0000)
get_all_physical_volumes() runs:

pvs --noheadings --unit=g -o vg_name,name,size,free
    --separator : --nosuffix

Which can produce a variable number of fields if the 'name'
incorporates ':', as in the following:

cinder-volumes-array-lun-0:/dev/disk/by-path/ip-10.8.77.11:3260-
    iscsi-iqn.1984-05.com.dell:powervault.md3600i.6f01faf000eb1b
    540000000053c487b0-lun-0:931.01:931.01

Change-Id: Ia5442af2a06a004ff1af58ce08b816506b369f22
Closes-Bug: 1414076

cinder/brick/local_dev/lvm.py
cinder/tests/brick/test_brick_lvm.py
cinder/tests/test_srb.py

index 9d2cdf7ff6eb1c95c8fe1d78c23f09bc339edcd7..a37beec65a49f5be8e0e7a7100009139fa513518 100644 (file)
@@ -311,10 +311,12 @@ class LVM(executor.Executor):
         :returns: List of Dictionaries with PV info
 
         """
+        field_sep = '|'
+
         cmd = ['env', 'LC_ALL=C', 'pvs', '--noheadings',
                '--unit=g',
                '-o', 'vg_name,name,size,free',
-               '--separator', ':',
+               '--separator', field_sep,
                '--nosuffix']
 
         (out, _err) = putils.execute(*cmd,
@@ -323,11 +325,11 @@ class LVM(executor.Executor):
 
         pvs = out.split()
         if vg_name is not None:
-            pvs = [pv for pv in pvs if vg_name == pv.split(':')[0]]
+            pvs = [pv for pv in pvs if vg_name == pv.split(field_sep)[0]]
 
         pv_list = []
         for pv in pvs:
-            fields = pv.split(':')
+            fields = pv.split(field_sep)
             pv_list.append({'vg': fields[0],
                             'name': fields[1],
                             'size': float(fields[2]),
index 588bd72810564407de0243dbaf30dee4e0fad8c2..8d8a454a260846801e28e7a92dcc8b8e5086c00e 100644 (file)
@@ -107,10 +107,10 @@ class BrickLvmTestCase(test.TestCase):
             else:
                 data = '  owi-a-'
         elif 'env, LC_ALL=C, pvs, --noheadings' in cmd_string:
-            data = "  fake-vg:/dev/sda:10.00:1.00\n"
-            data += "  fake-vg:/dev/sdb:10.00:1.00\n"
-            data += "  fake-vg:/dev/sdc:10.00:8.99\n"
-            data += "  fake-vg-2:/dev/sdd:10.00:9.99\n"
+            data = "  fake-vg|/dev/sda|10.00|1.00\n"
+            data += "  fake-vg|/dev/sdb|10.00|1.00\n"
+            data += "  fake-vg|/dev/sdc|10.00|8.99\n"
+            data += "  fake-vg-2|/dev/sdd|10.00|9.99\n"
         elif 'env, LC_ALL=C, lvs, --noheadings, --unit=g' \
              ', -o, size,data_percent, --separator, :' in cmd_string:
             data = "  9:12\n"
index b084c2680215652b16c0d80d91d1baa14a48e139..72cc63ecc510b785fd8c1353e31176625baa3b90 100644 (file)
@@ -432,18 +432,18 @@ class SRBDriverTestCase(test.TestCase):
     def _fake_get_all_physical_volumes(self):
         def check(cmd_string):
             return 'env, LC_ALL=C, pvs, --noheadings, --unit=g, ' \
-                '-o, vg_name,name,size,free, --separator, :, --nosuffix' \
-                in cmd_string
+                '-o, vg_name,name,size,free, --separator, |, ' \
+                '--nosuffix' in cmd_string
 
         def act(cmd):
-            data = "  fake-outer-vg:/dev/fake1:10.00:1.00\n"
+            data = "  fake-outer-vg|/dev/fake1|10.00|1.00\n"
             for vname in self._volumes:
                 vol = self._volumes[vname]
                 for vgname in vol['vgs']:
                     vg = vol['vgs'][vgname]
                     for lvname in vg['lvs']:
                         lv_size = vg['lvs'][lvname]
-                        data += "  %s:/dev/srb/%s/device:%.2f:%.2f\n" %\
+                        data += "  %s|/dev/srb/%s/device|%.2f|%.2f\n" %\
                             (vgname, vol['name'],
                              lv_size / units.Gi, lv_size / units.Gi)