Exemplo n.º 1
0
def boot_order_precision_set(
        handle,
        reboot_on_update="no",
        reapply="no",
        configured_boot_mode="Legacy",
        secure_boot="no",
        boot_devices=[],
        server_id=1):
    """
    This method will replace the existing boot order precision with the new one
        and also set the boot mode
    This functionality is available only in release EP and above

    Args:
        handle (ImcHandle)
        reboot_on_update (string): "yes", "no"
        reapply(string): "yes", "no"
        configured_boot_mode(string): "Legacy", "Uefi", "None"
        boot_devices (list of dict): format
            [{"order":'1', "device-type":"vmedia", "name":"vmedia"},
             {"order":'2', "device-type":"hdd", "name":"hdd"}]

            boot-order(string): Order
            boot-device-type(string): "hdd", "iscsi", "pchstorage", "pxe",
                                      "san", "sdcard", "uefishell", "usb",
                                      "vmedia"
            boot-device-name(string): Unique label for the boot device
        server_id (int): Id of the server to perform
                         this operation on C3260 platforms

    Returns:
        LsBootDevPrecision object

    Examples:
        boot_order_precision_set(
            handle,
            reboot_on_update="no",
            reapply="no",
            configured_boot_mode="Uefi",
            boot_devices = [{"order":'1', "device-type":"vmedia",
                            "name":"vmedia"},
                            {"order":'2', "device-type":"hdd", "name":"hdd"}]
    """
    from imcsdk.mometa.lsboot.LsbootDef import LsbootDef
    from imcsdk.mometa.lsboot.LsbootBootSecurity import LsbootBootSecurity

    boot_devices = sanitize_input_from_intersight(boot_devices)

    # Insert version check here to gracefully handle older versions of CIMC

    # IMC expects the devices to be configured in sorted order
    boot_devices = sorted(boot_devices, key=lambda x: int(x["order"]))

    server_dn = imccoreutils.get_server_dn(handle, server_id)

    # secure boot is a part of LsBootDef
    boot_policy = LsbootDef(parent_mo_or_dn=server_dn)
    secure_boot_mo = LsbootBootSecurity(parent_mo_or_dn=boot_policy.dn)
    if secure_boot == "yes":
        secure_boot_mo.secure_boot = "enabled"
    else:
        secure_boot_mo.secure_boot = "disabled"
    handle.set_mo(secure_boot_mo)

    lsbootdev = LsbootDevPrecision(parent_mo_or_dn=server_dn)

    # clean existing configuration
    # Need to check if doing this everytime will have any adverse impact
    boot_order_child_mos = handle.query_children(in_dn=lsbootdev.dn)
    for mo in boot_order_child_mos:
        if mo.get_class_id() == "LsbootCdd":
            # Deletion of LsbootCdd is not yet supported using XML API
            # Remove this check when CSCvh47929 is fixed
            # Existing Cdd device will automatically move down the
            # order when configuring other devices with CDD device's order
            continue
        handle.remove_mo(mo)

    # set the boot order precision related properties and devices
    lsbootdev.reboot_on_update = reboot_on_update
    lsbootdev.reapply = reapply
    if secure_boot == "no":
        lsbootdev.configured_boot_mode = configured_boot_mode

    for device in boot_devices:
        _add_boot_device(handle, lsbootdev, device)

    handle.set_mo(lsbootdev)
    return lsbootdev
