Method to filter non-root block device mappings

Adding a generator that would provide a non-root block device
mappings, when it's optional variable exclude_root_mapping is
set to true. Otherwise, all mappings will be returned.

The method will be used to handle LXC volumes, as it's root FS
should be handled differently.

Change-Id: I879916021c3b61f19dd69ff11838dbbac19f72d1
Related-Bug: #1269990
This commit is contained in:
Vladik Romanovsky
2014-06-13 10:11:08 -04:00
parent 90cf9f6542
commit 099aad2c3f
2 changed files with 19 additions and 0 deletions

View File

@@ -422,6 +422,14 @@ def get_root_bdm(bdms):
return None
def get_bdms_to_connect(bdms, exclude_root_mapping=False):
"""Will return non-root mappings, when exclude_root_mapping is true.
Otherwise all mappings will be returned.
"""
return (bdm for bdm in bdms if bdm.get('boot_index', -1) != 0 or
not exclude_root_mapping)
def mappings_prepend_dev(mappings):
"""Prepend '/dev/' to 'device' entry of swap/ephemeral virtual type."""
for m in mappings: