Changeset 437 for trunk/packages/sipb-xen-www
- Timestamp:
- Apr 21, 2008, 7:14:17 PM (17 years ago)
- Location:
- trunk/packages/sipb-xen-www/code
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/sipb-xen-www/code/controls.py
r419 r437 100 100 remctl('web', 'unregister', machine.name) 101 101 102 def createVm(owner, contact, name, memory, disk_size, is_hvm, cdrom, clone_from):102 def createVm(owner, contact, name, memory, disk_size, machine_type, cdrom, clone_from): 103 103 """Create a VM and put it in the database""" 104 104 # put stuff in the table … … 120 120 machine.uuid = uuidToString(randomUUID()) 121 121 machine.boot_off_cd = True 122 machine_type = Type.get_by(hvm=is_hvm)123 122 machine.type_id = machine_type.type_id 124 123 ctx.current.save(machine) -
trunk/packages/sipb-xen-www/code/main.py
r432 r437 153 153 154 154 vm_type = fields.getfirst('vmtype') 155 if vm_type not in ('hvm', 'paravm'): 156 raise CodeError("Invalid vm type '%s'" % vm_type) 157 is_hvm = (vm_type == 'hvm') 155 vm_type = validation.validVmType(vm_type) 158 156 159 157 cdrom = fields.getfirst('cdrom') … … 166 164 167 165 return dict(contact=user, name=name, memory=memory, disk_size=disk_size, 168 owner=owner, is_hvm=is_hvm, cdrom=cdrom, clone_from=clone_from)166 owner=owner, machine_type=vm_type, cdrom=cdrom, clone_from=clone_from) 169 167 170 168 def create(user, fields): -
trunk/packages/sipb-xen-www/code/validation.py
r431 r437 5 5 import re 6 6 import string 7 from sipb_xen_database import Machine, NIC 7 from sipb_xen_database import Machine, NIC, Type 8 8 from webcommon import InvalidInput, g 9 9 … … 124 124 "Minimum %s GiB" % MIN_DISK_SINGLE) 125 125 return disk 126 126 127 def 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 raise CodeError("Invalid vm type '%s'" % vm_type) 134 127 135 def testMachineId(user, machine_id, exists=True): 128 136 """Parse, validate and check authorization for a given user and machine.
Note: See TracChangeset
for help on using the changeset viewer.