Changeset 572 for trunk/packages/sipb-xen-www/code/controls.py
- Timestamp:
- Jun 2, 2008, 11:25:47 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/sipb-xen-www/code/controls.py
r563 r572 93 93 % (err, machine.name, cdtype)) 94 94 95 def createVm( owner, contact, name, memory, disk_size, machine_type, cdrom, clone_from):95 def createVm(username, state, owner, contact, name, memory, disksize, machine_type, cdrom, clone_from): 96 96 """Create a VM and put it in the database""" 97 97 # put stuff in the table 98 98 transaction = ctx.current.create_transaction() 99 99 try: 100 validation.validMemory(owner, memory) 101 validation.validDisk(owner, disk_size * 1. / 1024) 102 validation.validAddVm(owner) 100 validation.Validate(username, state, owner=owner, memory=memory, disksize=disksize/1024.) 103 101 res = meta.engine.execute('select nextval(' 104 102 '\'"machines_machine_id_seq"\')') … … 116 114 ctx.current.save(machine) 117 115 disk = Disk(machine_id=machine.machine_id, 118 guest_device_name='hda', size=disk _size)116 guest_device_name='hda', size=disksize) 119 117 open_nics = NIC.select_by(machine_id=None) 120 118 if not open_nics: #No IPs left! … … 141 139 """Return a dictionary mapping machine names to dicts.""" 142 140 value_string = remctl('web', 'listvms') 143 value_dict = yaml.load(value_string, yaml. CSafeLoader)141 value_dict = yaml.load(value_string, yaml.SafeLoader) 144 142 return value_dict 145 143 … … 209 207 remctl('web', 'lvremove', mname, dname) 210 208 211 def commandResult(user , fields):209 def commandResult(username, state, fields): 212 210 start_time = 0 213 machine = validation. testMachineId(user, fields.getfirst('machine_id'))211 machine = validation.Validate(username, state, machine_id=fields.getfirst('machine_id')).machine 214 212 action = fields.getfirst('action') 215 213 cdrom = fields.getfirst('cdrom') … … 236 234 237 235 elif action == 'Power on': 238 if validation.maxMemory(user , machine) < machine.memory:236 if validation.maxMemory(username, state, machine) < machine.memory: 239 237 raise InvalidInput('action', 'Power on', 240 238 "You don't have enough free RAM quota " … … 264 262 deleteVM(machine) 265 263 266 d = dict(user=user ,264 d = dict(user=username, 267 265 command=action, 268 266 machine=machine)
Note: See TracChangeset
for help on using the changeset viewer.