for disk in machine.disks:
lvcreate(machine, disk)
+def lvcopy(machine_orig_name, machine, rootpw):
+ """Copy a golden image onto a machine's disk"""
+ remctl('web', 'lvcopy', machine_orig_name, machine.name, rootpw)
+
def bootMachine(machine, cdtype):
"""Boot a machine with a given boot CD.
"""Unregister a machine to not be controlled by the web interface"""
remctl('web', 'unregister', machine.name)
-def createVm(owner, contact, name, memory, disk_size, is_hvm, cdrom):
+def createVm(owner, contact, name, memory, disk_size, is_hvm, cdrom, clone_from):
"""Create a VM and put it in the database"""
# put stuff in the table
transaction = ctx.current.create_transaction()
raise
registerMachine(machine)
makeDisks(machine)
+ if clone_from:
+ lvcopy(clone_from, machine, 'password')
# tell it to boot with cdrom
bootMachine(machine, cdrom)
return machine
cdrom = fields.getfirst('cdrom')
if cdrom is not None and not CDROM.get(cdrom):
raise CodeError("Invalid cdrom type '%s'" % cdrom)
+
+ clone_from = fields.getfirst('clone_from')
+ if clone_from and clone_from != 'ice3':
+ raise CodeError("Invalid clone image '%s'" % clone_from)
+
return dict(contact=user, name=name, memory=memory, disk_size=disk_size,
- owner=owner, is_hvm=is_hvm, cdrom=cdrom)
+ owner=owner, is_hvm=is_hvm, cdrom=cdrom, clone_from=clone_from)
def create(user, fields):
"""Handler for create requests."""
</tr>
$errorRow('cdrom', $err)
<tr>
+ <td>Clone image?</td>
+ <td><input type="checkbox" name="clone_from" value="ice3"/>
+ (experimental; 1-2 minutes, and you have an etch machine; root pw is 'password'.)</td>
+ </tr>
+$errorRow('cdrom', $err)
+ <tr>
<td>Owner</td>
<td><input type="text" name="owner" value="$defaults.owner"/></td>
</tr>