remctl('control', machine.name, 'install',
'dist=%s' % autoinstall.distribution,
'mirror=%s' % autoinstall.mirror,
remctl('control', machine.name, 'install',
'dist=%s' % autoinstall.distribution,
'mirror=%s' % autoinstall.mirror,
'imagesize=%s' % imagesize)
def lvcopy(machine_orig_name, machine, rootpw):
'imagesize=%s' % imagesize)
def lvcopy(machine_orig_name, machine, rootpw):
machine.contact = contact
machine.uuid = uuidToString(randomUUID())
machine.boot_off_cd = True
machine.contact = contact
machine.uuid = uuidToString(randomUUID())
machine.boot_off_cd = True
session.save_or_update(machine)
disk = Disk(machine=machine,
guest_device_name='hda', size=disksize)
session.save_or_update(machine)
disk = Disk(machine=machine,
guest_device_name='hda', size=disksize)
if not nic: #No IPs left!
raise CodeError("No IP addresses left! "
"Contact %s." % config.web.errormail)
if not nic: #No IPs left!
raise CodeError("No IP addresses left! "
"Contact %s." % config.web.errormail)
session.save_or_update(nic)
session.save_or_update(disk)
cache_acls.refreshMachine(machine)
session.save_or_update(nic)
session.save_or_update(disk)
cache_acls.refreshMachine(machine)
- makeDisks(machine)
- if autoinstall:
- lvinstall(machine, autoinstall)
- else:
- # tell it to boot with cdrom
- bootMachine(machine, cdrom)
+ try:
+ if autoinstall:
+ lvinstall(machine, autoinstall)
+ else:
+ # tell it to boot with cdrom
+ bootMachine(machine, cdrom)
+ except CodeError, e:
+ deleteVM(machine)
+ raise
-def commandResult(username, state, fields):
+def commandResult(username, state, command_name, machine_id, fields):
- machine = validation.Validate(username, state, machine_id=fields.getfirst('machine_id')).machine
- action = fields.getfirst('action')
- cdrom = fields.getfirst('cdrom')
+ machine = validation.Validate(username, state, machine_id=machine_id).machine
+ action = command_name
+ cdrom = fields.get('cdrom') or None
if cdrom is not None and not CDROM.query().filter_by(cdrom_id=cdrom).one():
raise CodeError("Invalid cdrom type '%s'" % cdrom)
if cdrom is not None and not CDROM.query().filter_by(cdrom_id=cdrom).one():
raise CodeError("Invalid cdrom type '%s'" % cdrom)
if cdrom is not None:
out, err = remctl('control', machine.name, 'reboot', cdrom,
err=True)
if cdrom is not None:
out, err = remctl('control', machine.name, 'reboot', cdrom,
err=True)
if validation.maxMemory(username, state, machine) < machine.memory:
raise InvalidInput('action', 'Power on',
"You don't have enough free RAM quota "
"to turn on this machine.")
bootMachine(machine, cdrom)
if validation.maxMemory(username, state, machine) < machine.memory:
raise InvalidInput('action', 'Power on',
"You don't have enough free RAM quota "
"to turn on this machine.")
bootMachine(machine, cdrom)
out, err = remctl('control', machine.name, 'destroy', err=True)
if err:
if re.match("machine '.*' is not on", err):
out, err = remctl('control', machine.name, 'destroy', err=True)
if err:
if re.match("machine '.*' is not on", err):
print >> sys.stderr, 'Error on power off:'
print >> sys.stderr, err
raise CodeError('ERROR on remctl')
print >> sys.stderr, 'Error on power off:'
print >> sys.stderr, err
raise CodeError('ERROR on remctl')
out, err = remctl('control', machine.name, 'shutdown', err=True)
if err:
if re.match("machine '.*' is not on", err):
out, err = remctl('control', machine.name, 'shutdown', err=True)
if err:
if re.match("machine '.*' is not on", err):
print >> sys.stderr, 'Error on Shutdown:'
print >> sys.stderr, err
raise CodeError('ERROR on remctl')
print >> sys.stderr, 'Error on Shutdown:'
print >> sys.stderr, err
raise CodeError('ERROR on remctl')