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
: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,
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]),
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"
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)