示例#1
0
def get_node_memtune_parameter(test, params):
    """
    Get the node memory parameters
    :params: the parameter dictionary
    """
    options = params.get("options")
    result = virsh.node_memtune(options)
    status = result.exit_status

    _params = {}

    for i in result.stdout.strip().split('\n\t')[1:]:
        _params[i.split(' ')[0]] = i.split(' ')[-1]

    logging.debug(_params)

    (ksm_dicts, change_list) = get_ksm_values_and_change_list()
    ksm_dicts['change_list'] = change_list

    # Check status_error
    status_error = params.get("status_error", "no")

    if status_error == "yes":
        if status:
            logging.info("It's an expected error: %s", result.stderr)
        else:
            test.fail("%d not a expected command " "return value" % status)
    elif status_error == "no":
        if status:
            test.fail(result.stderr)
        else:
            if check_node_memtune(_params, ksm_dicts):
                logging.info(result)
            else:
                test.fail("The memory parameters " "mismatch with result")
示例#2
0
def set_node_memtune_parameter(params):
    """
    Set the node memory parameters
    :params: the parameter dictionary
    """
    options = params.get("options")
    shm_pages_to_scan = params.get("shm_pages_to_scan")
    shm_sleep_millisecs = params.get("shm_sleep_millisecs")
    shm_merge_across_nodes = params.get("shm_merge_across_nodes")

    result = virsh.node_memtune(shm_pages_to_scan,
                                shm_sleep_millisecs,
                                shm_merge_across_nodes,
                                options=options)

    status = result.exit_status

    (ksm_dicts, change_list) = get_ksm_values_and_change_list()
    ksm_dicts['change_list'] = change_list

    # Check status_error
    status_error = params.get("status_error", "no")

    # the 'merge_across_nodes' is supported by specific kernel
    if shm_merge_across_nodes and not \
            os.access("%s/merge_across_nodes" % _SYSFS_MEMORY_KSM_PATH, os.R_OK):
        status_error = "yes"

    if status_error == "yes":
        if status:
            logging.info("It's an expected error: %s", result.stderr)
        else:
            raise error.TestFail("%d not a expected command "
                                 "return value" % status)
    elif status_error == "no":
        if status:
            raise error.TestFail(result.stderr)
        else:
            if check_node_memtune(params, ksm_dicts):
                logging.info(result)
            else:
                raise error.TestFail("The memory parameters "
                                     "mismatch with result")
def set_node_memtune_parameter(params):
    """
    Set the node memory parameters
    :params: the parameter dictionary
    """
    options = params.get("options")
    shm_pages_to_scan = params.get("shm_pages_to_scan")
    shm_sleep_millisecs = params.get("shm_sleep_millisecs")
    shm_merge_across_nodes = params.get("shm_merge_across_nodes")

    result = virsh.node_memtune(shm_pages_to_scan, shm_sleep_millisecs,
                                shm_merge_across_nodes, options=options)

    status = result.exit_status

    (ksm_dicts, change_list) = get_ksm_values_and_change_list()
    ksm_dicts['change_list'] = change_list

    # Check status_error
    status_error = params.get("status_error", "no")

    # the 'merge_across_nodes' is supported by specific kernel
    if shm_merge_across_nodes and not \
            os.access("%s/merge_across_nodes" % _SYSFS_MEMORY_KSM_PATH, os.R_OK):
        status_error = "yes"

    if status_error == "yes":
        if status:
            logging.info("It's an expected error: %s", result.stderr)
        else:
            raise error.TestFail("%d not a expected command "
                                 "return value" % status)
    elif status_error == "no":
        if status:
            raise error.TestFail(result.stderr)
        else:
            if check_node_memtune(params, ksm_dicts):
                logging.info(result)
            else:
                raise error.TestFail("The memory parameters "
                                     "mismatch with result")
def get_node_memtune_parameter(params):
    """
    Get the node memory parameters
    :params: the parameter dictionary
    """
    options = params.get("options")
    result = virsh.node_memtune(options)
    status = result.exit_status

    _params = {}

    for i in result.stdout.strip().split('\n\t')[1:]:
        _params[i.split(' ')[0]] = i.split(' ')[-1]

    logging.debug(_params)

    (ksm_dicts, change_list) = get_ksm_values_and_change_list()
    ksm_dicts['change_list'] = change_list

    # Check status_error
    status_error = params.get("status_error", "no")

    if status_error == "yes":
        if status:
            logging.info("It's an expected error: %s", result.stderr)
        else:
            raise error.TestFail("%d not a expected command "
                                 "return value" % status)
    elif status_error == "no":
        if status:
            raise error.TestFail(result.stderr)
        else:
            if check_node_memtune(_params, ksm_dicts):
                logging.info(result)
            else:
                raise error.TestFail("The memory parameters "
                                     "mismatch with result")