Exemple #1
0
def launch_rv(client_vm, guest_vm, params):
    """
    Launches rv_binary with args based on spice configuration
    inside client_session on background.
    remote-viewer will try to connect from vm1 from vm2

    @param client_vm - vm object
    @param guest_vm - vm object
    @param params
    """
    rv_binary = params.get("rv_binary", "remote-viewer")
    host_ip = utils_misc.get_host_ip_address(params)
    host_port = None
    full_screen = params.get("full_screen")
    display = params.get("display")
    cmd = rv_binary + " --display=:0.0"
    ticket = None

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

    if display == "spice":
        ticket = guest_vm.get_spice_var("spice_password")

        if guest_vm.get_spice_var("spice_ssl") == "yes":
            host_port = guest_vm.get_spice_var("spice_tls_port")
            cacert = "%s/%s" % (
                guest_vm.get_spice_var("spice_x509_prefix"),
                guest_vm.get_spice_var("spice_x509_cacert_file"))
            #cacert subj is in format for create certificate(with '/' delimiter)
            #remote-viewer needs ',' delimiter. And also is needed to remove
            #first character (it's '/')
            host_subj = guest_vm.get_spice_var("spice_x509_server_subj")
            host_subj = host_subj.replace('/', ',')[1:]

            cmd += " spice://%s?tls-port=%s" % (host_ip, host_port)
            cmd += " --spice-ca-file=%s" % cacert

            if params.get("spice_client_host_subject") == "yes":
                cmd += " --spice-host-subject=\"%s\"" % host_subj

            #client needs cacert file
            client_session.cmd("rm -rf %s && mkdir -p %s" %
                               (guest_vm.get_spice_var("spice_x509_prefix"),
                                guest_vm.get_spice_var("spice_x509_prefix")))
            remote.copy_files_to(client_vm.get_address(), 'scp',
                                 params.get("username"),
                                 params.get("password"),
                                 params.get("shell_port"), cacert, cacert)
        else:
            host_port = guest_vm.get_spice_var("spice_port")
            cmd += " spice://%s?port=%s" % (host_ip, host_port)

    elif display == "vnc":
        raise NotImplementedError("remote-viewer vnc")

    else:
        raise Exception("Unsupported display value")

    # Check to see if the test is using the full screen option.
    if full_screen == "yes":
        logging.info("Remote Viewer Set to use Full Screen")
        cmd += " --full-screen"

    cmd = "nohup " + cmd + " &> /dev/null &"  # Launch it on background

    # Launching the actual set of commands
    try:
        client_session.cmd("startx &", timeout=15)
    except (ShellCmdError, ShellStatusError):
        logging.debug("Ignoring an Exception that Occurs from calling startx")

    utils_spice.wait_timeout(15)

    try:
        print_rv_version(client_session, rv_binary)
    except ShellStatusError:
        # Sometimes It fails with Status error, ingore it and continue.
        # It's not that important to have printed versions in the log.
        logging.debug("Ignoring a Status Exception that occurs from calling " \
                      + "print versions of remote-viewer or spice-gtk")

    logging.info("Launching %s on the client (virtual)", cmd)
    client_session.cmd(cmd)

    # client waits for user entry (authentication) if spice_password is set
    if ticket:
        utils_spice.wait_timeout(5)  # Wait for remote-viewer to launch
        send_ticket(client_vm, ticket)

    utils_spice.wait_timeout(5)  # Wait for conncetion to establish
    verify_established(client_session, host_ip, host_port, rv_binary)

    #prevent from kill remote-viewer after test finish
    cmd = "disown -ar"
    client_session.cmd(cmd)
