Beispiel #1
0
def vm_console(vmid):
    user = User(session['userinfo']['preferred_username'])
    connect_proxmox()
    if user.rtp or int(vmid) in user.allowed_vms:
        vm = VM(vmid)
        stop_ssh_tunnel(vm.id, ssh_tunnels)
        port = str(5900 + int(vmid))
        token = add_vnc_target(port)
        node = '{}.csh.rit.edu'.format(vm.node)
        logging.info('creating SSH tunnel to %s for VM %s', node, vm.id)
        tunnel = start_ssh_tunnel(node, port)
        ssh_tunnels.append(tunnel)
        vm.start_vnc(port)
        return token, 200
    else:
        return '', 403
Beispiel #2
0
def vm_console_stop(vmid):
    if request.form['token'] == app.config['VNC_CLEANUP_TOKEN']:
        stop_ssh_tunnel(vmid, ssh_tunnels)
        return '', 200
    else:
        return '', 403