From: Eric Price Date: Mon, 2 Jun 2008 05:48:27 +0000 (-0400) Subject: Avoid a second remctl to determine whether ice3 is up X-Git-Tag: sipb-xen-www/3.4~1 X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/invirt-web.git/commitdiff_plain/d37941f98e7a15e191c77c6d45bf41cff53bf811?hp=966553f52ce277810245551803109ba11014d72e Avoid a second remctl to determine whether ice3 is up svn path=/trunk/packages/sipb-xen-www/; revision=554 --- 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."""