Exemple #2
0
def launch_rv(client_vm, guest_vm, params):
    """
    Launches rv_binary with args based on spice configuration
    inside client_session on background.
    remote-viewer will try to connect from vm1 from vm2

    @param client_vm - vm object
    @param guest_vm - vm object
    @param params
    """
    rv_binary = params.get("rv_binary", "remote-viewer")
    host_ip = utils_misc.get_host_ip_address(params)
    host_port = None
    display = params.get("display")
    cmd = rv_binary + " --display=:0.0"
    ticket = None

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

    if display == "spice":
        ticket = guest_vm.get_spice_var("spice_password")

        if guest_vm.get_spice_var("spice_ssl") == "yes":
            host_port = guest_vm.get_spice_var("spice_tls_port")
            cacert = "%s/%s" % (guest_vm.get_spice_var("spice_x509_prefix"),
                               guest_vm.get_spice_var("spice_x509_cacert_file"))
            #cacert subj is in format for create certificate(with '/' delimiter)
            #remote-viewer needs ',' delimiter. And also is needed to remove
            #first character (it's '/')
            host_subj = guest_vm.get_spice_var("spice_x509_server_subj")
            host_subj = host_subj.replace('/',',')[1:]

            cmd += " spice://%s?tls-port=%s" % (host_ip, host_port)
            cmd += " --spice-ca-file=%s" % cacert

            if params.get("spice_client_host_subject") == "yes":
                cmd += " --spice-host-subject=\"%s\"" % host_subj

            #client needs cacert file
            client_session.cmd("rm -rf %s && mkdir -p %s" % (
                               guest_vm.get_spice_var("spice_x509_prefix"),
                               guest_vm.get_spice_var("spice_x509_prefix")))
            remote.copy_files_to(client_vm.get_address(), 'scp',
                                      params.get("username"),
                                      params.get("password"),
                                      params.get("shell_port"),
                                      cacert, cacert)
        else:
            host_port = guest_vm.get_spice_var("spice_port")
            cmd += " spice://%s?port=%s" % (host_ip, host_port)

    elif display == "vnc":
        raise NotImplementedError("remote-viewer vnc")

    else:
        raise Exception("Unsupported display value")
    cmd = "nohup " + cmd + " &> /dev/null &" # Launch it on background

    # Launching the actual set of commands
    launch_xorg(client_session)
    wait_timeout() # Wait for Xorg to start up
    launch_gnome_session(client_session)
    wait_timeout() # Wait till gnome-session starts up

    print_rv_version(client_session, rv_binary)

    logging.info("Launching %s on the client (virtual)", cmd)
    client_session.cmd(cmd)

    # client waits for user entry (authentication) if spice_password is set
    if ticket:
        wait_timeout() # Wait for remote-viewer to launch
        send_ticket(client_vm, ticket)

    wait_timeout() # Wait for conncetion to establish
    verify_established(client_session, host_ip, host_port, rv_binary)

    #prevent from kill remote-viewer after test finish
    cmd = "disown -ar"
    client_session.cmd(cmd)
Exemple #3
0
def launch_rv(client_vm, guest_vm, params):
    """
    Launches rv_binary with args based on spice configuration
    inside client_session on background.
    remote-viewer will try to connect from vm1 from vm2

    @param client_vm - vm object
    @param guest_vm - vm object
    @param params
    """
    rv_binary = params.get("rv_binary", "remote-viewer")
    host_ip = utils_misc.get_host_ip_address(params)
    host_port = None
    full_screen = params.get("full_screen")
    display = params.get("display")
    cmd = rv_binary + " --display=:0.0"
    ticket = None

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

    if display == "spice":
        ticket = guest_vm.get_spice_var("spice_password")

        if guest_vm.get_spice_var("spice_ssl") == "yes":
            host_port = guest_vm.get_spice_var("spice_tls_port")
            cacert = "%s/%s" % (guest_vm.get_spice_var("spice_x509_prefix"),
                               guest_vm.get_spice_var("spice_x509_cacert_file"))
            #cacert subj is in format for create certificate(with '/' delimiter)
            #remote-viewer needs ',' delimiter. And also is needed to remove
            #first character (it's '/')
            host_subj = guest_vm.get_spice_var("spice_x509_server_subj")
            host_subj = host_subj.replace('/', ',')[1:]

            cmd += " spice://%s?tls-port=%s" % (host_ip, host_port)
            cmd += " --spice-ca-file=%s" % cacert

            if params.get("spice_client_host_subject") == "yes":
                cmd += " --spice-host-subject=\"%s\"" % host_subj

            #client needs cacert file
            client_session.cmd("rm -rf %s && mkdir -p %s" % (
                               guest_vm.get_spice_var("spice_x509_prefix"),
                               guest_vm.get_spice_var("spice_x509_prefix")))
            remote.copy_files_to(client_vm.get_address(), 'scp',
                                      params.get("username"),
                                      params.get("password"),
                                      params.get("shell_port"),
                                      cacert, cacert)
        else:
            host_port = guest_vm.get_spice_var("spice_port")
            cmd += " spice://%s?port=%s" % (host_ip, host_port)

    elif display == "vnc":
        raise NotImplementedError("remote-viewer vnc")

    else:
        raise Exception("Unsupported display value")

    # Check to see if the test is using the full screen option.
    if full_screen == "yes":
        logging.info("Remote Viewer Set to use Full Screen")
        cmd += " --full-screen"


    cmd = "nohup " + cmd + " &> /dev/null &" # Launch it on background

    # Launching the actual set of commands
    try:
        client_session.cmd("startx &", timeout=15)
    except (ShellCmdError, ShellStatusError):
        logging.debug("Ignoring an Exception that Occurs from calling startx")

    utils_spice.wait_timeout(15)

    try:
        print_rv_version(client_session, rv_binary)
    except ShellStatusError:
        # Sometimes It fails with Status error, ingore it and continue.
        # It's not that important to have printed versions in the log.
        logging.debug("Ignoring a Status Exception that occurs from calling " \
                      + "print versions of remote-viewer or spice-gtk")

    logging.info("Launching %s on the client (virtual)", cmd)
    client_session.cmd(cmd)

    # client waits for user entry (authentication) if spice_password is set
    if ticket:
        utils_spice.wait_timeout(5)  # Wait for remote-viewer to launch
        send_ticket(client_vm, ticket)

    utils_spice.wait_timeout(5)  # Wait for conncetion to establish
    verify_established(client_session, host_ip, host_port, rv_binary)

    #prevent from kill remote-viewer after test finish
    cmd = "disown -ar"
    client_session.cmd(cmd)
