• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python utils_misc.get_winutils_vol函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中virttest.utils_misc.get_winutils_vol函数的典型用法代码示例。如果您正苦于以下问题:Python get_winutils_vol函数的具体用法?Python get_winutils_vol怎么用?Python get_winutils_vol使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_winutils_vol函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: install_driver

    def install_driver(session, operation):
        """
        Install / Uninstall / Query driver.

        :param session: VM session.
        :param operation: Install / Uninstall / Query driver.
        """
        driver_name = params["driver_name"]
        device_name = params["device_name"]
        driver_path = get_driver_path(session, driver_name)
        driver_install_cmd = params["driver_install_cmd"]
        driver_name = r"--driver_name %s" % driver_name
        device_name = "--device_name \"%s\"" % device_name
        operation = r"--%s" % operation
        vol_utils = utils_misc.get_winutils_vol(session)
        driver_install_cmd = re.sub("WIN_UTILS", vol_utils, driver_install_cmd)
        vol_utils = r"--vol_utils %s:" % vol_utils

        driver_path = r"--driver_path %s" % driver_path
        driver_install_cmd = driver_install_cmd % (operation, driver_path,
                                                   driver_name, device_name,
                                                   vol_utils)

        install_timeout = int(params.get("driver_install_timeout", 600))
        session.cmd(driver_install_cmd, timeout=install_timeout)
开发者ID:gogoxiaoxiao,项目名称:tp-qemu,代码行数:25,代码来源:single_driver_install.py


示例2: run

def run(test, params, env):
    """
    Run IOzone for windows on a windows guest:
    1) Log into a guest
    2) Execute the IOzone test contained in the winutils.iso
    3) Get results
    4) Postprocess it with the IOzone postprocessing module

    :param test: kvm test object
    :param params: Dictionary with the test parameters
    :param env: Dictionary with test environment.
    """
    vm = env.get_vm(params["main_vm"])
    vm.verify_alive()
    timeout = int(params.get("login_timeout", 360))
    session = vm.wait_for_login(timeout=timeout)
    results_path = os.path.join(test.resultsdir, "raw_output_%s" % test.iteration)
    analysisdir = os.path.join(test.resultsdir, "analysis_%s" % test.iteration)

    # Run IOzone and record its results
    drive_letter = utils_misc.get_winutils_vol(session)
    c = params["iozone_cmd"] % drive_letter
    t = int(params.get("iozone_timeout"))
    logging.info("Running IOzone command on guest, timeout %ss", t)
    results = session.cmd_output(cmd=c, timeout=t)
    utils.open_write_close(results_path, results)

    # Postprocess the results using the IOzone postprocessing module
    logging.info("Iteration succeed, postprocessing")
    a = postprocess_iozone.IOzoneAnalyzer(list_files=[results_path], output_dir=analysisdir)
    a.analyze()
    p = postprocess_iozone.IOzonePlotter(results_file=results_path, output_dir=analysisdir)
    p.plot_all()
开发者ID:MiriamDeng,项目名称:tp-qemu,代码行数:33,代码来源:iozone_windows.py


示例3: __init__

 def __init__(self, params, session):
     label = params.get('win_utils_label', 'WIN_UTILS')
     drive_letter = utils_misc.get_winutils_vol(session, label)
     self.cmd = 'set nodosfilewarning=1 && set CYGWIN=nodosfilewarning'
     self.iozone_path = drive_letter + r':\Iozone\iozone.exe'
     self.setups = {'session_cmd': (self.cmd, 300)}
     self.setups_order = ['session_cmd']
开发者ID:vivianQizhu,项目名称:tp-qemu,代码行数:7,代码来源:storage_benchmark.py


示例4: run

