Changeset 632 for trunk/packages/sipb-xen-www/code/validation.py
- Timestamp:
- Jun 21, 2008, 10:39:27 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/sipb-xen-www/code/validation.py
r629 r632 37 37 38 38 if machine_id is not None: 39 self.machine = testMachineId(username, machine_id)39 self.machine = testMachineId(username, state, machine_id) 40 40 machine = getattr(self, 'machine', None) 41 41 … … 59 59 on=not created_new) 60 60 if disksize is not None: 61 self.disksize = validDisk(self.owner, disksize, machine)61 self.disksize = validDisk(self.owner, state, disksize, machine) 62 62 if vmtype is not None: 63 63 self.vmtype = validVmType(vmtype) … … 124 124 return False 125 125 126 def haveAccess(user, machine):126 def haveAccess(user, state, machine): 127 127 """Return whether a user has administrative access to a machine""" 128 return user in cache_acls.accessList(machine)128 return state.overlord or user in cache_acls.accessList(machine) 129 129 130 130 def owns(user, machine): … … 158 158 "Minimum %s MiB" % MIN_MEMORY_SINGLE) 159 159 max_val = maxMemory(owner, g, machine, on) 160 if memory > max_val:160 if not g.overlord and memory > max_val: 161 161 raise InvalidInput('memory', memory, 162 162 'Maximum %s MiB for %s' % (max_val, owner)) 163 163 return memory 164 164 165 def validDisk(owner, disk, machine=None):165 def validDisk(owner, g, disk, machine=None): 166 166 """Parse and validate limits for disk for a given owner and machine.""" 167 167 try: 168 168 disk = float(disk) 169 if disk > maxDisk(owner, machine):169 if not g.overlord and disk > maxDisk(owner, machine): 170 170 raise InvalidInput('disk', disk, 171 171 "Maximum %s G" % maxDisk(owner, machine)) … … 186 186 return t 187 187 188 def testMachineId(user, machine_id, exists=True):188 def testMachineId(user, state, machine_id, exists=True): 189 189 """Parse, validate and check authorization for a given user and machine. 190 190 … … 201 201 if exists and machine is None: 202 202 raise InvalidInput('machine_id', machine_id, "Does not exist.") 203 if machine is not None and not haveAccess(user, machine):203 if machine is not None and not haveAccess(user, state, machine): 204 204 raise InvalidInput('machine_id', machine_id, 205 205 "You do not have access to this machine.")
Note: See TracChangeset
for help on using the changeset viewer.