import templates
from Cheetah.Template import Template
-from sipb_xen_database import Machine, CDROM, ctx, connect, MachineAccess
+import sipb_xen_database
+from sipb_xen_database import Machine, CDROM, ctx, connect, MachineAccess, Type, Autoinstall
import validation
from webcommon import InvalidInput, CodeError, g
import controls
else:
return '<p>STDERR:</p><pre>' + str(addition) + '</pre>'
+Template.sipb_xen_database = sipb_xen_database
Template.helppopup = staticmethod(helppopup)
Template.err = None
memory = 256
disk = 4.0
cdrom = ''
+ autoinstall = ''
name = ''
- vmtype = 'hvm'
def __init__(self, max_memory=None, max_disk=None, **kws):
+ self.type = Type.get('linux-hvm')
if max_memory is not None:
self.memory = min(self.memory, max_memory)
if max_disk is not None:
defaults=defaults,
machines=machines,
has_vnc=has_vnc,
- uptimes=g.uptimes,
- cdroms=CDROM.select())
+ uptimes=g.uptimes)
return d
def listVms(user, fields):
memory = validation.validMemory(user, memory, machine, on=False)
machine.memory = memory
+ vm_type = validation.validVmType(fields.getfirst('vmtype'))
+ if vm_type is not None:
+ machine.type = vm_type
+
disksize = validation.testDisk(user, fields.getfirst('disk'))
if disksize is not None:
disksize = validation.validDisk(user, disksize, machine)
checkpoint.checkpoint('Got mem')
max_disk = validation.maxDisk(user, machine)
defaults = Defaults()
- for name in 'machine_id name administrator owner memory contact'.split():
+ for name in 'machine_id name administrator owner memory contact type'.split():
setattr(defaults, name, getattr(machine, name))
defaults.disk = "%0.2f" % (machine.disks[0].size/1024.)
checkpoint.checkpoint('Got defaults')
d = dict(user=user,
- cdroms=CDROM.select(),
on=status is not None,
machine=machine,
defaults=defaults,