Exemplo n.º 1
0
def launch_spice_client(host, port, ticket, certurl, title, debug=False):
    """Launch the SPICE client."""
    display = os.environ.get('DISPLAY')
    if display is None:
        raise Error, 'not running in a GUI, cannot start a SPICE client'
    cmd = util.which('spicec')
    if cmd is None:
        cmd = util.which('/usr/libexec/spicec')
    if cmd is None:
        raise Error, 'spicec: command not found'
    certdir = os.path.join(util.get_home_dir(), '.spicec')
    try:
        os.stat(certdir)
    except OSError:
        os.mkdir(certdir)
    certfile = os.path.join(certdir, 'spice_truststore.pem')
    try:
        os.stat(certfile)
    except OSError:
        certtmp = '%s.%d-tmp' % (certfile, os.getpid())
        urllib.urlretrieve(certurl, certtmp)
        os.rename(certtmp, certfile)
    secport = 11800 - port   # Ticket #212
    if cmd.startswith('/usr/libexec'):
        args = [ 'spicec', host, str(port), str(secport), '--ssl-channels',
                 'smain,sinputs', '--ca-file', certfile, '-p', ticket ]
    else:
        args = [ 'spicec', '-h', host, '-p', str(port), '-s', str(secport),
                 '-w', ticket, '-t', title ]
    pid, pstdin = util.spawn(cmd, args, debug)
Exemplo n.º 2
0
def launch_vnc_viewer(host, port, ticket, debug=False):
    """Launch a VNC viewer on host::port with `password'."""
    display = os.environ.get('DISPLAY')
    if display is None:
        raise Error, 'not running in a GUI, cannot start a VNC viewer'
    cmd = util.which('vncviewer')
    if cmd is None:
        raise Error, 'vncviewer: command not found'
    args = ['vncviewer', '%s::%s' % (host, port), '-passwdInput' ]
    pid, pstdin = util.spawn(cmd, args, debug)
    os.write(pstdin, ticket)
    os.close(pstdin)