A monster checkin, with a variety of changes to the web
[invirt/packages/invirt-web.git] / templates / list.tmpl
1 #from skeleton import skeleton
2 #extends skeleton
3
4
5 #def title
6 List of your VMs
7 #end def
8
9 #def createTable()
10 #if $cant_add_vm
11 <p>$cant_add_vm</p>
12 #else
13 <p>Create a new VM:</p>
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" onsubmit="return jsFormSubmit('create', this);">
20       <table>
21       $errorRow('create', $err)
22         <tr>
23           <td>Name</td>
24           <td><input type="text" name="name" value="$defaults.name"/></td>
25         </tr>
26 $errorRow('name', $err)
27         <tr>
28           <td>Memory</td>
29           <td><input type="text" name="memory" value="$defaults.memory" size=3/> megabytes ($max_memory max)</td>
30         </tr>
31 $errorRow('memory', $err)
32         <tr>
33           <td>Disk</td>
34           <td><input type="text" name="disk" value="$defaults.disk" size=3/> gigabytes (${"%0.1f" % ($max_disk-0.05)} max)</td>
35         </tr>
36 $errorRow('disk', $err)
37         <tr>
38           <td>HVM/ParaVM$helppopup('hvm_paravm')</td>
39           <td>
40 #for $value, $name in (('hvm', 'HVM'), ('paravm', 'ParaVM'))
41    <input #slurp
42 #if $defaults.vmtype == $value then 'checked' else ''
43  type="radio" name="vmtype" value="$value">$name</input>
44 #end for
45           </td>
46         </tr>
47 $errorRow('vmtype', $err)
48         <tr>
49           <td>Boot CD</td>
50           <td>$cdromList($cdroms, $defaults.cdrom)</td>
51         </tr>
52 $errorRow('cdrom', $err)
53       </table>
54       <input type="submit" class="button" value="Create it!"/>
55     </form>
56 #end if
57 #end def
58
59 #def machineRow($machine)
60       <tr> 
61         <td><a href="info?machine_id=$machine.machine_id">$machine.name</a></td>
62         <td>${machine.memory}M</td>
63         <td>$machine.owner</td>
64 #if $machine.nics
65 #set $nic = $machine.nics[0]
66         <td>$nic.ip</td>
67         <td>$nic.hostname</td>
68 #else
69         <td></td>
70         <td></td>
71 #end if
72 <td>#slurp
73 #if $machine.uptime
74 $machine.uptime#slurp
75 #else
76 Off#slurp
77 #end if
78 </td>
79         <td>#slurp
80 #if $has_vnc[$machine] == True
81 <a href="vnc?machine_id=$machine.machine_id">Console</a>#slurp
82 #else
83 $has_vnc[$machine]
84 #end if
85 </td>
86         <td>
87           <form action="command" method="post" onsubmit="return rowFormSubmit(this, 'list');">
88             <input type="hidden" name="machine_id"
89                    value="$machine.machine_id"/>
90 <input type="submit" class="button" name="action" value="#slurp
91 #if $machine.uptime then 'Shutdown' else 'Power on'
92 "/>
93           </form>
94         </td>
95       </tr>
96 #end def
97
98 #def machineList($machines)
99     <table>
100       <tr>
101         <td>Name</td>
102         <td>Memory</td>
103         <td>owner</td>
104         <td>IP</td>
105         <td>Hostname</td>
106         <td>Uptime</td>
107         <td>VNC</td>
108         <td></td>
109       #for $machine in $machines:
110         $machineRow($machine)
111       #end for
112     </table>
113 #end def
114
115
116 #def body
117 #if not $machines
118 <p>You don't currently control any VMs.</p>   
119 #else
120     <p>You have the following VMs:</p>
121 #end if
122     <p><a href="list" onclick="new Ajax.Updater('machinelist', 'list?js=machinelist', {method: 'get' });return false">refresh</a></p>
123     <div id="machinelist">
124     $machineList($machines)
125     </div>
126 <div id="createtable">
127 $createTable()
128 </div>
129 #end def