From 4aa59cefff165e527b2a32642fea1be3c983705c Mon Sep 17 00:00:00 2001 From: Evan Broder Date: Tue, 11 Nov 2008 04:32:18 -0500 Subject: [PATCH] Pull the vnctoken remctl into the controls module svn path=/trunk/packages/invirt-web/; revision=1615 --- code/controls.py | 7 +++++++ code/main.py | 3 +-- 2 files changed, 8 insertions(+), 2 deletions(-) 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) -- 1.7.9.5