"""Unregister a machine to not be controlled by the web interface"""
remctl('web', 'unregister', machine.name)
-def createVm(owner, contact, name, memory, disk, is_hvm, cdrom):
+def createVm(owner, contact, name, memory, disk_size, is_hvm, cdrom):
"""Create a VM and put it in the database"""
# put stuff in the table
transaction = ctx.current.create_transaction()
try:
validation.validMemory(owner, memory)
- validation.validDisk(owner, disk * 1. / 1024)
+ validation.validDisk(owner, disk_size * 1. / 1024)
validation.validAddVm(owner)
res = meta.engine.execute('select nextval('
'\'"machines_machine_id_seq"\')')
machine_type = Type.get_by(hvm=is_hvm)
machine.type_id = machine_type.type_id
ctx.current.save(machine)
- disk = Disk(machine.machine_id,
- 'hda', disk)
+ disk = Disk(machine_id=machine.machine_id,
+ guest_device_name='hda', size=disk_size)
open_nics = NIC.select_by(machine_id=None)
if not open_nics: #No IPs left!
raise CodeError("No IP addresses left! "
memory = fields.getfirst('memory')
memory = validation.validMemory(user, memory, on=True)
- disk = fields.getfirst('disk')
- disk = validation.validDisk(user, disk)
+ disk_size = fields.getfirst('disk')
+ disk_size = validation.validDisk(user, disk_size)
vm_type = fields.getfirst('vmtype')
if vm_type not in ('hvm', 'paravm'):
cdrom = fields.getfirst('cdrom')
if cdrom is not None and not CDROM.get(cdrom):
raise CodeError("Invalid cdrom type '%s'" % cdrom)
- return dict(contact=user, name=name, memory=memory, disk=disk,
+ return dict(contact=user, name=name, memory=memory, disk_size=disk_size,
owner=owner, is_hvm=is_hvm, cdrom=cdrom)
def create(user, fields):
print >> sys.stderr, "USAGE: " + sys.argv[0] + " <ip>"
def addip(ip):
- n = NIC(None, randomMAC(), ip, None)
+ n = NIC(machine_id=None, mac_addr=randomMAC(), ip=ip, hostname=None)
ctx.current.save(n)
ctx.current.flush()