Exemple #1
0
def launch_spice_client(host,
                        host_subject,
                        port,
                        secport,
                        ticket,
                        url,
                        title,
                        proxy,
                        debug=False):
    """Launch the SPICE client."""

    # Check that there is a X display available:
    display = os.environ.get('DISPLAY')
    if display is None:
        raise Error, Messages.Error.CANNOT_START_CONSOLE_CLIENT % 'SPICE'

    # Download and save the CA certificate tot he directory and file where the
    # clients expect it:
    ca_dir = os.path.join(util.get_home_dir(), '.spicec')
    try:
        os.stat(ca_dir)
    except OSError:
        os.mkdir(ca_dir)
    ca_file = os.path.join(ca_dir, 'spice_truststore.pem')
    try:
        os.stat(ca_file)
    except OSError:
        ca_text = download_ca_certificate(url)
        with open(ca_file, "w") as ca_stream:
            ca_stream.write(ca_text)

    # Try to use remote viewer:
    cmd = util.which("remote-viewer")
    if cmd is not None:
        launch_remote_viewer(cmd, host, host_subject, port, secport, ticket,
                             title, ca_file, proxy, debug)
        return

    # Try to use spicec (this is older, so we try only if remote-viewer isn't
    # available):
    cmd = util.which('spicec')
    if cmd is None:
        cmd = util.which('/usr/libexec/spicec')
    if cmd is not None:
        launch_spicec(cmd, host, host_subject, port, secport, ticket, title,
                      ca_file, debug)
        return

    # No luck, no known command is available:
    raise Error, Messages.Error.NO_SPICE_VIEWER_FOUND
Exemple #2
0
def launch_spice_client(host, host_subject, port, secport, ticket, url,
                        title, proxy, debug=False):
    """Launch the SPICE client."""

    # Check that there is a X display available:
    display = os.environ.get('DISPLAY')
    if display is None:
        raise Error, Messages.Error.CANNOT_START_CONSOLE_CLIENT % 'SPICE'

    # Download and save the CA certificate tot he directory and file where the
    # clients expect it:
    ca_dir = os.path.join(util.get_home_dir(), '.spicec')
    try:
        os.stat(ca_dir)
    except OSError:
        os.mkdir(ca_dir)
    ca_file = os.path.join(ca_dir, 'spice_truststore.pem')
    try:
        os.stat(ca_file)
    except OSError:
        ca_text = download_ca_certificate(url)
        with open(ca_file, "w") as ca_stream:
            ca_stream.write(ca_text)

    # Try to use remote viewer:
    cmd = util.which("remote-viewer")
    if cmd is not None:
        launch_remote_viewer(cmd, host, host_subject, port, secport, ticket,
                             title, ca_file, proxy, debug)
        return

    # Try to use spicec (this is older, so we try only if remote-viewer isn't
    # available):
    cmd = util.which('spicec')
    if cmd is None:
        cmd = util.which('/usr/libexec/spicec')
    if cmd is not None:
        launch_spicec(cmd, host, host_subject, port, secport, ticket,
                      title, ca_file, debug)
        return

    # No luck, no known command is available:
    raise Error, Messages.Error.NO_SPICE_VIEWER_FOUND
Exemple #3
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)
Exemple #4
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)
Exemple #5
0
def launch_vnc_client(host, port, ticket, title, debug=False):
    """Launch the VNC client."""

    # Check that there is a X display available:
    display = os.environ.get('DISPLAY')
    if display is None:
        raise Error, Messages.Error.CANNOT_START_CONSOLE_CLIENT % 'VNC'

    # Try to use remote viewer:
    cmd = util.which("remote-viewer")
    if cmd is not None:
        launch_remote_viewer(cmd, host, port, ticket, title, debug)
        return

    # Try to use vncviewer:
    cmd = util.which("vncviewer")
    if cmd is not None:
        launch_vncviewer(cmd, host, port, ticket, debug)
        return

    # No luck, no known command is available:
    raise Error, Messages.Error.NO_VNC_VIEWER_FOUND
Exemple #6
0
def launch_vnc_client(host, port, ticket, title, debug=False):
    """Launch the VNC client."""

    # Check that there is a X display available:
    display = os.environ.get('DISPLAY')
    if display is None:
        raise Error, Messages.Error.CANNOT_START_CONSOLE_CLIENT % 'VNC'

    # Try to use remote viewer:
    cmd = util.which("remote-viewer")
    if cmd is not None:
        launch_remote_viewer(cmd, host, port, ticket, title, debug)
        return

    # Try to use vncviewer:
    cmd = util.which("vncviewer")
    if cmd is not None:
        launch_vncviewer(cmd, host, port, ticket, debug)
        return

    # No luck, no known command is available:
    raise Error, Messages.Error.NO_CONSOLE_FOUND % ('vnc', 'vnc')