X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/invirt-web.git/blobdiff_plain/0aa4d89f6b6825785a4d95d312c86284cd5a32f8..49466ab6194ad35f3857e950721252621c3e539d:/templates/main.py diff --git a/templates/main.py b/templates/main.py index 36518d6..4a50e43 100755 --- a/templates/main.py +++ b/templates/main.py @@ -41,7 +41,9 @@ def maxDisk(user, machine=None): return 10.0 def haveAccess(user, machine): - return True + if user.username == 'moo': + return True + return machine.owner == user.username def error(op, user, fields, err): d = dict(op=op, user=user, errorMessage=str(err)) @@ -268,11 +270,19 @@ def create(user, fields): searchList=d); def listVms(user, fields): - machines = Machine.select() + machines = [m for m in Machine.select() if haveAccess(user, m)] on = {} has_vnc = {} uptimes = getUptimes(machines) - on = has_vnc = uptimes + on = uptimes + for m in machines: + if not on.get(m.name): + has_vnc[m.name] = 'Off' + elif m.type.hvm: + has_vnc[m.name] = True + else: + help_name = 'paravm_console' + has_vnc[m.name] = 'ParaVM (?)' % (help_name, help_name) # for m in machines: # status = statusInfo(m) # on[m.name] = status is not None @@ -434,6 +444,7 @@ def info(user, fields): display_fields = [('name', 'Name'), ('owner', 'Owner'), ('contact', 'Contact'), + ('type', 'Type'), 'NIC_INFO', ('uptime', 'uptime'), ('cputime', 'CPU usage'), @@ -450,6 +461,7 @@ def info(user, fields): ] fields = [] machine_info = {} + machine_info['type'] = machine.type.hvm and 'HVM' or 'ParaVM' machine_info['owner'] = machine.owner machine_info['contact'] = machine.contact