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/> MiB ($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/> GiB (${"%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 | <tr> |
---|
55 | <td>Owner</td> |
---|
56 | <td><input type="text" name="owner" value="$defaults.owner"/></td> |
---|
57 | </tr> |
---|
58 | $errorRow('owner', $err) |
---|
59 | </table> |
---|
60 | <input type="submit" class="button" value="Create it!"/> |
---|
61 | </form> |
---|
62 | #end if |
---|
63 | #end def |
---|
64 | |
---|
65 | #def machineRow($machine) |
---|
66 | <tr> |
---|
67 | <td><a href="info?machine_id=$machine.machine_id">$machine.name</a></td> |
---|
68 | <td>${machine.memory}M</td> |
---|
69 | <td>$machine.owner</td> |
---|
70 | #if $machine.nics |
---|
71 | #set $nic = $machine.nics[0] |
---|
72 | <td>$nic.ip</td> |
---|
73 | #else |
---|
74 | <td></td> |
---|
75 | #end if |
---|
76 | <td>#slurp |
---|
77 | #if $machine.uptime |
---|
78 | $machine.uptime#slurp |
---|
79 | #else |
---|
80 | Off#slurp |
---|
81 | #end if |
---|
82 | </td> |
---|
83 | <td>#slurp |
---|
84 | #if $has_vnc[$machine] == True |
---|
85 | <a href="vnc?machine_id=$machine.machine_id">Console</a>#slurp |
---|
86 | #else |
---|
87 | $has_vnc[$machine] |
---|
88 | #end if |
---|
89 | </td> |
---|
90 | <td> |
---|
91 | <form action="command" method="post"> |
---|
92 | <input type="hidden" name="back" value="list"/> |
---|
93 | <input type="hidden" name="machine_id" |
---|
94 | value="$machine.machine_id"/> |
---|
95 | <input type="submit" class="button" name="action" value="#slurp |
---|
96 | #if $machine.uptime then 'Power off' else 'Power on' |
---|
97 | "/> |
---|
98 | </form> |
---|
99 | </td> |
---|
100 | </tr> |
---|
101 | #end def |
---|
102 | |
---|
103 | #def machineList($machines) |
---|
104 | <table> |
---|
105 | <tr> |
---|
106 | <td>Name</td> |
---|
107 | <td>Memory</td> |
---|
108 | <td>Owner</td> |
---|
109 | <td>IP</td> |
---|
110 | <td>Uptime</td> |
---|
111 | <td>VNC</td> |
---|
112 | <td></td> |
---|
113 | #for $machine in $machines: |
---|
114 | $machineRow($machine) |
---|
115 | #end for |
---|
116 | </table> |
---|
117 | #end def |
---|
118 | |
---|
119 | |
---|
120 | #def body |
---|
121 | #if not $machines |
---|
122 | <p>You don't currently control any VMs.</p> |
---|
123 | #else |
---|
124 | <p>You have the following VMs:</p> |
---|
125 | #end if |
---|
126 | <p><a href="list">refresh</a></p> |
---|
127 | <div id="machinelist"> |
---|
128 | $machineList($machines) |
---|
129 | </div> |
---|
130 | <div id="createtable"> |
---|
131 | $createTable() |
---|
132 | </div> |
---|
133 | #end def |
---|