From: Evan Broder Date: Tue, 11 Nov 2008 09:32:18 +0000 (-0500) Subject: Pull the vnctoken remctl into the controls module X-Git-Tag: 0.0.9~13 X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/invirt-web.git/commitdiff_plain/4aa59cefff165e527b2a32642fea1be3c983705c?ds=sidebyside;hp=1acdba7805c9af8696244e6a5c44c931afa0cc07 Pull the vnctoken remctl into the controls module svn path=/trunk/packages/invirt-web/; revision=1615 --- diff --git a/code/controls.py b/code/controls.py index d895364..5512f66 100644 --- a/code/controls.py +++ b/code/controls.py @@ -171,6 +171,13 @@ def listHost(machine): return None return out.strip() +def vnctoken(machine): + """Return a time-stamped VNC token""" + out, err = remctl('control', machine.name, 'vnctoken') + if err: + return None + return out.strip() + def deleteVM(machine): """Delete a VM.""" remctl('control', machine.name, 'destroy', err=True) diff --git a/code/main.py b/code/main.py index 42fe3c7..5037a09 100755 --- a/code/main.py +++ b/code/main.py @@ -43,7 +43,6 @@ from invirt import database from invirt.database import Machine, CDROM, session, connect, MachineAccess, Type, Autoinstall from invirt.config import structs as config from invirt.common import InvalidInput, CodeError -from invirt.remctl import remctl def pathSplit(path): if path.startswith('/'): @@ -247,7 +246,7 @@ def vnc(username, state, path, fields): """ machine = validation.Validate(username, state, machine_id=fields.getfirst('machine_id')).machine - token = controls.remctl('control', machine.name, 'vnctoken').strip() + token = control.vnctoken(machine) host = controls.listHost(machine) if host: port = 10003 + [h.hostname for h in config.hosts].index(host)