Allow block devices without device_name
This patch removes the check in the API that prevented having block devices without 'device_name' and makes the compute manager capable of guessing those names. Before creating the instance, the manager will try to guess a valid name using the method 'default_device_names_for_instance', which should be implemented by the drivers, or defer to the generic function from the utils module 'default_device_names_for_instance' which uses the already existing 'get_device_name_for_instance' function. It also takes care of assigning the correct device name to the root device (boot_index=0) to make it agree with the field `root_device_name' from the instance. If none were supplied - it will try to guess it by calling driver 'default_root_device_name' or defer to the generic 'get_device_name_for_instance'. if driver does not provide it. What is worth noting also is that, should the drivers override the two methods mentioned above, the code should expect to be passed the standard block device mapping format, and not the one used in other driver methods. DocImpact Part of blueprint: improve-block-device-handling Co-authored-by: Xavier Queralt <xqueralt@redhat.com> Change-Id: I84541f8ff6e1b5978734e5def69946d014c66fdf
This commit is contained in:
@@ -327,3 +327,18 @@ def get_swap(transformed_list):
|
||||
return transformed_list.pop()
|
||||
except IndexError:
|
||||
return None
|
||||
|
||||
|
||||
_IMPLEMENTED_CLASSES = (DriverSwapBlockDevice, DriverEphemeralBlockDevice,
|
||||
DriverVolumeBlockDevice, DriverSnapshotBlockDevice,
|
||||
DriverImageBlockDevice)
|
||||
|
||||
|
||||
def is_implemented(bdm):
|
||||
for cls in _IMPLEMENTED_CLASSES:
|
||||
try:
|
||||
cls(bdm)
|
||||
return True
|
||||
except _NotTransformable:
|
||||
pass
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user