How to use the imcsdk.imccoreutils.get_server_dn function in imcsdk

To help you get started, we’ve selected a few imcsdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CiscoUcs / imcsdk / imcsdk / apis / v2 / server / bios.py View on Github external
def _get_bios_dn(handle, server_id=1):
    server_dn = imccoreutils.get_server_dn(handle, server_id)
    return (server_dn + '/bios')
github CiscoUcs / imcsdk / imcsdk / apis / server / boot.py View on Github external
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)
github CiscoUcs / imcsdk / imcsdk / apis / v2 / server / boot.py View on Github external
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:
github CiscoUcs / imcsdk / imcsdk / apis / v2 / admin / ipmi.py View on Github external
def _get_comm_mo_dn(handle, server_id=1):
    """
    Internal method to get the IPMI mo's parent_dn based \
            on the type of platform
    """
    from imcsdk.imcexception import ImcValidationException

    if handle.platform == IMC_PLATFORM.TYPE_CLASSIC:
        return("sys/svc-ext")
    elif handle.platform == IMC_PLATFORM.TYPE_MODULAR:
        return(get_server_dn(handle, server_id) + "/svc-ext")
    else:
        raise ImcValidationException("Invalid platform detected:%s" %
                                     handle.platform)
github CiscoUcs / imcsdk / imcsdk / apis / server / power.py View on Github external
def server_power_characterization_start(handle, server_id=1):
    """
    Starts a power characterization run.
    From 3.0(1c) onwards, server_power_characterization_enable needs to be
    explicitly done, before invoking this api.

    Args:
        handle (ImcHandle)
        server_id (int): Server Id to be specified for C3260 platforms

    Returns:
        PowerBudget object
    """
    if not is_supported_model(handle):
        return
    power_budget_mo = PowerBudget(parent_mo_or_dn=get_server_dn(handle, server_id))

    power_budget_mo.admin_action = \
        PowerBudgetConsts.ADMIN_ACTION_START_POWER_CHAR
    handle.set_mo(power_budget_mo)
    return power_budget_mo
github CiscoUcs / imcsdk / imcsdk / apis / server / boot.py View on Github external
This is supported from EP release onwards only

    Args:
        handle (ImcHandle)
        dump (bool): True or False
        server_id (int): Id of the server in case of C3260 platforms

    Returns:
        List of dict in the format
            [{"order": '2', "device-type": "pxe", "name": "pxe"}]

    Example:
        boot_order_precision(handle, dump=False)
    """

    server_dn = imccoreutils.get_server_dn(handle, server_id)
    parent_dn = server_dn + "/bios/bdgep"

    boot_order_list = []
    boot_device_list = handle.query_children(
        in_dn=parent_dn, class_id="BiosBootDevPrecision")

    for device in boot_device_list:
        device_type = device.type if device.type else str(device.type)
        boot_order_list.append({"order": device.order,
                                "device-type": device_type,
                                "name": device.name})

    sorted_boot_order_list = sorted(
        boot_order_list, key=lambda item: item["order"])

    if dump:
github CiscoUcs / imcsdk / imcsdk / apis / server / storage.py View on Github external
def _get_controller_dn(handle, controller_type, controller_slot, server_id=1):
    server_dn = imccoreutils.get_server_dn(handle, server_id)
    return (server_dn + "/board/storage-" + controller_type + "-" + controller_slot)
github CiscoUcs / imcsdk / imcsdk / apis / server / remotepresence.py View on Github external
def sol_disable(handle, server_id=1):
    """
    This method will disable Serial over Lan connection

    Args:
        handle (ImcHandle)
        server_id (int): Server Id to be specified for C3260 platforms

    Returns:
        None
    """

    solif_mo = SolIf(parent_mo_or_dn=get_server_dn(handle, server_id))
    solif_mo.admin_state = SolIfConsts.ADMIN_STATE_DISABLE
    handle.set_mo(solif_mo)
github CiscoUcs / imcsdk / imcsdk / apis / admin / ipmi.py View on Github external
def _get_comm_mo_dn(handle, server_id=1):
    """
    Internal method to get the IPMI mo's parent_dn based \
            on the type of platform
    """
    from imcsdk.imcexception import ImcValidationException

    if handle.platform == IMC_PLATFORM.TYPE_CLASSIC:
        return("sys/svc-ext")
    elif handle.platform == IMC_PLATFORM.TYPE_MODULAR:
        return(get_server_dn(handle, server_id) + "/svc-ext")
    else:
        raise ImcValidationException("Invalid platform detected:%s" %
                                     handle.platform)