Exemplo n.º 1
0
    def set_power_state(self, task, pstate):
        """Turn the power on or off.

        :param task: a TaskManager instance containing the node to act on.
        :param pstate: The desired power state, one of ironic.common.states
            POWER_ON, POWER_OFF.
        :raises: InvalidParameterValue if an invalid power state was specified.
        :raises: MissingParameterValue if required ipmi parameters are missing
        :raises: PowerStateFailure if the power couldn't be set to pstate.

        """
        driver_info = _parse_driver_info(task.node)

        if pstate == states.POWER_ON:
            driver_utils.ensure_next_boot_device(task, driver_info)
            state = _power_on(driver_info)
        elif pstate == states.POWER_OFF:
            state = _power_off(driver_info)
        else:
            raise exception.InvalidParameterValue(
                _("set_power_state called "
                  "with invalid power state %s.") % pstate)

        if state != pstate:
            raise exception.PowerStateFailure(pstate=pstate)
Exemplo n.º 2
0
    def set_power_state(self, task, pstate):
        """Turn the power on or off.

        :param task: a TaskManager instance containing the node to act on.
        :param pstate: a power state that will be set on the task's node.
        :raises: IPMIFailure when the native ipmi call fails.
        :raises: MissingParameterValue when required ipmi credentials
                 are missing.
        :raises: InvalidParameterValue when an invalid power state
                 is specified
        :raises: PowerStateFailure when invalid power state is returned
                 from ipmi.
        """

        driver_info = _parse_driver_info(task.node)

        if pstate == states.POWER_ON:
            driver_utils.ensure_next_boot_device(task, driver_info)
            _power_on(driver_info)
        elif pstate == states.POWER_OFF:
            _power_off(driver_info)
        else:
            raise exception.InvalidParameterValue(
                _("set_power_state called with an invalid power state: %s.") %
                pstate)
Exemplo n.º 3
0
 def test_ensure_next_boot_device(self, node_set_boot_device_mock):
     with task_manager.acquire(self.context, self.node.uuid,
                               shared=False) as task:
         task.node.driver_internal_info['persistent_boot_device'] = 'pxe'
         driver_utils.ensure_next_boot_device(task,
                                              {'force_boot_device': True})
         node_set_boot_device_mock.assert_called_once_with(task, 'pxe')
Exemplo n.º 4
0
    def set_power_state(self, task, pstate):
        """Turn the power on or off.

        :param task: a TaskManager instance containing the node to act on.
        :param pstate: a power state that will be set on the task's node.
        :raises: IPMIFailure when the native ipmi call fails.
        :raises: MissingParameterValue when required ipmi credentials
                 are missing.
        :raises: InvalidParameterValue when an invalid power state
                 is specified
        :raises: PowerStateFailure when invalid power state is returned
                 from ipmi.
        """

        driver_info = _parse_driver_info(task.node)

        if pstate == states.POWER_ON:
            driver_utils.ensure_next_boot_device(task, driver_info)
            _power_on(driver_info)
        elif pstate == states.POWER_OFF:
            _power_off(driver_info)
        else:
            raise exception.InvalidParameterValue(
                _("set_power_state called with an invalid power state: %s."
                  ) % pstate)
Exemplo n.º 5
0
    def set_power_state(self, task, pstate):
        """Turn the power on or off.

        :param task: a TaskManager instance containing the node to act on.
        :param pstate: The desired power state, one of ironic.common.states
            POWER_ON, POWER_OFF.
        :raises: InvalidParameterValue if an invalid power state was specified.
        :raises: MissingParameterValue if required ipmi parameters are missing
        :raises: PowerStateFailure if the power couldn't be set to pstate.

        """
        driver_info = _parse_driver_info(task.node)

        if pstate == states.POWER_ON:
            driver_utils.ensure_next_boot_device(task, driver_info)
            state = _power_on(driver_info)
        elif pstate == states.POWER_OFF:
            state = _power_off(driver_info)
        else:
            raise exception.InvalidParameterValue(
                _("set_power_state called "
                  "with invalid power state %s.") % pstate)

        if state != pstate:
            raise exception.PowerStateFailure(pstate=pstate)