def run(test, params, env):
    """
    KVM reboot test:
    1) Log into a guest with virtio data disk
    2) Format the disk and copy file to it
    3) Stop the guest and boot up it again with the data disk set to readonly
    4) Try to copy file to the data disk
    5) Try to copy file from the data disk

    :param test: QEMU test object
    :param params: Dictionary with the test parameters
    :param env: Dictionary with test environment.
    """
    error.context("Try to log into guest.", logging.info)
    vm = env.get_vm(params["main_vm"])
    vm.verify_alive()
    timeout = float(params.get("login_timeout", 240))
    session = vm.wait_for_login(timeout=timeout)
    vols = utils_misc.get_winutils_vol(session)
    if not vols:
        raise error.TestError("Can not find winutils in guest.")
    filen = 0
    error.context("Format the disk and copy file to it", logging.info)
    os_type = params["os_type"]
    copy_cmd = params.get("copy_cmd", "copy %s %s")
    disk_idx = params.get("disk_index", 1)
    fs_type = params.get("fstype", "ntfs")
    drive_letter = params.get("drive_letter", "I")
    disk_size = params.get("partition_size_data", "200M")
    src_file = params.get("src_file", "").replace("WIN_UTIL", vols)
    utils_misc.format_guest_disk(session, disk_idx, drive_letter,
                                 disk_size, fs_type, os_type)
    dst_file = drive_letter + ":\\" + str(filen)
    session.cmd(copy_cmd % (src_file, dst_file))
    filen += 1

    msg = "Stop the guest and boot up it again with the data disk"
    msg += " set to readonly"
    error.context(msg, logging.info)
    session.close()
    vm.destroy()
    data_img = params.get("images").split()[-1]
    params["image_readonly_%s" % data_img] = "yes"
    params["force_create_image_%s" % data_img] = "no"
    env_process.preprocess(test, params, env)

    vm = env.get_vm(params["main_vm"])
    vm.verify_alive()
    session = vm.wait_for_login(timeout=timeout)

    try:
        error.context("Try to write to the readonly disk", logging.info)
        dst_file_readonly = drive_letter + ":\\" + str(filen)
        session.cmd(copy_cmd % (src_file, dst_file_readonly))
        raise error.TestFail("Write in readonly disk should failed.")
    except aexpect.ShellCmdError:
        error.context("Try to read from the readonly disk", logging.info)
        session.cmd(copy_cmd % (dst_file, "C:\\"))

    session.close()
开发者ID:Chenditang,项目名称:tp-qemu,代码行数:60,代码来源:readonly_disk.py


示例5: run

def run(test, params, env):
    """
    Run Iometer for Windows on a Windows guest:

    1) Boot guest with additional disk
    2) Format the additional disk
    3) Install and register Iometer
    4) Perpare icf to Iometer.exe
    5) Run Iometer.exe with icf
    6) Copy result to host

    :param test: kvm test object
    :param params: Dictionary with the test parameters
    :param env: Dictionary with test environment.
    """
    vm = env.get_vm(params["main_vm"])
    vm.verify_alive()
    timeout = int(params.get("login_timeout", 360))
    session = vm.wait_for_login(timeout=timeout)

    # format the target disk
    utils_test.run_virt_sub_test(test, params, env, "format_disk")

    error_context.context("Install Iometer", logging.info)
    cmd_timeout = int(params.get("cmd_timeout", 360))
    ins_cmd = params["install_cmd"]
    vol_utils = utils_misc.get_winutils_vol(session)
    if not vol_utils:
        raise exceptions.TestError("WIN_UTILS CDROM not found")
    ins_cmd = re.sub("WIN_UTILS", vol_utils, ins_cmd)
    session.cmd(cmd=ins_cmd, timeout=cmd_timeout)
    time.sleep(0.5)

    error_context.context("Register Iometer", logging.info)
    reg_cmd = params["register_cmd"]
    reg_cmd = re.sub("WIN_UTILS", vol_utils, reg_cmd)
    session.cmd_output(cmd=reg_cmd, timeout=cmd_timeout)

    error_context.context("Prepare icf for Iometer", logging.info)
    icf_name = params["icf_name"]
    ins_path = params["install_path"]
    res_file = params["result_file"]
    icf_file = os.path.join(data_dir.get_deps_dir(), "iometer", icf_name)
    vm.copy_files_to(icf_file, "%s\\%s" % (ins_path, icf_name))

    # Run Iometer
    error_context.context("Start Iometer", logging.info)
    session.cmd("cd %s" % ins_path)
    logging.info("Change dir to: %s" % ins_path)
    run_cmd = params["run_cmd"]
    run_timeout = int(params.get("run_timeout", 1000))
    logging.info("Set Timeout: %ss" % run_timeout)
    run_cmd = run_cmd % (icf_name, res_file)
    logging.info("Execute Command: %s" % run_cmd)
    s, o = session.cmd_status_output(cmd=run_cmd, timeout=run_timeout)
    error_context.context("Copy result '%s' to host" % res_file, logging.info)
    vm.copy_files_from(res_file, test.resultsdir)

    if s != 0:
        raise exceptions.TestFail("iometer test failed. {}".format(o))
开发者ID:EIChaoYang,项目名称:tp-qemu,代码行数:60,代码来源:iometer_windows.py


示例6: launch_client

