#NEWLINE# def _power_off( node , timeout = None ) : #NEWLINE# #INDENT# 'Power OFF this node\n\n    :param node: Ironic node one of :class:`ironic.db.models.Node`\n    :param timeout: Time in seconds to wait till power off is compelete\n    :raises: InvalidParameterValue if a seamicro parameter is invalid.\n    :raises: MissingParameterValue if required seamicro parameters are\n        missing.\n    :returns: Power state of the given node\n    ' #NEWLINE# if ( timeout is None ) : #NEWLINE# #INDENT# timeout = CONF . seamicro . action_timeout #NEWLINE# #UNINDENT# state = [ None ] #NEWLINE# retries = [ 0 ] #NEWLINE# seamicro_info = _parse_driver_info ( node ) #NEWLINE# server = _get_server ( seamicro_info ) #NEWLINE# def _wait_for_power_off( state , retries ) : #NEWLINE# #INDENT# 'Called at an interval until the node is powered off.' #NEWLINE# state [ 0 ] = _get_power_status ( node ) #NEWLINE# if ( state [ 0 ] == states . POWER_OFF ) : #NEWLINE# #INDENT# raise loopingcall . LoopingCallDone ( ) #NEWLINE# #UNINDENT# if ( retries [ 0 ] > CONF . seamicro . max_retry ) : #NEWLINE# #INDENT# state [ 0 ] = states . ERROR #NEWLINE# raise loopingcall . LoopingCallDone ( ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# retries [ 0 ] += 1 #NEWLINE# server . power_off ( ) #NEWLINE# #UNINDENT# except seamicro_client_exception . ClientException : #NEWLINE# #INDENT# LOG . warning ( _LW ( 'Power-off failed for node %s.' ) , node . uuid ) #NEWLINE# #UNINDENT# #UNINDENT# timer = loopingcall . FixedIntervalLoopingCall ( _wait_for_power_off , state , retries ) #NEWLINE# timer . start ( interval = timeout ) . wait ( ) #NEWLINE# return state [ 0 ]