summaryrefslogtreecommitdiff
path: root/nova/block_device.py
diff options
context:
space:
mode:
authorVladik Romanovsky <vladik.romanovsky@enovance.com>2014-06-13 10:11:08 -0400
committerVladik Romanovsky <vladik.romanovsky@enovance.com>2014-07-24 16:00:23 -0400
commit099aad2c3f8887fb9c7c1e81cf4239a104227f48 (patch)
treec77654bdc1a5d0c779dc17f877bb5c23d7fe659b /nova/block_device.py
parent90cf9f654238b138f96ae67897e707a37e71beae (diff)
downloadnova-099aad2c3f8887fb9c7c1e81cf4239a104227f48.tar.gz
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
Diffstat (limited to 'nova/block_device.py')
-rw-r--r--nova/block_device.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/nova/block_device.py b/nova/block_device.py
index b0e048d6c5..3cb123bd68 100644
--- a/nova/block_device.py
+++ b/nova/block_device.py
@@ -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: