Add helper functions for getting local disk
Following functions are added in order to be used by validate_bdm and resource_tracker code. get_bdm_ephemeral_disk_size: return sum of eph disk size of bdms get_bdm_swap_list: return a swap disk list of bdms get_bdm_local_disk_num: return local disk number (include eph and swap) Change-Id: I215970bea72b502042472aa310fe64ffc4304b25
This commit is contained in:
		@@ -529,3 +529,19 @@ def volume_in_mapping(mount_device, block_device_info):
 | 
			
		||||
 | 
			
		||||
    LOG.debug("block_device_list %s", block_device_list)
 | 
			
		||||
    return strip_dev(mount_device) in block_device_list
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def get_bdm_ephemeral_disk_size(block_device_mappings):
 | 
			
		||||
    return sum(bdm.get('volume_size', 0)
 | 
			
		||||
            for bdm in block_device_mappings
 | 
			
		||||
            if new_format_is_ephemeral(bdm))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def get_bdm_swap_list(block_device_mappings):
 | 
			
		||||
    return [bdm for bdm in block_device_mappings
 | 
			
		||||
            if new_format_is_swap(bdm)]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def get_bdm_local_disk_num(block_device_mappings):
 | 
			
		||||
    return len([bdm for bdm in block_device_mappings
 | 
			
		||||
                if bdm.get('destination_type') == 'local'])
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user