Changeset 629 for trunk


Ignore:
Timestamp:
Jun 21, 2008, 9:23:59 PM (16 years ago)
Author:
ecprice
Message:

Autoinstalls

Location:
trunk/packages/sipb-xen-www/code
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/sipb-xen-www/code/controls.py

    r626 r629  
    7070        lvcreate(machine, disk)
    7171
     72def getswap(disksize, memsize):
     73    """Returns the recommended swap partition size."""
     74    return int(min(disksize / 4, memsize * 1.5))
     75
     76def 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
    7284def lvcopy(machine_orig_name, machine, rootpw):
    7385    """Copy a golden image onto a machine's disk"""
     
    93105                        % (err, machine.name, cdtype))
    94106
    95 def createVm(username, state, owner, contact, name, description, memory, disksize, machine_type, cdrom, clone_from):
     107def createVm(username, state, owner, contact, name, description, memory, disksize, machine_type, cdrom, autoinstall):
    96108    """Create a VM and put it in the database"""
    97109    # put stuff in the table
     
    131143        raise
    132144    makeDisks(machine)
    133     if clone_from:
    134         lvcopy(clone_from, machine, 'password')
     145    if autoinstall:
     146        lvinstall(machine, autoinstall)
    135147    # tell it to boot with cdrom
    136148    bootMachine(machine, cdrom)
  • trunk/packages/sipb-xen-www/code/main.py

    r627 r629  
    3232    atexit.register(printError)
    3333
    34 sys.path.append('/home/ecprice/.local/lib/python2.5/site-packages')
    35 
    3634import templates
    3735from Cheetah.Template import Template
     
    137135
    138136def 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()])
    140138    validate = validation.Validate(username, state, strict=True, **kws)
    141139    return dict(contact=username, name=validate.name, description=validate.description, memory=validate.memory,
    142140                disksize=validate.disksize, owner=validate.owner, machine_type=validate.vmtype,
    143141                cdrom=getattr(validate, 'cdrom', None),
    144                 clone_from=getattr(validate, 'clone_from', None))
     142                autoinstall=getattr(validate, 'autoinstall', None))
    145143
    146144def create(username, state, fields):
     
    626624def getUser(environ):
    627625    """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)
    634627
    635628class App:
  • trunk/packages/sipb-xen-www/code/templates/list.tmpl

    r621 r629  
    6767$errorRow('vmtype', $err)
    6868#end filter
    69         <tr>
    70           <td>Clone image?</td>
    71 #if $can_clone
    72           <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 #else
    76           <td><input type="checkbox" name="clone_from" id="clone_from" value="ice3" disabled="disabled"/> Image cloning is currently disabled for maintenance</td>
    77 #end if
    78         </tr>
    7969#filter None
    8070$errorRow('autoinstall', $err)
    8171#end filter
    82         <!--<tr>
     72        <tr>
    8373          <td>Autoinstall#slurp
    8474#filter None
     
    9282#end filter
    9383          </input>
    94         </tr>-->
     84        </tr>
    9585        <tr>
    9686          <td>Boot CD</td>
  • trunk/packages/sipb-xen-www/code/validation.py

    r609 r629  
    55import re
    66import string
    7 from sipb_xen_database import Machine, NIC, Type, Disk, CDROM
     7from sipb_xen_database import Machine, NIC, Type, Disk, CDROM, Autoinstall
    88from webcommon import InvalidInput
    99
     
    2020    def __init__(self, username, state, machine_id=None, name=None, description=None, owner=None,
    2121                 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):
    2323        # XXX Successive quota checks aren't a good idea, since you
    2424        # can't necessarily change the locker and disk size at the
     
    6666                raise CodeError("Invalid cdrom type '%s'" % cdrom)
    6767            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)
    7270
    7371
Note: See TracChangeset for help on using the changeset viewer.