def run(test, params, env):
    """
    Build and install packages from git on the client or guest VM

    Supported configurations:
    build_install_pkg: name of the package to get from git, build and install

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

    # Collect test parameters
    pkgName = params.get("build_install_pkg")
    script = params.get("script")
    vm_name = params.get("vm_name")
    dst_dir = params.get("dst_dir")

    # Path of the script on the VM
    vm_script_path = os.path.join(dst_dir, script)

    # Get root session for the VM
    (vm, vm_root_session) = connect_to_vm(vm_name, env, params)

    # location of the script on the host
    host_script_path = os.path.join(data_dir.get_deps_dir(), "spice", script)

    logging.info(
        "Transferring the script to %s," "destination directory: %s, source script location: %s",
        vm_name,
        vm_script_path,
        host_script_path,
    )

    vm.copy_files_to(host_script_path, vm_script_path, timeout=60)
    time.sleep(5)

    # All packages require spice-protocol
    build_install_spiceprotocol(vm_root_session, vm_script_path, params)

    # Run build_install.py script
    if pkgName == "xf86-video-qxl":
        build_install_qxl(vm_root_session, vm_script_path, params)
    elif pkgName == "spice-vd-agent":
        build_install_vdagent(vm_root_session, vm_script_path, params)
    elif pkgName == "spice-gtk":
        build_install_spicegtk(vm_root_session, vm_script_path, params)
    elif pkgName == "virt-viewer":
        build_install_virtviewer(vm_root_session, vm_script_path, params)
    else:
        logging.info("Not supported right now")
        raise error.TestFail("Incorrect Test_Setup")

    utils_spice.clear_interface(vm)
def run(test, params, env):
    """
    Build and install packages from git on the client or guest VM

    Supported configurations:
    build_install_pkg: name of the package to get from git, build and install

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

    # Collect test parameters
    pkgName = params.get("build_install_pkg")
    script = params.get("script")
    vm_name = params.get("vm_name")
    dst_dir = params.get("dst_dir")

    # Path of the script on the VM
    vm_script_path = os.path.join(dst_dir, script)

    # Get root session for the VM
    (vm, vm_root_session) = connect_to_vm(vm_name, env, params)

    # location of the script on the host
    host_script_path = os.path.join(data_dir.get_deps_dir(), "spice", script)

    logging.info(
        "Transferring the script to %s,"
        "destination directory: %s, source script location: %s", vm_name,
        vm_script_path, host_script_path)

    vm.copy_files_to(host_script_path, vm_script_path, timeout=60)
    time.sleep(5)

    # All packages require spice-protocol
    build_install_spiceprotocol(vm_root_session, vm_script_path, params)

    # Run build_install.py script
    if pkgName == "xf86-video-qxl":
        build_install_qxl(vm_root_session, vm_script_path, params)
    elif pkgName == "spice-vd-agent":
        build_install_vdagent(vm_root_session, vm_script_path, params)
    elif pkgName == "spice-gtk":
        build_install_spicegtk(vm_root_session, vm_script_path, params)
    elif pkgName == "virt-viewer":
        build_install_virtviewer(vm_root_session, vm_script_path, params)
    else:
        logging.info("Not supported right now")
        raise error.TestFail("Incorrect Test_Setup")

    utils_spice.clear_interface(vm)
Exemple #3
0
def run(test, params, env):
    """
    Simple test for Remote Desktop connection
    Tests expectes that Remote Desktop client (spice/vnc) will be executed
    from within a second guest so we won't be limited to Linux only clients

    The plan is to support remote-viewer at first place

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

    guest_vm = env.get_vm(params["guest_vm"])

    guest_vm.verify_alive()
    guest_session = guest_vm.wait_for_login(
        timeout=int(params.get("login_timeout", 360)))

    client_vm = env.get_vm(params["client_vm"])
    client_vm.verify_alive()
    client_session = client_vm.wait_for_login(
        timeout=int(params.get("login_timeout", 360)))

    if (client_vm.params.get("os_type") == "windows"
            and client_vm.params.get("rv_installer", None)):
        utils_spice.install_rv_win(client_vm, params.get("rv_installer"))
        return

    if params.get("clear_interface", "yes") == "yes":
        for vm in params.get("vms").split():
            try:
                session = env.get_vm(vm).wait_for_login(timeout=360)
                output = session.cmd('cat /etc/redhat-release')
                logging.info(output)
            except ShellCmdError:
                test.cancel("Test is only currently supported on "
                            "RHEL and Fedora operating systems")
            if "release 6." in output:
                waittime = 15
            else:
                waittime = 60
            utils_spice.clear_interface(
                env.get_vm(vm), int(params.get("login_timeout", "360")))

        utils_spice.wait_timeout(waittime)

    launch_rv(test, client_vm, guest_vm, params)

    client_session.close()
    guest_session.close()
def run(test, params, env):
    """
    Simple test for Remote Desktop connection
    Tests expectes that Remote Desktop client (spice/vnc) will be executed
    from within a second guest so we won't be limited to Linux only clients

    The plan is to support remote-viewer at first place

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

    guest_vm = env.get_vm(params["guest_vm"])

    guest_vm.verify_alive()
    guest_session = guest_vm.wait_for_login(
        timeout=int(params.get("login_timeout", 360)))

    client_vm = env.get_vm(params["client_vm"])
    client_vm.verify_alive()
    client_session = client_vm.wait_for_login(
        timeout=int(params.get("login_timeout", 360)))

    if (client_vm.params.get("os_type") == "windows" and
            client_vm.params.get("rv_installer", None)):
        utils_spice.install_rv_win(client_vm, params.get("rv_installer"))
        return

    if params.get("clear_interface", "yes") == "yes":
        for vm in params.get("vms").split():
            try:
                session = env.get_vm(vm).wait_for_login(timeout=360)
                output = session.cmd('cat /etc/redhat-release')
                logging.info(output)
            except ShellCmdError:
                raise error.TestNAError("Test is only currently supported on "
                                        "RHEL and Fedora operating systems")
            if "release 6." in output:
                waittime = 15
            else:
                waittime = 60
            utils_spice.clear_interface(env.get_vm(vm),
                                        int(params.get("login_timeout", "360")))

        utils_spice.wait_timeout(waittime)

    launch_rv(client_vm, guest_vm, params)

    client_session.close()
    guest_session.close()
