Пример #1
0
def get_all_cells():
    """
    Use virsh freecell --all to get all cells on host
    # virsh freecell --all
        0:     124200 KiB
        1:    1059868 KiB
    --------------------
    Total:    1184068 KiB

    return: cell_dict, {"0":"124200 KiB",
                        "1":"1059868 KiB",
                        "Total":"1184068 KiB"}
    """
    fc_result = virsh.freecell(options="--all", ignore_status=True)
    if fc_result.exit_status:
        if fc_result.stderr.count("NUMA not supported"):
            raise error.TestNAError(fc_result.stderr.strip())
        else:
            raise error.TestFail(fc_result.stderr.strip())
    output = fc_result.stdout.strip()
    cell_list = output.splitlines()
    # remove "------------" line
    del cell_list[-2]
    cell_dict = {}
    for cell_line in cell_list:
        cell_info = cell_line.split(":")
        cell_num = cell_info[0].strip()
        cell_mem = cell_info[-1].strip()
        cell_dict[cell_num] = cell_mem
    return cell_dict
Пример #2
0
def get_all_cells():
    """
    Use virsh freecell --all to get all cells on host
    # virsh freecell --all
        0:     124200 KiB
        1:    1059868 KiB
    --------------------
    Total:    1184068 KiB

    return: cell_dict, {"0":"124200 KiB",
                        "1":"1059868 KiB",
                        "Total":"1184068 KiB"}
    """
    fc_result = virsh.freecell("--all", ignore_status=True)
    if fc_result.exit_status:
        if fc_result.stderr.count("NUMA not supported"):
            raise error.TestNAError(fc_result.stderr.strip())
        else:
            raise error.TestFail(fc_result.stderr.strip())
    output = fc_result.stdout.strip()
    cell_list = output.splitlines()
    # remove "------------" line
    del cell_list[-2]
    cell_dict = {}
    for cell_line in cell_list:
        cell_info = cell_line.split(":")
        cell_num = cell_info[0].strip()
        cell_mem = cell_info[-1].strip()
        cell_dict[cell_num] = cell_mem
    return cell_dict
Пример #3
0
def run(test, params, env):
    """
    Test the command virsh freecell

    (1) Call virsh freecell
    (2) Call virsh freecell --all
    (3) Call virsh freecell with a numeric argument
    (4) Call virsh freecell xyz
    (5) Call virsh freecell with libvirtd service stop
    """

    connect_uri = libvirt_vm.normalize_connect_uri(
        params.get("connect_uri", "default"))
    option = params.get("virsh_freecell_options")

    # Prepare libvirtd service
    check_libvirtd = params.has_key("libvirtd")
    if check_libvirtd:
        libvirtd = params.get("libvirtd")
        if libvirtd == "off":
            utils_libvirtd.libvirtd_stop()

    # Run test case
    cmd_result = virsh.freecell(ignore_status=True,
                                extra=option,
                                uri=connect_uri,
                                debug=True)
    output = cmd_result.stdout.strip()
    status = cmd_result.exit_status

    # Recover libvirtd service start
    if libvirtd == "off":
        utils_libvirtd.libvirtd_start()

    # Check the output
    if virsh.has_help_command('numatune'):
        OLD_LIBVIRT = False
    else:
        OLD_LIBVIRT = True
        if option == '--all':
            raise error.TestNAError("Older libvirt virsh freecell "
                                    "doesn't support --all option")

    def output_check(freecell_output):
        if not re.search("ki?B", freecell_output, re.IGNORECASE):
            raise error.TestFail("virsh freecell output invalid: " +
                                 freecell_output)

    # Check status_error
    status_error = params.get("status_error")
    if status_error == "yes":
        if status == 0:
            if libvirtd == "off":
                raise error.TestFail(
                    "Command 'virsh freecell' succeeded "
                    "with libvirtd service stopped, incorrect")
            else:
                # newer libvirt
                if not OLD_LIBVIRT:
                    raise error.TestFail(
                        "Command 'virsh freecell %s' succeeded"
                        "(incorrect command)" % option)
                else:  # older libvirt
                    raise error.TestNAError('Older libvirt virsh freecell '
                                            'incorrectly processes extranious'
                                            'command-line options')
    elif status_error == "no":
        output_check(output)
        if status != 0:
            raise error.TestFail("Command 'virsh freecell %s' failed "
                                 "(correct command)" % option)