def launch_client(sessions, servers, server_ctl, clients,
                  l, nf_args, port, params):
    """
    Launch netperf clients
    """
    # Start netserver
    error.context("Start Netserver on guest", logging.info)
    remote_dir = params.get("remote_dir", "/var/tmp")
    client_path = os.path.join(remote_dir, "netperf-2.6.0/src/netperf")
    server_path = os.path.join(remote_dir, "netperf-2.6.0/src/netserver")

    if params.get("os_type") == "windows":
        winutils_vol = utils_misc.get_winutils_vol(server_ctl)
        client_path = "%s:\\netperf" % winutils_vol
        netserv_start_cmd = params.get("netserv_start_cmd") % winutils_vol

        logging.info("Netserver start cmd is '%s'" % netserv_start_cmd)
        if "NETSERVER.EXE" not in server_ctl.cmd_output("tasklist"):
            server_ctl.cmd_output(netserv_start_cmd)
            o_tasklist = server_ctl.cmd_output("tasklist")
            if "NETSERVER.EXE" not in o_tasklist.upper():
                msg = "Can not start netserver in Windows guest"
                raise error.TestError(msg)

    else:
        logging.info("Netserver start cmd is '%s'" % server_path)
        ssh_cmd(server_ctl, "pidof netserver || %s" % server_path)
    logging.info("Netserver start successfully")

    # start netperf
    error.context("Start netperf client threads", logging.info)
    client_threads = []

    for client in clients:
        test_timeout = len(clients) * l
        server = servers[clients.index(client) % len(servers)]
        netperf_cmd = "%s -H %s -l %s %s" % (client_path, server,
                                             int(l), nf_args)
        client_threads.append([ssh_cmd, (client, netperf_cmd, test_timeout)])

    result_info = utils_misc.parallel(client_threads)

    counts = 5
    for server in servers:
        if not re.findall("TEST.*to %s" % server, str(result_info)):
            raise error.TestError("Nerperf stress on nic %s failed" % server)
        logging.info("Network stress on %s successfully" % server)

        status, output = utils_test.ping(server, counts,
                                         timeout=float(counts) * 1.5)
        if status != 0:
            raise error.TestFail("Ping returns non-zero value %s" % output)

        package_lost = utils_test.get_loss_ratio(output)
        if package_lost != 0:
            raise error.TestFail("%s packeage lost when ping server ip %s " %
                                 (package_lost, server))
开发者ID:QiuMike,项目名称:tp-qemu,代码行数:57,代码来源:multi_nic_stress.py


示例7: set_winutils_letter

 def set_winutils_letter(cmd, session, params):
     """
     Replace 'X:' in command to real cdrom drive letter.
     """
     vol = "X:"
     if params["os_type"] != "linux":
         vol = utils_misc.get_winutils_vol(session)
         vol = "%s:" % vol
     return cmd.replace("X:", vol)
开发者ID:Chenditang,项目名称:tp-qemu,代码行数:9,代码来源:rng_bat.py


示例8: run

def run(test, params, env):
    """
    KVM guest stop test:
    1) Log into a guest
    2) Check is fio.msi installed, install it if not installed.
    3) Start fio test on both sys and data disk in guest
    4) Get the result

    :param test: kvm test object
    :param params: Dictionary with the test parameters
    :param env: Dictionary with test environment.
    """

    install_path = params["install_path"].rstrip("\\")
    fio_log_file = params.get("fio_log_file")
    fio_cmd = params.get("fio_cmd")
    timeout = float(params.get("login_timeout", 360))
    cmd_timeout = int(params.get("cmd_timeout", "360"))
    check_installed_cmd = 'dir "%s"|findstr /I fio' % install_path
    check_installed_cmd = params.get("check_installed_cmd",
                                     check_installed_cmd)

    vm = env.get_vm(params["main_vm"])
    vm.verify_alive()
    session = vm.wait_for_login(timeout=timeout)

    error_context.context("Format disk", logging.info)
    utils_misc.format_windows_disk(session, params["disk_index"],
                                   mountpoint=params["disk_letter"])
    try:
        installed = session.cmd_status(check_installed_cmd) == 0
        if not installed:
            dst = r"%s:\\" % utils_misc.get_winutils_vol(session)

            error_context.context("Install fio in guest", logging.info)
            install_cmd = params["install_cmd"]
            install_cmd = re.sub(r"DRIVE:\\+", dst, install_cmd)
            session.cmd(install_cmd, timeout=180)
            time.sleep(30)
            config_cmd = params.get("config_cmd")
            if config_cmd:
                session.cmd(config_cmd)

        error_context.context("Start fio in guest.", logging.info)
        status, output = session.cmd_status_output(fio_cmd, timeout=(cmd_timeout*2))
        if status:
            test.error("Failed to run fio, output: %s" % output)

    finally:
        error_context.context("Copy fio log from guest to host.", logging.info)
        try:
            vm.copy_files_from(fio_log_file, test.resultsdir)
        except Exception as err:
            logging.warn("Log file copy failed: %s" % err)
        if session:
            session.close()
开发者ID:bssrikanth,项目名称:tp-qemu,代码行数:56,代码来源:fio_windows.py


示例9: run

