Changeset 2737 for trunk/packages/invirt-web/code/controls.py
- Timestamp:
- Dec 20, 2009, 11:27:10 PM (14 years ago)
- Location:
- trunk/packages/invirt-web
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/invirt-web
-
Property
svn:mergeinfo
set to
False
/package_branches/invirt-web/cherrypy-rebased merged eligible
-
Property
svn:mergeinfo
set to
False
-
trunk/packages/invirt-web/code/controls.py
r2295 r2737 205 205 raise 206 206 207 def commandResult(username, state, fields):207 def commandResult(username, state, command_name, machine_id, fields): 208 208 start_time = 0 209 machine = validation.Validate(username, state, machine_id= fields.getfirst('machine_id')).machine210 action = fields.getfirst('action')211 cdrom = fields.get first('cdrom')209 machine = validation.Validate(username, state, machine_id=machine_id).machine 210 action = command_name 211 cdrom = fields.get('cdrom') or None 212 212 if cdrom is not None and not CDROM.query().filter_by(cdrom_id=cdrom).one(): 213 213 raise CodeError("Invalid cdrom type '%s'" % cdrom) 214 if action not in ('Reboot', 'Power on', 'Power off', 'Shutdown', 215 'Delete VM'): 214 if action not in "reboot create destroy shutdown delete".split(" "): 216 215 raise CodeError("Invalid action '%s'" % action) 217 if action == ' Reboot':216 if action == 'reboot': 218 217 if cdrom is not None: 219 218 out, err = remctl('control', machine.name, 'reboot', cdrom, … … 231 230 raise CodeError('ERROR on remctl') 232 231 233 elif action == ' Power on':232 elif action == 'create': 234 233 if validation.maxMemory(username, state, machine) < machine.memory: 235 234 raise InvalidInput('action', 'Power on', … … 237 236 "to turn on this machine.") 238 237 bootMachine(machine, cdrom) 239 elif action == ' Power off':238 elif action == 'destroy': 240 239 out, err = remctl('control', machine.name, 'destroy', err=True) 241 240 if err: … … 247 246 print >> sys.stderr, err 248 247 raise CodeError('ERROR on remctl') 249 elif action == ' Shutdown':248 elif action == 'shutdown': 250 249 out, err = remctl('control', machine.name, 'shutdown', err=True) 251 250 if err: … … 257 256 print >> sys.stderr, err 258 257 raise CodeError('ERROR on remctl') 259 elif action == ' Delete VM':258 elif action == 'delete': 260 259 deleteVM(machine) 261 260
Note: See TracChangeset
for help on using the changeset viewer.