[113] | 1 | #from skeleton import skeleton |
---|
| 2 | #extends skeleton |
---|
| 3 | |
---|
[205] | 4 | |
---|
[113] | 5 | #def title |
---|
[422] | 6 | VM List |
---|
[113] | 7 | #end def |
---|
| 8 | |
---|
[425] | 9 | #def createForm() |
---|
[205] | 10 | #if $cant_add_vm |
---|
| 11 | <p>$cant_add_vm</p> |
---|
[113] | 12 | #else |
---|
[425] | 13 | <h2>Create a new VM</h2> |
---|
[205] | 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 |
---|
[207] | 19 | <form action="create" method="POST"> |
---|
| 20 | <input type="hidden" name="back" value="list"/> |
---|
[205] | 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> |
---|
[229] | 30 | <td><input type="text" name="memory" value="$defaults.memory" size=3/> MiB ($max_memory max)</td> |
---|
[205] | 31 | </tr> |
---|
| 32 | $errorRow('memory', $err) |
---|
| 33 | <tr> |
---|
| 34 | <td>Disk</td> |
---|
[229] | 35 | <td><input type="text" name="disk" value="$defaults.disk" size=3/> GiB (${"%0.1f" % ($max_disk-0.05)} max)</td> |
---|
[205] | 36 | </tr> |
---|
| 37 | $errorRow('disk', $err) |
---|
[440] | 38 | <tr> |
---|
| 39 | <td>HVM/ParaVM$helppopup('hvm_paravm')</td> |
---|
| 40 | <td>$vmTypeList($defaults.type)</td> |
---|
| 41 | </tr> |
---|
[205] | 42 | $errorRow('vmtype', $err) |
---|
| 43 | <tr> |
---|
| 44 | <td>Boot CD</td> |
---|
| 45 | <td>$cdromList($cdroms, $defaults.cdrom)</td> |
---|
| 46 | </tr> |
---|
| 47 | $errorRow('cdrom', $err) |
---|
[228] | 48 | <tr> |
---|
[340] | 49 | <td>Clone image?</td> |
---|
[406] | 50 | <td><input type="checkbox" name="clone_from" id="clone_from" value="ice3" onchange="onclone(event)"/> |
---|
| 51 | (experimental; 1-2 minutes, and you have an etch machine; root pw is 'password'.) |
---|
| 52 | <script type='text/javascript'>function onclone(e){ document.getElementById('cdromlist').value = ''; }</script></td> |
---|
[340] | 53 | </tr> |
---|
| 54 | $errorRow('cdrom', $err) |
---|
| 55 | <tr> |
---|
[228] | 56 | <td>Owner</td> |
---|
| 57 | <td><input type="text" name="owner" value="$defaults.owner"/></td> |
---|
| 58 | </tr> |
---|
| 59 | $errorRow('owner', $err) |
---|
[205] | 60 | </table> |
---|
| 61 | <input type="submit" class="button" value="Create it!"/> |
---|
| 62 | </form> |
---|
| 63 | #end if |
---|
| 64 | #end def |
---|
| 65 | |
---|
| 66 | #def machineRow($machine) |
---|
[113] | 67 | <tr> |
---|
| 68 | <td><a href="info?machine_id=$machine.machine_id">$machine.name</a></td> |
---|
| 69 | <td>${machine.memory}M</td> |
---|
| 70 | <td>$machine.owner</td> |
---|
[234] | 71 | <td>$machine.administrator</td> |
---|
[113] | 72 | #if $machine.nics |
---|
| 73 | #set $nic = $machine.nics[0] |
---|
| 74 | <td>$nic.ip</td> |
---|
| 75 | #else |
---|
| 76 | <td></td> |
---|
| 77 | #end if |
---|
[133] | 78 | <td>#slurp |
---|
[205] | 79 | #if $machine.uptime |
---|
| 80 | $machine.uptime#slurp |
---|
[133] | 81 | #end if |
---|
| 82 | </td> |
---|
| 83 | <td>#slurp |
---|
[144] | 84 | #if $has_vnc[$machine] == True |
---|
[133] | 85 | <a href="vnc?machine_id=$machine.machine_id">Console</a>#slurp |
---|
[424] | 86 | #else if $has_vnc[$machine] != 'Off' |
---|
[144] | 87 | $has_vnc[$machine] |
---|
[133] | 88 | #end if |
---|
| 89 | </td> |
---|
[113] | 90 | <td> |
---|
[207] | 91 | <form action="command" method="post"> |
---|
| 92 | <input type="hidden" name="back" value="list"/> |
---|
[113] | 93 | <input type="hidden" name="machine_id" |
---|
| 94 | value="$machine.machine_id"/> |
---|
[205] | 95 | <input type="submit" class="button" name="action" value="#slurp |
---|
[228] | 96 | #if $machine.uptime then 'Power off' else 'Power on' |
---|
[205] | 97 | "/> |
---|
[113] | 98 | </form> |
---|
| 99 | </td> |
---|
| 100 | </tr> |
---|
[205] | 101 | #end def |
---|
| 102 | |
---|
| 103 | #def machineList($machines) |
---|
| 104 | <table> |
---|
| 105 | <tr> |
---|
[424] | 106 | <th>Name</th> |
---|
| 107 | <th>Memory</th> |
---|
[426] | 108 | <th>Owner$helppopup('owner')</th> |
---|
| 109 | <th>Administrator$helppopup('administrator')</th> |
---|
[424] | 110 | <th>IP</th> |
---|
| 111 | <th>Uptime</th> |
---|
| 112 | <th>VNC</th> |
---|
| 113 | <th></th> |
---|
| 114 | </tr> |
---|
[205] | 115 | #for $machine in $machines: |
---|
| 116 | $machineRow($machine) |
---|
[113] | 117 | #end for |
---|
| 118 | </table> |
---|
[205] | 119 | #end def |
---|
| 120 | |
---|
| 121 | |
---|
| 122 | #def body |
---|
[423] | 123 | <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> |
---|
[205] | 124 | #if not $machines |
---|
| 125 | <p>You don't currently control any VMs.</p> |
---|
[144] | 126 | #end if |
---|
[207] | 127 | <p><a href="list">refresh</a></p> |
---|
[205] | 128 | <div id="machinelist"> |
---|
| 129 | $machineList($machines) |
---|
| 130 | </div> |
---|
[425] | 131 | $createForm() |
---|
[113] | 132 | #end def |
---|