Exemplo n.º 6
0
 def test_ensure_next_boot_device_clears_is_next_boot_persistent(self):
     with task_manager.acquire(self.context, self.node.uuid, shared=False) as task:
         task.node.driver_internal_info["persistent_boot_device"] = "pxe"
         task.node.driver_internal_info["is_next_boot_persistent"] = False
         driver_utils.ensure_next_boot_device(task, {"force_boot_device": True})
         task.node.refresh()
         self.assertNotIn("is_next_boot_persistent", task.node.driver_internal_info)
Exemplo n.º 7
0
 def test_ensure_next_boot_device(self, node_set_boot_device_mock):
     with task_manager.acquire(self.context, self.node.uuid,
                               shared=False) as task:
         task.node.driver_internal_info['persistent_boot_device'] = 'pxe'
         driver_utils.ensure_next_boot_device(
             task,
             {'force_boot_device': True}
         )
         node_set_boot_device_mock.assert_called_once_with(task, 'pxe')
Exemplo n.º 8
0
 def test_ensure_next_boot_device_clears_is_next_boot_persistent(self):
     with task_manager.acquire(self.context, self.node.uuid,
                               shared=False) as task:
         task.node.driver_internal_info['persistent_boot_device'] = 'pxe'
         task.node.driver_internal_info['is_next_boot_persistent'] = False
         driver_utils.ensure_next_boot_device(task,
                                              {'force_boot_device': True})
         task.node.refresh()
         self.assertNotIn('is_next_boot_persistent',
                          task.node.driver_internal_info)
Exemplo n.º 9
0
 def test_ensure_next_boot_device_clears_is_next_boot_persistent(self):
     with task_manager.acquire(self.context, self.node.uuid,
                               shared=False) as task:
         task.node.driver_internal_info['persistent_boot_device'] = 'pxe'
         task.node.driver_internal_info['is_next_boot_persistent'] = False
         driver_utils.ensure_next_boot_device(
             task,
             {'force_boot_device': True}
         )
         task.node.refresh()
         self.assertNotIn('is_next_boot_persistent',
                          task.node.driver_internal_info)
Exemplo n.º 10
0
    def reboot(self, task):
        """Cycles the power to the task's node.

        :param task: a TaskManager instance containing the node to act on.
        :raises: IPMIFailure when the native ipmi call fails.
        :raises: MissingParameterValue when required ipmi credentials
                 are missing.
        :raises: PowerStateFailure when invalid power state is returned
                 from ipmi.
        """

        driver_info = _parse_driver_info(task.node)
        driver_utils.ensure_next_boot_device(task, driver_info)
        _reboot(driver_info)
Exemplo n.º 11
0
    def reboot(self, task):
        """Cycles the power to the task's node.

        :param task: a TaskManager instance containing the node to act on.
        :raises: IPMIFailure when the native ipmi call fails.
        :raises: MissingParameterValue when required ipmi credentials
                 are missing.
        :raises: PowerStateFailure when invalid power state is returned
                 from ipmi.
        """

        driver_info = _parse_driver_info(task.node)
        driver_utils.ensure_next_boot_device(task, driver_info)
        _reboot(driver_info)
Exemplo n.º 12
0
    def reboot(self, task):
        """Cycles the power to the task's node.

        :param task: a TaskManager instance containing the node to act on.
        :raises: MissingParameterValue if required ipmi parameters are missing.
        :raises: InvalidParameterValue if an invalid power state was specified.
        :raises: PowerStateFailure if the final state of the node is not
            POWER_ON.

        """
        driver_info = _parse_driver_info(task.node)
        _power_off(driver_info)
        driver_utils.ensure_next_boot_device(task, driver_info)
        state = _power_on(driver_info)

        if state != states.POWER_ON:
            raise exception.PowerStateFailure(pstate=states.POWER_ON)
Exemplo n.º 13
0
    def reboot(self, task):
        """Cycles the power to the task's node.

        :param task: a TaskManager instance containing the node to act on.
        :raises: MissingParameterValue if required ipmi parameters are missing.
        :raises: InvalidParameterValue if an invalid power state was specified.
        :raises: PowerStateFailure if the final state of the node is not
            POWER_ON.

        """
        driver_info = _parse_driver_info(task.node)
        _power_off(driver_info)
        driver_utils.ensure_next_boot_device(task, driver_info)
        state = _power_on(driver_info)

        if state != states.POWER_ON:
            raise exception.PowerStateFailure(pstate=states.POWER_ON)