Exemple #5
0
def run(test, params, env):
    """
    Simple test for Remote Desktop connection
    Tests expectes that Remote Desktop client (spice/vnc) will be executed
    from within a second guest so we won't be limited to Linux only clients

    The plan is to support remote-viewer at first place

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

    guest_vm = env.get_vm(params["guest_vm"])

    guest_vm.verify_alive()
    guest_session = guest_vm.wait_for_login(
        timeout=int(params.get("login_timeout", 360)))

    client_vm = env.get_vm(params["client_vm"])
    client_vm.verify_alive()
    client_session = client_vm.wait_for_login(
        timeout=int(params.get("login_timeout", 360)))

    if (client_vm.params.get("os_type") == "windows"
            and client_vm.params.get("rv_installer", None)):
        utils_spice.install_rv_win(client_vm, params.get("rv_installer"))
        return

    if params.get("clear_interface", "yes") == "yes":
        for vm in params.get("vms").split():
            utils_spice.clear_interface(
                env.get_vm(vm), int(params.get("login_timeout", "360")))
        utils_spice.wait_timeout(15)

    launch_rv(client_vm, guest_vm, params)

    client_session.close()
    guest_session.close()
Exemple #6
0
def run_rv_connect(test, params, env):
    """
    Simple test for Remote Desktop connection
    Tests expectes that Remote Desktop client (spice/vnc) will be executed
    from within a second guest so we won't be limited to Linux only clients

    The plan is to support remote-viewer at first place

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

    guest_vm = env.get_vm(params["guest_vm"])

    guest_vm.verify_alive()
    guest_session = guest_vm.wait_for_login(
        timeout=int(params.get("login_timeout", 360)))

    client_vm = env.get_vm(params["client_vm"])
    client_vm.verify_alive()
    client_session = client_vm.wait_for_login(
        timeout=int(params.get("login_timeout", 360)))

    if (client_vm.params.get("os_type") == "windows" and
       client_vm.params.get("rv_installer", None)):
        utils_spice.install_rv_win(client_vm, params.get("rv_installer"))
        return

    if params.get("clear_interface", "yes") == "yes":
        for vm in params.get("vms").split():
            utils_spice.clear_interface(env.get_vm(vm),
                                        int(params.get("login_timeout", "360")))
        utils_spice.wait_timeout(15)

    launch_rv(client_vm, guest_vm, params)

    client_session.close()
    guest_session.close()
Exemple #7
0
def run(test, params, env):
    """
    Simple setup test to create certs on the client to be passed to VM's
    smartcard.

    :param test: QEMU test object.
    :param params: Dictionary with the test parameters.
    :param env: Dictionary with test environment.
    """
    # Get necessary params
    cert_list = params.get("gencerts").split(",")
    cert_db = params.get("certdb")
    self_sign = params.get("self_sign")
    cert_trustargs = params.get("trustargs")

    logging.debug("Cert List:")
    for cert in cert_list:
        logging.debug(cert)
        logging.debug(cert_trustargs)
        logging.debug("CN=%s", cert)
        logging.debug(cert_db)

    client_vm = env.get_vm(params["client_vm"])
    client_vm.verify_alive()

    client_session = client_vm.wait_for_login(timeout=int(
        params.get("login_timeout", 360)),
                                              username="******",
                                              password="******")

    for vm in params.get("vms").split():
        utils_spice.clear_interface(env.get_vm(vm),
                                    int(params.get("login_timeout", "360")))

    # generate a random string, used to create a random key for the certs
    randomstring = utils_misc.generate_random_string(2048)
    cmd = "echo '" + randomstring + "' > /tmp/randomtext.txt"
    output = client_session.cmd(cmd)
    #output2 = client_session.cmd("cat /tmp/randomtext.txt")
    utils_spice.wait_timeout(5)

    # for each cert listed by the test, create it on the client
    for cert in cert_list:
        cmd = "certutil "
        if self_sign:
            cmd += " -x "
        cmd += "-t '" + cert_trustargs + "' -S -s " + "'CN=" + cert
        cmd += "' -n '" + cert + "' -d " + cert_db
        cmd += " -z " + "/tmp/randomtext.txt"
        logging.debug(cmd)
        output = client_session.cmd(cmd)
        logging.debug("Cert Created: %s", output)

    cmd = "certutil -L -d " + cert_db
    output = client_session.cmd(cmd)
    logging.info("Listing all certs on the client: %s", output)

    # Verify that all the certs have been generated on the client
    for cert in cert_list:
        if not (cert in output):
            test.fail("Certificate %s not found" % cert)

    client_session.close()
