Exemplo n.º 1
0
    def set_power_state(self, task, pstate):
        """Set the power state of the node.

        Turn the node power on or off.

        :param task: a TaskManager instance contains the target node.
        :param pstate: The desired power state of the node.
        :raises: PowerStateFailure if the power cannot set to pstate.
        :raises: InvalidParameterValue
        """
        client, blade_id = msftocs_common.get_client_info(
            task.node.driver_info)

        try:
            if pstate == states.POWER_ON:
                client.set_blade_on(blade_id)
            elif pstate == states.POWER_OFF:
                client.set_blade_off(blade_id)
            else:
                raise exception.InvalidParameterValue(
                    _('Unsupported target_state: %s') % pstate)
        except exception.MSFTOCSClientApiException as ex:
            LOG.exception(_LE("Changing the power state to %(pstate)s failed. "
                              "Error: %(err_msg)s"),
                          {"pstate": pstate, "err_msg": ex})
            raise exception.PowerStateFailure(pstate=pstate)
Exemplo n.º 2
0
    def set_power_state(self, task, pstate):
        """Set the power state of the node.

        Turn the node power on or off.

        :param task: a TaskManager instance contains the target node.
        :param pstate: The desired power state of the node.
        :raises: PowerStateFailure if the power cannot set to pstate.
        :raises: InvalidParameterValue
        """
        client, blade_id = msftocs_common.get_client_info(
            task.node.driver_info)

        try:
            if pstate == states.POWER_ON:
                client.set_blade_on(blade_id)
            elif pstate == states.POWER_OFF:
                client.set_blade_off(blade_id)
            else:
                raise exception.InvalidParameterValue(
                    _('Unsupported target_state: %s') % pstate)
        except exception.MSFTOCSClientApiException as ex:
            LOG.exception(
                _LE("Changing the power state to %(pstate)s failed. "
                    "Error: %(err_msg)s"), {
                        "pstate": pstate,
                        "err_msg": ex
                    })
            raise exception.PowerStateFailure(pstate=pstate)
Exemplo n.º 3
0
    def get_power_state(self, task):
        """Get the power state from the node.

        :param task: a TaskManager instance containing the target node.
        :raises: MSFTOCSClientApiException.
        """
        client, blade_id = msftocs_common.get_client_info(task.node.driver_info)
        return POWER_STATES_MAP[client.get_blade_state(blade_id)]
Exemplo n.º 4
0
    def get_power_state(self, task):
        """Get the power state from the node.

        :param task: a TaskManager instance containing the target node.
        :raises: MSFTOCSClientApiException.
        """
        client, blade_id = msftocs_common.get_client_info(
            task.node.driver_info)
        return POWER_STATES_MAP[client.get_blade_state(blade_id)]
Exemplo n.º 5
0
    def test_get_client_info(self):
        with task_manager.acquire(self.context, self.node.uuid,
                                  shared=True) as task:
            driver_info = task.node.driver_info
            (client, blade_id) = msftocs_common.get_client_info(driver_info)

            self.assertEqual(driver_info['msftocs_base_url'], client._base_url)
            self.assertEqual(driver_info['msftocs_username'], client._username)
            self.assertEqual(driver_info['msftocs_password'], client._password)
            self.assertEqual(driver_info['msftocs_blade_id'], blade_id)
Exemplo n.º 6
0
    def test_get_client_info(self):
        with task_manager.acquire(self.context, self.node.uuid,
                                  shared=True) as task:
            driver_info = task.node.driver_info
            (client, blade_id) = msftocs_common.get_client_info(driver_info)

            self.assertEqual(driver_info['msftocs_base_url'], client._base_url)
            self.assertEqual(driver_info['msftocs_username'], client._username)
            self.assertEqual(driver_info['msftocs_password'], client._password)
            self.assertEqual(driver_info['msftocs_blade_id'], blade_id)
Exemplo n.º 7
0
    def reboot(self, task):
        """Cycle the power of the node

        :param task: a TaskManager instance contains the target node.
        :raises: PowerStateFailure if failed to reboot.
        """
        client, blade_id = msftocs_common.get_client_info(task.node.driver_info)
        try:
            client.set_blade_power_cycle(blade_id)
        except exception.MSFTOCSClientApiException as ex:
            LOG.exception(_LE("Reboot failed. Error: %(err_msg)s"), {"err_msg": ex})
            raise exception.PowerStateFailure(pstate=states.REBOOT)
