Exemplo n.º 1
0
def test_patch_versions():
    version1 = ImcVersion("2.0(12b)")
    version2 = ImcVersion("2.0(12)")
    assert_equal((version1 > version2), True)
Exemplo n.º 2
0
def test_spin_version4():
    # version interpreted as 4.0(234z)
    version1 = ImcVersion("4.0(234S3)")
    version2 = ImcVersion("4.0(234z)")
    assert_equal((version1 == version2), True)
Exemplo n.º 3
0
def test_patch_version1():
    # version interpreted as 4.0(235a)
    version1 = ImcVersion("4.0(234.5)")
    version2 = ImcVersion("4.0(235a)")
    assert_equal((version1 == version2), True)
Exemplo n.º 4
0
def test_nightly_version4():
    version1 = ImcVersion("2.0(2cS6)")
    version2 = ImcVersion("2.0(3)")
    assert_equal((version1 < version2), True)
Exemplo n.º 5
0
def test_nightly_version3():
    # 2.0(2cS6) will be considered as 2.0(2d) internally
    version1 = ImcVersion("2.0(2cS6)")
    version2 = ImcVersion("2.0(2c)")
    assert_equal((version1 == version2), False)
Exemplo n.º 6
0
def test_nightly_version2():
    version1 = ImcVersion("2.0(13aS6)")
    version2 = ImcVersion("2.0(1S10)")
    assert_equal((version1 > version2), True)
