Changeset 161 for trunk/web/templates
- Timestamp:
- Oct 9, 2007, 10:08:20 PM (17 years ago)
- Location:
- trunk/web/templates
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/web/templates/info.tmpl
r153 r161 63 63 <input type="hidden" name="machine_id" value="$machine.machine_id"/> 64 64 <table> 65 <tr><td>Owner:</td><td><input type="text" name="owner", value="$machine.owner"/></td></tr> 65 <tr><td>Owner:</td><td><input type="text" name="owner", value="$machine.owner"/></td> 66 <td>NOTE: The Owner must the name of a locker that you administer</td></tr> 66 67 <tr><td>Contact email:</td><td><input type="text" name="contact" value="$machine.contact"/></td></tr> 68 <tr><td>Machine Name:</td><td><input type="text" name="name" value="$machine.name"/></td></tr> 67 69 #if $machine.nics 68 <tr><td>Hostname:</td><td><input type="text" name="hostname" value="$machine.nics[0].hostname"/>.servers.csail.mit.edu</td></tr> 70 <tr><td>Hostname:</td><td><input type="text" name="hostname" value="$machine.nics[0].hostname"/>.servers.csail.mit.edu</td> 71 <td>NOTE: The hostname must being with "Owner_".</td></tr> 69 72 #end if 70 73 #if not $on -
trunk/web/templates/main.py
r159 r161 14 14 import datetime 15 15 import StringIO 16 import getafsgroups 16 17 17 18 sys.stderr = StringIO.StringIO() … … 118 119 if user.username == 'moo': 119 120 return True 120 return machine.owner == user.username121 return getafsgroups.checkLockerOwner(user.username,machine.owner) 121 122 122 123 def error(op, user, fields, err, emsg): … … 568 569 569 570 def testOwner(user, owner, machine=None): 570 if owner != user.username:571 if not getafsgroups.checkLockerOwner(user.username, owner): 571 572 raise InvalidInput('owner', owner, 572 573 "Invalid") … … 579 580 return contact 580 581 582 def testDisk(user, disksize, machine=None): 583 return disksize 584 585 def testName(user, name, machine=None): 586 return name 587 581 588 def testHostname(user, hostname, machine): 582 589 for nic in machine.nics: 583 590 if hostname == nic.hostname: 584 591 return hostname 592 # check if doesn't already exist 593 if NIC.select_by(hostname=hostname) == []: 594 return hostname 585 595 raise InvalidInput('hostname', hostname, 586 596 "Different from before") … … 590 600 """Handler for modifying attributes of a machine.""" 591 601 #XXX not written yet 592 machine = testMachineId(user, fields.getfirst('machine_id')) 593 owner = testOwner(user, fields.getfirst('owner'), machine) 594 contact = testContact(user, fields.getfirst('contact')) 595 hostname = testHostname(user, fields.getfirst('hostname'), 602 603 transaction = ctx.current.create_transaction() 604 try: 605 machine = testMachineId(user, fields.getfirst('machine_id')) 606 owner = testOwner(user, fields.getfirst('owner'), machine) 607 contact = testContact(user, fields.getfirst('contact')) 608 hostname = testHostname(owner, fields.getfirst('hostname'), 596 609 machine) 597 ram = fields.getfirst('memory') 598 if ram is not None: 599 ram = validMemory(user, ram, machine) 600 disk = testDisk(user, fields.getfirst('disk')) 601 if disk is not None: 602 disk = validDisk(user, disk, machine) 603 604 610 name = testName(user, fields.getfirst('name')) 611 oldname = machine.name 612 olddisk = {} 613 614 memory = fields.getfirst('memory') 615 if memory is not None: 616 memory = validMemory(user, memory, machine) 617 if memory != machine.memory: 618 machine.memory = memory 619 620 disksize = testDisk(user, fields.getfirst('disk')) 621 if disksize is not None: 622 disksize = validDisk(user, disksize, machine) 623 624 for disk in machine.disks: 625 disk.size = disksize 626 olddisk[disk.guest_device_name] = disk.size 627 ctx.current.save(disk) 628 629 # XXX all NICs get same hostname on change? Interface doesn't support more. 630 for nic in machine.nics: 631 nic.hostname = hostname 632 ctx.current.save(nic) 633 634 if owner != machine.owner: 635 machine.owner = owner 636 if name != machine.name: 637 machine.name = name 638 639 ctx.current.save(machine) 640 transaction.commit() 641 except: 642 transaction.rollback() 643 remctl("web", "moveregister", oldname, name) 644 for disk in machine.disks: 645 # XXX all disks get the same size on change? Interface doesn't support more. 646 if disk.size != olddisk[disk.guest_device_name]: 647 remctl("web", "lvresize", oldname, disk.guest_device_name, str(disk.size)) 648 if oldname != name: 649 remctl("web", "lvrename", oldname, disk.guest_device_name, name) 650 d = dict(user=user, 651 command="modify", 652 machine=machine) 653 return Template(file="command.tmpl", searchList=[d, global_dict]) 654 605 655 606 656 def help(user, fields):
Note: See TracChangeset
for help on using the changeset viewer.