X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/invirt-web.git/blobdiff_plain/230d47ec0096ba45aeb3a690fa2c4551f4fcbb16..b812ecb815635726dca92b6c3725ac0a4bb86ab6:/code/main.py diff --git a/code/main.py b/code/main.py index 9caf7c4..3fe04d5 100755 --- a/code/main.py +++ b/code/main.py @@ -36,7 +36,8 @@ sys.path.append('/home/ecprice/.local/lib/python2.5/site-packages') 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 @@ -71,6 +72,7 @@ def makeErrorPre(old, addition): else: return '
STDERR:
' + str(addition) + '' +Template.sipb_xen_database = sipb_xen_database Template.helppopup = staticmethod(helppopup) Template.err = None @@ -96,9 +98,10 @@ class Defaults: 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: @@ -219,8 +222,7 @@ def getListDict(user): defaults=defaults, machines=machines, has_vnc=has_vnc, - uptimes=g.uptimes, - cdroms=CDROM.select()) + uptimes=g.uptimes) return d def listVms(user, fields): @@ -379,6 +381,10 @@ def modifyDict(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) @@ -560,12 +566,11 @@ def infoDict(user, 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,