コード例 #1
0
ファイル: power.py プロジェクト: saintifly/ironic
    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)
コード例 #2
0
ファイル: power.py プロジェクト: saintifly/ironic
    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)
コード例 #3
0
ファイル: power.py プロジェクト: bopopescu/OpenStack-Stein
    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)
コード例 #4
0
ファイル: power.py プロジェクト: Tehsmash/ironic
    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)
コード例 #5
0
ファイル: power.py プロジェクト: michaeltchapman/ironic
    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)
コード例 #6
0
ファイル: power.py プロジェクト: bopopescu/OpenStack-Stein
    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)
コード例 #7
0
ファイル: power.py プロジェクト: bopopescu/OpenStack-Stein
    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)
コード例 #8
0
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)
コード例 #9
0
ファイル: power.py プロジェクト: michaeltchapman/ironic
    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)
コード例 #10
0
ファイル: power.py プロジェクト: bopopescu/OpenStack-Stein
    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)
コード例 #11
0
ファイル: power.py プロジェクト: Tehsmash/ironic
    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)