Cheetah is painful.
svn path=/trunk/packages/sipb-xen-www/; revision=447
import simplejson
import sys
import time
import simplejson
import sys
import time
from StringIO import StringIO
def revertStandardError():
from StringIO import StringIO
def revertStandardError():
checkpoint = Checkpoint()
checkpoint = Checkpoint()
+def jquote(string):
+ return "'" + string.replace('\\', '\\\\').replace("'", "\\'").replace('\n', '\\n') + "'"
def helppopup(subj):
"""Return HTML code for a (?) link to a specified help topic"""
def helppopup(subj):
"""Return HTML code for a (?) link to a specified help topic"""
- return ('<span class="helplink"><a href="help?subject=' + subj +
- '&simple=true" target="_blank" ' +
- 'onclick="return helppopup(\'' + subj + '\')">(?)</a></span>')
+ return ('<span class="helplink"><a href="help?' +
+ cgi.escape(urllib.urlencode(dict(subject=subj, simple='true')))
+ +'" target="_blank" ' +
+ 'onclick="return helppopup(' + cgi.escape(jquote(subj)) + ')">(?)</a></span>')
def makeErrorPre(old, addition):
if addition is None:
def makeErrorPre(old, addition):
if addition is None:
#def databaseList($lst, $default, $onchange, $name, $id, $valueattr, $descattr)
<select name="$name" id="$id"#slurp
#if $onchange is not None
#def databaseList($lst, $default, $onchange, $name, $id, $valueattr, $descattr)
<select name="$name" id="$id"#slurp
#if $onchange is not None
#end def
#def cdromList($default="", $onchange=None)
#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')
$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)
#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(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)
#end def
#def vmTypeList($default=None)
-
-$full_body
\ No newline at end of file
+#filter None
+$full_body
+#end filter
+#end filter
\ No newline at end of file
<td><input type="submit" class="button" name="action" value="Power on"/></td>
#end if
<td>Boot CD:</td>
<td><input type="submit" class="button" name="action" value="Power on"/></td>
#end if
<td>Boot CD:</td>
+ <td>#slurp
+#filter None
+$cdromList()#slurp
+#end filter
+</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>
<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>
<form action="modify" method="POST">
<input type="hidden" name="machine_id" value="$defaults.machine_id"/>
<table>
<form action="modify" method="POST">
<input type="hidden" name="machine_id" value="$defaults.machine_id"/>
<table>
- <tr><td>Owner${helppopup("owner")}:</td><td><input type="text" name="owner", value="$defaults.owner"/></td></tr>
+ <tr><td>Owner#slurp
+#filter None
+$helppopup("owner")#slurp
+#end filter
+:</td><td><input type="text" name="owner", value="$defaults.owner"/></td></tr>
+#filter None
- <tr><td>Administrator${helppopup("administrator")}:</td><td><input type="text" name="administrator", value="$defaults.administrator"/></td></tr>
+#end filter
+ <tr><td>Administrator#slurp
+#filter None
+$helppopup("administrator")#slurp
+#end filter
+:</td><td><input type="text" name="administrator", value="$defaults.administrator"/></td></tr>
+#filter None
$errorRow('administrator', $err)
$errorRow('administrator', $err)
<tr><td>Contact email:</td><td><input type="text" name="contact" value="$defaults.contact"/></td></tr>
<tr><td>Contact email:</td><td><input type="text" name="contact" value="$defaults.contact"/></td></tr>
$errorRow('contact', $err)
$errorRow('contact', $err)
#if not $on
<tr><td>Machine Name:</td><td><input type="text" name="name" value="$defaults.name"/></td></tr>
#if not $on
<tr><td>Machine Name:</td><td><input type="text" name="name" value="$defaults.name"/></td></tr>
- <td>HVM/ParaVM$helppopup('hvm_paravm')</td>
- <td>$vmTypeList($defaults.type)</td>
+ <td>HVM/ParaVM#slurp
+#filter None
+$helppopup('hvm_paravm')#slurp
+#end filter
+</td>
+ <td>#slurp
+#filter None
+$vmTypeList($defaults.type)#slurp
+#end filter
+</td>
</tr>
<tr><td>Ram:</td><td><input type="text" size=3 name="memory" value="$defaults.memory"/>MiB (max $max_mem)</td></tr>
</tr>
<tr><td>Ram:</td><td><input type="text" size=3 name="memory" value="$defaults.memory"/>MiB (max $max_mem)</td></tr>
$errorRow('memory', $err)
$errorRow('memory', $err)
<tr><td>Disk:</td><td><input type="text" size=3 name="disk" value="$defaults.disk"/>GiB (max $max_disk)</td><td>WARNING: Modifying disk size may corrupt your data.</td></tr>
<tr><td>Disk:</td><td><input type="text" size=3 name="disk" value="$defaults.disk"/>GiB (max $max_disk)</td><td>WARNING: Modifying disk size may corrupt your data.</td></tr>
$errorRow('name', $err)
$errorRow('memory', $err)
$errorRow('disk', $err)
$errorRow('name', $err)
$errorRow('memory', $err)
$errorRow('disk', $err)
#end if
<tr><td><input type="submit" class="button" name="action" value="Change"/></td></tr>
</table>
#end if
<tr><td><input type="submit" class="button" name="action" value="Change"/></td></tr>
</table>
#def body
<div id="info">
#def body
<div id="info">
</div>
<h2>Commands</h2>
<div id="commands">
</div>
<h2>Commands</h2>
<div id="commands">
</div>
<h2>Settings</h2>
<div id="modify">
</div>
<h2>Settings</h2>
<div id="modify">
<form action="create" method="POST">
<input type="hidden" name="back" value="list"/>
<table>
<form action="create" method="POST">
<input type="hidden" name="back" value="list"/>
<table>
$errorRow('create', $err)
$errorRow('create', $err)
<tr>
<td>Name</td>
<td><input type="text" name="name" value="$defaults.name"/></td>
</tr>
<tr>
<td>Name</td>
<td><input type="text" name="name" value="$defaults.name"/></td>
</tr>
<tr>
<td>Memory</td>
<td><input type="text" name="memory" value="$defaults.memory" size=3/> MiB ($max_memory max)</td>
</tr>
<tr>
<td>Memory</td>
<td><input type="text" name="memory" value="$defaults.memory" size=3/> MiB ($max_memory max)</td>
</tr>
$errorRow('memory', $err)
$errorRow('memory', $err)
<tr>
<td>Disk</td>
<td><input type="text" name="disk" value="$defaults.disk" size=3/> GiB (${"%0.1f" % ($max_disk-0.05)} max)</td>
</tr>
<tr>
<td>Disk</td>
<td><input type="text" name="disk" value="$defaults.disk" size=3/> GiB (${"%0.1f" % ($max_disk-0.05)} max)</td>
</tr>
- <td>HVM/ParaVM$helppopup('hvm_paravm')</td>
- <td>$vmTypeList($defaults.type)</td>
+ <td>HVM/ParaVM#slurp
+#filter None
+$helppopup('hvm_paravm')#slurp
+#end filter
+</td>
+ <td>
+#filter None
+$vmTypeList($defaults.type)
+#end filter
+</td>
$errorRow('vmtype', $err)
$errorRow('vmtype', $err)
- <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 = ''")
+ <td>Autoinstall#slurp
+#filter None
+$helppopup('autoinstall')#slurp
+#end filter
+</td>
+ <td><input type="radio" name="cd_or_auto" id="cd_or_auto_auto">
+#filter None
+$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'.)
(experimental; 1-2 minutes, and you have a machine; root pw is 'password'.)
</input>
</tr>
<tr>
<td>Boot CD</td>
</input>
</tr>
<tr>
<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>
+ <td><input type="radio" name="cd_or_auto" id="cd_or_auto_cd" checked>
+#filter None
+$cdromList($defaults.cdrom, "document.getElementById('cd_or_auto_cd').checked = true;document.getElementById('autoinstalllist').value = ''")
+#end filter
+</td>
</input>
</tr>
$errorRow('cdrom', $err)
</input>
</tr>
$errorRow('cdrom', $err)
<td>Owner</td>
<td><input type="text" name="owner" value="$defaults.owner"/></td>
</tr>
<td>Owner</td>
<td><input type="text" name="owner" value="$defaults.owner"/></td>
</tr>
</table>
<input type="submit" class="button" value="Create it!"/>
</form>
</table>
<input type="submit" class="button" value="Create it!"/>
</form>
#if $has_vnc[$machine] == True
<a href="vnc?machine_id=$machine.machine_id">Console</a>#slurp
#else if $has_vnc[$machine] != 'Off'
#if $has_vnc[$machine] == True
<a href="vnc?machine_id=$machine.machine_id">Console</a>#slurp
#else if $has_vnc[$machine] != 'Off'
<tr>
<th>Name</th>
<th>Memory</th>
<tr>
<th>Name</th>
<th>Memory</th>
- <th>Owner$helppopup('owner')</th>
- <th>Administrator$helppopup('administrator')</th>
+ <th>Owner#slurp
+#filter None
+$helppopup('owner')#slurp
+#end filter
+</th>
+ <th>Administrator#slurp
+#filter None
+$helppopup('administrator')#slurp
+#end filter
+</th>
<th>IP</th>
<th>Uptime</th>
<th>VNC</th>
<th></th>
</tr>
#for $machine in $machines:
<th>IP</th>
<th>Uptime</th>
<th>VNC</th>
<th></th>
</tr>
#for $machine in $machines:
#end for
</table>
#end def
#end for
</table>
#end def
#end if
<p><a href="list">refresh</a></p>
<div id="machinelist">
#end if
<p><a href="list">refresh</a></p>
<div id="machinelist">
<li><a href="help">Help</a></ul></li>
</ul>
#end if
<li><a href="help">Help</a></ul></li>
</ul>
#end if
<div id="result" class="result">
#if $varExists('result')
$result
<div id="result" class="result">
#if $varExists('result')
$result
#if not $varExists('simple') or not $simple
<h1>$title — SIPB Virtual Servers</h1>
#end if
#if not $varExists('simple') or not $simple
<h1>$title — SIPB Virtual Servers</h1>
#end if
#if not $varExists('simple') or not $simple
<hr />
Questions? Contact <a href="mailto:sipb-xen@mit.edu">sipb-xen@mit.edu</a>.
#if not $varExists('simple') or not $simple
<hr />
Questions? Contact <a href="mailto:sipb-xen@mit.edu">sipb-xen@mit.edu</a>.