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"> |
---|
20 | <input type="hidden" name="back" value="list"/> |
---|
21 | <table> |
---|
22 | $errorRow('create', $err) |
---|
23 | <tr> |
---|
24 | <td>Name</td> |
---|
25 | <td><input type="text" name="name" value="$defaults.name"/></td> |
---|
26 | </tr> |
---|
27 | $errorRow('name', $err) |
---|
28 | <tr> |
---|
29 | <td>Memory</td> |
---|
30 | <td><input type="text" name="memory" value="$defaults.memory" size=3/> megabytes ($max_memory max)</td> |
---|
31 | </tr> |
---|
32 | $errorRow('memory', $err) |
---|
33 | <tr> |
---|
34 | <td>Disk</td> |
---|
35 | <td><input type="text" name="disk" value="$defaults.disk" size=3/> gigabytes (${"%0.1f" % ($max_disk-0.05)} max)</td> |
---|
36 | </tr> |
---|
37 | $errorRow('disk', $err) |
---|
38 | <tr> |
---|
39 | <td>HVM/ParaVM$helppopup('hvm_paravm')</td> |
---|
40 | <td> |
---|
41 | #for $value, $name in (('hvm', 'HVM'), ('paravm', 'ParaVM')) |
---|
42 | <input #slurp |
---|
43 | #if $defaults.vmtype == $value then 'checked' else '' |
---|
44 | type="radio" name="vmtype" value="$value">$name</input> |
---|
45 | #end for |
---|
46 | </td> |
---|
47 | </tr> |
---|
48 | $errorRow('vmtype', $err) |
---|
49 | <tr> |
---|
50 | <td>Boot CD</td> |
---|
51 | <td>$cdromList($cdroms, $defaults.cdrom)</td> |
---|
52 | </tr> |
---|
53 | $errorRow('cdrom', $err) |
---|
54 | </table> |
---|
55 | <input type="submit" class="button" value="Create it!"/> |
---|
56 | </form> |
---|
57 | #end if |
---|
58 | #end def |
---|
59 | |
---|
60 | #def machineRow($machine) |
---|
61 | <tr> |
---|
62 | <td><a href="info?machine_id=$machine.machine_id">$machine.name</a></td> |
---|
63 | <td>${machine.memory}M</td> |
---|
64 | <td>$machine.owner</td> |
---|
65 | #if $machine.nics |
---|
66 | #set $nic = $machine.nics[0] |
---|
67 | <td>$nic.ip</td> |
---|
68 | #else |
---|
69 | <td></td> |
---|
70 | #end if |
---|
71 | <td>#slurp |
---|
72 | #if $machine.uptime |
---|
73 | $machine.uptime#slurp |
---|
74 | #else |
---|
75 | Off#slurp |
---|
76 | #end if |
---|
77 | </td> |
---|
78 | <td>#slurp |
---|
79 | #if $has_vnc[$machine] == True |
---|
80 | <a href="vnc?machine_id=$machine.machine_id">Console</a>#slurp |
---|
81 | #else |
---|
82 | $has_vnc[$machine] |
---|
83 | #end if |
---|
84 | </td> |
---|
85 | <td> |
---|
86 | <form action="command" method="post"> |
---|
87 | <input type="hidden" name="back" value="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>Uptime</td> |
---|
106 | <td>VNC</td> |
---|
107 | <td></td> |
---|
108 | #for $machine in $machines: |
---|
109 | $machineRow($machine) |
---|
110 | #end for |
---|
111 | </table> |
---|
112 | #end def |
---|
113 | |
---|
114 | |
---|
115 | #def body |
---|
116 | #if not $machines |
---|
117 | <p>You don't currently control any VMs.</p> |
---|
118 | #else |
---|
119 | <p>You have the following VMs:</p> |
---|
120 | #end if |
---|
121 | <p><a href="list">refresh</a></p> |
---|
122 | <div id="machinelist"> |
---|
123 | $machineList($machines) |
---|
124 | </div> |
---|
125 | <div id="createtable"> |
---|
126 | $createTable() |
---|
127 | </div> |
---|
128 | #end def |
---|