Create an image BDM for every instance
This patch makes every boot create a block device mapping if the instance was started with an image. These block devices are not used anywhere at the moment but will be used in the future as part of a more flexible block device API. This patch also makes sure they are deleted once the instance is deleted as well. Change-Id: Ia89d531be71c460f1f82fcfce34b270639a23061 blueprint: improve-block-device-handling
This commit is contained in:
		 Nikola Dipanov
					Nikola Dipanov
				
			
				
					committed by
					
						 Chris Behrens
						Chris Behrens
					
				
			
			
				
	
			
			
			 Chris Behrens
						Chris Behrens
					
				
			
						parent
						
							0d5fb06b39
						
					
				
				
					commit
					41eb083d22
				
			| @@ -166,6 +166,21 @@ def is_safe_for_update(block_device_dict): | ||||
|                       bdm_db_only_fields) | ||||
|  | ||||
|  | ||||
| def create_image_bdm(image_ref, boot_index=0): | ||||
|     """Create a block device dict based on the image_ref. | ||||
|  | ||||
|     This is useful in the API layer to keep the compatibility | ||||
|     with having an image_ref as a field in the instance requests | ||||
|     """ | ||||
|     return BlockDeviceDict( | ||||
|         {'source_type': 'image', | ||||
|          'image_id': image_ref, | ||||
|          'delete_on_termination': True, | ||||
|          'boot_index': boot_index, | ||||
|          'device_type': 'disk', | ||||
|          'destination_type': 'local'}) | ||||
|  | ||||
|  | ||||
| def legacy_mapping(block_device_mapping): | ||||
|     """Transform a list of block devices of an instance back to the | ||||
|     legacy data format.""" | ||||
|   | ||||
		Reference in New Issue
	
	Block a user