import templates
from Cheetah.Template import Template
import sipb_xen_database
-from sipb_xen_database import Machine, CDROM, ctx, connect, MachineAccess, Type
+from sipb_xen_database import Machine, CDROM, ctx, connect, MachineAccess, Type, Autoinstall
import validation
from webcommon import InvalidInput, CodeError, g
import controls
memory = 256
disk = 4.0
cdrom = ''
+ autoinstall = ''
name = ''
def __init__(self, max_memory=None, max_disk=None, **kws):
self.type = Type.get('linux-hvm')
defaults=defaults,
machines=machines,
has_vnc=has_vnc,
- uptimes=g.uptimes,
- cdroms=CDROM.select())
+ uptimes=g.uptimes)
return d
def listVms(user, fields):
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,
-#def cdromList($cdroms, $default="")
-<select name="cdrom" id="cdromlist">
+#def databaseList($lst, $default, $onchange, $name, $id, $valueattr, $descattr)
+<select name="$name" id="$id"#slurp
+#if $onchange is not None
+onchange="$onchange"#slurp
+#end if
+>
<option #slurp
#if $default then '' else 'selected'
value="">None</option>
- #for $cdrom in $cdroms
+ #for $item in $lst
<option #slurp
-#if $default == $cdrom.cdrom_id then 'selected' else ''
- value="$cdrom.cdrom_id">
- $cdrom.description
+#if $default == getattr(item, valueattr) then 'selected' else ''
+ value="${getattr(item, valueattr)}">
+ ${getattr(item, descattr)}
</option>
#end for
</select>
#end def
+#def cdromList($default="", $onchange=None)
+$databaseList(sorted($sipb_xen_database.CDROM.select(), key=lambda x: x.description),
+ default, onchange, 'cdrom', 'cdromlist', 'cdrom_id', 'description')
+#end def
+
+#def autoList($default="", $onchange=None)
+$databaseList(sorted($sipb_xen_database.Autoinstall.select(), key=lambda x: x.description),
+ default, onchange, 'autoinstall', 'autoinstalllist', 'autoinstall_id', 'description')
+## $databaseList(autos, default, onchange, 'autoinstall', 'autoinstalllist', 'autoinstall_id', 'description')
+#end def
+
#def vmTypeList($default=None)
#for $vmtype in sorted($sipb_xen_database.Type.select(), key=lambda x: x.description)
<label>
<td><input type="submit" class="button" name="action" value="Power on"/></td>
#end if
<td>Boot CD:</td>
- <td>$cdromList($cdroms)</td>
+ <td>$cdromList()</td>
</tr>
<tr>
<td><input type="submit" class="button" name="action" value="Delete VM" onclick="return confirm('Are you sure that you want to delete this VM?');"/></td>
</tr>
$errorRow('vmtype', $err)
<tr>
- <td>Boot CD</td>
- <td>$cdromList($cdroms, $defaults.cdrom)</td>
+ <td>Autoinstall$helppopup('autoinstall')</td>
+ <td><input type="radio" name="cd_or_auto" id="cd_or_auto_auto">$autoList($defaults.cdrom, "document.getElementById('cd_or_auto_auto').checked = true;document.getElementById('cdromlist').value = ''")
+ (experimental; 1-2 minutes, and you have a machine; root pw is 'password'.)
+ </input>
</tr>
-$errorRow('cdrom', $err)
<tr>
- <td>Clone image?</td>
- <td><input type="checkbox" name="clone_from" id="clone_from" value="ice3" onchange="onclone(event)"/>
- (experimental; 1-2 minutes, and you have an etch machine; root pw is 'password'.)
- <script type='text/javascript'>function onclone(e){ document.getElementById('cdromlist').value = ''; }</script></td>
+ <td>Boot CD</td>
+ <td><input type="radio" name="cd_or_auto" id="cd_or_auto_cd" checked>$cdromList($defaults.cdrom, "document.getElementById('cd_or_auto_cd').checked = true;document.getElementById('autoinstalllist').value = ''")</td>
+ </input>
</tr>
$errorRow('cdrom', $err)
+$errorRow('cdrom', $err)
<tr>
<td>Owner</td>
<td><input type="text" name="owner" value="$defaults.owner"/></td>