#NEWLINE# def handle( self , request , data ) : #NEWLINE# #INDENT# if ( data [ 'disk_format' ] in ( 'ami' , 'aki' , 'ari' ) ) : #NEWLINE# #INDENT# container_format = data [ 'disk_format' ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# container_format = 'bare' #NEWLINE# #UNINDENT# meta = { #NEWLINE# #INDENT# 'is_public' : data [ 'is_public' ] , #NEWLINE# 'protected' : data [ 'protected' ] , #NEWLINE# 'disk_format' : data [ 'disk_format' ] , #NEWLINE# 'container_format' : container_format , #NEWLINE# 'min_disk' : ( data [ 'minimum_disk' ] or 0 ) , #NEWLINE# 'min_ram' : ( meta [ 'minimum_ram' ] or 0 ) , #NEWLINE# 'name' : data [ 'name' ] , #NEWLINE# 'properties' : { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# if data [ 'description' ] : #NEWLINE# #INDENT# meta [ 'properties' ] [ 'description' ] = data [ 'description' ] #NEWLINE# #UNINDENT# if data [ 'architecture' ] : #NEWLINE# #INDENT# meta [ 'properties' ] [ 'architecture' ] = data [ 'architecture' ] #NEWLINE# #UNINDENT# if ( settings . HORIZON_IMAGES_ALLOW_UPLOAD and policy . check ( ( ( 'image' , 'upload_image' ) , ) , request ) and data . get ( 'image_file' , None ) ) : #NEWLINE# #INDENT# meta [ 'data' ] = self . files [ 'image_file' ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# meta [ 'copy_from' ] = data [ 'copy_from' ] #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# image = api . glance . image_create ( request , ** meta ) #NEWLINE# messages . success ( request , ( _ ( 'Your image %s has been queued for creation.' ) % data [ 'name' ] ) ) #NEWLINE# return image #NEWLINE# #UNINDENT# except Exception : #NEWLINE# #INDENT# exceptions . handle ( request , _ ( 'Unable to create new image.' ) )