+class Validate:
+ def __init__(self, username, state, machine_id=None, name=None, owner=None,
+ admin=None, contact=None, memory=None, disksize=None,
+ vmtype=None, cdrom=None, clone_from=None):
+ # XXX Successive quota checks aren't a good idea, since you
+ # can't necessarily change the locker and disk size at the
+ # same time.
+ created_new = (machine_id is None)
+
+ if machine_id is not None:
+ self.machine = testMachineId(username, machine_id)
+ machine = getattr(self, 'machine', None)
+
+ owner = testOwner(username, owner, machine)
+ if owner is not None:
+ self.owner = owner
+ admin = testAdmin(username, admin, machine)
+ if admin is not None:
+ self.admin = admin
+ contact = testContact(username, contact, machine)
+ if contact is not None:
+ self.contact = contact
+ name = testName(username, name, machine)
+ if name is not None:
+ self.name = name
+ if memory is not None:
+ self.memory = validMemory(self.owner, state, memory, machine,
+ on=not created_new)
+ if disksize is not None:
+ self.disksize = validDisk(self.owner, disksize, machine)
+ if vmtype is not None:
+ self.vmtype = validVmType(vmtype)
+ if cdrom is not None:
+ if not CDROM.get(cdrom):
+ raise CodeError("Invalid cdrom type '%s'" % cdrom)
+ self.cdrom = cdrom
+ if clone_from is not None:
+ if clone_from not in ('ice3', ):
+ raise CodeError("Invalid clone image '%s'" % clone_from)
+ self.clone_from = clone_from
+
+
+def getMachinesByOwner(owner, machine=None):