projects
/
invirt/packages/invirt-web.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Remove the useless User class (now user is a string)
[invirt/packages/invirt-web.git]
/
templates
/
main.py
diff --git
a/templates/main.py
b/templates/main.py
index
7e92c8b
..
0bf16b9
100755
(executable)
--- a/
templates/main.py
+++ b/
templates/main.py
@@
-47,12
+47,6
@@
def helppopup(subj):
'&simple=true" target="_blank" ' +
'onclick="return helppopup(\'' + subj + '\')">(?)</a></span>')
'&simple=true" target="_blank" ' +
'onclick="return helppopup(\'' + subj + '\')">(?)</a></span>')
-class User:
- """User class (sort of useless, I admit)"""
- def __init__(self, username, email):
- self.username = username
- self.email = email
-
def makeErrorPre(old, addition):
if addition is None:
return
def makeErrorPre(old, addition):
if addition is None:
return
@@
-133,6
+127,8
@@
def parseCreate(user, fields):
raise InvalidInput('name', name,
"Name already exists.")
raise InvalidInput('name', name,
"Name already exists.")
+ owner = validation.testOwner(user, fields.getfirst('owner'))
+
memory = fields.getfirst('memory')
memory = validation.validMemory(user, memory, on=True)
memory = fields.getfirst('memory')
memory = validation.validMemory(user, memory, on=True)
@@
-147,8
+143,8
@@
def parseCreate(user, fields):
cdrom = fields.getfirst('cdrom')
if cdrom is not None and not CDROM.get(cdrom):
raise CodeError("Invalid cdrom type '%s'" % cdrom)
cdrom = fields.getfirst('cdrom')
if cdrom is not None and not CDROM.get(cdrom):
raise CodeError("Invalid cdrom type '%s'" % cdrom)
- return dict(user=user, name=name, memory=memory, disk=disk,
- is_hvm=is_hvm, cdrom=cdrom)
+ return dict(contact=user, name=name, memory=memory, disk=disk,
+ owner=owner, is_hvm=is_hvm, cdrom=cdrom)
def create(user, fields):
"""Handler for create requests."""
def create(user, fields):
"""Handler for create requests."""
@@
-188,6
+184,7
@@
def getListDict(user):
max_disk = validation.maxDisk(user)
defaults = Defaults(max_memory=max_memory,
max_disk=max_disk,
max_disk = validation.maxDisk(user)
defaults = Defaults(max_memory=max_memory,
max_disk=max_disk,
+ owner=user,
cdrom='gutsy-i386')
d = dict(user=user,
cant_add_vm=validation.cantAddVm(user),
cdrom='gutsy-i386')
d = dict(user=user,
cant_add_vm=validation.cantAddVm(user),
@@
-230,7
+227,7
@@
def vnc(user, fields):
TOKEN_KEY = "0M6W0U1IXexThi5idy8mnkqPKEq1LtEnlK/pZSn0cDrN"
data = {}
TOKEN_KEY = "0M6W0U1IXexThi5idy8mnkqPKEq1LtEnlK/pZSn0cDrN"
data = {}
- data["user"] = user.username
+ data["user"] = user
data["machine"] = machine.name
data["expires"] = time.time()+(5*60)
pickled_data = cPickle.dumps(data)
data["machine"] = machine.name
data["expires"] = time.time()+(5*60)
pickled_data = cPickle.dumps(data)
@@
-544,9
+541,9
@@
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 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 User(username, os.environ['SSL_CLIENT_S_DN_Email'])
+ return username
else:
else:
- return User('moo', 'nobody')
+ return 'moo'
def main(operation, user, fields):
fun = mapping.get(operation, badOperation)
def main(operation, user, fields):
fun = mapping.get(operation, badOperation)