Exemple #4
0
def launch_rv(client_vm, guest_vm, params):
    """
    Launches rv_binary with args based on spice configuration
    inside client_session on background.
    remote-viewer will try to connect from vm1 from vm2

    @param client_vm - vm object
    @param guest_vm - vm object
    @param params
    """
    rv_binary = params.get("rv_binary", "remote-viewer")
    host_ip = utils_misc.get_host_ip_address(params)
    host_port = None
    display = params.get("display")
    cmd = rv_binary + " --display=:0.0"
    ticket = None

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

    if display == "spice":
        ticket = guest_vm.get_spice_var("spice_password")

        if guest_vm.get_spice_var("spice_ssl") == "yes":
            host_port = guest_vm.get_spice_var("spice_tls_port")
            cacert = "%s/%s" % (
                guest_vm.get_spice_var("spice_x509_prefix"),
                guest_vm.get_spice_var("spice_x509_cacert_file"))
            #cacert subj is in format for create certificate(with '/' delimiter)
            #remote-viewer needs ',' delimiter. And also is needed to remove
            #first character (it's '/')
            host_subj = guest_vm.get_spice_var("spice_x509_server_subj")
            host_subj = host_subj.replace('/', ',')[1:]

            cmd += " spice://%s?tls-port=%s" % (host_ip, host_port)
            cmd += " --spice-ca-file=%s" % cacert

            if params.get("spice_client_host_subject") == "yes":
                cmd += " --spice-host-subject=\"%s\"" % host_subj

            #client needs cacert file
            client_session.cmd("rm -rf %s && mkdir -p %s" %
                               (guest_vm.get_spice_var("spice_x509_prefix"),
                                guest_vm.get_spice_var("spice_x509_prefix")))
            remote.copy_files_to(client_vm.get_address(), 'scp',
                                 params.get("username"),
                                 params.get("password"),
                                 params.get("shell_port"), cacert, cacert)
        else:
            host_port = guest_vm.get_spice_var("spice_port")
            cmd += " spice://%s?port=%s" % (host_ip, host_port)

    elif display == "vnc":
        raise NotImplementedError("remote-viewer vnc")

    else:
        raise Exception("Unsupported display value")
    cmd = "nohup " + cmd + " &> /dev/null &"  # Launch it on background

    # Launching the actual set of commands
    launch_xorg(client_session)
    wait_timeout()  # Wait for Xorg to start up
    launch_gnome_session(client_session)
    wait_timeout()  # Wait till gnome-session starts up

    print_rv_version(client_session, rv_binary)

    logging.info("Launching %s on the client (virtual)", cmd)
    client_session.cmd(cmd)

    # client waits for user entry (authentication) if spice_password is set
    if ticket:
        wait_timeout()  # Wait for remote-viewer to launch
        send_ticket(client_vm, ticket)

    wait_timeout()  # Wait for conncetion to establish
    verify_established(client_session, host_ip, host_port, rv_binary)

    #prevent from kill remote-viewer after test finish
    cmd = "disown -ar"
    client_session.cmd(cmd)