From dbd56d540e7ec9cbb22025f37c0a69278674d3bb Mon Sep 17 00:00:00 2001 From: Greg Price Date: Mon, 4 Aug 2008 23:20:25 -0400 Subject: [PATCH] rename overlord -> admin mode svn path=/trunk/packages/sipb-xen-www/; revision=867 --- code/main.py | 11 ++++++----- code/validation.py | 6 +++--- code/webcommon.py | 6 +++--- files/etc/apache2/sites-available/default | 2 +- files/etc/apache2/sites-available/ssl | 2 +- 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/code/main.py b/code/main.py index bb863c1..42a456e 100755 --- a/code/main.py +++ b/code/main.py @@ -595,14 +595,15 @@ def unauthFront(_, _2, _3, fields): """Information for unauth'd users.""" return templates.unauth(searchList=[{'simple' : True}]) -def overlord(username, state, path, fields): +def admin(username, state, path, fields): if path == '': return ({'Status': '303 See Other', - 'Location': 'overlord/'}, + 'Location': 'admin/'}, "You shouldn't see this message.") if not username in getAfsGroupMembers('system:xvm', 'athena.mit.edu'): - raise InvalidInput('username', username, 'Not an overlord.') - newstate = State(username, overlord=True) + raise InvalidInput('username', username, + 'Not in admin group %s.' % 'system:xvm') + newstate = State(username, isadmin=True) newstate.environ = state.environ return handler(username, newstate, path, fields) @@ -618,7 +619,7 @@ mapping = dict(list=listVms, create=create, help=helpHandler, unauth=unauthFront, - overlord=overlord, + admin=admin, errortest=throwError) def printHeaders(headers): diff --git a/code/validation.py b/code/validation.py index 817c2cf..79fa10c 100644 --- a/code/validation.py +++ b/code/validation.py @@ -125,7 +125,7 @@ def cantAddVm(owner, g): def haveAccess(user, state, machine): """Return whether a user has administrative access to a machine""" - return state.overlord or user in cache_acls.accessList(machine) + return state.isadmin or user in cache_acls.accessList(machine) def owns(user, machine): """Return whether a user owns a machine""" @@ -157,7 +157,7 @@ def validMemory(owner, g, memory, machine=None, on=True): raise InvalidInput('memory', memory, "Minimum %s MiB" % MIN_MEMORY_SINGLE) max_val = maxMemory(owner, g, machine, on) - if not g.overlord and memory > max_val: + if not g.isadmin and memory > max_val: raise InvalidInput('memory', memory, 'Maximum %s MiB for %s' % (max_val, owner)) return memory @@ -166,7 +166,7 @@ def validDisk(owner, g, disk, machine=None): """Parse and validate limits for disk for a given owner and machine.""" try: disk = float(disk) - if not g.overlord and disk > maxDisk(owner, machine): + if not g.isadmin and disk > maxDisk(owner, machine): raise InvalidInput('disk', disk, "Maximum %s G" % maxDisk(owner, machine)) disk = int(disk * 1024) diff --git a/code/webcommon.py b/code/webcommon.py index 0449046..e82f790 100644 --- a/code/webcommon.py +++ b/code/webcommon.py @@ -38,12 +38,12 @@ def cachedproperty(func): class State(object): """State for a request""" - def __init__(self, user, overlord=False): + def __init__(self, user, isadmin=False): self.username = user - self.overlord = overlord + self.isadmin = isadmin def getMachines(self): - if self.overlord: + if self.isadmin: return Machine.select() else: return Machine.query().join('acl').select_by(user=self.username) diff --git a/files/etc/apache2/sites-available/default b/files/etc/apache2/sites-available/default index 1faf9d8..672526c 100644 --- a/files/etc/apache2/sites-available/default +++ b/files/etc/apache2/sites-available/default @@ -12,7 +12,7 @@ NameVirtualHost *:80 RewriteEngine On RewriteRule ^/static(.*) - [L] - RewriteRule ^/overlord/static(.*) /static/$1 [L] + RewriteRule ^/admin/static(.*) /static/$1 [L] RewriteRule ^/trac.fcgi(.*) - [L] RewriteRule ^/trac/chrome/common(.*) /usr/share/trac/htdocs$1 [L] RewriteRule ^/trac/login(.*) https://xvm.mit.edu/trac/login$1 [L] diff --git a/files/etc/apache2/sites-available/ssl b/files/etc/apache2/sites-available/ssl index 901d6d6..57aa91d 100644 --- a/files/etc/apache2/sites-available/ssl +++ b/files/etc/apache2/sites-available/ssl @@ -19,7 +19,7 @@ RewriteEngine On RewriteRule ^/favicon.ico - [L] RewriteRule ^/static(.*) - [L] - RewriteRule ^/overlord/static(.*) /static/$1 [L] + RewriteRule ^/admin/static(.*) /static/$1 [L] RewriteRule ^/trac.fcgi(.*) - [L] RewriteRule ^/trac/chrome/common(.*) /usr/share/trac/htdocs$1 [L] RewriteRule ^/trac(.*) /var/www/trac/trac.fcgi$1 [L] -- 1.7.9.5