def run(test, params, env):
    """
    KVM guest stop test:
    1) Log into a guest
    2) Check is fio.msi installed, install it if not installed.
    3) Start fio in guest
    4) Get the result

    :param test: kvm test object
    :param params: Dictionary with the test parameters
    :param env: Dictionary with test environment.
    """

    install_path = params["install_path"].rstrip("\\")
    log_file = params.get("log_file")
    fio_cmd = params.get("fio_cmd")
    timeout = float(params.get("login_timeout", 360))
    test_timeout = int(params.get("test_timeout", "360"))
    check_installed_cmd = 'dir "%s"|findstr /I fio' % install_path
    check_installed_cmd = params.get("check_installed_cmd",
                                     check_installed_cmd)

    vm = env.get_vm(params["main_vm"])
    vm.verify_alive()
    session = vm.wait_for_login(timeout=timeout)
    try:
        installed = session.cmd_status(check_installed_cmd) == 0
        if not installed:
            dst = r"%s:\\" % utils_misc.get_winutils_vol(session)

            error_context.context("Install fio in guest", logging.info)
            install_cmd = params["install_cmd"]
            install_cmd = re.sub(r"DRIVE:\\+", dst, install_cmd)
            session.cmd(install_cmd, timeout=180)
            time.sleep(30)
            config_cmd = params.get("config_cmd")
            if config_cmd:
                session.cmd(config_cmd)

        error_context.context("Start fio in guest.", logging.info)
        s, o = session.cmd_status_output(fio_cmd, timeout=(test_timeout+60))
        if s:
            raise exceptions.TestError("Failed to run fio, output: %s") % o

    finally:
        error_context.context("Copy fio log from guest to host.", logging.info)
        vm.copy_files_from(log_file, test.resultsdir)
        if session:
            session.close()
开发者ID:CongLi,项目名称:tp-qemu,代码行数:49,代码来源:fio_windows.py


示例10: get_testing_cdrom_device

    def get_testing_cdrom_device(session, cdrom_dev_list):
        """
        Get the testing cdrom used for eject
        :param session: VM session
        :param cdrom_dev_list: cdrom_dev_list
        """
        if params["os_type"] == "windows":
            winutil_drive = utils_misc.get_winutils_vol(session)
            winutil_drive = "%s:" % winutil_drive
            cdrom_dev_list.remove(winutil_drive)
        try:
            testing_cdrom_device = cdrom_dev_list[-1]
        except IndexError:
            raise error.TestFail("Could not find the testing cdrom device")

        return testing_cdrom_device
开发者ID:qilongyun,项目名称:tp-qemu,代码行数:16,代码来源:cdrom.py


示例11: save_file

 def save_file(self, dst):
     login_timeout = int(self.params.get("login_timeout", 360))
     cmd = self.params.get("sync_bin", "sync")
     error.context("save file('%s') md5sum in guest" % dst, logging.info)
     self.__create_file(dst)
     session = self.vm.wait_for_login(timeout=login_timeout)
     logging.info("sync guest data")
     if "X:" in cmd:
         vol = utils_misc.get_winutils_vol(session)
         cmd = cmd.replace("X:", "%s:" % vol)
     status, output = session.cmd_status_output(cmd)
     if status != 0:
         logging.error("Execute '%s' with failures('%s') " % (cmd, output))
         return None
     session.close()
     return self.__md5sum(dst)
开发者ID:CongLi,项目名称:tp-qemu,代码行数:16,代码来源:qemu_disk_img.py


示例12: prepare_traceview_windows

    def prepare_traceview_windows(session, timeout):
        """
        First check the driver installation status, then copy traceview.exe
        and corresponding pdb file to drive c: for future use.

        :param session: a session to send command
        :timeout: the command execute timeout
        :return: the session after driver checking.
        """

        # verify driver
        error_context.context("Check if the driver is installed and "
                              "verified", logging.info)
        driver_name = params.get("driver_name", "netkvm")
        session = utils_test.qemu.windrv_check_running_verifier(session, vm,
                                                                test,
                                                                driver_name,
                                                                timeout)

        # copy traceview.exe
        error_context.context("Copy traceview.exe to drive C", logging.info)
        traceview_path_template = params.get("traceview_path_template")
        cd_drive = utils_misc.get_winutils_vol(session)
        traceview_path = traceview_path_template % cd_drive
        _copy_file(session, traceview_path, "c:\\")

        # copy Netkvm.pdb
        error_context.context("Find Netkvm.pdb and copy to drive C", logging.info)
        viowin_ltr = virtio_win.drive_letter_iso(session)
        if not viowin_ltr:
            test.error("Could not find virtio-win drive in guest")
        guest_name = virtio_win.product_dirname_iso(session)
        if not guest_name:
            test.error("Could not get product dirname of the vm")
        guest_arch = virtio_win.arch_dirname_iso(session)
        if not guest_arch:
            test.error("Could not get architecture dirname of the vm")

        pdb_middle_path = "%s\\%s" % (guest_name, guest_arch)
        pdb_find_cmd = 'dir /b /s %s\\%s.pdb | findstr "\\%s\\\\"'
        pdb_find_cmd %= (viowin_ltr, driver_name, pdb_middle_path)
        pdb_path = session.cmd(pdb_find_cmd, timeout=timeout).strip()
        logging.info("Found Netkvm.pdb file at '%s'", pdb_path)
        _copy_file(session, pdb_path, "c:\\")
        return session
