#NEWLINE# def get_image_metadata_from_volume( volume ) : #NEWLINE# #INDENT# properties = copy . copy ( volume . get ( 'volume_image_metadata' , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) ) #NEWLINE# image_meta = { #NEWLINE# #INDENT# 'properties' : properties , #NEWLINE# #UNINDENT# } #NEWLINE# image_meta [ 'size' ] = ( volume . get ( 'size' , 0 ) * units . Gi ) #NEWLINE# for attr in VIM_IMAGE_ATTRIBUTES : #NEWLINE# #INDENT# val = properties . pop ( attr , None ) #NEWLINE# if ( attr in ( 'min_ram' , 'min_disk' ) ) : #NEWLINE# #INDENT# image_meta [ attr ] = int ( ( val or 0 ) ) #NEWLINE# #UNINDENT# #UNINDENT# image_meta [ 'status' ] = 'active' #NEWLINE# return image_meta