- Timestamp:
- Oct 11, 2007, 1:55:29 AM (17 years ago)
- Location:
- trunk/web/templates
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/web/templates/help.tmpl
r139 r187 3 3 4 4 #def title 5 #if len($subjects) == 1 6 Help on $subjects[0] 7 #else 5 8 Help 9 #end if 6 10 #end def 7 11 … … 10 14 #if not $simple 11 15 <h1>Help</h1> 16 <p>Topics: 17 #for $key in sorted($mapping) 18 <a href="help?subject=$key">$key</a> 19 #end for 20 </p> 12 21 #end if 13 22 #for $subject in $subjects 23 #if $subject in $mapping 24 #if not $simple 25 <h2>$subject</h2> 26 #end if 14 27 <p>$mapping[$subject]</p> 28 #else 29 <p>Unknown subject '$subject'.</p> 30 #end if 15 31 #end for 32 #if $simple 33 <a href="javascript:window.close();">Close</a> 34 #end if 16 35 #end def -
trunk/web/templates/info.tmpl
r177 r187 64 64 <table> 65 65 <tr><td>Owner${helppopup("owner")}:</td><td><input type="text" name="owner", value="$machine.owner"/></td></tr> 66 <tr><td>Administrator${helppopup("administrator")}:</td><td><input type="text" name="administrator", value="$machine.administrator"/></td></tr> 66 67 <tr><td>Contact email:</td><td><input type="text" name="contact" value="$machine.contact"/></td></tr> 67 68 #if $machine.nics -
trunk/web/templates/main.py
r182 r187 16 16 import getafsgroups 17 17 18 sys.stderr = StringIO.StringIO() 18 errio = StringIO.StringIO() 19 sys.stderr = errio 19 20 sys.path.append('/home/ecprice/.local/lib/python2.5/site-packages') 20 21 … … 84 85 MAX_VMS_ACTIVE = 4 85 86 86 def getMachinesByOwner(owner): 87 """Return the machines owned by a given owner.""" 87 def getMachinesByOwner(user, machine=None): 88 """Return the machines owned by the same as a machine. 89 90 If the machine is None, return the machines owned by the same 91 user. 92 """ 93 if machine: 94 owner = machine.owner 95 else: 96 owner = user.username 88 97 return Machine.select_by(owner=owner) 89 98 … … 100 109 if not on: 101 110 return MAX_MEMORY_SINGLE 102 machines = getMachinesByOwner(user .username)111 machines = getMachinesByOwner(user, machine) 103 112 active_machines = [x for x in machines if g.uptimes[x]] 104 113 mem_usage = sum([x.memory for x in active_machines if x != machine]) … … 106 115 107 116 def maxDisk(user, machine=None): 108 machines = getMachinesByOwner(user .username)117 machines = getMachinesByOwner(user, machine) 109 118 disk_usage = sum([sum([y.size for y in x.disks]) 110 119 for x in machines if x != machine]) … … 112 121 113 122 def canAddVm(user): 114 machines = getMachinesByOwner(user .username)123 machines = getMachinesByOwner(user) 115 124 active_machines = [x for x in machines if g.uptimes[x]] 116 125 return (len(machines) < MAX_VMS_TOTAL and … … 118 127 119 128 def haveAccess(user, machine): 120 """Return whether a user has access to a machine""" 129 """Return whether a user has adminstrative access to a machine""" 130 if user.username == 'moo': 131 return True 132 if user.username in (machine.administrator, machine.owner): 133 return True 134 if checkAfsGroup(user, machine.administrator, 'athena.mit.edu'): #XXX Cell? 135 return True 136 return owns(user, machine) 137 138 def owns(user, machine): 139 """Return whether a user owns a machine""" 121 140 if user.username == 'moo': 122 141 return True … … 573 592 return Template(file="command.tmpl", searchList=[d, global_dict]) 574 593 575 def testOwner(user, owner, machine=None): 576 if owner == machine.owner: #XXX What do we do when you lose access to the locker? 577 return owner 594 def testAdmin(user, admin, machine): 595 if admin in (None, machine.administrator): 596 return None 597 if admin == user.username: 598 return admin 599 if getafsgroups.checkAfsGroup(user, admin, 'athena.mit.edu'): 600 return admin 601 if getafsgroups.checkAfsGroup(user, 'system:'+admin, 'athena.mit.edu'): 602 return 'system:'+admin 603 raise InvalidInput('admin', admin, 604 'You must control the group you move it to') 605 606 def testOwner(user, owner, machine): 607 if owner in (None, machine.owner): 608 return None 609 #XXX should you be able to transfer ownership if you don't already own it? 610 #if not owns(user, machine): 611 # raise InvalidInput('owner', owner, "You don't own this machine, so you can't transfer ownership") 578 612 value = getafsgroups.checkLockerOwner(user.username, owner, verbose=True) 579 613 if value == True: … … 582 616 583 617 def testContact(user, contact, machine=None): 618 if contact in (None, machine.contact): 619 return None 584 620 if not re.match("^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$", contact, re.I): 585 621 raise InvalidInput('contact', contact, "Not a valid email") … … 590 626 591 627 def testName(user, name, machine=None): 592 if name i s None:628 if name in (None, machine.name): 593 629 return None 594 630 if not Machine.select_by(name=name): 595 return name596 if name == machine.name:597 631 return name 598 632 raise InvalidInput('name', name, "Already taken") … … 618 652 machine = testMachineId(user, fields.getfirst('machine_id')) 619 653 owner = testOwner(user, fields.getfirst('owner'), machine) 620 contact = testContact(user, fields.getfirst('contact'))621 hostname = testHostname(owner, fields.getfirst('hostname'),622 654 admin = testAdmin(user, fields.getfirst('administrator'), machine) 655 contact = testContact(user, fields.getfirst('contact'), machine) 656 hostname = testHostname(owner, fields.getfirst('hostname'), machine) 623 657 name = testName(user, fields.getfirst('name'), machine) 624 658 oldname = machine.name … … 644 678 ctx.current.save(nic) 645 679 646 if owner is not None and owner != machine.owner:680 if owner is not None: 647 681 machine.owner = owner 648 if name is not None and name != machine.name:682 if name is not None: 649 683 machine.name = name 684 if admin is not None: 685 machine.administrator = admin 686 if contact is not None: 687 machine.contact = contact 650 688 651 689 ctx.current.save(machine) … … 656 694 for diskname in olddisk: 657 695 remctl("web", "lvresize", oldname, diskname, str(olddisk[diskname])) 658 if name is not None and name != oldname:696 if name is not None: 659 697 for disk in machine.disks: 660 if oldname != name: 661 remctl("web", "lvrename", oldname, disk.guest_device_name, name) 698 remctl("web", "lvrename", oldname, disk.guest_device_name, name) 662 699 remctl("web", "moveregister", oldname, name) 663 700 d = dict(user=user, … … 681 718 want an HVM virtualized machine.""", 682 719 cpu_weight="""Don't ask us! We're as mystified as you are.""", 683 owner="""The Owner must be the name of a locker that you are an AFS 684 administrator of. In particular, you or an AFS group you are a member 685 of must have AFS rlidwka bits on the locker. You can check see who 686 administers the LOCKER locker using the command 'fs la /mit/LOCKER' on 687 Athena.)""") 688 720 owner="""The owner field is used to determine <a href="help?subject=quotas">quotas</a>. It must be the name 721 of a locker that you are an AFS administrator of. In particular, you 722 or an AFS group you are a member of must have AFS rlidwka bits on the 723 locker. You can check see who administers the LOCKER locker using the 724 command 'fs la /mit/LOCKER' on Athena.) See also <a href="help?subject=administrator">administrator</a>.""", 725 administrator="""The administrator field determines who can access the console and power on and off the machine. This can be either a user or a moira group.""", 726 quotas="""Quotas are determined on a per-locker basis. Each 727 quota may have a maximum of 512 megabytes of active ram, 50 gigabytes of disk, and 4 active machines.""" 728 729 ) 730 731 if not subjects: 732 subjects = sorted(mapping.keys()) 733 689 734 d = dict(user=user, 690 735 simple=simple, … … 715 760 display_fields = [('name', 'Name'), 716 761 ('owner', 'Owner'), 762 ('administrator', 'Administrator'), 717 763 ('contact', 'Contact'), 718 764 ('type', 'Type'), … … 736 782 machine_info['type'] = machine.type.hvm and 'HVM' or 'ParaVM' 737 783 machine_info['owner'] = machine.owner 784 machine_info['administrator'] = machine.administrator 738 785 machine_info['contact'] = machine.contact 739 786 … … 817 864 output = fun(u, fields) 818 865 print 'Content-Type: text/html\n' 819 sys.stderr.seek(0)820 e = sys.stderr.read()821 866 sys.stderr=sys.stdout 867 errio.seek(0) 868 e = errio.read() 822 869 if e: 823 870 output = str(output) … … 826 873 except CodeError, err: 827 874 print 'Content-Type: text/html\n' 828 sys.stderr.seek(0)829 e = sys.stderr.read()830 875 sys.stderr=sys.stdout 876 errio.seek(0) 877 e = errio.read() 831 878 print error(operation, u, fields, err, e) 832 879 except InvalidInput, err: 833 880 print 'Content-Type: text/html\n' 834 sys.stderr.seek(0)835 e = sys.stderr.read()836 881 sys.stderr=sys.stdout 882 errio.seek(0) 883 e = errio.read() 837 884 print invalidInput(operation, u, fields, err, e) 838 885 except: 839 886 print 'Content-Type: text/plain\n' 840 sys.stderr.seek(0) 841 e = sys.stderr.read() 887 sys.stderr=sys.stdout 888 errio.seek(0) 889 e = errio.read() 842 890 print e 843 891 print '----' 844 sys.stderr = sys.stdout845 892 raise -
trunk/web/templates/skeleton.py
r184 r187 34 34 __CHEETAH_version__ = '2.0rc8' 35 35 __CHEETAH_versionTuple__ = (2, 0, 0, 'candidate', 8) 36 __CHEETAH_genTime__ = 11920 25116.069462137 __CHEETAH_genTimestamp__ = ' Wed Oct 10 10:05:162007'36 __CHEETAH_genTime__ = 1192082083.444865 37 __CHEETAH_genTimestamp__ = 'Thu Oct 11 01:54:43 2007' 38 38 __CHEETAH_src__ = 'skeleton.tmpl' 39 __CHEETAH_srcLastModified__ = ' Wed Oct 10 10:04:552007'39 __CHEETAH_srcLastModified__ = 'Thu Oct 11 01:54:41 2007' 40 40 __CHEETAH_docstring__ = 'Autogenerated by CHEETAH: The Python-Powered Template Engine' 41 41 … … 117 117 if _v is not None: write(_filter(_v, rawExpr='$user.username')) # from line 26, col 26. 118 118 write('''.]</p> 119 <p><a href="list">List</a> 119 120 ''') 120 _v = VFFSL(SL,"body",True) # '$body' on line 28, col 1 121 if _v is not None: write(_filter(_v, rawExpr='$body')) # from line 28, col 1. 121 if VFFSL(SL,"varExists",False)('machine'): # generated from line 28, col 1 122 write('''<a href="info?machine_id=''') 123 _v = VFFSL(SL,"machine.machine_id",True) # '$machine.machine_id' on line 29, col 26 124 if _v is not None: write(_filter(_v, rawExpr='$machine.machine_id')) # from line 29, col 26. 125 write('''">Info</a> 126 <a href="vnc?machine_id=''') 127 _v = VFFSL(SL,"machine.machine_id",True) # '$machine.machine_id' on line 30, col 25 128 if _v is not None: write(_filter(_v, rawExpr='$machine.machine_id')) # from line 30, col 25. 129 write('''">Console</a> 130 ''') 131 write('''<a href="help">Help</a></p> 132 ''') 133 _v = VFFSL(SL,"body",True) # '$body' on line 34, col 1 134 if _v is not None: write(_filter(_v, rawExpr='$body')) # from line 34, col 1. 122 135 write(''' 123 136 ''') 124 if not VFFSL(SL,"varExists",False)('simple') or not VFFSL(SL,"simple",True): # generated from line 29, col 1137 if not VFFSL(SL,"varExists",False)('simple') or not VFFSL(SL,"simple",True): # generated from line 35, col 1 125 138 write('''<hr /> 126 139 Questions? Contact <a href="mailto:sipb-xen-dev@mit.edu">sipb-xen-dev@mit.edu</a>. -
trunk/web/templates/skeleton.tmpl
r184 r187 25 25 #if not $varExists('simple') or not $simple 26 26 <p>[You are logged in as $user.username.]</p> 27 <p><a href="list">List</a> 28 #if $varExists('machine') 29 <a href="info?machine_id=$machine.machine_id">Info</a> 30 <a href="vnc?machine_id=$machine.machine_id">Console</a> 31 #end if 32 <a href="help">Help</a></p> 27 33 #end if 28 34 $body
Note: See TracChangeset
for help on using the changeset viewer.