#NEWLINE# def update( self , req , id , body ) : #NEWLINE# #INDENT# 'Update server then pass on to version-specific controller.' #NEWLINE# if ( not self . is_valid_body ( self , 'server' ) ) : #NEWLINE# #INDENT# raise exc . HTTPUnprocessableEntity ( ) #NEWLINE# #UNINDENT# ctxt = req . environ [ 'nova.context' ] #NEWLINE# update_dict = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# if ( 'name' in body [ 'server' ] ) : #NEWLINE# #INDENT# name = body [ 'server' ] [ 'name' ] #NEWLINE# self . _validate_server_name ( name ) #NEWLINE# update_dict [ 'display_name' ] = name . strip ( ) #NEWLINE# #UNINDENT# if ( 'accessIPv4' in body [ 'server' ] ) : #NEWLINE# #INDENT# access_ipv4 = body [ 'server' ] [ 'accessIPv4' ] #NEWLINE# if access_ipv4 : #NEWLINE# #INDENT# self . _validate_access_ipv4 ( access_ipv4 ) #NEWLINE# #UNINDENT# update_dict [ 'access_ip_v4' ] = ( ( access_ipv4 and access_ipv4 . strip ( ) ) or None ) #NEWLINE# #UNINDENT# if ( 'accessIPv6' in body [ 'server' ] ) : #NEWLINE# #INDENT# access_ipv6 = body [ 'server' ] [ 'accessIPv6' ] #NEWLINE# if access_ipv6 : #NEWLINE# #INDENT# self . _validate_access_ipv6 ( access_ipv6 ) #NEWLINE# #UNINDENT# update_dict [ 'access_ip_v6' ] = ( ( access_ipv6 and access_ipv6 . strip ( ) ) or None ) #NEWLINE# #UNINDENT# if ( 'auto_disk_config' in body [ 'server' ] ) : #NEWLINE# #INDENT# auto_disk_config = strutils . bool_from_string ( body [ 'server' ] [ 'auto_disk_config' ] ) #NEWLINE# update_dict [ 'auto_disk_config' ] = auto_disk_config #NEWLINE# #UNINDENT# if ( 'hostId' in body [ 'server' ] ) : #NEWLINE# #INDENT# msg = _ ( 'HostId cannot be updated.' ) #NEWLINE# raise exc . HTTPBadRequest ( explanation = msg ) #NEWLINE# #UNINDENT# if ( 'personality' in body [ 'server' ] ) : #NEWLINE# #INDENT# msg = _ ( 'Personality cannot be updated.' ) #NEWLINE# raise exc . HTTPBadRequest ( explanation = msg ) #NEWLINE# #UNINDENT# instance = self . _get_server ( ctxt , req , id , is_detail = True ) #NEWLINE# try : #NEWLINE# #INDENT# policy . enforce ( ctxt , 'compute:update' , instance ) #NEWLINE# instance . update ( update_dict ) #NEWLINE# instance . save ( ) #NEWLINE# #UNINDENT# except exception . NotFound : #NEWLINE# #INDENT# msg = _ ( 'Instance could not be found' ) #NEWLINE# raise exc . HTTPNotFound ( explanation = msg ) #NEWLINE# #UNINDENT# return self . _view_builder . show ( req , instance )