- Timestamp:
- Dec 20, 2009, 9:45:14 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
package_branches/invirt-web/cherrypy-rebased/code/controls.py
r2295 r2684 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')).machine 210 action = fields.getfirst('action') 211 cdrom = fields.getfirst('cdrom') 209 machine = validation.Validate(username, state, machine_id=machine_id).machine 210 action = command_name 211 cdrom = fields.get('cdrom') 212 if not cdrom: 213 cdrom = None 212 214 if cdrom is not None and not CDROM.query().filter_by(cdrom_id=cdrom).one(): 213 215 raise CodeError("Invalid cdrom type '%s'" % cdrom) 214 if action not in ('Reboot', 'Power on', 'Power off', 'Shutdown', 215 'Delete VM'): 216 if action not in "reboot create destroy shutdown delete".split(" "): 216 217 raise CodeError("Invalid action '%s'" % action) 217 if action == ' Reboot':218 if action == 'reboot': 218 219 if cdrom is not None: 219 220 out, err = remctl('control', machine.name, 'reboot', cdrom, … … 231 232 raise CodeError('ERROR on remctl') 232 233 233 elif action == ' Power on':234 elif action == 'create': 234 235 if validation.maxMemory(username, state, machine) < machine.memory: 235 236 raise InvalidInput('action', 'Power on', … … 237 238 "to turn on this machine.") 238 239 bootMachine(machine, cdrom) 239 elif action == ' Power off':240 elif action == 'destroy': 240 241 out, err = remctl('control', machine.name, 'destroy', err=True) 241 242 if err: … … 247 248 print >> sys.stderr, err 248 249 raise CodeError('ERROR on remctl') 249 elif action == ' Shutdown':250 elif action == 'shutdown': 250 251 out, err = remctl('control', machine.name, 'shutdown', err=True) 251 252 if err: … … 257 258 print >> sys.stderr, err 258 259 raise CodeError('ERROR on remctl') 259 elif action == ' Delete VM':260 elif action == 'delete': 260 261 deleteVM(machine) 261 262
Note: See TracChangeset
for help on using the changeset viewer.