Changeset 535 for trunk/packages/sipb-xen-www/code/controls.py
- Timestamp:
- May 15, 2008, 9:55:17 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/sipb-xen-www/code/controls.py
r522 r535 12 12 import re 13 13 import cache_acls 14 import cPickle 14 15 15 16 # ... and stolen from xend/uuid.py … … 114 115 machine.type_id = machine_type.type_id 115 116 ctx.current.save(machine) 116 disk = Disk(machine_id=machine.machine_id, 117 disk = Disk(machine_id=machine.machine_id, 117 118 guest_device_name='hda', size=disk_size) 118 119 open_nics = NIC.select_by(machine_id=None) … … 123 124 nic.machine_id = machine.machine_id 124 125 nic.hostname = name 125 ctx.current.save(nic) 126 ctx.current.save(nic) 126 127 ctx.current.save(disk) 127 128 cache_acls.refreshMachine(machine) … … 137 138 return machine 138 139 139 def getUptimes(machines=None): 140 """Return a dictionary mapping machine names to uptime strings""" 141 value_string = remctl('web', 'listvms') 142 lines = value_string.splitlines() 143 d = {} 144 for line in lines: 145 lst = line.split() 146 name, id = lst[:2] 147 uptime = ' '.join(lst[2:]) 148 d[name] = uptime 149 ans = {} 150 for m in machines: 151 ans[m] = d.get(m.name) 152 return ans 140 def getList(machines): 141 """Return a dictionary mapping machine to dicts.""" 142 value_string = remctl('web', 'listvms', '--pickle') 143 value_dict = cPickle.loads(value_string) 144 145 d = dict((m, value_dict[m.name]) for m in machines if m.name in value_dict) 146 return d 153 147 154 148 def parseStatus(s):
Note: See TracChangeset
for help on using the changeset viewer.