Example #1
0
def launch_spicec(cmd, host, host_subject, port, secport, ticket,
                  title, ca_file, debug=False):
    """Launch the SPICE client using the spicec command."""

    args = ['spicec']
    if cmd.startswith('/usr/libexec'):
        args.extend([host])
        if port is not None:
            args.append([str(port)])
        else:
            args.extend(["0"])
        if secport:
            args.extend([str(secport)])
            args.extend(['--ssl-channels', 'smain,sinputs'])
            args.extend(['--ca-file', ca_file])
            if host_subject and host_subject != '':
                args.extend(['--host-subject', host_subject])
        args.extend(['-p', ticket])
    else:
        args.extend(['-h', host])
        if port is not None:
            args.extend(['-p', str(port)])
        if secport:
            args.extend([ '-s', str(secport) ])
            args.extend(['--ca-file', ca_file])
            if host_subject and host_subject != '':
                args.extend(['--host-subject', host_subject])
        args.extend(['-w', ticket])
        args.extend(['-t', title])
    util.spawn(cmd, args, debug=True)
Example #2
0
def launch_remote_viewer(cmd, host, host_subject, port, secport, ticket,
                         title, ca_file, proxy, debug=False):
    """Launch the SPICE client using the remote-viewer command."""

    # Load the CA certificate:
    with open(ca_file, "r") as ca_stream:
        ca_text = ca_stream.read()

    # Generate the configuration:
    config_text = CONFIG_TEMPLATE.format(
        title=title,
        host=host,
        ticket=ticket,
        port=port,
        secport=secport,
        host_subject=host_subject,
        ca_text=ca_text.replace("\n", "\\n"),
    )

    # Add the proxy:
    if proxy is not None:
        config_text += "proxy=%s\n" % proxy

    # Write the configuation to a temporary file:
    config_fd, config_path = tempfile.mkstemp()
    with os.fdopen(config_fd, "w") as config_stream:
        config_stream.write(config_text.encode("utf-8"))

    # Run the remote-viewwer command:
    args = ["remote-viewer", config_path]
    util.spawn(cmd, args, debug)
Example #3
0
def launch_remote_viewer(cmd,
                         host,
                         host_subject,
                         port,
                         secport,
                         ticket,
                         title,
                         ca_file,
                         debug=False):
    """Launch the SPICE client using the remote-viewer command."""

    # Load the CA certificate:
    with open(ca_file, "r") as ca_stream:
        ca_text = ca_stream.read()

    # Generate the configuration file:
    config_text = CONFIG_TEMPLATE.format(
        title=title,
        host=host,
        ticket=ticket,
        port=port,
        secport=secport,
        host_subject=host_subject,
        ca_text=ca_text.replace("\n", "\\n"),
    )
    config_fd, config_path = tempfile.mkstemp()
    with os.fdopen(config_fd, "w") as config_stream:
        config_stream.write(config_text)

    # Run the remote-viewwer command:
    args = ["remote-viewer", config_path]
    util.spawn(cmd, args, debug)
Example #4
0
def launch_spicec(cmd,
                  host,
                  host_subject,
                  port,
                  secport,
                  ticket,
                  title,
                  ca_file,
                  debug=False):
    """Launch the SPICE client using the spicec command."""

    args = ['spicec']
    if cmd.startswith('/usr/libexec'):
        args.extend([host])
        args.extend([str(port)])
        if secport:
            args.extend([str(secport)])
            args.extend(['--ssl-channels', 'smain,sinputs'])
            args.extend(['--ca-file', ca_file])
            if host_subject and host_subject != '':
                args.extend(['--host-subject', host_subject])
        args.extend(['-p', ticket])
    else:
        args.extend(['-h', host])
        args.extend(['-p', str(port)])
        if secport:
            args.extend(['-s', str(secport)])
            args.extend(['--ca-file', ca_file])
            if host_subject and host_subject != '':
                args.extend(['--host-subject', host_subject])
        args.extend(['-w', ticket])
        args.extend(['-t', title])
    util.spawn(cmd, args, debug=True)
Example #5
0
def launch_remote_viewer(cmd, host, port, ticket, title, debug=False):
    """Launch the VNC client using the remote-viewer command."""

    # Generate the configuration file:
    config_text = CONFIG_TEMPLATE.format(
        title=title,
        host=host,
        ticket=ticket,
        port=port,
    )
    config_fd, config_path = tempfile.mkstemp()
    with os.fdopen(config_fd, "w") as config_stream:
        config_stream.write(config_text.encode("utf-8"))

    # Run the remote-viewwer command:
    args = ["remote-viewer", config_path]
    util.spawn(cmd, args, debug)
Example #6
0
def launch_remote_viewer(cmd, host, port, ticket, title, debug=False):
    """Launch the VNC client using the remote-viewer command."""

    # Generate the configuration file:
    config_text = CONFIG_TEMPLATE.format(
        title=title,
        host=host,
        ticket=ticket,
        port=port,
    )
    config_fd, config_path = tempfile.mkstemp()
    with os.fdopen(config_fd, "w") as config_stream:
        config_stream.write(config_text)

    # Run the remote-viewwer command:
    args = ["remote-viewer", config_path]
    util.spawn(cmd, args, debug)
Example #7
0
def launch_vncviewer(cmd, host, port, ticket, debug=False):
    """Launch a VNC viewer on host::port with `password'."""

    cmd_passwd = util.which('vncpasswd')
    if cmd_passwd is None:
        raise Error, Messages.Error.NO_SUCH_COMMAND % 'vncpasswd'
    p = Popen([cmd_passwd, "-f"], shell=False, stdin=PIPE, stdout=PIPE)
    password = p.communicate(input=ticket)[0]
    args = [cmd, '%s::%s' % (host, port), '-passwordFile', '/dev/stdin' ]
    pid, pstdin = util.spawn(cmd, args, debug)
    os.write(pstdin, password)
    os.close(pstdin)
Example #8
0
def launch_vncviewer(cmd, host, port, ticket, debug=False):
    """Launch a VNC viewer on host::port with `password'."""

    cmd_passwd = util.which('vncpasswd')
    if cmd_passwd is None:
        raise Error, Messages.Error.NO_SUCH_COMMAND % 'vncpasswd'
    p = Popen([cmd_passwd, "-f"], shell=False, stdin=PIPE, stdout=PIPE)
    password = p.communicate(input=ticket)[0]
    args = [cmd, '%s::%s' % (host, port), '-passwordFile', '/dev/stdin']
    pid, pstdin = util.spawn(cmd, args, debug)
    os.write(pstdin, password)
    os.close(pstdin)