[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> |
---|
[443] | 44 | <td>Autoinstall$helppopup('autoinstall')</td> |
---|
| 45 | <td><input type="radio" name="cd_or_auto" id="cd_or_auto_auto">$autoList($defaults.cdrom, "document.getElementById('cd_or_auto_auto').checked = true;document.getElementById('cdromlist').value = ''") |
---|
| 46 | (experimental; 1-2 minutes, and you have a machine; root pw is 'password'.) |
---|
| 47 | </input> |
---|
[205] | 48 | </tr> |
---|
[228] | 49 | <tr> |
---|
[443] | 50 | <td>Boot CD</td> |
---|
| 51 | <td><input type="radio" name="cd_or_auto" id="cd_or_auto_cd" checked>$cdromList($defaults.cdrom, "document.getElementById('cd_or_auto_cd').checked = true;document.getElementById('autoinstalllist').value = ''")</td> |
---|
| 52 | </input> |
---|
[340] | 53 | </tr> |
---|
| 54 | $errorRow('cdrom', $err) |
---|
[443] | 55 | $errorRow('cdrom', $err) |
---|
[340] | 56 | <tr> |
---|
[228] | 57 | <td>Owner</td> |
---|
| 58 | <td><input type="text" name="owner" value="$defaults.owner"/></td> |
---|
| 59 | </tr> |
---|
| 60 | $errorRow('owner', $err) |
---|
[205] | 61 | </table> |
---|
| 62 | <input type="submit" class="button" value="Create it!"/> |
---|
| 63 | </form> |
---|
| 64 | #end if |
---|
| 65 | #end def |
---|
| 66 | |
---|
| 67 | #def machineRow($machine) |
---|
[113] | 68 | <tr> |
---|
| 69 | <td><a href="info?machine_id=$machine.machine_id">$machine.name</a></td> |
---|
| 70 | <td>${machine.memory}M</td> |
---|
| 71 | <td>$machine.owner</td> |
---|
[234] | 72 | <td>$machine.administrator</td> |
---|
[113] | 73 | #if $machine.nics |
---|
| 74 | #set $nic = $machine.nics[0] |
---|
| 75 | <td>$nic.ip</td> |
---|
| 76 | #else |
---|
| 77 | <td></td> |
---|
| 78 | #end if |
---|
[133] | 79 | <td>#slurp |
---|
[205] | 80 | #if $machine.uptime |
---|
| 81 | $machine.uptime#slurp |
---|
[133] | 82 | #end if |
---|
| 83 | </td> |
---|
| 84 | <td>#slurp |
---|
[144] | 85 | #if $has_vnc[$machine] == True |
---|
[133] | 86 | <a href="vnc?machine_id=$machine.machine_id">Console</a>#slurp |
---|
[424] | 87 | #else if $has_vnc[$machine] != 'Off' |
---|
[144] | 88 | $has_vnc[$machine] |
---|
[133] | 89 | #end if |
---|
| 90 | </td> |
---|
[113] | 91 | <td> |
---|
[207] | 92 | <form action="command" method="post"> |
---|
| 93 | <input type="hidden" name="back" value="list"/> |
---|
[113] | 94 | <input type="hidden" name="machine_id" |
---|
| 95 | value="$machine.machine_id"/> |
---|
[205] | 96 | <input type="submit" class="button" name="action" value="#slurp |
---|
[228] | 97 | #if $machine.uptime then 'Power off' else 'Power on' |
---|
[205] | 98 | "/> |
---|
[113] | 99 | </form> |
---|
| 100 | </td> |
---|
| 101 | </tr> |
---|
[205] | 102 | #end def |
---|
| 103 | |
---|
| 104 | #def machineList($machines) |
---|
| 105 | <table> |
---|
| 106 | <tr> |
---|
[424] | 107 | <th>Name</th> |
---|
| 108 | <th>Memory</th> |
---|
[426] | 109 | <th>Owner$helppopup('owner')</th> |
---|
| 110 | <th>Administrator$helppopup('administrator')</th> |
---|
[424] | 111 | <th>IP</th> |
---|
| 112 | <th>Uptime</th> |
---|
| 113 | <th>VNC</th> |
---|
| 114 | <th></th> |
---|
| 115 | </tr> |
---|
[205] | 116 | #for $machine in $machines: |
---|
| 117 | $machineRow($machine) |
---|
[113] | 118 | #end for |
---|
| 119 | </table> |
---|
[205] | 120 | #end def |
---|
| 121 | |
---|
| 122 | |
---|
| 123 | #def body |
---|
[423] | 124 | <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] | 125 | #if not $machines |
---|
| 126 | <p>You don't currently control any VMs.</p> |
---|
[144] | 127 | #end if |
---|
[207] | 128 | <p><a href="list">refresh</a></p> |
---|
[205] | 129 | <div id="machinelist"> |
---|
| 130 | $machineList($machines) |
---|
| 131 | </div> |
---|
[425] | 132 | $createForm() |
---|
[113] | 133 | #end def |
---|