#NEWLINE# def get_system_metadata_from_image( image_meta , flavor = None ) : #NEWLINE# #INDENT# system_meta = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# prefix_format = ( SM_IMAGE_PROP_PREFIX + '%s' ) #NEWLINE# for ( key , value ) in six . iteritems ( image_meta . get ( 'properties' , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) ) : #NEWLINE# #INDENT# if ( key in SM_SKIP_KEYS ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# new_value = safe_truncate ( six . text_type ( value ) , 255 ) #NEWLINE# system_meta [ ( prefix_format % key ) ] = new_value #NEWLINE# #UNINDENT# for key in SM_INHERITABLE_KEYS : #NEWLINE# #INDENT# value = image_meta . get ( key ) #NEWLINE# if ( ( key == 'min_disk' ) and flavor ) : #NEWLINE# #INDENT# if ( image_meta . get ( 'disk_format' ) == 'vhd' ) : #NEWLINE# #INDENT# value = value [ 'root_gb' ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# value = max ( ( value or 0 ) , flavor [ 'root_gb' ] ) #NEWLINE# #UNINDENT# #UNINDENT# if ( value is None ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# system_meta [ ( prefix_format % key ) ] = value #NEWLINE# #UNINDENT# return system_meta