#NEWLINE# @ classmethod #NEWLINE# def provision_resp( cls , **kwargs ) : #NEWLINE# #INDENT# logger . info ( ( 'RPC method provision_resp received: %s' % jsonutils . dumps ( kwargs ) ) ) #NEWLINE# task_uuid = kwargs . get ( 'task_uuid' ) #NEWLINE# message = kwargs . get ( 'error' ) #NEWLINE# status = kwargs . get ( 'status' ) #NEWLINE# progress = kwargs . get ( 'progress' ) #NEWLINE# nodes = kwargs . get ( 'nodes' , [ ] ) #NEWLINE# task = objects . Task . get_by_uuid ( task_uuid , fail_if_not_found = True , lock_for_update = True ) #NEWLINE# nodes_by_id = { str ( n [ 'uid' ] ) : n for n in nodes } #NEWLINE# master = nodes_by_id . pop ( consts . MASTER_NODE_UID , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# if ( master . get ( 'status' ) == consts . TASK_STATUSES . error ) : #NEWLINE# #INDENT# status = consts . TASK_STATUSES . error #NEWLINE# progress = 100 #NEWLINE# #UNINDENT# q_nodes = objects . NodeCollection . filter_by_id_list ( None , nodes_by_id ) #NEWLINE# q_nodes = objects . NodeCollection . order_by ( q_nodes , 'id' ) #NEWLINE# db_nodes = objects . NodeCollection . lock_for_update ( q_nodes ) . all ( ) #NEWLINE# for node_db in db_nodes : #NEWLINE# #INDENT# node = nodes_by_id . pop ( node_db . uid ) #NEWLINE# if ( node . get ( 'status' ) == consts . TASK_STATUSES . error ) : #NEWLINE# #INDENT# node_db . status = consts . TASK_STATUSES . error #NEWLINE# node_db . progress = 100 #NEWLINE# node_db . error_type = consts . TASK_NAMES . provision #NEWLINE# node_db . error_msg = node . get ( 'error_msg' , 'Unknown error' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# node_db . status = node . get ( 'status' ) #NEWLINE# node_db . progress = node . get ( 'progress' ) #NEWLINE# #UNINDENT# #UNINDENT# db ( ) . flush ( ) #NEWLINE# if nodes_by_id : #NEWLINE# #INDENT# logger . warning ( 'The following nodes is not found: %s' , ',' . join ( sorted ( six . moves . map ( str , nodes_by_id ) ) ) ) #NEWLINE# #UNINDENT# if ( nodes and ( not progress ) ) : #NEWLINE# #INDENT# progress = TaskHelper . recalculate_provisioning_task_progress ( task ) #NEWLINE# #UNINDENT# cls . _update_task_status ( task , status , progress , message , db_nodes ) #NEWLINE# cls . _update_action_log_entry ( status , task . name , task_uuid , nodes_by_id )