#NEWLINE# def handle( self , request , data ) : #NEWLINE# #INDENT# id = self . initial [ 'id' ] #NEWLINE# old_metadata = self . initial [ 'metadata' ] #NEWLINE# try : #NEWLINE# #INDENT# new_metadata = json . loads ( self . data [ 'metadata' ] ) #NEWLINE# metadata = dict ( ( ( item [ 'key' ] , str ( item [ 'value' ] ) ) for item in new_metadata ) ) #NEWLINE# remove_props = [ key for key in old_metadata if ( key not in metadata ) ] #NEWLINE# api . glance . image_update_properties ( request , id , remove_props , ** metadata ) #NEWLINE# message = _ ( 'Metadata successfully updated.' ) #NEWLINE# messages . success ( request , message ) #NEWLINE# #UNINDENT# except Exception : #NEWLINE# #INDENT# exceptions . handle ( request , _ ( 'Unable to update the image metadata.' ) ) #NEWLINE# return False #NEWLINE# #UNINDENT# return True