Ignore:
Timestamp:
Dec 20, 2009, 11:27:10 PM (14 years ago)
Author:
broder
Message:

Merge cherrypy-rebased branch of invirt-web into trunk.

Location:
trunk/packages/invirt-web
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/invirt-web

  • trunk/packages/invirt-web/code/controls.py

    r2295 r2737  
    205205        raise
    206206
    207 def commandResult(username, state, fields):
     207def commandResult(username, state, command_name, machine_id, fields):
    208208    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') or None
    212212    if cdrom is not None and not CDROM.query().filter_by(cdrom_id=cdrom).one():
    213213        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(" "):
    216215        raise CodeError("Invalid action '%s'" % action)
    217     if action == 'Reboot':
     216    if action == 'reboot':
    218217        if cdrom is not None:
    219218            out, err = remctl('control', machine.name, 'reboot', cdrom,
     
    231230                raise CodeError('ERROR on remctl')
    232231               
    233     elif action == 'Power on':
     232    elif action == 'create':
    234233        if validation.maxMemory(username, state, machine) < machine.memory:
    235234            raise InvalidInput('action', 'Power on',
     
    237236                               "to turn on this machine.")
    238237        bootMachine(machine, cdrom)
    239     elif action == 'Power off':
     238    elif action == 'destroy':
    240239        out, err = remctl('control', machine.name, 'destroy', err=True)
    241240        if err:
     
    247246                print >> sys.stderr, err
    248247                raise CodeError('ERROR on remctl')
    249     elif action == 'Shutdown':
     248    elif action == 'shutdown':
    250249        out, err = remctl('control', machine.name, 'shutdown', err=True)
    251250        if err:
     
    257256                print >> sys.stderr, err
    258257                raise CodeError('ERROR on remctl')
    259     elif action == 'Delete VM':
     258    elif action == 'delete':
    260259        deleteVM(machine)
    261260
Note: See TracChangeset for help on using the changeset viewer.