X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/invirt-web.git/blobdiff_plain/92dd742e75e10d804cf1f0010c3b18e39902cdb5..fe18346ed6628e4e900ef9ab1105cdabbb94abd3:/controls.py diff --git a/controls.py b/controls.py index 2e9b541..b6f6dec 100644 --- a/controls.py +++ b/controls.py @@ -74,10 +74,20 @@ def bootMachine(machine, cdtype): id of the CD (e.g. 'gutsy_i386') """ if cdtype is not None: - remctl('control', machine.name, 'create', - cdtype) + out, err = remctl('control', machine.name, 'create', + cdtype, err=True) else: - remctl('control', machine.name, 'create') + out, err = remctl('control', machine.name, 'create', + err=True) + if 'already exists' in out: + raise InvalidInput('action', 'create', + 'VM %s is already on' % machine.name) + elif err: + raise CodeError('"%s" on "control %s create %s' + % (err, machine.name, cdtype)) + else: + raise CodeError('"%s" on "control %s create %s' + % (err, machine.name, cdtype)) def registerMachine(machine): """Register a machine to be controlled by the web interface""" @@ -214,11 +224,9 @@ def deleteVM(machine): def commandResult(user, fields): start_time = 0 - print >> sys.stderr, time.time()-start_time machine = validation.testMachineId(user, fields.getfirst('machine_id')) action = fields.getfirst('action') cdrom = fields.getfirst('cdrom') - print >> sys.stderr, time.time()-start_time if cdrom is not None and not CDROM.get(cdrom): raise CodeError("Invalid cdrom type '%s'" % cdrom) if action not in ('Reboot', 'Power on', 'Power off', 'Shutdown', @@ -268,7 +276,6 @@ def commandResult(user, fields): raise CodeError('ERROR on remctl') elif action == 'Delete VM': deleteVM(machine) - print >> sys.stderr, time.time()-start_time d = dict(user=user, command=action,