From: Joe D'Andrea Date: Fri, 16 Jan 2015 21:26:09 +0000 (+0000) Subject: Changed pvs separator from ':' to '|' to support names with ':'. X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=456a6f81d8da03ef852575e1e6053dae6958dd43;p=openstack-build%2Fcinder-build.git Changed pvs separator from ':' to '|' to support names with ':'. 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 --- diff --git a/cinder/brick/local_dev/lvm.py b/cinder/brick/local_dev/lvm.py index 9d2cdf7ff..a37beec65 100644 --- a/cinder/brick/local_dev/lvm.py +++ b/cinder/brick/local_dev/lvm.py @@ -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]), diff --git a/cinder/tests/brick/test_brick_lvm.py b/cinder/tests/brick/test_brick_lvm.py index 588bd7281..8d8a454a2 100644 --- a/cinder/tests/brick/test_brick_lvm.py +++ b/cinder/tests/brick/test_brick_lvm.py @@ -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" diff --git a/cinder/tests/test_srb.py b/cinder/tests/test_srb.py index b084c2680..72cc63ecc 100644 --- a/cinder/tests/test_srb.py +++ b/cinder/tests/test_srb.py @@ -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)