Deal with partitions without NAME labels
Partition NAME labels are optional; update parser to deal with an empty name. Change-Id: I179d74670a7e6b35b23f7423e5356db4199d53e6 Closes-Bug: 1731639
This commit is contained in:
parent
ccaffa0a59
commit
e1a0b3558b
|
@ -944,15 +944,27 @@ def get_partition_list(dev):
|
|||
# For each line of output
|
||||
for partition in partitions:
|
||||
parts = partition.split()
|
||||
partitions_list.append(
|
||||
Partition(number=parts[0],
|
||||
start=parts[1],
|
||||
end=parts[2],
|
||||
sectors=parts[3],
|
||||
size=parts[4],
|
||||
name=parts[5],
|
||||
uuid=parts[6])
|
||||
)
|
||||
try:
|
||||
partitions_list.append(
|
||||
Partition(number=parts[0],
|
||||
start=parts[1],
|
||||
end=parts[2],
|
||||
sectors=parts[3],
|
||||
size=parts[4],
|
||||
name=parts[5],
|
||||
uuid=parts[6])
|
||||
)
|
||||
except IndexError:
|
||||
partitions_list.append(
|
||||
Partition(number=parts[0],
|
||||
start=parts[1],
|
||||
end=parts[2],
|
||||
sectors=parts[3],
|
||||
size=parts[4],
|
||||
name="",
|
||||
uuid=parts[5])
|
||||
)
|
||||
|
||||
return partitions_list
|
||||
except subprocess.CalledProcessError:
|
||||
raise
|
||||
|
|
|
@ -1,2 +1,4 @@
|
|||
1 2099200 8377310 6278111 3G ceph\x20data 6e99ac59-1aa3-4812-abd7-9c886a151dd4
|
||||
2 2048 2099199 2097152 1G ceph\x20journal 0333f202-256c-4867-a85c-3e3c92abd461
|
||||
3 1050624 273680383 272629760 130G 21a38dc5-bc0d-4b9e-9151-2e480c081cca
|
||||
4 273680384 500118158 226437775 108G b351d068-08b5-4d1c-a90c-e72f6b742cc8
|
||||
|
|
|
@ -227,7 +227,7 @@ class CephTestCase(unittest.TestCase):
|
|||
with open('unit_tests/partx_output', 'r') as partx_out:
|
||||
output.return_value = partx_out.read().encode('UTF-8')
|
||||
partition_list = utils.get_partition_list('/dev/xvdb')
|
||||
self.assertEqual(len(partition_list), 2)
|
||||
self.assertEqual(len(partition_list), 4)
|
||||
|
||||
@patch.object(utils.subprocess, 'check_output')
|
||||
def test_get_ceph_pg_stat(self, output):
|
||||
|
|
Loading…
Reference in New Issue