#NEWLINE# @ extensions . expected_errors ( ( 400 , 403 , 404 , 413 ) ) #NEWLINE# @ validation . schema ( image_metadata . create ) #NEWLINE# def create( self , req , image_id , body ) : #NEWLINE# #INDENT# context = req . environ [ 'nova.context' ] #NEWLINE# image = self . _get_image ( context , body ) #NEWLINE# for ( key , value ) in six . iteritems ( body [ 'metadata' ] ) : #NEWLINE# #INDENT# image [ 'properties' ] [ key ] = value #NEWLINE# #UNINDENT# common . check_img_metadata_properties_quota ( context , image [ 'properties' ] ) #NEWLINE# try : #NEWLINE# #INDENT# image = self . image_api . update ( context , image_id , image , data = None , purge_props = True ) #NEWLINE# #UNINDENT# except exception . ImageNotAuthorized as e : #NEWLINE# #INDENT# raise exc . HTTPForbidden ( explanation = e . format_message ( ) ) #NEWLINE# #UNINDENT# return dict ( metadata = image [ 'properties' ] )