#NEWLINE# def wait_for_bm_node_status( client , node_id , attr , status ) : #NEWLINE# #INDENT# 'Waits for a baremetal node attribute to reach given status.\n\n    The client should have a show_node(node_uuid) method to get the node.\n    ' #NEWLINE# ( _ , node ) = client . show_node ( node_id ) #NEWLINE# start = int ( time . time ( ) ) #NEWLINE# while ( node [ attr ] != status ) : #NEWLINE# #INDENT# time . sleep ( client . build_interval ) #NEWLINE# ( _ , node ) = client . show_node ( node_id ) #NEWLINE# status_curr = node [ attr ] #NEWLINE# if ( status_curr == status ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# if ( ( int ( time . time ( ) ) - start ) >= client . build_timeout ) : #NEWLINE# #INDENT# message = ( 'Node %(node_id)s failed to reach %(attr)s=%(status)s within the required time (%(timeout)s s).' % { #NEWLINE# #INDENT# 'node_id' : node_id , #NEWLINE# 'attr' : attr , #NEWLINE# 'status' : status , #NEWLINE# 'timeout' : client . build_timeout , #NEWLINE# #UNINDENT# } ) #NEWLINE# message += ( ' Current state of %s: %s.' % ( attr , status_curr ) ) #NEWLINE# caller = misc_utils . find_test_caller ( ) #NEWLINE# if caller : #NEWLINE# #INDENT# message = ( '(%s) %s' % ( caller , message ) ) #NEWLINE# #UNINDENT# raise lib_exc . TimeoutException ( message )