def _copy_until_end(self, end_event):
            #Copy until migration not end.
            while not end_event.isSet():
                logging.info("Copy file to guest %s.", self.vm_addr)
                virt_remote.copy_files_to(self.vm_addr,
                                          "scp",
                                          guest_root,
                                          guest_pass,
                                          22,
                                          host_path,
                                          guest_path,
                                          limit=transfer_speed,
                                          verbose=True,
                                          timeout=transfer_timeout)
                logging.info("Copy file to guests %s done.", self.vm_addr)

                logging.info("Copy file from guest %s.", self.vm_addr)
                virt_remote.copy_files_from(self.vm_addr,
                                            "scp",
                                            guest_root,
                                            guest_pass,
                                            22,
                                            guest_path,
                                            host_path_returned,
                                            limit=transfer_speed,
                                            verbose=True,
                                            timeout=transfer_timeout)
                logging.info("Copy file from guests %s done.", self.vm_addr)
                check_sum = client_utils.hash_file(host_path_returned)
                #store checksum for later check.
                self.file_check_sums.append(check_sum)
        def _copy_until_end(self, end_event):
            #Copy until migration not end.
            while not end_event.isSet():
                logging.info("Copy file to guest %s.", self.vm_addr)
                virt_remote.copy_files_to(self.vm_addr, "scp", guest_root,
                                          guest_pass, 22, host_path,
                                          guest_path, limit=transfer_speed,
                                          verbose=True,
                                          timeout=transfer_timeout)
                logging.info("Copy file to guests %s done.", self.vm_addr)

                logging.info("Copy file from guest %s.", self.vm_addr)
                virt_remote.copy_files_from(self.vm_addr, "scp", guest_root,
                                            guest_pass, 22, guest_path,
                                            host_path_returned,
                                            limit=transfer_speed, verbose=True,
                                            timeout=transfer_timeout)
                logging.info("Copy file from guests %s done.", self.vm_addr)
                check_sum = client_utils.hash_file(host_path_returned)
                #store checksum for later check.
                self.file_check_sums.append(check_sum)
예제 #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 = virt_utils.get_ip_address_by_interface(params.get("bridge"))
    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")))
            virt_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)
    job_output = client_session.cmd(cmd)
    cmd = "disown -h %s" % get_pid(job_output)
    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)
예제 #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 = virt_utils.get_ip_address_by_interface(params.get("netdst"))
    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")))
            virt_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)