Changeset 629
- Timestamp:
- Jun 21, 2008, 9:23:59 PM (17 years ago)
- Location:
- trunk/packages/sipb-xen-www/code
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/sipb-xen-www/code/controls.py
r626 r629 70 70 lvcreate(machine, disk) 71 71 72 def getswap(disksize, memsize): 73 """Returns the recommended swap partition size.""" 74 return int(min(disksize / 4, memsize * 1.5)) 75 76 def lvinstall(machine, autoinstall): 77 disksize = machine.disks[0].size 78 memsize = machine.memory 79 imagesize = disksize - getswap(disksize, memsize) 80 ip = machine.nics[0].ip 81 remctl('web', 'install', machine.name, autoinstall.distribution, 82 autoinstall.mirror, str(imagesize), ip) 83 72 84 def lvcopy(machine_orig_name, machine, rootpw): 73 85 """Copy a golden image onto a machine's disk""" … … 93 105 % (err, machine.name, cdtype)) 94 106 95 def createVm(username, state, owner, contact, name, description, memory, disksize, machine_type, cdrom, clone_from):107 def createVm(username, state, owner, contact, name, description, memory, disksize, machine_type, cdrom, autoinstall): 96 108 """Create a VM and put it in the database""" 97 109 # put stuff in the table … … 131 143 raise 132 144 makeDisks(machine) 133 if clone_from:134 lv copy(clone_from, machine, 'password')145 if autoinstall: 146 lvinstall(machine, autoinstall) 135 147 # tell it to boot with cdrom 136 148 bootMachine(machine, cdrom) -
trunk/packages/sipb-xen-www/code/main.py
r627 r629 32 32 atexit.register(printError) 33 33 34 sys.path.append('/home/ecprice/.local/lib/python2.5/site-packages')35 36 34 import templates 37 35 from Cheetah.Template import Template … … 137 135 138 136 def parseCreate(username, state, fields): 139 kws = dict([(kw, fields.getfirst(kw)) for kw in 'name description owner memory disksize vmtype cdrom clone_from'.split()])137 kws = dict([(kw, fields.getfirst(kw)) for kw in 'name description owner memory disksize vmtype cdrom autoinstall'.split()]) 140 138 validate = validation.Validate(username, state, strict=True, **kws) 141 139 return dict(contact=username, name=validate.name, description=validate.description, memory=validate.memory, 142 140 disksize=validate.disksize, owner=validate.owner, machine_type=validate.vmtype, 143 141 cdrom=getattr(validate, 'cdrom', None), 144 clone_from=getattr(validate, 'clone_from', None))142 autoinstall=getattr(validate, 'autoinstall', None)) 145 143 146 144 def create(username, state, fields): … … 626 624 def getUser(environ): 627 625 """Return the current user based on the SSL environment variables""" 628 email = environ.get('SSL_CLIENT_S_DN_Email', None) 629 if email is None: 630 return None 631 if not email.endswith('@MIT.EDU'): 632 return None 633 return email[:-8] 626 return environ.get('REMOTE_USER', None) 634 627 635 628 class App: -
trunk/packages/sipb-xen-www/code/templates/list.tmpl
r621 r629 67 67 $errorRow('vmtype', $err) 68 68 #end filter 69 <tr>70 <td>Clone image?</td>71 #if $can_clone72 <td><input type="checkbox" name="clone_from" id="clone_from" value="ice3" onchange="onclone(event)"/>73 (experimental; 1-2 minutes, and you have an etch machine; root pw is 'password'.)74 <script type='text/javascript'>function onclone(e){ document.getElementById('cdromlist').value = ''; }</script></td>75 #else76 <td><input type="checkbox" name="clone_from" id="clone_from" value="ice3" disabled="disabled"/> Image cloning is currently disabled for maintenance</td>77 #end if78 </tr>79 69 #filter None 80 70 $errorRow('autoinstall', $err) 81 71 #end filter 82 < !--<tr>72 <tr> 83 73 <td>Autoinstall#slurp 84 74 #filter None … … 92 82 #end filter 93 83 </input> 94 </tr> -->84 </tr> 95 85 <tr> 96 86 <td>Boot CD</td> -
trunk/packages/sipb-xen-www/code/validation.py
r609 r629 5 5 import re 6 6 import string 7 from sipb_xen_database import Machine, NIC, Type, Disk, CDROM 7 from sipb_xen_database import Machine, NIC, Type, Disk, CDROM, Autoinstall 8 8 from webcommon import InvalidInput 9 9 … … 20 20 def __init__(self, username, state, machine_id=None, name=None, description=None, owner=None, 21 21 admin=None, contact=None, memory=None, disksize=None, 22 vmtype=None, cdrom=None, clone_from=None, strict=False):22 vmtype=None, cdrom=None, autoinstall=None, strict=False): 23 23 # XXX Successive quota checks aren't a good idea, since you 24 24 # can't necessarily change the locker and disk size at the … … 66 66 raise CodeError("Invalid cdrom type '%s'" % cdrom) 67 67 self.cdrom = cdrom 68 if clone_from is not None: 69 if clone_from not in ('ice3', ): 70 raise CodeError("Invalid clone image '%s'" % clone_from) 71 self.clone_from = clone_from 68 if autoinstall is not None: 69 self.autoinstall = Autoinstall.get(autoinstall) 72 70 73 71
Note: See TracChangeset
for help on using the changeset viewer.