web: don't send mail on error if it's one of us testing
[invirt/packages/invirt-web.git] / code / templates / list.tmpl
1 #from skeleton import skeleton
2 #extends skeleton
3 #import datetime
4
5
6 #def title
7 VM List
8 #end def
9
10 #def createForm()
11 #if $cant_add_vm
12 <p>$cant_add_vm</p>
13 #else
14 <h2>Create a new VM</h2>
15 #if $err
16 <p class="error">We had a problem with your request:</p>
17 #else if $varExists('new_machine')
18 <p>Congratulations! You successfully created a new VM called $new_machine.</p>
19 #end if
20     <form action="create" method="POST">
21     <input type="hidden" name="back" value="list"/>
22       <table>
23 #filter None
24       $errorRow('create', $err)
25 #end filter
26         <tr>
27           <td>Name</td>
28           <td><input type="text" name="name" value="$defaults.name"/>.xvm.mit.edu</td>
29         </tr>
30 #filter None
31 $errorRow('name', $err)
32 #end filter
33         <tr>
34           <td>Description</td>
35           <td><textarea name="description" rows="4" cols="60">$defaults.description</textarea></td>
36         </tr>
37 #filter None
38 $errorRow('description', $err)
39 #end filter
40         <tr>
41           <td>Memory</td>
42           <td><input type="text" name="memory" value="$defaults.memory" size=3/> MiB ($max_memory max)</td>
43         </tr>
44 #filter None
45 $errorRow('memory', $err)
46 #end filter
47         <tr>
48           <td>Disk</td>
49           <td><input type="text" name="disksize" value="$defaults.disk" size=3/> GiB (${"%0.1f" % ($max_disk-0.05)} max)</td>
50         </tr>
51 #filter None
52 $errorRow('disk', $err)
53 #end filter
54         <tr>
55           <td>HVM/ParaVM#slurp
56 #filter None
57 $helppopup('HVM/ParaVM')#slurp
58 #end filter
59 </td>
60           <td>
61 #filter None
62 $vmTypeList($defaults.type)
63 #end filter
64 </td>
65         </tr>
66 #filter None
67 $errorRow('vmtype', $err)
68 #end filter
69         <tr>
70           <td>Clone image?</td>
71 #if $can_clone
72           <td><input type="checkbox" name="clone_from" id="clone_from" value="ice3" onchange="onclone(event)"/>
73               (experimental; 1-2 minutes, and you have an etch machine; root pw is 'password'.)
74               <script type='text/javascript'>function onclone(e){ document.getElementById('cdromlist').value = ''; }</script></td>
75 #else
76           <td><input type="checkbox" name="clone_from" id="clone_from" value="ice3" disabled="disabled"/> Image cloning is currently disabled for maintenance</td>
77 #end if
78         </tr>
79 #filter None
80 $errorRow('autoinstall', $err)
81 #end filter
82         <!--<tr>
83           <td>Autoinstall#slurp
84 #filter None
85 $helppopup('Autoinstall')#slurp
86 #end filter
87 </td>
88           <td><input type="radio" name="cd_or_auto" id="cd_or_auto_auto">
89 #filter None
90 $autoList($defaults.cdrom, "document.getElementById('cd_or_auto_auto').checked = true;document.getElementById('cdromlist').value = ''")
91               (experimental; 1-2 minutes, and you have a machine; root pw is 'password'.)
92 #end filter
93           </input>
94         </tr>-->
95         <tr>
96           <td>Boot CD</td>
97           <td><input type="radio" name="cd_or_auto" id="cd_or_auto_cd" checked>
98 #filter None
99 $cdromList($defaults.cdrom, "document.getElementById('cd_or_auto_cd').checked = true;document.getElementById('autoinstalllist').value = ''")
100 #end filter
101 </td>
102           </input>
103         </tr>
104 $errorRow('cdrom', $err)
105 $errorRow('cdrom', $err)
106         <tr>
107           <td>Owner</td>
108           <td><input type="text" name="owner" value="$defaults.owner"/></td>
109         </tr>
110 #filter None
111         $errorRow('owner', $err)
112 #end filter
113       </table>
114       <input type="submit" class="button" value="Create it!"/>
115     </form>
116 #end if
117 #end def
118
119 #def machineRow($machine)
120       <tr> 
121         <td rowspan="2">
122           <form action="command" method="post">
123             <input type="hidden" name="back" value="list"/>
124             <input type="hidden" name="machine_id"
125                    value="$machine.machine_id"/>
126 <input type="submit" class="button" name="action" value="#slurp
127 #if $machine.uptime then 'Power off' else 'Power on'
128 "/>
129           </form>
130         </td>
131         <td><a href="info?machine_id=$machine.machine_id">$machine.name</a></td>
132         <td>${machine.memory}M</td>
133         <td>$machine.owner</td>
134         <td>$machine.administrator</td>
135 #if $machine.nics
136 #set $nic = $machine.nics[0]
137         <td>$nic.ip</td>
138 #else
139         <td></td>
140 #end if
141 <td>#slurp
142 #if $machine.uptime
143 ${datetime.timedelta(seconds=int(machine.uptime))}#slurp
144 #end if
145 </td>
146         <td>#slurp
147 #if $has_vnc[$machine] == True
148 <a href="vnc?machine_id=$machine.machine_id">Console</a>#slurp
149 #else if $has_vnc[$machine] != 'Off'
150 #filter None
151 $has_vnc[$machine]
152 #end filter
153 #end if
154 </td>
155       </tr>
156       <tr>
157         <td colspan="7" style="padding-left: 1em; color: #666">$machine.description</td>
158       </tr>
159 #end def
160
161 #def machineList($machines)
162     <table cellspacing="0" cellpadding="2">
163       <tr>
164         <th></th>
165         <th>Name</th>
166         <th>Memory</th>
167         <th>Owner#slurp
168 #filter None
169 $helppopup('Owner')#slurp
170 #end filter
171 </th>
172         <th>Administrator#slurp
173 #filter None
174 $helppopup('Administrator')#slurp
175 #end filter
176 </th>
177         <th>IP</th>
178         <th>Uptime</th>
179         <th>VNC</th>
180       </tr>
181       #for $machine in $machines:
182     #filter None
183         $machineRow($machine)
184     #end filter
185       #end for
186     </table>
187     <script type="text/javascript" src="/static/stripe.js"></script>
188     <script type="text/javascript">
189         document.observe("dom:loaded", function() {
190             stripe(\$('machinelist').getElementsByTagName('table')[0],
191                    'stripedrow');
192         });
193     </script>
194 #end def
195
196
197 #def body
198 <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>
199 #if not $machines
200 <p>You don't currently control any VMs.</p>   
201 #end if
202     <p><a href="list">refresh</a></p>
203     <div id="machinelist">
204     #filter None
205     $machineList($machines)
206     #end filter
207     </div>
208 #filter None
209 $createForm()
210 #end filter
211 #end def