Ignore:
Timestamp:
Apr 21, 2008, 9:13:53 PM (16 years ago)
Author:
ecprice
Message:

Support setting paravm/hvm for off, but already created, VMs.

File:
1 edited

Legend:

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

    r437 r440  
    1919def getMachinesByOwner(user, machine=None):
    2020    """Return the machines owned by the same as a machine.
    21    
     21
    2222    If the machine is None, return the machines owned by the same
    2323    user.
     
    3232    """Return the maximum memory for a machine or a user.
    3333
    34     If machine is None, return the memory available for a new 
     34    If machine is None, return the memory available for a new
    3535    machine.  Else, return the maximum that machine can have.
    3636
     
    5050
    5151def maxDisk(user, machine=None):
     52    """Return the maximum disk that a machine can reach.
     53
     54    If machine is None, the maximum disk for a new machine. Otherwise,
     55    return the maximum that a given machine can be changed to.
     56    """
    5257    machines = getMachinesByOwner(user, machine)
    5358    disk_usage = sum([sum([y.size for y in x.disks])
     
    102107            raise ValueError
    103108    except ValueError:
    104         raise InvalidInput('memory', memory, 
     109        raise InvalidInput('memory', memory,
    105110                           "Minimum %s MiB" % MIN_MEMORY_SINGLE)
    106111    if memory > maxMemory(user, machine, on):
     
    126131
    127132def validVmType(vm_type):
    128     if vm_type == 'hvm':
    129         return Type.get('linux-hvm')
    130     elif vm_type == 'paravm':
    131         return Type.get('linux')
    132     else:
     133    if vm_type is None:
     134        return None
     135    t = Type.get(vm_type)
     136    if t is None:
    133137        raise CodeError("Invalid vm type '%s'"  % vm_type)
     138    return t
    134139
    135140def testMachineId(user, machine_id, exists=True):
     
    139144    """
    140145    if machine_id is None:
    141         raise InvalidInput('machine_id', machine_id, 
     146        raise InvalidInput('machine_id', machine_id,
    142147                           "Must specify a machine ID.")
    143148    try:
     
    177182    #XXX Should we require that user is in the admin group?
    178183    return admin
    179    
     184
    180185def testOwner(user, owner, machine=None):
    181186    """Determine whether a user can set the owner of a machine to this value.
Note: See TracChangeset for help on using the changeset viewer.