#NEWLINE# def _resize( self , req , instance_id , flavor_id , **kwargs ) : #NEWLINE# #INDENT# 'Begin the resize process with given instance/flavor.' #NEWLINE# context = req . environ [ 'nova.context' ] #NEWLINE# authorize ( flavor_id , action = 'resize' ) #NEWLINE# instance = self . _get_server ( context , req , instance_id ) #NEWLINE# try : #NEWLINE# #INDENT# self . compute_api . resize ( context , instance , flavor_id , ** kwargs ) #NEWLINE# #UNINDENT# except exception . InstanceUnknownCell as e : #NEWLINE# #INDENT# raise exc . HTTPNotFound ( explanation = e . format_message ( ) ) #NEWLINE# #UNINDENT# except exception . QuotaError as error : #NEWLINE# #INDENT# raise exc . HTTPForbidden ( explanation = error . format_message ( ) ) #NEWLINE# #UNINDENT# except exception . InstanceIsLocked as e : #NEWLINE# #INDENT# raise exc . HTTPConflict ( explanation = e . format_message ( ) ) #NEWLINE# #UNINDENT# except exception . InstanceInvalidState as state_error : #NEWLINE# #INDENT# common . raise_http_conflict_for_instance_invalid_state ( state_error , 'resize' , instance_id ) #NEWLINE# #UNINDENT# except exception . ImageNotAuthorized : #NEWLINE# #INDENT# msg = _ ( 'You are not authorized to access the image the instance was started with.' ) #NEWLINE# raise exc . HTTPUnauthorized ( explanation = msg ) #NEWLINE# #UNINDENT# except exception . ImageNotFound : #NEWLINE# #INDENT# msg = _ ( 'Image that the instance was started with could not be found.' ) #NEWLINE# raise exc . HTTPBadRequest ( explanation = msg ) #NEWLINE# #UNINDENT# except ( exception . AutoDiskConfigDisabledByImage , exception . CannotResizeDisk , exception . CannotResizeToSameFlavor , exception . FlavorNotFound , exception . NoValidHost ) as e : #NEWLINE# #INDENT# raise exc . HTTPBadRequest ( explanation = e . format_message ( ) ) #NEWLINE# #UNINDENT# except exception . Invalid : #NEWLINE# #INDENT# msg = _ ( 'Invalid instance image.' ) #NEWLINE# raise exc . HTTPBadRequest ( explanation = msg )