source: trunk/packages/sipb-xen-www/code/templates/list.tmpl @ 447

Last change on this file since 447 was 447, checked in by ecprice, 17 years ago

Avoid html injection.

Cheetah is painful.

File size: 4.0 KB
Line 
1#from skeleton import skeleton
2#extends skeleton
3
4
5#def title
6VM List
7#end def
8
9#def createForm()
10#if $cant_add_vm
11<p>$cant_add_vm</p>
12#else
13<h2>Create a new VM</h2>
14#if $err
15<p class="error">We had a problem with your request:</p>
16#else if $varExists('new_machine')
17<p>Congratulations! You successfully created a new VM called $new_machine.</p>
18#end if
19    <form action="create" method="POST">
20    <input type="hidden" name="back" value="list"/>
21      <table>
22#filter None
23      $errorRow('create', $err)
24#end filter
25        <tr>
26          <td>Name</td>
27          <td><input type="text" name="name" value="$defaults.name"/></td>
28        </tr>
29#filter None
30$errorRow('name', $err)
31#end filter
32        <tr>
33          <td>Memory</td>
34          <td><input type="text" name="memory" value="$defaults.memory" size=3/> MiB ($max_memory max)</td>
35        </tr>
36#filter None
37$errorRow('memory', $err)
38#end filter
39        <tr>
40          <td>Disk</td>
41          <td><input type="text" name="disk" value="$defaults.disk" size=3/> GiB (${"%0.1f" % ($max_disk-0.05)} max)</td>
42        </tr>
43#filter None
44$errorRow('disk', $err)
45#end filter
46        <tr>
47          <td>HVM/ParaVM#slurp
48#filter None
49$helppopup('hvm_paravm')#slurp
50#end filter
51</td>
52          <td>
53#filter None
54$vmTypeList($defaults.type)
55#end filter
56</td>
57        </tr>
58#filter None
59$errorRow('vmtype', $err)
60#end filter
61        <tr>
62          <td>Autoinstall#slurp
63#filter None
64$helppopup('autoinstall')#slurp
65#end filter
66</td>
67          <td><input type="radio" name="cd_or_auto" id="cd_or_auto_auto">
68#filter None
69$autoList($defaults.cdrom, "document.getElementById('cd_or_auto_auto').checked = true;document.getElementById('cdromlist').value = ''")
70              (experimental; 1-2 minutes, and you have a machine; root pw is 'password'.)
71#end filter
72          </input>
73        </tr>
74        <tr>
75          <td>Boot CD</td>
76          <td><input type="radio" name="cd_or_auto" id="cd_or_auto_cd" checked>
77#filter None
78$cdromList($defaults.cdrom, "document.getElementById('cd_or_auto_cd').checked = true;document.getElementById('autoinstalllist').value = ''")
79#end filter
80</td>
81          </input>
82        </tr>
83$errorRow('cdrom', $err)
84$errorRow('cdrom', $err)
85        <tr>
86          <td>Owner</td>
87          <td><input type="text" name="owner" value="$defaults.owner"/></td>
88        </tr>
89#filter None
90        $errorRow('owner', $err)
91#end filter
92      </table>
93      <input type="submit" class="button" value="Create it!"/>
94    </form>
95#end if
96#end def
97
98#def machineRow($machine)
99      <tr>
100        <td><a href="info?machine_id=$machine.machine_id">$machine.name</a></td>
101        <td>${machine.memory}M</td>
102        <td>$machine.owner</td>
103        <td>$machine.administrator</td>
104#if $machine.nics
105#set $nic = $machine.nics[0]
106        <td>$nic.ip</td>
107#else
108        <td></td>
109#end if
110<td>#slurp
111#if $machine.uptime
112$machine.uptime#slurp
113#end if
114</td>
115        <td>#slurp
116#if $has_vnc[$machine] == True
117<a href="vnc?machine_id=$machine.machine_id">Console</a>#slurp
118#else if $has_vnc[$machine] != 'Off'
119#filter None
120$has_vnc[$machine]
121#end filter
122#end if
123</td>
124        <td>
125          <form action="command" method="post">
126            <input type="hidden" name="back" value="list"/>
127            <input type="hidden" name="machine_id"
128                   value="$machine.machine_id"/>
129<input type="submit" class="button" name="action" value="#slurp
130#if $machine.uptime then 'Power off' else 'Power on'
131"/>
132          </form>
133        </td>
134      </tr>
135#end def
136
137#def machineList($machines)
138    <table>
139      <tr>
140        <th>Name</th>
141        <th>Memory</th>
142        <th>Owner#slurp
143#filter None
144$helppopup('owner')#slurp
145#end filter
146</th>
147        <th>Administrator#slurp
148#filter None
149$helppopup('administrator')#slurp
150#end filter
151</th>
152        <th>IP</th>
153        <th>Uptime</th>
154        <th>VNC</th>
155        <th></th>
156      </tr>
157      #for $machine in $machines:
158    #filter None
159        $machineRow($machine)
160    #end filter
161      #end for
162    </table>
163#end def
164
165
166#def body
167<p style="font-size: 125%;">SIPB Virtual Servers is an <strong>alpha service</strong>.  <a href="/static/about.html">What does this mean?</a></p>
168#if not $machines
169<p>You don't currently control any VMs.</p>  
170#end if
171    <p><a href="list">refresh</a></p>
172    <div id="machinelist">
173    #filter None
174    $machineList($machines)
175    #end filter
176    </div>
177#filter None
178$createForm()
179#end filter
180#end def
Note: See TracBrowser for help on using the repository browser.