Exemplo n.º 2
0
def boot_order_precision_set(handle,
                             reboot_on_update="no",
                             reapply="no",
                             configured_boot_mode="Legacy",
                             secure_boot="no",
                             boot_devices=[],
                             server_id=1):
    """
    This method will replace the existing boot order precision with the new one
        and also set the boot mode
    This functionality is available only in release EP and above

    Args:
        handle (ImcHandle)
        reboot_on_update (string): "yes", "no"
        reapply(string): "yes", "no"
        configured_boot_mode(string): "Legacy", "Uefi", "None"
        boot_devices (list of dict): format
            [{"order":'1', "device-type":"vmedia", "name":"vmedia"},
             {"order":'2', "device-type":"hdd", "name":"hdd"}]

            boot-order(string): Order
            boot-device-type(string): "hdd", "iscsi", "pchstorage", "pxe",
                                      "san", "sdcard", "uefishell", "usb",
                                      "vmedia"
            boot-device-name(string): Unique label for the boot device
        server_id (int): Id of the server to perform
                         this operation on C3260 platforms

    Returns:
        LsBootDevPrecision object

    Examples:
        boot_order_precision_set(
            handle,
            reboot_on_update="no",
            reapply="no",
            configured_boot_mode="Uefi",
            boot_devices = [{"order":'1', "device-type":"vmedia",
                            "name":"vmedia"},
                            {"order":'2', "device-type":"hdd", "name":"hdd"}]
    """
    from imcsdk.mometa.lsboot.LsbootDef import LsbootDef
    from imcsdk.mometa.lsboot.LsbootBootSecurity import LsbootBootSecurity

    boot_devices = sanitize_input_from_intersight(boot_devices)

    # Insert version check here to gracefully handle older versions of CIMC

    # IMC expects the devices to be configured in sorted order
    boot_devices = sorted(boot_devices, key=lambda x: int(x["order"]))

    server_dn = imccoreutils.get_server_dn(handle, server_id)

    # secure boot is a part of LsBootDef
    boot_policy = LsbootDef(parent_mo_or_dn=server_dn)
    secure_boot_mo = LsbootBootSecurity(parent_mo_or_dn=boot_policy.dn)
    if secure_boot == "yes":
        secure_boot_mo.secure_boot = "enabled"
    else:
        secure_boot_mo.secure_boot = "disabled"
    handle.set_mo(secure_boot_mo)

    lsbootdev = LsbootDevPrecision(parent_mo_or_dn=server_dn)

    # clean existing configuration
    # Need to check if doing this everytime will have any adverse impact
    boot_order_child_mos = handle.query_children(in_dn=lsbootdev.dn)
    for mo in boot_order_child_mos:
        if mo.get_class_id() == "LsbootCdd":
            # Deletion of LsbootCdd is not yet supported using XML API
            # Remove this check when CSCvh47929 is fixed
            # Existing Cdd device will automatically move down the
            # order when configuring other devices with CDD device's order
            continue
        handle.remove_mo(mo)

    # set the boot order precision related properties and devices
    lsbootdev.reboot_on_update = reboot_on_update
    lsbootdev.reapply = reapply
    if secure_boot == "no":
        lsbootdev.configured_boot_mode = configured_boot_mode

    for device in boot_devices:
        _add_boot_device(handle, lsbootdev, device)

    handle.set_mo(lsbootdev)
    return lsbootdev
