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

Autoinstalls

File:
1 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)
Note: See TracChangeset for help on using the changeset viewer.