开发者ID:ldoktor,项目名称:tp-qemu,代码行数:45,代码来源:boot_with_different_vectors.py


示例13: get_testing_cdrom_device

    def get_testing_cdrom_device(vm, session, cdrom_dev_list, serial_num=None):
        """
        Get the testing cdrom used for eject
        :param session: VM session
        :param cdrom_dev_list: cdrom_dev_list
        """
        try:
            if params["os_type"] == "windows":
                winutil_drive = utils_misc.get_winutils_vol(session)
                winutil_drive = "%s:" % winutil_drive
                cdrom_dev_list.remove(winutil_drive)
                testing_cdrom_device = cdrom_dev_list[-1]
            else:
                testing_cdrom_device = get_match_cdrom(vm, session, serial_num)
        except IndexError:
            test.fail("Could not find the testing cdrom device")

        return testing_cdrom_device
开发者ID:bssrikanth,项目名称:tp-qemu,代码行数:18,代码来源:cdrom.py


示例14: run

def run(test, params, env):
    """
    KVM guest stop test:
    1) Log into a guest
    2) Check is HeavyLoad.exe installed , download and
       install it if not installed.
    3) Start Heavyload to make guest in heavyload
    4) Check vm is alive
    5) Stop heavyload process and clean temp file.

    :param test: kvm test object
    :param params: Dictionary with the test parameters
    :param env: Dictionary with test environment.
    """

    def loop_session_cmd(session, cmd):
        def session_cmd(session, cmd):
            try:
                return session.cmd_status(cmd) == 0
            except (aexpect.ShellStatusError, aexpect.ShellTimeoutError):
                pass

        count = 0
        while count < 3:
            ret = session_cmd(session, cmd)
            if ret is not None:
                return ret
            count += 1
        return None

    def add_option(cmd, key, val):
        """
        Append options into command;
        """
        if re.match(r".*/%s.*", cmd, re.I):
            if val:
                rex = r"/%s\b+\S+\b+" % key
                val = "/%s %s " % (key, val)
                cmd = re.sub(rex, val, cmd, re.I)
        else:
            cmd += " /%s %s " % (key, val)
        return cmd

    tmp_dir = data_dir.get_tmp_dir()
    install_path = params["install_path"].rstrip("\\")
    heavyload_bin = '"%s\heavyload.exe"' % install_path
    start_cmd = "%s /CPU /MEMORY /FILE " % heavyload_bin
    stop_cmd = "taskkill /T /F /IM heavyload.exe"
    stop_cmd = params.get("stop_cmd", stop_cmd)
    start_cmd = params.get("start_cmd", start_cmd)
    check_running_cmd = "tasklist|findstr /I heavyload"
    check_running_cmd = params.get("check_running_cmd", check_running_cmd)
    test_installed_cmd = "dir '%s'|findstr /I heavyload" % install_path
    test_installed_cmd = params.get("check_installed_cmd", test_installed_cmd)

    vm = env.get_vm(params["main_vm"])
    vm.verify_alive()
    timeout = float(params.get("login_timeout", 240))
    session = vm.wait_for_login(timeout=timeout)
    try:
        installed = session.cmd_status(test_installed_cmd) == 0
        if not installed:
            download_url = params.get("download_url")
            if download_url:
                dst = r"c:\\"
                pkg_md5sum = params["pkg_md5sum"]
                error.context("Download HeavyLoadSetup.exe", logging.info)
                pkg = utils.unmap_url_cache(tmp_dir,
                                            download_url, pkg_md5sum)
                vm.copy_files_to(pkg, dst)
            else:
                dst = r"%s:\\" % utils_misc.get_winutils_vol(session)

            error.context("Install HeavyLoad in guest", logging.info)
            install_cmd = params["install_cmd"]
            install_cmd = re.sub(r"DRIVE:\\+", dst, install_cmd)
            session.cmd(install_cmd)
            config_cmd = params.get("config_cmd")
            if config_cmd:
                session.cmd(config_cmd)

        error.context("Start heavyload in guest", logging.info)
        # genery heavyload command automaticly
        if params.get("autostress") == "yes":
            free_mem = utils_misc.get_free_mem(session, "windows")
            free_disk = utils_misc.get_free_disk(session, "C:")
            start_cmd = '"%s\heavyload.exe"' % params["install_path"]
            start_cmd = add_option(start_cmd, 'CPU', params["smp"])
            start_cmd = add_option(start_cmd, 'MEMORY', free_mem)
            start_cmd = add_option(start_cmd, 'FILE', free_disk)
        else:
            start_cmd = params["start_cmd"]
        # reformat command to ensure heavyload started as except
        test_timeout = int(params.get("timeout", "60"))
        steping = 60
        if test_timeout < 60:
            logging.warn("Heavyload use minis as unit of timeout,"
                         "values is too small, use default: 60s")
            test_timeout = 60
            steping = 30
