#NEWLINE# @ task_manager . require_exclusive_lock #NEWLINE# def set_power_state( self , task , pstate ) : #NEWLINE# #INDENT# "Turn the power on or off.\n\n        Set the power state of a node.\n\n        :param task: a TaskManager instance containing the node to act on.\n        :param pstate: Either POWER_ON or POWER_OFF from :class:\n            `ironic.common.states`.\n        :raises: InvalidParameterValue if an invalid power state was specified\n            or a seamicro parameter is invalid.\n        :raises: MissingParameterValue when a required parameter is missing\n        :raises: PowerStateFailure if the desired power state couldn't be set.\n        " #NEWLINE# if ( pstate == states . POWER_ON ) : #NEWLINE# #INDENT# state = _power_on ( task . node ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( pstate == states . POWER_OFF ) : #NEWLINE# #INDENT# state = _power_off ( task . node ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise exception . InvalidParameterValue ( _ ( 'set_power_state called with invalid power state.' ) ) #NEWLINE# #UNINDENT# #UNINDENT# if ( state != pstate ) : #NEWLINE# #INDENT# raise exception . PowerStateFailure ( pstate = pstate )