Exemplo n.º 3
0
def boot_order_precision_set(handle,
                             reboot_on_update="no",
                             reapply="no",
                             configured_boot_mode="Legacy",
                             secure_boot="no",
                             boot_devices=[],
                             server_id=1):
    """
    This method will replace the existing boot order precision with the new one
        and also set the boot mode
    This functionality is available only in release EP and above

    Args:
        handle (ImcHandle)
        reboot_on_update (string): "yes", "no"
        reapply(string): "yes", "no"
        configured_boot_mode(string): "Legacy", "Uefi", "None"
        boot_devices (list of dict): format
            [{"order":'1', "device-type":"vmedia", "name":"vmedia"},
             {"order":'2', "device-type":"hdd", "name":"hdd"}]

            boot-order(string): Order
            boot-device-type(string): "hdd", "iscsi", "pchstorage", "pxe",
                                      "san", "sdcard", "uefishell", "usb",
                                      "vmedia"
            boot-device-name(string): Unique label for the boot device
        server_id (int): Id of the server to perform
                         this operation on C3260 platforms

    Returns:
        LsBootDevPrecision object

    Examples:
        boot_order_precision_set(
            handle,
            reboot_on_update="no",
            reapply="no",
            configured_boot_mode="Uefi",
            boot_devices = [{"order":'1', "device-type":"vmedia",
                            "name":"vmedia"},
                            {"order":'2', "device-type":"hdd", "name":"hdd"}]
    """
    from imcsdk.mometa.lsboot.LsbootDef import LsbootDef
    from imcsdk.mometa.lsboot.LsbootBootSecurity import LsbootBootSecurity
    from imcsdk.imccoreutils import is_platform_m4

    boot_devices = sanitize_input_from_intersight(handle, boot_devices)

    # Insert version check here to gracefully handle older versions of CIMC

    # IMC expects the devices to be configured in sorted order
    boot_devices = sorted(boot_devices, key=lambda x: int(x["order"]))

    # filter pxe device
    # enable pxe boot on respective interface
    # derive logical port
    pxe.disable_pxeboot_vnics_all(handle)
    pxe.prepare_pxe_devices(handle, boot_devices)

    server_dn = imccoreutils.get_server_dn(handle, server_id)

    # secure boot is a part of LsBootDef
    boot_policy = LsbootDef(parent_mo_or_dn=server_dn)
    secure_boot_mo = LsbootBootSecurity(parent_mo_or_dn=boot_policy.dn)
    if secure_boot == "yes":
        secure_boot_mo.secure_boot = "enabled"
    else:
        secure_boot_mo.secure_boot = "disabled"
    handle.set_mo(secure_boot_mo)

    lsbootdev = LsbootDevPrecision(parent_mo_or_dn=server_dn)

    # clean existing configuration
    # Need to check if doing this everytime will have any adverse impact
    boot_order_child_mos = handle.query_children(in_dn=lsbootdev.dn)

    #check the version as CSCvh47929 fix is applied to later versions
    for mo in boot_order_child_mos:
        if str(handle.version) < "3.1(3a)" and mo.get_class_id(
        ) == "LsbootCdd":
            # Deletion of LsbootCdd is not supported using XML API for older versions
            # although CSCvh47929 is fixed
            # Existing Cdd device will automatically move down the
            # order when configuring other devices with CDD device's order
            continue
        handle.remove_mo(mo)

    # set the boot order precision related properties and devices
    lsbootdev.reboot_on_update = reboot_on_update
    lsbootdev.reapply = reapply
    if secure_boot == "no":
        lsbootdev.configured_boot_mode = configured_boot_mode

    i = 0
    #check the version and skip if the device is of type localcdd
    for device in boot_devices:
        if device["device-type"] == "cdd" and (
                is_platform_m4(handle) or str(handle.version) < "3.1(3a)"):
            i = i + 1
            continue
        if device['device-type'] == 'pxe' and is_platform_m4(
                handle) and device['interface_source'] == 'mac':
            i = i + 1
            continue

        #if the list has cdd, reorder the policy types that are after cdd  as cdd will be skipped
        #and CIMC expects the devices in sorted order.
        if i != 0:
            device["order"] = str(int(device["order"]) - i)
        _add_boot_device(handle, lsbootdev, device)
    handle.set_mo(lsbootdev)
    return lsbootdev