#.........这里部分代码省略.........
开发者ID:MiriamDeng,项目名称:tp-qemu,代码行数:101,代码来源:win_heavyload.py


示例15: launch_client

def launch_client(sessions, server, server_ctl, host, clients, l, nf_args,
                  port, params, server_cyg):
    """ Launch netperf clients """

    netperf_version = params.get("netperf_version", "2.6.0")
    client_path = "/tmp/netperf-%s/src/netperf" % netperf_version
    server_path = "/tmp/netperf-%s/src/netserver" % netperf_version
    # Start netserver
    error.context("Start Netserver on guest", logging.info)
    if params.get("os_type") == "windows":
        timeout = float(params.get("timeout", "240"))
        cdrom_drv = utils_misc.get_winutils_vol(server_ctl)
        get_status_flag = False
        if params.get("use_cygwin") == "yes":
            netserv_start_cmd = params.get("netserv_start_cmd")
            netperf_src = params.get("netperf_src") % cdrom_drv
            cygwin_root = params.get("cygwin_root")
            netserver_path = params.get("netserver_path")
            netperf_install_cmd = params.get("netperf_install_cmd")
            start_session = server_cyg
            logging.info("Start netserver with cygwin, cmd is: %s" %
                         netserv_start_cmd)
            if "netserver" not in server_ctl.cmd_output("tasklist"):
                netperf_pack = "netperf-%s" % params.get("netperf_version")
                s_check_cmd = "dir %s" % netserver_path
                p_check_cmd = "dir %s" % cygwin_root
                if not ("netserver.exe" in server_ctl.cmd(s_check_cmd) and
                        netperf_pack in server_ctl.cmd(p_check_cmd)):
                    error.context("Install netserver in Windows guest cygwin",
                                  logging.info)
                    cmd = "xcopy %s %s /S /I /Y" % (netperf_src, cygwin_root)
                    server_ctl.cmd(cmd)
                    server_cyg.cmd_output(netperf_install_cmd, timeout=timeout)
                    if "netserver.exe" not in server_ctl.cmd(s_check_cmd):
                        err_msg = "Install netserver cygwin failed"
                        raise error.TestNAError(err_msg)
                    logging.info("Install netserver in cygwin successfully")

        else:
            start_session = server_ctl
            netserv_start_cmd = params.get("netserv_start_cmd") % cdrom_drv
            logging.info("Start netserver without cygwin, cmd is: %s" %
                         netserv_start_cmd)

        error.context("Start netserver on windows guest", logging.info)
        start_netserver_win(start_session, netserv_start_cmd)

    else:
        logging.info("Netserver start cmd is '%s'" % server_path)
        ssh_cmd(server_ctl, "pidof netserver || %s" % server_path)
        get_status_flag = True
        ncpu = ssh_cmd(server_ctl, "cat /proc/cpuinfo |grep processor |wc -l")
        ncpu = re.findall(r"\d+", ncpu)[0]

    logging.info("Netserver start successfully")

    def count_interrupt(name):
        """
        :param name: the name of interrupt, such as "virtio0-input"
        """
        intr = 0
        stat = ssh_cmd(server_ctl, "cat /proc/interrupts |grep %s" % name)
        stat = stat.strip().split("\n")[-1]
        for cpu in range(int(ncpu)):
            intr += int(stat.split()[cpu + 1])
        return intr

    def get_state():
        for i in ssh_cmd(server_ctl, "ifconfig").split("\n\n"):
            if server in i:
                ifname = re.findall(r"(\w+\d+)[:\s]", i)[0]

        path = "find /sys/devices|grep net/%s/statistics" % ifname
        cmd = "%s/rx_packets|xargs cat;%s/tx_packets|xargs cat;" \
            "%s/rx_bytes|xargs cat;%s/tx_bytes|xargs cat" % (path,
                                                             path, path, path)
        output = ssh_cmd(server_ctl, cmd).split()[-4:]

        nrx = int(output[0])
        ntx = int(output[1])
        nrxb = int(output[2])
        ntxb = int(output[3])

        nre = int(ssh_cmd(server_ctl, "grep Tcp /proc/net/snmp|tail -1"
                          ).split()[12])
        state_list = ['rx_pkts', nrx, 'tx_pkts', ntx, 'rx_byts', nrxb,
                      'tx_byts', ntxb, 're_pkts', nre]
        try:
            nrx_intr = count_interrupt("virtio.-input")
            ntx_intr = count_interrupt("virtio.-output")
            state_list.append('rx_intr')
            state_list.append(nrx_intr)
            state_list.append('tx_intr')
            state_list.append(ntx_intr)
        except IndexError:
            ninit = count_interrupt("virtio.")
            state_list.append('intr')
            state_list.append(ninit)

        io_exit = int(ssh_cmd(host, "cat /sys/kernel/debug/kvm/io_exits"))
