source: trunk/packages/invirt-web/code/templates/list.tmpl @ 2702

Last change on this file since 2702 was 2238, checked in by broder, 16 years ago

Power off VMs after a Javascript popup.

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