def reboot(self, task, timeout=None): """Perform a hard reboot of the task's node. :param task: A TaskManager instance containing the node to act on. :param timeout: Time to wait for the node to become powered on. :raises: InvalidParameterValue on malformed parameter(s) :raises: MissingParameterValue if a required parameter is missing. :raises: IBMCConnectionError when it fails to connect to iBMC :raises: IBMCError on an error from the iBMC """ self.validate(task) system = utils.get_system(task.node) current_power_state = (mappings.GET_POWER_STATE_MAP.get( system.power_state)) try: if current_power_state == states.POWER_ON: system.reset_system( mappings.SET_POWER_STATE_MAP_REV.get(states.REBOOT)) else: system.reset_system( mappings.SET_POWER_STATE_MAP_REV.get(states.POWER_ON)) except requests.exceptions.RequestException as e: error_msg = (_('IBMC reboot failed for node %(node)s. ' 'Error: %(error)s') % { 'node': task.node.uuid, 'error': e }) LOG.error(error_msg) raise exception.IBMCError(error=error_msg) cond_utils.node_wait_for_power_state(task, states.POWER_ON, timeout=timeout)
def set_power_state(self, task, power_state, timeout=None): """Set the power state of the task's node. :param task: A TaskManager instance containing the node to act on. :param power_state: Any power state from :mod:`ironic.common.states`. :param timeout: Time to wait for the node to reach the requested state. :raises: InvalidParameterValue on malformed parameter(s) :raises: MissingParameterValue if a required parameter is missing. :raises: IBMCConnectionError when it fails to connect to iBMC :raises: IBMCError on an error from the iBMC """ self.validate(task) system = utils.get_system(task.node) try: system.reset_system( mappings.SET_POWER_STATE_MAP_REV.get(power_state)) except requests.exceptions.RequestException as e: error_msg = (_('IBMC set power state failed for node ' '%(node)s. Error: %(error)s') % { 'node': task.node.uuid, 'error': e }) LOG.error(error_msg) raise exception.IBMCError(error=error_msg) target_state = TARGET_STATE_MAP.get(power_state, power_state) cond_utils.node_wait_for_power_state(task, target_state, timeout=timeout)
def reboot(self, task, timeout=None): """Perform a hard reboot of the task's node. :param task: A TaskManager instance containing the node to act on. :param timeout: Time to wait for the node to become powered on. :raises: InvalidParameterValue on malformed parameter(s) :raises: MissingParameterValue if a required parameter is missing. :raises: IBMCConnectionError when it fails to connect to iBMC :raises: IBMCError when iBMC responses an error information """ ibmc = utils.parse_driver_info(task.node) with ibmc_client.connect(**ibmc) as conn: system = conn.system.get() current_power_state = (mappings.GET_POWER_STATE_MAP.get( system.power_state)) if current_power_state == states.POWER_ON: conn.system.reset( mappings.SET_POWER_STATE_MAP.get(states.REBOOT)) else: conn.system.reset( mappings.SET_POWER_STATE_MAP.get(states.POWER_ON)) cond_utils.node_wait_for_power_state(task, states.POWER_ON, timeout=timeout)
def reboot(self, task, timeout=None): """Perform a hard reboot of the task's node. :param task: a TaskManager instance containing the node to act on. :param timeout: Time to wait for the node to become powered on. :raises: MissingParameterValue if a required parameter is missing. :raises: RedfishConnectionError when it fails to connect to Redfish :raises: RedfishError on an error from the Sushy library """ system = redfish_utils.get_system(task.node) current_power_state = GET_POWER_STATE_MAP.get(system.power_state) try: if current_power_state == states.POWER_ON: system.reset_system(SET_POWER_STATE_MAP.get(states.REBOOT)) else: system.reset_system(SET_POWER_STATE_MAP.get(states.POWER_ON)) except sushy.exceptions.SushyError as e: error_msg = (_('Redfish reboot failed for node %(node)s. ' 'Error: %(error)s') % {'node': task.node.uuid, 'error': e}) LOG.error(error_msg) raise exception.RedfishError(error=error_msg) cond_utils.node_wait_for_power_state(task, states.POWER_ON, timeout=timeout)
def reboot(self, task, timeout=None): """Perform a hard reboot of the task's node. :param task: A TaskManager instance containing the node to act on. :param timeout: Time to wait for the node to become powered on. :raises: InvalidParameterValue on malformed parameter(s) :raises: MissingParameterValue if a required parameter is missing. :raises: IBMCConnectionError when it fails to connect to iBMC :raises: IBMCError when iBMC responses an error information """ ibmc = utils.parse_driver_info(task.node) with ibmc_client.connect(**ibmc) as conn: system = conn.system.get() current_power_state = ( mappings.GET_POWER_STATE_MAP.get(system.power_state) ) if current_power_state == states.POWER_ON: conn.system.reset( mappings.SET_POWER_STATE_MAP.get(states.REBOOT)) else: conn.system.reset( mappings.SET_POWER_STATE_MAP.get(states.POWER_ON)) cond_utils.node_wait_for_power_state(task, states.POWER_ON, timeout=timeout)
def set_power_state(self, task, power_state, timeout=None): """Set the power state of the task's node. :param task: a TaskManager instance containing the node to act on. :param power_state: Any power state from :mod:`ironic.common.states`. :param timeout: Time to wait for the node to reach the requested state. :raises: MissingParameterValue if a required parameter is missing. :raises: RedfishConnectionError when it fails to connect to Redfish :raises: RedfishError on an error from the Sushy library """ system = redfish_utils.get_system(task.node) try: system.reset_system(SET_POWER_STATE_MAP.get(power_state)) except sushy.exceptions.SushyError as e: error_msg = (_('Redfish set power state failed for node ' '%(node)s. Error: %(error)s') % { 'node': task.node.uuid, 'error': e }) LOG.error(error_msg) raise exception.RedfishError(error=error_msg) target_state = TARGET_STATE_MAP.get(power_state, power_state) cond_utils.node_wait_for_power_state(task, target_state, timeout=timeout)
def reboot(self, task, timeout=None): """Perform a hard reboot of the task's node. :param task: a TaskManager instance containing the node to act on. :param timeout: Time to wait for the node to become powered on. :raises: MissingParameterValue if a required parameter is missing. :raises: RedfishConnectionError when it fails to connect to Redfish :raises: RedfishError on an error from the Sushy library """ system = redfish_utils.get_system(task.node) current_power_state = GET_POWER_STATE_MAP.get(system.power_state) try: if current_power_state == states.POWER_ON: system.reset_system(SET_POWER_STATE_MAP.get(states.REBOOT)) else: system.reset_system(SET_POWER_STATE_MAP.get(states.POWER_ON)) except sushy.exceptions.SushyError as e: error_msg = (_('Redfish reboot failed for node %(node)s. ' 'Error: %(error)s') % { 'node': task.node.uuid, 'error': e }) LOG.error(error_msg) raise exception.RedfishError(error=error_msg) cond_utils.node_wait_for_power_state(task, states.POWER_ON, timeout=timeout)
def _set_power_state(task, system, power_state, timeout=None): """An internal helper to set a power state on the system. :param task: a TaskManager instance containing the node to act on. :param system: a Redfish System object. :param power_state: Any power state from :mod:`ironic.common.states`. :param timeout: Time to wait for the node to reach the requested state. :raises: MissingParameterValue if a required parameter is missing. :raises: RedfishConnectionError when it fails to connect to Redfish :raises: RedfishError on an error from the Sushy library """ system.reset_system(SET_POWER_STATE_MAP.get(power_state)) target_state = TARGET_STATE_MAP.get(power_state, power_state) cond_utils.node_wait_for_power_state(task, target_state, timeout=timeout)
def set_power_state(self, task, power_state, timeout=None): """Set the power state of the task's node. :param task: A TaskManager instance containing the node to act on. :param power_state: Any power state from :mod:`ironic.common.states`. :param timeout: Time to wait for the node to reach the requested state. :raises: InvalidParameterValue on malformed parameter(s) :raises: MissingParameterValue if a required parameter is missing. :raises: IBMCConnectionError when it fails to connect to iBMC :raises: IBMCError when iBMC responses an error information """ ibmc = utils.parse_driver_info(task.node) with ibmc_client.connect(**ibmc) as conn: reset_type = mappings.SET_POWER_STATE_MAP.get(power_state) conn.system.reset(reset_type) target_state = EXPECT_POWER_STATE_MAP.get(power_state, power_state) cond_utils.node_wait_for_power_state(task, target_state, timeout=timeout)
def set_power_state(self, task, power_state, timeout=None): """Set the power state of the task's node. :param task: A TaskManager instance containing the node to act on. :param power_state: Any power state from :mod:`ironic.common.states`. :param timeout: Time to wait for the node to reach the requested state. :raises: InvalidParameterValue on malformed parameter(s) :raises: MissingParameterValue if a required parameter is missing. :raises: IBMCConnectionError when it fails to connect to iBMC :raises: IBMCError when iBMC responses an error information """ ibmc = utils.parse_driver_info(task.node) with ibmc_client.connect(**ibmc) as conn: reset_type = mappings.SET_POWER_STATE_MAP.get(power_state) conn.system.reset(reset_type) target_state = EXPECT_POWER_STATE_MAP.get(power_state, power_state) cond_utils.node_wait_for_power_state(task, target_state, timeout=timeout)
def set_power_state(self, task, power_state, timeout=None): """Set the power state of the task's node. :param task: a TaskManager instance containing the node to act on. :param power_state: Any power state from :mod:`ironic.common.states`. :param timeout: Time to wait for the node to reach the requested state. :raises: MissingParameterValue if a required parameter is missing. :raises: RedfishConnectionError when it fails to connect to Redfish :raises: RedfishError on an error from the Sushy library """ system = redfish_utils.get_system(task.node) try: system.reset_system(SET_POWER_STATE_MAP.get(power_state)) except sushy.exceptions.SushyError as e: error_msg = (_('Redfish set power state failed for node ' '%(node)s. Error: %(error)s') % {'node': task.node.uuid, 'error': e}) LOG.error(error_msg) raise exception.RedfishError(error=error_msg) target_state = TARGET_STATE_MAP.get(power_state, power_state) cond_utils.node_wait_for_power_state(task, target_state, timeout=timeout)