Ejemplo n.º 1
0
def boot_order_policy_set(handle,
                          reboot_on_update="no",
                          secure_boot="disabled",
                          boot_devices=[],
                          server_id=1):
    """
    This method will set the boot order policy passed from the user
    This is the deprecated way of setting the boot order
        and is applicable releases older than EP

    Args:
        handle (ImcHandle)
        reboot_on_update (string): "yes", "no"
        secure_boot (string): "enabled", "disabled"
        boot_devices (list of dict): format
            [{"order":'1', "device-type":"cdrom", "name":"cdrom0"},
             {"order":'2', "device-type":"lan", "name":"lan"}]

            boot-order(string): Order
            boot-device-type(string): "efi", "lan", "storage", "cdrom", "fdd"
            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:
        LsBootDef object

    Examples:
        boot_order_policy_set(
            handle,
            reboot_on_update="yes",
            secure_boot="enabled",
            boot_devices = [{"order":'1', "device-type":"cdrom",
                            "name":"cdrom0"},
                            {"order":'2', "device-type":"lan", "name":"lan"}]


    """

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

    from imcsdk.mometa.lsboot.LsbootDef import LsbootDef
    from imcsdk.mometa.lsboot.LsbootBootSecurity import LsbootBootSecurity

    server_dn = imccoreutils.get_server_dn(handle, server_id)

    boot_policy = LsbootDef(parent_mo_or_dn=server_dn)
    boot_policy.reboot_on_update = reboot_on_update
    handle.set_mo(boot_policy)

    secure_boot_policy = LsbootBootSecurity(parent_mo_or_dn=boot_policy.dn)
    # Secure boot policy is supported only from ImcVersion 2.0(1a)
    if handle.version >= secure_boot_policy.get_version(handle.platform):
        secure_boot_policy.secure_boot = secure_boot
        handle.set_mo(secure_boot_policy)

    boot_policy_child_mos = handle.query_children(in_dn=boot_policy.dn)
    for mo in boot_policy_child_mos:
        if mo.dn == secure_boot_policy.dn:
            continue
        # handle.remove_mo(mo)

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

    boot_policy = handle.query_classid("LsbootDef")
    return boot_policy
Ejemplo 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
Ejemplo n.º 3
0
def boot_order_policy_set(handle, reboot_on_update="no",
                          secure_boot="no",
                          boot_devices=[],
                          server_id=1):
    """
    This method will set the boot order policy passed from the user
    This is the deprecated way of setting the boot order
        and is applicable releases older than EP

    Args:
        handle (ImcHandle)
        reboot_on_update (string): "yes", "no"
        secure_boot (string): "enabled", "disabled"
        boot_devices (list of dict): format
            [{"order":'1', "device-type":"cdrom", "name":"cdrom0"},
             {"order":'2', "device-type":"lan", "name":"lan"}]

            boot-order(string): Order
            boot-device-type(string): "efi", "lan", "storage", "cdrom", "fdd"
            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:
        LsBootDef object

    Examples:
        boot_order_policy_set(
            handle,
            reboot_on_update="yes",
            secure_boot="no",
            boot_devices = [{"order":'1', "device-type":"cdrom",
                            "name":"cdrom0"},
                            {"order":'2', "device-type":"lan", "name":"lan"}]


    """

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

    from imcsdk.mometa.lsboot.LsbootDef import LsbootDef
    from imcsdk.mometa.lsboot.LsbootBootSecurity import LsbootBootSecurity

    server_dn = imccoreutils.get_server_dn(handle, server_id)

    boot_policy = LsbootDef(parent_mo_or_dn=server_dn)
    boot_policy.reboot_on_update = reboot_on_update
    handle.set_mo(boot_policy)

    secure_boot_policy = LsbootBootSecurity(parent_mo_or_dn=boot_policy.dn)
    # Secure boot policy is supported only from ImcVersion 2.0(1a)
    if handle.version >= secure_boot_policy.get_version(handle.platform):
        if secure_boot == "yes":
            secure_boot_policy.secure_boot = "enabled"
        else:
            secure_boot_policy.secure_boot = "disabled"
        handle.set_mo(secure_boot_policy)

    boot_policy_child_mos = handle.query_children(in_dn=boot_policy.dn)
    for mo in boot_policy_child_mos:
        if mo.dn == secure_boot_policy.dn:
            continue
        handle.remove_mo(mo)

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

    boot_policy = handle.query_classid("LsbootDef")
    return boot_policy
Ejemplo n.º 4
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