Exemplo n.º 4
0
def boot_order_precision_set(handle,
                             reboot_on_update="no",
                             reapply="no",
                             configured_boot_mode="Legacy",
                             boot_devices=[],
                             server_id=1):
    """
    This method will replace the existing boot order precision with the new one
        and also set the boot mode
    This functionality is available only in release EP and above

    Args:
        handle (ImcHandle)
        reboot_on_update (string): "yes", "no"
        reapply(string): "yes", "no"
        configured_boot_mode(string): "Legacy", "Uefi", "None"
        boot_devices (list of dict): format
            [{"order":'1', "device-type":"vmedia", "name":"vmedia"},
             {"order":'2', "device-type":"hdd", "name":"hdd"}]

            boot-order(string): Order
            boot-device-type(string): "hdd", "iscsi", "pchstorage", "pxe",
                                      "san", "sdcard", "uefishell", "usb",
                                      "vmedia"
            boot-device-name(string): Unique label for the boot device
        server_id (int): Id of the server to perform
                         this operation on C3260 platforms

    Returns:
        LsBootDevPrecision object

    Examples:
        boot_order_precision_set(
            handle,
            reboot_on_update="no",
            reapply="no",
            configured_boot_mode="Uefi",
            boot_devices = [{"order":'1', "device-type":"vmedia",
                            "name":"vmedia"},
                            {"order":'2', "device-type":"hdd", "name":"hdd"}]
    """

    # Insert version check here to gracefully handle older versions of CIMC

    # IMC expects the devices to be configured in sorted order
    boot_devices = sorted(boot_devices, key=lambda x: x["order"])

    server_dn = imccoreutils.get_server_dn(handle, server_id)

    lsbootdevprecision_mo = LsbootDevPrecision(parent_mo_or_dn=server_dn)
    lsbootdevprecision_mo.reboot_on_update = reboot_on_update
    lsbootdevprecision_mo.reapply = reapply
    lsbootdevprecision_mo.configured_boot_mode = configured_boot_mode

    handle.set_mo(lsbootdevprecision_mo)

    boot_order_child_mos = handle.query_children(
        in_dn=lsbootdevprecision_mo.dn)
    for mo in boot_order_child_mos:
        handle.remove_mo(mo)

    for device in boot_devices:
        _add_boot_device(handle, lsbootdevprecision_mo.dn, device)

    lsbootdevprecision_mo = handle.query_classid("LsbootDevPrecision")
    return lsbootdevprecision_mo
Exemplo n.º 5
0
Arquivo: bios.py Projeto: vvb/imcsdk
def boot_order_precision_set(
        handle,
        reboot_on_update=False,
        reapply=False,
        configured_boot_mode="Legacy",
        boot_devices=[],
        server_id=1):
    """
    This method will replace the existing boot order precision with the new one
        and also set the boot mode
    This functionality is available only in release EP and above

    Args:
        handle (ImcHandle)
        reboot_on_update (bool): True, False
        reapply(bool): True, False
        configured_boot_mode(string): "Legacy", "Uefi", "None"
        boot_devices (list of dict): format
            [{"order":'1', "device-type":"vmedia", "name":"vmedia"},
             {"order":'2', "device-type":"hdd", "name":"hdd"}]

            boot-order(string): Order
            boot-device-type(string): "hdd", "iscsi", "pchstorage", "pxe",
                                      "san", "sdcard", "uefishell", "usb",
                                      "vmedia"
            boot-device-name(string): Unique label for the boot device
        server_id (int): Id of the server to perform
                         this operation on C3260 platforms

    Returns:
        LsBootDevPrecision object

    Examples:
        boot_order_precision_set(
            handle,
            reboot_on_update=False,
            reapply=False,
            configured_boot_mode="Uefi",
            boot_devices = [{"order":'1', "device-type":"vmedia", "name":"vmedia"},
                            {"order":'2', "device-type":"hdd", "name":"hdd"}]
    """

    # Insert version check here to gracefully handle older versions of CIMC

    # IMC expects the devices to be configured in sorted order
    boot_devices = sorted(boot_devices, key=lambda x: x["order"])

    server_dn = imccoreutils.get_server_dn(handle, server_id)
    lsbootdevprecision_mo = LsbootDevPrecision(parent_mo_or_dn=server_dn)

    lsbootdevprecision_mo.reboot_on_update = "no"
    if reboot_on_update:
        lsbootdevprecision_mo.reboot_on_update = "yes"

    lsbootdevprecision_mo.reapply = "no"
    if reapply:
        lsbootdevprecision_mo.reapply = "yes"

    lsbootdevprecision_mo.configured_boot_mode = configured_boot_mode

    handle.set_mo(lsbootdevprecision_mo)

    boot_order_child_mos = handle.query_children(
        in_dn=lsbootdevprecision_mo.dn)
    for mo in boot_order_child_mos:
        handle.remove_mo(mo)

    for device in boot_devices:
        _add_boot_device(handle, lsbootdevprecision_mo.dn, device)

    lsbootdevprecision_mo = handle.query_classid("LsbootDevPrecision")
    return lsbootdevprecision_mo