class Validate:
def __init__(self, username, state, machine_id=None, name=None, description=None, owner=None,
admin=None, contact=None, memory=None, disksize=None,
- vmtype=None, cdrom=None, autoinstall=None, strict=False):
+ vmtype=None, nictype=None, cdrom=None, autoinstall=None, strict=False):
# XXX Successive quota checks aren't a good idea, since you
# can't necessarily change the locker and disk size at the
# same time.
self.disksize = validDisk(self.owner, state, disksize, machine)
if vmtype is not None:
self.vmtype = validVmType(vmtype)
+ if nictype is not None:
+ self.nictype = validNICType(nictype)
if cdrom is not None:
if not CDROM.query.get(cdrom):
raise CodeError("Invalid cdrom type '%s'" % cdrom)
raise CodeError("Invalid vm type '%s'" % vm_type)
return t
+def validNICType(nic_type):
+ if nic_type is None:
+ return None
+ t = nic_type
+ if not (t is "e1000" or t is "pcnet"):
+ raise CodeError("Invalid nic type '%s'" % nic_type)
+ return t
+
def testMachineId(user, state, machine_id, exists=True):
"""Parse, validate and check authorization for a given user and machine.