Changeset 440 for trunk/packages/sipb-xen-www/code/validation.py
- Timestamp:
- Apr 21, 2008, 9:13:53 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/sipb-xen-www/code/validation.py
r437 r440 19 19 def getMachinesByOwner(user, machine=None): 20 20 """Return the machines owned by the same as a machine. 21 21 22 22 If the machine is None, return the machines owned by the same 23 23 user. … … 32 32 """Return the maximum memory for a machine or a user. 33 33 34 If machine is None, return the memory available for a new 34 If machine is None, return the memory available for a new 35 35 machine. Else, return the maximum that machine can have. 36 36 … … 50 50 51 51 def maxDisk(user, machine=None): 52 """Return the maximum disk that a machine can reach. 53 54 If machine is None, the maximum disk for a new machine. Otherwise, 55 return the maximum that a given machine can be changed to. 56 """ 52 57 machines = getMachinesByOwner(user, machine) 53 58 disk_usage = sum([sum([y.size for y in x.disks]) … … 102 107 raise ValueError 103 108 except ValueError: 104 raise InvalidInput('memory', memory, 109 raise InvalidInput('memory', memory, 105 110 "Minimum %s MiB" % MIN_MEMORY_SINGLE) 106 111 if memory > maxMemory(user, machine, on): … … 126 131 127 132 def validVmType(vm_type): 128 if vm_type == 'hvm': 129 return Type.get('linux-hvm') 130 elif vm_type == 'paravm': 131 return Type.get('linux') 132 else: 133 if vm_type is None: 134 return None 135 t = Type.get(vm_type) 136 if t is None: 133 137 raise CodeError("Invalid vm type '%s'" % vm_type) 138 return t 134 139 135 140 def testMachineId(user, machine_id, exists=True): … … 139 144 """ 140 145 if machine_id is None: 141 raise InvalidInput('machine_id', machine_id, 146 raise InvalidInput('machine_id', machine_id, 142 147 "Must specify a machine ID.") 143 148 try: … … 177 182 #XXX Should we require that user is in the admin group? 178 183 return admin 179 184 180 185 def testOwner(user, owner, machine=None): 181 186 """Determine whether a user can set the owner of a machine to this value.
Note: See TracChangeset
for help on using the changeset viewer.