#.........这里部分代码省略.........
开发者ID:Antique,项目名称:virt-test,代码行数:101,代码来源:netperf.py


示例16: run

def run(test, params, env):
    """
    KVM guest stop test:
    1) Log into a guest
    2) Check is fio.msi installed, install it if not installed.
    3) Start fio test on both sys and data disk in guest
    4) Get the result

    :param test: kvm test object
    :param params: Dictionary with the test parameters
    :param env: Dictionary with test environment.
    """

    install_path = params["install_path"].rstrip("\\")
    fio_log_file = params.objects("fio_log_file")
    fio_file_name = params.objects("fio_file_name")
    fio_cmd_sys = params.get("fio_cmd") % (fio_file_name[0], "sys", fio_log_file[0])
    fio_cmd_data = params.get("fio_cmd") % (fio_file_name[1], "data", fio_log_file[1])
    timeout = float(params.get("login_timeout", 360))
    cmd_timeout = int(params.get("cmd_timeout", "360"))
    check_installed_cmd = 'dir "%s"|findstr /I fio' % install_path
    check_installed_cmd = params.get("check_installed_cmd",
                                     check_installed_cmd)

    vm = env.get_vm(params["main_vm"])
    vm.verify_alive()
    session_sys = vm.wait_for_login(timeout=timeout)
    session_data = vm.wait_for_login(timeout=timeout)

    error_context.context("Format disk", logging.info)
    utils_misc.format_windows_disk(session_sys, params["disk_index"],
                                   mountpoint=params["disk_letter"])
    try:
        installed = session_sys.cmd_status(check_installed_cmd) == 0
        if not installed:
            dst = r"%s:\\" % utils_misc.get_winutils_vol(session_sys)

            error_context.context("Install fio in guest", logging.info)
            install_cmd = params["install_cmd"]
            install_cmd = re.sub(r"DRIVE:\\+", dst, install_cmd)
            session_sys.cmd(install_cmd, timeout=180)
            time.sleep(30)
            config_cmd = params.get("config_cmd")
            if config_cmd:
                session_sys.cmd(config_cmd)

        error_context.context("Start fio in guest.", logging.info)
        # FIXME:Here use the timeout=(cmd_timeout*2)
        # Will determine a better specific calculation later
        fio_thread_data = utils_misc.InterruptedThread(session_data.cmd_status_output,
                                                       (fio_cmd_data, (cmd_timeout*2)))
        fio_thread_data.start()
        status_sys, output_sys = session_sys.cmd_status_output(fio_cmd_sys,
                                                               timeout=(cmd_timeout*2))
        status_data, output_data = fio_thread_data.join()
        if status_sys or status_data:
            test.error("Failed to run fio, output: %s\n%s" % (output_sys, output_data))

    finally:
        error_context.context("Copy fio log from guest to host.", logging.info)
        try:
            vm.copy_files_from(fio_log_file[0], test.resultsdir)
            vm.copy_files_from(fio_log_file[1], test.resultsdir)
        except Exception, err:
            logging.warn("Log file copy failed: %s" % err)
        session_data.close()
        if session_sys:
            session_sys.close()
开发者ID:Zhengtong,项目名称:tp-qemu,代码行数:68,代码来源:fio_windows.py


示例17: run

