X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/invirt-web.git/blobdiff_plain/4a94bedaf54426e167141e321eefdd076a106d77..f3c1b256ad0f930d2f7fc623ad538692a3829979:/templates/main.py diff --git a/templates/main.py b/templates/main.py index ed5f09c..915b5eb 100755 --- a/templates/main.py +++ b/templates/main.py @@ -131,7 +131,9 @@ def haveAccess(user, machine): return True if user.username in (machine.administrator, machine.owner): return True - if getafsgroups.checkAfsGroup(user, machine.administrator, 'athena.mit.edu'): #XXX Cell? + if getafsgroups.checkAfsGroup(user.username, machine.administrator, 'athena.mit.edu'): #XXX Cell? + return True + if getafsgroups.checkLockerOwner(user.username, machine.owner): return True return owns(user, machine) @@ -217,10 +219,10 @@ def bootMachine(machine, cdtype): id of the CD (e.g. 'gutsy_i386') """ if cdtype is not None: - remctl('web', 'vmboot', machine.name, + remctl('control', machine.name, 'create', cdtype) else: - remctl('web', 'vmboot', machine.name) + remctl('control', machine.name, 'create') def registerMachine(machine): """Register a machine to be controlled by the web interface""" @@ -274,7 +276,7 @@ def statusInfo(machine): Gets and parses xm list --long """ - value_string, err_string = remctl('list-long', machine.name, err=True) + value_string, err_string = remctl('control', machine.name, 'list-long', err=True) if 'Unknown command' in err_string: raise CodeError("ERROR in remctl list-long %s is not registered" % (machine.name,)) elif 'does not exist' in err_string: @@ -538,7 +540,7 @@ def getDiskInfo(data_dict, machine): def deleteVM(machine): """Delete a VM.""" - remctl('destroy', machine.name, err=True) + remctl('control', machine.name, 'destroy', err=True) transaction = ctx.current.create_transaction() delete_disk_pairs = [(machine.name, d.guest_device_name) for d in machine.disks] try: @@ -570,18 +572,18 @@ def command(user, fields): raise CodeError("Invalid action '%s'" % action) if action == 'Reboot': if cdrom is not None: - remctl('reboot', machine.name, cdrom) + remctl('control', machine.name, 'reboot', cdrom) else: - remctl('reboot', machine.name) + remctl('control', machine.name, 'reboot') elif action == 'Power on': if maxMemory(user) < machine.memory: raise InvalidInput('action', 'Power on', "You don't have enough free RAM quota to turn on this machine") bootMachine(machine, cdrom) elif action == 'Power off': - remctl('destroy', machine.name) + remctl('control', machine.name, 'destroy') elif action == 'Shutdown': - remctl('shutdown', machine.name) + remctl('control', machine.name, 'shutdown') elif action == 'Delete VM': deleteVM(machine) print >> sys.stderr, time.time()-start_time @@ -596,9 +598,9 @@ def testAdmin(user, admin, machine): return None if admin == user.username: return admin - if getafsgroups.checkAfsGroup(user, admin, 'athena.mit.edu'): + if getafsgroups.checkAfsGroup(user.username, admin, 'athena.mit.edu'): return admin - if getafsgroups.checkAfsGroup(user, 'system:'+admin, 'athena.mit.edu'): + if getafsgroups.checkAfsGroup(user.username, 'system:'+admin, 'athena.mit.edu'): return 'system:'+admin raise InvalidInput('admin', admin, 'You must control the group you move it to')