From: Quentin Smith Date: Mon, 12 Nov 2007 10:05:26 +0000 (-0500) Subject: Remove unnecessary constructors X-Git-Tag: sipb-xen-www/1~33 X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/invirt-web.git/commitdiff_plain/ce218046309253419efd5665ab2fa507e87a1d01 Remove unnecessary constructors Rename disk to disk_size in some (but not all!) places Added MachineAccess to __all__ svn path=/trunk/web/; revision=243 --- diff --git a/controls.py b/controls.py index 3671f21..4099d3b 100644 --- a/controls.py +++ b/controls.py @@ -87,13 +87,13 @@ def unregisterMachine(machine): """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"\')') @@ -110,8 +110,8 @@ def createVm(owner, contact, name, memory, disk, is_hvm, cdrom): 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! " diff --git a/main.py b/main.py index e7412ba..29b410e 100755 --- a/main.py +++ b/main.py @@ -149,8 +149,8 @@ def parseCreate(user, fields): 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'): @@ -160,7 +160,7 @@ def parseCreate(user, fields): 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): diff --git a/xen-ips b/xen-ips index a56b402..3a69a77 100755 --- a/xen-ips +++ b/xen-ips @@ -37,7 +37,7 @@ def usage(): print >> sys.stderr, "USAGE: " + sys.argv[0] + " " 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()