def run(test, params, env):
    """
    Test the RX jumbo frame function of vnics:

    1) Boot the VM.
    2) Change the MTU of guest nics and host taps depending on the NIC model.
    3) Add the static ARP entry for guest NIC.
    4) Wait for the MTU ok.
    5) Verify the path MTU using ping.
    6) Ping the guest with large frames.
    7) Increment size ping.
    8) Flood ping the guest with large frames.
    9) Verify the path MTU.
    10) Recover the MTU.

    :param test: QEMU test object.
    :param params: Dictionary with the test parameters.
    :param env: Dictionary with test environment.
    """
    def get_ovs_ports(ovs):
        '''
        get the ovs bridge all Interface list.

        :param ovs: Ovs bridge name
        '''
        cmd = "ovs-vsctl list-ports %s" % ovs
        return process.getoutput(cmd, shell=True)

    netdst = params.get("netdst", "switch")
    host_bridges = utils_net.find_bridge_manager(netdst)
    if not isinstance(host_bridges, utils_net.Bridge):
        ovs = host_bridges
        host_hw_interface = get_ovs_ports(netdst)
        tmp_ports = re.findall(r"t[0-9]{1,}-[a-zA-Z0-9]{6}", host_hw_interface)
        if tmp_ports:
            for p in tmp_ports:
                process.system_output("ovs-vsctl del-port %s %s" %
                                      (netdst, p))

    params["start_vm"] = "yes"
    env_process.preprocess_vm(test, params, env, params["main_vm"])

    timeout = int(params.get("login_timeout", 360))
    mtu_default = 1500
    mtu = params.get("mtu", "1500")
    def_max_icmp_size = int(mtu) - 28
    max_icmp_pkt_size = int(params.get("max_icmp_pkt_size",
                                       def_max_icmp_size))
    flood_time = params.get("flood_time", "300")
    os_type = params.get("os_type")
    os_variant = params.get("os_variant")

    vm = env.get_vm(params["main_vm"])
    vm.verify_alive()
    session = vm.wait_for_login(timeout=timeout)
    session_serial = vm.wait_for_serial_login(timeout=timeout)

    ifname = vm.get_ifname(0)
    guest_ip = vm.get_address(0)
    if guest_ip is None:
        test.error("Could not get the guest ip address")

    host_mtu_cmd = "ifconfig %s mtu %s"
    if not isinstance(host_bridges, utils_net.Bridge):
        target_ifaces = set(get_ovs_ports(netdst).splitlines())
    else:
        br_in_use = host_bridges.list_br()
        ifaces_in_use = host_bridges.list_iface()
        target_ifaces = set(ifaces_in_use) - set(br_in_use)

    error_context.context("Change all Bridge NICs MTU to %s" %
                          mtu, logging.info)
    for iface in target_ifaces:
        process.run(host_mtu_cmd % (iface, mtu), shell=True)

    try:
        error_context.context("Changing the MTU of guest", logging.info)
        # Environment preparation
        mac = vm.get_mac_address(0)
        if os_type == "linux":
            ethname = utils_net.get_linux_ifname(session, mac)
            guest_mtu_cmd = "ifconfig %s mtu %s" % (ethname, mtu)
        else:
            connection_id = utils_net.get_windows_nic_attribute(
                session, "macaddress", mac, "netconnectionid")

            index = utils_net.get_windows_nic_attribute(
                session, "netconnectionid", connection_id, "index")
            if os_variant == "winxp":
                pnpdevice_id = utils_net.get_windows_nic_attribute(
                    session, "netconnectionid", connection_id, "pnpdeviceid")
                cd_num = utils_misc.get_winutils_vol(session)
                copy_cmd = r"xcopy %s:\devcon\wxp_x86\devcon.exe c:\ " % cd_num
                session.cmd(copy_cmd)

            reg_set_mtu_pattern = params.get("reg_mtu_cmd")
            mtu_key_word = params.get("mtu_key", "MTU")
            reg_set_mtu = reg_set_mtu_pattern % (int(index), mtu_key_word,
                                                 int(mtu))
            guest_mtu_cmd = "%s " % reg_set_mtu
#.........这里部分代码省略.........
开发者ID:ldoktor,项目名称:tp-qemu,代码行数:101,代码来源:jumbo.py


示例18: run


#.........这里部分代码省略.........
        cmd = params.get("pre_cmd")
        if cmd:
            error.context("Create partition on those disks", logging.info)
            s, output = session.cmd_status_output(cmd, timeout=cmd_timeout)
            if s != 0:
                raise error.TestFail("Create partition on disks failed.\n"
                                     "Output is: %s\n" % output)

        error.context("Get disks dev filenames in guest", logging.info)
        cmd = params["list_volume_command"]
        s, output = session.cmd_status_output(cmd, timeout=cmd_timeout)
        if s != 0:
            raise error.TestFail("List volume command failed with cmd '%s'.\n"
                                 "Output is: %s\n" % (cmd, output))

        output = session.cmd_output(cmd, timeout=cmd_timeout)
        disks = re.findall(re_str, output)
        disks = map(string.strip, disks)
        disks.sort()
        logging.debug("Volume list that meet regular expressions: %s",
                      " ".join(disks))

        images = params 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils_misc.mount函数代码示例发布时间:2022-05-26
下一篇:
Python utils_misc.get_qemu_img_binary函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap