X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/invirt-web.git/blobdiff_plain/31a80e557fe527ec94c3a490b4b6bd73a4fd9af5..43c105be35eb49744112ccb6f28644d0c794585a:/main.py diff --git a/main.py b/main.py index e182095..a3c84ee 100755 --- a/main.py +++ b/main.py @@ -36,7 +36,7 @@ sys.path.append('/home/ecprice/.local/lib/python2.5/site-packages') import templates from Cheetah.Template import Template -from sipb_xen_database import Machine, CDROM, ctx, connect +from sipb_xen_database import Machine, CDROM, ctx, connect, MachineAccess import validation from webcommon import InvalidInput, CodeError, g import controls @@ -146,10 +146,10 @@ def parseCreate(user, fields): owner = validation.testOwner(user, fields.getfirst('owner')) memory = fields.getfirst('memory') - memory = validation.validMemory(user, memory, on=True) + memory = validation.validMemory(owner, memory, on=True) disk_size = fields.getfirst('disk') - disk_size = validation.validDisk(user, disk_size) + disk_size = validation.validDisk(owner, disk_size) vm_type = fields.getfirst('vmtype') if vm_type not in ('hvm', 'paravm'): @@ -183,12 +183,7 @@ def create(user, fields): def getListDict(user): - machines = [m for m in Machine.select() - if validation.haveAccess(user, m)] - #if user == 'moo': - # machines = Machine.select() - #else: - # machines = Machine.query().join('users').filter_by(user=user).all() + machines = g.machines checkpoint.checkpoint('Got my machines') on = {} has_vnc = {} @@ -331,8 +326,8 @@ def command(user, fields): except InvalidInput, err: if not back: raise - print >> sys.stderr, err - result = None + #print >> sys.stderr, err + result = err else: result = 'Success!' if not back: @@ -348,8 +343,7 @@ def command(user, fields): d['result'] = result return templates.info(searchList=[d]) else: - raise InvalidInput - ('back', back, 'Not a known back page.') + raise InvalidInput('back', back, 'Not a known back page.') def modifyDict(user, fields): olddisk = {} @@ -583,11 +577,8 @@ def printHeaders(headers): def getUser(): """Return the current user based on the SSL environment variables""" - if 'SSL_CLIENT_S_DN_Email' in os.environ: - username = os.environ['SSL_CLIENT_S_DN_Email'].split("@")[0] - return username - else: - return 'moo' + username = os.environ['SSL_CLIENT_S_DN_Email'].split("@")[0] + return username def main(operation, user, fields): start_time = time.time()