From d37941f98e7a15e191c77c6d45bf41cff53bf811 Mon Sep 17 00:00:00 2001 From: Eric Price Date: Mon, 2 Jun 2008 01:48:27 -0400 Subject: [PATCH] Avoid a second remctl to determine whether ice3 is up svn path=/trunk/packages/sipb-xen-www/; revision=554 --- code/controls.py | 8 +++----- code/main.py | 2 +- code/webcommon.py | 5 ++++- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/code/controls.py b/code/controls.py index 79aa311..e389823 100644 --- a/code/controls.py +++ b/code/controls.py @@ -137,13 +137,11 @@ def createVm(owner, contact, name, memory, disk_size, machine_type, cdrom, clone bootMachine(machine, cdrom) return machine -def getList(machines): - """Return a dictionary mapping machine to dicts.""" +def getList(): + """Return a dictionary mapping machine names to dicts.""" value_string = remctl('web', 'listvms') value_dict = yaml.safe_load(value_string) - - d = dict((m, value_dict[m.name]) for m in machines if m.name in value_dict) - return d + return value_dict def parseStatus(s): """Parse a status string into nested tuples of strings. diff --git a/code/main.py b/code/main.py index 60c2818..c7dff0e 100755 --- a/code/main.py +++ b/code/main.py @@ -203,7 +203,7 @@ def getListDict(user): has_vnc = {} xmlist = g.xmlist checkpoint.checkpoint('Got uptimes') - can_clone = (controls.getList([Machine.get_by(name='ice3')])) == {} + can_clone = 'ice3' in g.xmlist_raw for m in machines: if m not in xmlist: has_vnc[m] = 'Off' diff --git a/code/webcommon.py b/code/webcommon.py index ee9bb73..58d9333 100644 --- a/code/webcommon.py +++ b/code/webcommon.py @@ -43,8 +43,11 @@ class Global(object): machines = cachedproperty(lambda self: Machine.query().join('acl').select_by(user=self.user)) + xmlist_raw = cachedproperty(lambda self: controls.getList()) xmlist = cachedproperty(lambda self: - controls.getList(self.machines)) + dict((m, self.xmlist_raw[m.name]) + for m in self.machines + if m.name in self.xmlist_raw)) def clear(self): """Clear the state so future accesses reload it.""" -- 1.7.9.5