Exemplo n.º 8
0
    def reboot(self, task):
        """Cycle the power of the node

        :param task: a TaskManager instance contains the target node.
        :raises: PowerStateFailure if failed to reboot.
        """
        client, blade_id = msftocs_common.get_client_info(
            task.node.driver_info)
        try:
            client.set_blade_power_cycle(blade_id)
        except exception.MSFTOCSClientApiException as ex:
            LOG.exception(_LE("Reboot failed. Error: %(err_msg)s"),
                          {"err_msg": ex})
            raise exception.PowerStateFailure(pstate=states.REBOOT)
Exemplo n.º 9
0
    def set_boot_device(self, task, device, persistent=False):
        """Set the boot device for the task's node.

        Set the boot device to use on next boot of the node.

        :param task: a task from TaskManager.
        :param device: the boot device.
        :param persistent: Boolean value. True if the boot device will
                           persist to all future boots, False if not.
                           Default: False.
        :raises: InvalidParameterValue if an invalid boot device is specified.
        """
        self._check_valid_device(device, task.node)
        client, blade_id = msftocs_common.get_client_info(
            task.node.driver_info)

        boot_mode = drivers_utils.get_node_capability(task.node, 'boot_mode')
        uefi = (boot_mode == 'uefi')

        boot_type = DEVICE_TO_BOOT_TYPE_MAP[device]
        client.set_next_boot(blade_id, boot_type, persistent, uefi)
Exemplo n.º 10
0
    def set_boot_device(self, task, device, persistent=False):
        """Set the boot device for the task's node.

        Set the boot device to use on next boot of the node.

        :param task: a task from TaskManager.
        :param device: the boot device.
        :param persistent: Boolean value. True if the boot device will
                           persist to all future boots, False if not.
                           Default: False.
        :raises: InvalidParameterValue if an invalid boot device is specified.
        """
        self._check_valid_device(device, task.node)
        client, blade_id = msftocs_common.get_client_info(
            task.node.driver_info)

        boot_mode = drivers_utils.get_node_capability(task.node, 'boot_mode')
        uefi = (boot_mode == 'uefi')

        boot_type = DEVICE_TO_BOOT_TYPE_MAP[device]
        client.set_next_boot(blade_id, boot_type, persistent, uefi)
Exemplo n.º 11
0
    def get_boot_device(self, task):
        """Get the current boot device for the task's node.

        Returns the current boot device of the node.

        :param task: a task from TaskManager.
        :returns: a dictionary containing:
            :boot_device: the boot device
            :persistent: Whether the boot device will persist to all
                future boots or not, None if it is unknown.
        """
        client, blade_id = msftocs_common.get_client_info(
            task.node.driver_info)
        device = BOOT_TYPE_TO_DEVICE_MAP.get(
            client.get_next_boot(blade_id), DEFAULT_BOOT_DEVICE)

        # Note(alexpilotti): Although the ChasssisManager REST API allows to
        # specify the persistent boot status in SetNextBoot, currently it does
        # not provide a way to retrieve the value with GetNextBoot.
        # This is being addressed in the ChassisManager API.
        return {'boot_device': device,
                'persistent': None}
Exemplo n.º 12
0
    def get_boot_device(self, task):
        """Get the current boot device for the task's node.

        Returns the current boot device of the node.

        :param task: a task from TaskManager.
        :returns: a dictionary containing:

            :boot_device: the boot device
            :persistent: Whether the boot device will persist to all
                future boots or not, None if it is unknown.

        """
        client, blade_id = msftocs_common.get_client_info(
            task.node.driver_info)
        device = BOOT_TYPE_TO_DEVICE_MAP.get(client.get_next_boot(blade_id),
                                             DEFAULT_BOOT_DEVICE)

        # Note(alexpilotti): Although the ChasssisManager REST API allows to
        # specify the persistent boot status in SetNextBoot, currently it does
        # not provide a way to retrieve the value with GetNextBoot.
        # This is being addressed in the ChassisManager API.
        return {'boot_device': device, 'persistent': None}