コード例 #1
0
def set_onetime_boot(task):
    """Set onetime boot to server hardware.

    Change the onetime boot option of an OneView server hardware.

    :param task: a task from TaskManager.
    """
    driver_internal_info = task.node.driver_internal_info
    next_boot_device = driver_internal_info.get('next_boot_device')

    if next_boot_device:
        boot_device = next_boot_device.get('boot_device')
        persistent = next_boot_device.get('persistent')

        if not persistent:
            server_hardware = task.node.driver_info.get('server_hardware_uri')
            ilo_client = common.get_ilorest_client(server_hardware)
            boot_device = BOOT_DEVICE_MAP_ILO.get(boot_device)
            body = {
                "Boot": {
                    "BootSourceOverrideTarget": boot_device,
                    "BootSourceOverrideEnabled": "Once"
                }
            }
            ilo_client.patch(path=ILO_SYSTEM_PATH,
                             body=body,
                             headers=ILO_REQUEST_HEADERS)
コード例 #2
0
def _is_onetime_boot(task):
    """Check onetime boot from server hardware.

    Check if the onetime boot option of an OneView server hardware
    is set to 'Once' in iLO.

    :param task: a task from TaskManager.
    :returns: Boolean value. True if onetime boot is 'Once'
              False otherwise.

    """
    server_hardware = task.node.driver_info.get('server_hardware_uri')
    ilo_client = common.get_ilorest_client(server_hardware)
    response = ilo_client.get(path=ILO_SYSTEM_PATH,
                              headers=ILO_REQUEST_HEADERS)
    boot = response.dict.get('Boot')
    onetime_boot = boot.get('BootSourceOverrideEnabled')
    return onetime_boot == 'Once'
コード例 #3
0
def set_onetime_boot(task):
    """Set onetime boot to server hardware.

    Change the onetime boot option of an OneView server hardware.

    :param task: a task from TaskManager.
    """
    driver_internal_info = task.node.driver_internal_info
    next_boot_device = driver_internal_info.get('next_boot_device')

    if not next_boot_device:
        return

    boot_device = next_boot_device.get('boot_device')
    persistent = next_boot_device.get('persistent')

    if persistent:
        return

    server_hardware = task.node.driver_info.get('server_hardware_uri')
    ilo_client = common.get_ilorest_client(server_hardware)
    boot_device = BOOT_DEVICE_MAP_ILO.get(boot_device)
    body = {
        "Boot": {
            "BootSourceOverrideTarget": boot_device,
            "BootSourceOverrideEnabled": "Once"
        }
    }
    try:
        ilo_client.patch(path=ILO_SYSTEM_PATH,
                         body=body,
                         headers=ILO_REQUEST_HEADERS)
    except Exception as e:
        msg = (_("Error while trying to set onetime boot on Server Hardware: "
                 "%(sh_uri)s. Error: %(error)s") % {
                     'sh_uri': server_hardware,
                     'error': e
                 })
        raise exception.OneViewError(error=msg)