Exemple #8
0
def run(test, params, env):
    """
    Simple test for Remote Desktop connection
    Tests expectes that Remote Desktop client (spice/vnc) will be executed
    from within a second guest so we won't be limited to Linux only clients

    The plan is to support remote-viewer at first place

    :param test: QEMU test object.
    :param params: Dictionary with the test parameters.
    :param env: Dictionary with test environment.
    """
    # Get necessary params
    test_timeout = float(params.get("test_timeout", 600))

    utils_spice.wait_timeout(20)

    for vm in params.get("vms").split():
        utils_spice.clear_interface(env.get_vm(vm),
                                    int(params.get("login_timeout", "360")))

    utils_spice.wait_timeout(20)

    guest_vm = env.get_vm(params["guest_vm"])
    guest_vm.verify_alive()
    guest_session = guest_vm.wait_for_login(
        timeout=int(params.get("login_timeout", 360)))
    guest_root_session = guest_vm.wait_for_login(username="******",
                                                 password="******")

    logging.debug("Exporting guest display")
    guest_session.cmd("export DISPLAY=:0.0")

    # Get the min, current, and max resolution on the guest
    output = guest_session.cmd("xrandr | grep Screen")
    outputlist = output.split()

    minimum = "640x480"

    current_index = outputlist.index("current")
    current = outputlist[current_index + 1]
    current += outputlist[current_index + 2]
    # Remove trailing comma
    current += outputlist[current_index + 3].replace(",", "")

    maximum = "2560x1600"

    logging.info("Minimum: " + minimum + " Current: " + current +
                 " Maximum: " + maximum)
    if(current != minimum):
        resolution = minimum
    else:
        resolution = maximum

    # Changing the guest resolution
    guest_session.cmd("xrandr -s " + resolution)
    logging.info("The resolution on the guest has been changed from " +
                 current + " to: " + resolution)

    # Start vdagent daemon
    utils_spice.start_vdagent(guest_root_session, test_timeout)

    client_vm = env.get_vm(params["client_vm"])
    client_vm.verify_alive()
    client_session = client_vm.wait_for_login(
        timeout=int(params.get("login_timeout", 360)))

    client_session.close()
    guest_session.close()
def run(test, params, env):
    """
    Simple setup test to create certs on the client to be passed to VM's
    smartcard.

    :param test: QEMU test object.
    :param params: Dictionary with the test parameters.
    :param env: Dictionary with test environment.
    """
    # Get necessary params
    cert_list = params.get("gencerts").split(",")
    cert_db = params.get("certdb")
    self_sign = params.get("self_sign")
    cert_trustargs = params.get("trustargs")

    logging.debug("Cert List:")
    for cert in cert_list:
        logging.debug(cert)
        logging.debug(cert_trustargs)
        logging.debug("CN=" + cert)
        logging.debug(cert_db)

    client_vm = env.get_vm(params["client_vm"])
    client_vm.verify_alive()

    client_session = client_vm.wait_for_login(
        timeout=int(params.get("login_timeout", 360)),
        username="******", password="******")

    for vm in params.get("vms").split():
        utils_spice.clear_interface(env.get_vm(vm),
                                    int(params.get("login_timeout", "360")))

    # generate a random string, used to create a random key for the certs
    randomstring = utils_misc.generate_random_string(2048)
    cmd = "echo '" + randomstring + "' > /tmp/randomtext.txt"
    output = client_session.cmd(cmd)
    #output2 = client_session.cmd("cat /tmp/randomtext.txt")
    utils_spice.wait_timeout(5)

    # for each cert listed by the test, create it on the client
    for cert in cert_list:
        cmd = "certutil "
        if self_sign:
            cmd += " -x "
        cmd += "-t '" + cert_trustargs + "' -S -s " + "'CN=" + cert
        cmd += "' -n '" + cert + "' -d " + cert_db
        cmd += " -z " + "/tmp/randomtext.txt"
        logging.debug(cmd)
        output = client_session.cmd(cmd)
        logging.debug("Cert Created: " + output)

    cmd = "certutil -L -d " + cert_db
    output = client_session.cmd(cmd)
    logging.info("Listing all certs on the client: " + output)

    # Verify that all the certs have been generated on the client
    for cert in cert_list:
        if not(cert in output):
            raise error.TestFail("Certificate %s not found" % cert)

    client_session.close()