Changeset 340 for trunk


Ignore:
Timestamp:
Mar 30, 2008, 4:28:10 AM (17 years ago)
Author:
price
Message:

expose cloning autoinstaller in web interface

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

Legend:

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

    r265 r340  
    6969        lvcreate(machine, disk)
    7070
     71def lvcopy(machine_orig_name, machine, rootpw):
     72    """Copy a golden image onto a machine's disk"""
     73    remctl('web', 'lvcopy', machine_orig_name, machine.name, rootpw)
     74
    7175def bootMachine(machine, cdtype):
    7276    """Boot a machine with a given boot CD.
     
    96100    remctl('web', 'unregister', machine.name)
    97101
    98 def createVm(owner, contact, name, memory, disk_size, is_hvm, cdrom):
     102def createVm(owner, contact, name, memory, disk_size, is_hvm, cdrom, clone_from):
    99103    """Create a VM and put it in the database"""
    100104    # put stuff in the table
     
    137141    registerMachine(machine)
    138142    makeDisks(machine)
     143    if clone_from:
     144        lvcopy(clone_from, machine, 'password')
    139145    # tell it to boot with cdrom
    140146    bootMachine(machine, cdrom)
  • trunk/packages/sipb-xen-www/code/main.py

    r309 r340  
    160160    if cdrom is not None and not CDROM.get(cdrom):
    161161        raise CodeError("Invalid cdrom type '%s'" % cdrom)
     162
     163    clone_from = fields.getfirst('clone_from')
     164    if clone_from and clone_from != 'ice3':
     165        raise CodeError("Invalid clone image '%s'" % clone_from)
     166   
    162167    return dict(contact=user, name=name, memory=memory, disk_size=disk_size,
    163                 owner=owner, is_hvm=is_hvm, cdrom=cdrom)
     168                owner=owner, is_hvm=is_hvm, cdrom=cdrom, clone_from=clone_from)
    164169
    165170def create(user, fields):
  • trunk/packages/sipb-xen-www/code/templates/list.tmpl

    r280 r340  
    5050          <td>Boot CD</td>
    5151          <td>$cdromList($cdroms, $defaults.cdrom)</td>
     52        </tr>
     53$errorRow('cdrom', $err)
     54        <tr>
     55          <td>Clone image?</td>
     56          <td><input type="checkbox" name="clone_from" value="ice3"/>
     57              (experimental; 1-2 minutes, and you have an etch machine; root pw is 'password'.)</td>
    5258        </tr>
    5359$errorRow('cdrom', $err)
Note: See TracChangeset for help on using the changeset viewer.