- Timestamp:
- Oct 28, 2007, 11:57:32 PM (17 years ago)
- Location:
- trunk/web/templates
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/web/templates/controls.py
r216 r228 88 88 remctl('web', 'unregister', machine.name) 89 89 90 def createVm( user, name, memory, disk, is_hvm, cdrom):90 def createVm(owner, contact, name, memory, disk, is_hvm, cdrom): 91 91 """Create a VM and put it in the database""" 92 92 # put stuff in the table 93 93 transaction = ctx.current.create_transaction() 94 94 try: 95 validation.validMemory( user, memory)96 validation.validDisk( user, disk * 1. / 1024)97 validation.validAddVm( user)95 validation.validMemory(owner, memory) 96 validation.validDisk(owner, disk * 1. / 1024) 97 validation.validAddVm(owner) 98 98 res = meta.engine.execute('select nextval(' 99 99 '\'"machines_machine_id_seq"\')') … … 103 103 machine.name = name 104 104 machine.memory = memory 105 machine.owner = user.username106 machine.administrator = user.username107 machine.contact = user.email105 machine.owner = owner 106 machine.administrator = owner 107 machine.contact = contact 108 108 machine.uuid = uuidToString(randomUUID()) 109 109 machine.boot_off_cd = True -
trunk/web/templates/list.tmpl
r227 r228 52 52 </tr> 53 53 $errorRow('cdrom', $err) 54 <tr> 55 <td>Owner</td> 56 <td><input type="text" name="owner" value="$defaults.owner"/></td> 57 </tr> 58 $errorRow('owner', $err) 54 59 </table> 55 60 <input type="submit" class="button" value="Create it!"/> … … 89 94 value="$machine.machine_id"/> 90 95 <input type="submit" class="button" name="action" value="#slurp 91 #if $machine.uptime then ' Shutdown' else 'Power on'96 #if $machine.uptime then 'Power off' else 'Power on' 92 97 "/> 93 98 </form> … … 101 106 <td>Name</td> 102 107 <td>Memory</td> 103 <td> owner</td>108 <td>Owner</td> 104 109 <td>IP</td> 105 110 <td>Uptime</td> -
trunk/web/templates/main.py
r227 r228 47 47 '&simple=true" target="_blank" ' + 48 48 'onclick="return helppopup(\'' + subj + '\')">(?)</a></span>') 49 50 class User:51 """User class (sort of useless, I admit)"""52 def __init__(self, username, email):53 self.username = username54 self.email = email55 49 56 50 def makeErrorPre(old, addition): … … 134 128 "Name already exists.") 135 129 130 owner = validation.testOwner(user, fields.getfirst('owner')) 131 136 132 memory = fields.getfirst('memory') 137 133 memory = validation.validMemory(user, memory, on=True) … … 148 144 if cdrom is not None and not CDROM.get(cdrom): 149 145 raise CodeError("Invalid cdrom type '%s'" % cdrom) 150 return dict( user=user, name=name, memory=memory, disk=disk,151 is_hvm=is_hvm, cdrom=cdrom)146 return dict(contact=user, name=name, memory=memory, disk=disk, 147 owner=owner, is_hvm=is_hvm, cdrom=cdrom) 152 148 153 149 def create(user, fields): … … 189 185 defaults = Defaults(max_memory=max_memory, 190 186 max_disk=max_disk, 187 owner=user, 191 188 cdrom='gutsy-i386') 192 189 d = dict(user=user, … … 231 228 232 229 data = {} 233 data["user"] = user .username230 data["user"] = user 234 231 data["machine"] = machine.name 235 232 data["expires"] = time.time()+(5*60) … … 545 542 if 'SSL_CLIENT_S_DN_Email' in os.environ: 546 543 username = os.environ['SSL_CLIENT_S_DN_Email'].split("@")[0] 547 return User(username, os.environ['SSL_CLIENT_S_DN_Email'])548 else: 549 return User('moo', 'nobody')544 return username 545 else: 546 return 'moo' 550 547 551 548 def main(operation, user, fields): -
trunk/web/templates/skeleton.tmpl
r207 r228 39 39 40 40 #if not $varExists('simple') or not $simple 41 <p>[You are logged in as $user. username.]</p>41 <p>[You are logged in as $user.]</p> 42 42 43 43 <div class="navigation"> -
trunk/web/templates/validation.py
r211 r228 25 25 owner = machine.owner 26 26 else: 27 owner = user .username27 owner = user 28 28 return Machine.select_by(owner=owner) 29 29 … … 69 69 def haveAccess(user, machine): 70 70 """Return whether a user has adminstrative access to a machine""" 71 if user .username== 'moo':72 return True 73 if user .usernamein (machine.administrator, machine.owner):74 return True 75 if getafsgroups.checkAfsGroup(user .username, machine.administrator,71 if user == 'moo': 72 return True 73 if user in (machine.administrator, machine.owner): 74 return True 75 if getafsgroups.checkAfsGroup(user, machine.administrator, 76 76 'athena.mit.edu'): #XXX Cell? 77 77 return True 78 if getafsgroups.checkLockerOwner(user .username, machine.owner):78 if getafsgroups.checkLockerOwner(user, machine.owner): 79 79 return True 80 80 return owns(user, machine) … … 82 82 def owns(user, machine): 83 83 """Return whether a user owns a machine""" 84 if user .username== 'moo':85 return True 86 return getafsgroups.checkLockerOwner(user .username, machine.owner)84 if user == 'moo': 85 return True 86 return getafsgroups.checkLockerOwner(user, machine.owner) 87 87 88 88 def validMachineName(name): … … 154 154 if admin in (None, machine.administrator): 155 155 return None 156 if admin == user .username:156 if admin == user: 157 157 return admin 158 if getafsgroups.checkAfsGroup(user .username, admin, 'athena.mit.edu'):158 if getafsgroups.checkAfsGroup(user, admin, 'athena.mit.edu'): 159 159 return admin 160 if getafsgroups.checkAfsGroup(user .username, 'system:'+admin,160 if getafsgroups.checkAfsGroup(user, 'system:'+admin, 161 161 'athena.mit.edu'): 162 162 return 'system:'+admin 163 163 return admin 164 164 165 def testOwner(user, owner, machine): 166 if owner in (None, machine.owner): 167 return None 168 value = getafsgroups.checkLockerOwner(user.username, owner, verbose=True) 165 def testOwner(user, owner, machine=None): 166 if owner == user or machine is not None and owner == machine.owner: 167 return owner 168 if owner is None: 169 raise InvalidInput('owner', owner, "Owner must be specified") 170 value = getafsgroups.checkLockerOwner(user, owner, verbose=True) 169 171 if not value: 170 172 return owner
Note: See TracChangeset
for help on using the changeset viewer.