From 74cf12ca4c1ba056483885a9b3b0d5c86014f1d1 Mon Sep 17 00:00:00 2001
From: Eric Price STDERR:' + str(addition) + '
'
+Template.sipb_xen_database = sipb_xen_database
Template.helppopup = staticmethod(helppopup)
Template.err = None
@@ -97,8 +99,8 @@ class Defaults:
disk = 4.0
cdrom = ''
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:
@@ -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,7 +566,7 @@ 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')
diff --git a/code/templates/functions.tmpl b/code/templates/functions.tmpl
index 7b917b0..c3aa050 100644
--- a/code/templates/functions.tmpl
+++ b/code/templates/functions.tmpl
@@ -13,6 +13,16 @@
#end def
+#def vmTypeList($default=None)
+#for $vmtype in $sipb_xen_database.Type.select()
+
+#end for
+#end def
+
#def addError(txt)
#if $varExists('txt')
#set global $error_text = $error_text + '----\n' + $txt
diff --git a/code/templates/info.tmpl b/code/templates/info.tmpl
index 3dc1b37..743034f 100644
--- a/code/templates/info.tmpl
+++ b/code/templates/info.tmpl
@@ -58,7 +58,6 @@ Info on $machine.name
#if $on
(To edit ram, disk size, or machine name, turn off the machine first.)
#end if
-