Пример #4
0
def run_virsh_freecell(test, params, env):
    """
    Test the command virsh freecell

    (1) Call virsh freecell
    (2) Call virsh freecell --all
    (3) Call virsh freecell with a numeric argument
    (4) Call virsh freecell xyz
    (5) Call virsh freecell with libvirtd service stop
    """

    connect_uri = libvirt_vm.normalize_connect_uri( params.get("connect_uri",
                                                               "default") )
    option = params.get("virsh_freecell_options")

    # Prepare libvirtd service
    check_libvirtd = params.has_key("libvirtd")
    if check_libvirtd:
        libvirtd = params.get("libvirtd")
        if libvirtd == "off":
            libvirt_vm.service_libvirtd_control("stop")

    # Run test case
    cmd_result = virsh.freecell(ignore_status=True, extra=option,
                                uri=connect_uri, debug=True)
    output = cmd_result.stdout.strip()
    status = cmd_result.exit_status

    # Recover libvirtd service start
    if libvirtd == "off":
        libvirt_vm.service_libvirtd_control("start")

    # Check the output
    if virsh.has_help_command('numatune'):
        OLD_LIBVIRT = False
    else:
        OLD_LIBVIRT = True
        if option == '--all':
            raise error.TestNAError("Older libvirt virsh freecell "
                                    "doesn't support --all option")

    def output_check(freecell_output):
        if not re.search("ki?B", freecell_output, re.IGNORECASE):
            raise error.TestFail("virsh freecell output invalid: " + freecell_output)

    # Check status_error
    status_error = params.get("status_error")
    if status_error == "yes":
        if status == 0:
            if libvirtd == "off":
                raise error.TestFail("Command 'virsh freecell' succeeded "
                                     "with libvirtd service stopped, incorrect")
            else:
                # newer libvirt
                if not OLD_LIBVIRT:
                    raise error.TestFail("Command 'virsh freecell %s' succeeded"
                                         "(incorrect command)" % option)
                else: # older libvirt
                    raise error.TestNAError('Older libvirt virsh freecell '
                                            'incorrectly processes extranious'
                                            'command-line options')
    elif status_error == "no":
        output_check(output)
        if status != 0:
            raise error.TestFail("Command 'virsh freecell %s' failed "
                                 "(correct command)" % option)
Пример #5
0
def run(test, params, env):
    """
    Test the command virsh freecell

    (1) Call virsh freecell
    (2) Call virsh freecell --all
    (3) Call virsh freecell with a numeric argument
    (4) Call virsh freecell xyz
    (5) Call virsh freecell with libvirtd service stop
    """

    args = params.get("virsh_freecell_args")
    option = params.get("virsh_freecell_opts")

    # Prepare libvirtd service
    check_libvirtd = "libvirtd" in params
    if check_libvirtd:
        libvirtd = params.get("libvirtd")
        if libvirtd == "off":
            utils_libvirtd.libvirtd_stop()

    # Run test case
    cmd_result = virsh.freecell(cellno=args, options=option)
    output = cmd_result.stdout.strip()
    status = cmd_result.exit_status

    # Recover libvirtd service start
    if libvirtd == "off":
        utils_libvirtd.libvirtd_start()

    # Check the output
    if virsh.has_help_command('numatune'):
        OLD_LIBVIRT = False
    else:
        OLD_LIBVIRT = True
        if option == '--all':
            test.cancel("Older libvirt virsh freecell "
                        "doesn't support --all option")

    def output_check(freecell_output):
        if not re.search("ki?B", freecell_output, re.IGNORECASE):
            test.fail(
                "virsh freecell output invalid: " + freecell_output)

    # Check status_error
    status_error = params.get("status_error")
    if status_error == "yes":
        if status == 0:
            if libvirtd == "off":
                test.fail("Command 'virsh freecell' succeeded "
                          "with libvirtd service stopped, incorrect")
            else:
                # newer libvirt
                if not OLD_LIBVIRT:
                    test.fail("Command 'virsh freecell %s' succeeded"
                              "(incorrect command)" % option)
                else:  # older libvirt
                    test.cancel('Older libvirt virsh freecell '
                                'incorrectly processes extranious'
                                'command-line options')
    elif status_error == "no":
        output_check(output)
        if status != 0:
            test.fail("Command 'virsh freecell %s' failed "
                      "(correct command)" % option)