#NEWLINE# def _wait_for_completion( conn , promise , wait_timeout , msg ) : #NEWLINE# #INDENT# '\n    Poll request status until resource is provisioned.\n    ' #NEWLINE# if ( not promise ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# wait_timeout = ( time . time ( ) + wait_timeout ) #NEWLINE# while ( wait_timeout > time . time ( ) ) : #NEWLINE# #INDENT# time . sleep ( 5 ) #NEWLINE# operation_result = conn . get_request ( request_id = promise [ 'requestId' ] , status = True ) #NEWLINE# if ( operation_result [ 'metadata' ] [ 'status' ] == 'DONE' ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( operation_result [ 'metadata' ] [ 'status' ] == 'FAILED' ) : #NEWLINE# #INDENT# raise Exception ( ( ( ( ( 'Request failed to complete ' + msg ) + ' "' ) + str ( promise [ 'requestId' ] ) ) + '" to complete.' ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# raise Exception ( ( ( ( ( 'Timed out waiting for async operation ' + operation_result ) + ' "' ) + str ( promise [ 'requestId' ] ) ) + '" to complete.' ) )