Allow a Config Drive source on a partition, if the label matches.
This commit is contained in:
parent
1a6ad1d61a
commit
69d9382194
@ -284,8 +284,10 @@ def find_candidate_devs():
|
||||
# followed by fstype items, but with dupes removed
|
||||
combined = (by_label + [d for d in by_fstype if d not in by_label])
|
||||
|
||||
# We are looking for block device (sda, not sda1), ignore partitions
|
||||
combined = [d for d in combined if not util.is_partition(d)]
|
||||
# We are looking for a block device or partition with necessary label or
|
||||
# an unpartitioned block device.
|
||||
combined = [d for d in combined
|
||||
if d in by_label or not util.is_partition(d)]
|
||||
|
||||
return combined
|
||||
|
||||
|
@ -285,10 +285,11 @@ class TestConfigDriveDataSource(MockerTestCase):
|
||||
self.assertEqual(["/dev/vdb", "/dev/zdd"],
|
||||
ds.find_candidate_devs())
|
||||
|
||||
# verify that partitions are not considered
|
||||
# verify that partitions are considered, but only if they have a label.
|
||||
devs_with_answers = {"TYPE=vfat": ["/dev/sda1"],
|
||||
"TYPE=iso9660": [], "LABEL=config-2": ["/dev/vdb3"]}
|
||||
self.assertEqual([], ds.find_candidate_devs())
|
||||
self.assertEqual(["/dev/vdb3"],
|
||||
ds.find_candidate_devs())
|
||||
|
||||
finally:
|
||||
util.find_devs_with = orig_find_devs_with
|
||||
|
Loading…
x
Reference in New Issue
Block a user