Add a get_root_bdm utility function
Getting the root block device out of a list of block devices is a common idiom and we use it in several places in our code base. This patch factors it out in a handy utilty method and adds tests for it. Change-Id: I4a2cb3c689fed9fbc0bc51ddba095e1269cacb2d blueprint: clean-up-legacy-block-device-mapping
This commit is contained in:
@@ -388,6 +388,13 @@ def new_format_is_ephemeral(bdm):
|
||||
return False
|
||||
|
||||
|
||||
def get_root_bdm(bdms):
|
||||
try:
|
||||
return (bdm for bdm in bdms if bdm.get('boot_index', -1) == 0).next()
|
||||
except StopIteration:
|
||||
return None
|
||||
|
||||
|
||||
def mappings_prepend_dev(mappings):
|
||||
"""Prepend '/dev/' to 'device' entry of swap/ephemeral virtual type."""
|
||||
for m in mappings:
|
||||
|
Reference in New Issue
Block a user