Exemplo n.º 7
0
def bios_tokens_set(handle, tokens={}, server_id=1):
    """
    Args:
        handle (ImcHandle)
        tokens (dictionary) : (key, value) pair of bios tokens with key being the name of the token
        server_id (int): Id of the server to perform
                         this operation on C3260 platforms.

    Returns:
        Dictionary with a failure message, if any.

    Examples:
        bios_tokens_set(handle,
                        tokens = {
                            "baudRate": "19200",
                            "intelVtdatsSupport": "enabled",
                            "consoleRedirection": "com-1",
                            "flowControl": "rts-cts",
                            "sataModeSelect": "platform-default",
                            "txtSupport": "platform-default",
                            "packageCstateLimit": "C0 C1 State"},
                        server_id=2)
    """

    from imcsdk.imccoreutils import load_class, sanitize_xml_parsing_error
    from imcsdk.mometa.bios.BiosSettings import BiosSettings
    from imcsdk.imccoremeta import ImcVersion

    messages = []
    ret = {}

    bios_mo = BiosSettings(parent_mo_or_dn=_get_bios_dn(handle, server_id))
    mo_table = _get_bios_mo_table(handle, tokens, server_id)
    server_mos = _get_server_bios_mo_table(handle, dn=bios_mo.dn)

    # Prepare the filtered table i.e. send only those MOs that exist on the server
    table = {k: v for k, v in mo_table.items() if k in server_mos}

    log.debug("Mo Table       Count: %s Values: %s" %
              (len(mo_table), mo_table))
    log.debug("Server Table   Count: %s Values: %s" %
              (len(server_mos), server_mos))
    log.debug("Filtered Table Count: %s Values: %s" % (len(table), table))

    processed_tokens = []
    # Separate the MOs which have only platform-default
    for mo_name, props in table.items():
        non_default_props = {
            k: v
            for k, v in props.items() if v != "platform-default"
        }
        # if there are no non-default props, it can be batched
        if len(non_default_props) == 0:
            # filter properties to only those applicable to the server
            server_mo_props = server_mos[mo_name]
            filtered_props = {
                k: v
                for k, v in props.items()
                if k in server_mo_props and server_mo_props[k]
            }

            if len(filtered_props) == 0:
                log.debug("skipping token %s props: %s server_mo_props %s " %
                          (mo_name, props, server_mo_props))
                processed_tokens.append(mo_name)
                continue

            # load an instance of the class
            mo_class = load_class(mo_name)
            filtered_props["_handle"] = handle
            mo_obj = mo_class(parent_mo_or_dn=bios_mo, **filtered_props)

            # HACK for CIMC ISSUE. 'rn' is different for M4 and M5
            # rn for M5 for this token has been corrected in GP-MR2
            if mo_name == "BiosVfSataModeSelect" and \
                    is_platform_m5(handle) and \
                    handle.version < ImcVersion("3.1(3a)"):
                mo_obj.rn = "SataModeSelect"
                mo_obj.dn = bios_mo.dn + "/" + mo_obj.rn

            # In HP release, for Janus platform, vp_cbs_cmn_cpu_gen_downcore_ctrl token
            # does not have a platform default value supported on the endpoint
            if mo_name == "BiosVfCbsCmnCpuGenDowncoreCtrl" and \
                    mo_obj.vp_cbs_cmn_cpu_gen_downcore_ctrl == "platform-default" and \
                    handle.version == ImcVersion("4.0(1a)"):
                mo_obj.vp_cbs_cmn_cpu_gen_downcore_ctrl = "Auto"

            # pop the object from the table dictionary
            processed_tokens.append(mo_name)

    for each in processed_tokens:
        table.pop(each)

    log.debug("Modified Tokens Count: %s Values: %s" % (len(table), table))

    # Send all the MOs with default properties in one shot
    handle.set_mo(bios_mo)

    # Send the rest of the MOs
    for mo_name, props in table.items():
        d = {}
        server_mo_props = server_mos[mo_name]
        filtered_props = {
            k: v
            for k, v in props.items()
            if k in server_mo_props and server_mo_props[k]
        }

        # REALLY DIRTY HACK!!
        # C6 Non Retention - Works on M5, fails on M4
        # C6 non Retention - Works on M4, fails on M5
        if mo_name == "BiosVfPackageCStateLimit" and is_platform_m4(
                handle) and "vp_package_c_state_limit" in filtered_props:
            if filtered_props[
                    "vp_package_c_state_limit"] == "C6 Non Retention":
                filtered_props["vp_package_c_state_limit"] = "C6 non Retention"

        if len(filtered_props) != 0:
            mo_class = load_class(mo_name)
            filtered_props["_handle"] = handle
            try:
                mo_obj = mo_class(parent_mo_or_dn=bios_mo.dn, **filtered_props)

                # HACK for CIMC ISSUE. 'rn' is different for M4 and M5
                # rn for M5 for this token has been corrected in GP-MR2
                if mo_name == "BiosVfSataModeSelect" and \
                        is_platform_m5(handle) and \
                        handle.version < ImcVersion("3.1(3a)"):
                    mo_obj.rn = "SataModeSelect"
                    mo_obj.dn = bios_mo.dn + "/" + mo_obj.rn

                # HP and below only "Disabled" was supported for this token
                # In HP, "disabled" was also supported and hence need to send the older
                # version of this value for an older server
                if mo_name == "BiosVfCDNSupport" and \
                        mo_obj.vp_cdn_support == "disabled" and \
                        handle.version < ImcVersion("4.0(1a)"):
                    mo_obj.vp_cdn_support = "Disabled"

                handle.set_mo(mo_obj)
            except ImcException as e:
                d["Object"] = mo_name
                error = e.error_descr
                if e.error_code == "ERR-xml-parse-error":
                    error = sanitize_xml_parsing_error(e.error_descr)
                d["Error"] = error
                messages.append(d)
                continue
            except Exception as e:
                d["Object"] = mo_name
                d["Error"] = str(e)
                messages.append(d)
                continue

    message = ""

    if len(messages) != 0:
        message = "Following issues were seen during application of BIOS " \
                "tokens: \n"
        for m in messages:
            message += m["Object"] + ": " + m["Error"] + "\n"

    ret["msg"] = message
    ret["msg_params"] = messages
    ret["changed"] = True
    return ret
Exemplo n.º 8
0
def test_patch_versions():
    # when we don't see a patch version we use z
    # so 2.0(12) will be considerde as 2.0(12z)
    version1 = ImcVersion("2.0(12b)")
    version2 = ImcVersion("2.0(12)")
    assert_equal((version1 > version2), False)