[113] | 1 | #from skeleton import skeleton |
---|
| 2 | #extends skeleton |
---|
[535] | 3 | #import datetime |
---|
[113] | 4 | |
---|
[205] | 5 | |
---|
[113] | 6 | #def title |
---|
[422] | 7 | VM List |
---|
[113] | 8 | #end def |
---|
| 9 | |
---|
[425] | 10 | #def createForm() |
---|
[205] | 11 | #if $cant_add_vm |
---|
| 12 | <p>$cant_add_vm</p> |
---|
[113] | 13 | #else |
---|
[425] | 14 | <h2>Create a new VM</h2> |
---|
[205] | 15 | #if $err |
---|
| 16 | <p class="error">We had a problem with your request:</p> |
---|
| 17 | #else if $varExists('new_machine') |
---|
| 18 | <p>Congratulations! You successfully created a new VM called $new_machine.</p> |
---|
| 19 | #end if |
---|
[207] | 20 | <form action="create" method="POST"> |
---|
| 21 | <input type="hidden" name="back" value="list"/> |
---|
[205] | 22 | <table> |
---|
[447] | 23 | #filter None |
---|
[205] | 24 | $errorRow('create', $err) |
---|
[447] | 25 | #end filter |
---|
[205] | 26 | <tr> |
---|
| 27 | <td>Name</td> |
---|
| 28 | <td><input type="text" name="name" value="$defaults.name"/></td> |
---|
| 29 | </tr> |
---|
[447] | 30 | #filter None |
---|
[205] | 31 | $errorRow('name', $err) |
---|
[447] | 32 | #end filter |
---|
[205] | 33 | <tr> |
---|
| 34 | <td>Memory</td> |
---|
[229] | 35 | <td><input type="text" name="memory" value="$defaults.memory" size=3/> MiB ($max_memory max)</td> |
---|
[205] | 36 | </tr> |
---|
[447] | 37 | #filter None |
---|
[205] | 38 | $errorRow('memory', $err) |
---|
[447] | 39 | #end filter |
---|
[205] | 40 | <tr> |
---|
| 41 | <td>Disk</td> |
---|
[229] | 42 | <td><input type="text" name="disk" value="$defaults.disk" size=3/> GiB (${"%0.1f" % ($max_disk-0.05)} max)</td> |
---|
[205] | 43 | </tr> |
---|
[447] | 44 | #filter None |
---|
[205] | 45 | $errorRow('disk', $err) |
---|
[447] | 46 | #end filter |
---|
[440] | 47 | <tr> |
---|
[447] | 48 | <td>HVM/ParaVM#slurp |
---|
| 49 | #filter None |
---|
| 50 | $helppopup('hvm_paravm')#slurp |
---|
| 51 | #end filter |
---|
| 52 | </td> |
---|
| 53 | <td> |
---|
| 54 | #filter None |
---|
| 55 | $vmTypeList($defaults.type) |
---|
| 56 | #end filter |
---|
| 57 | </td> |
---|
[440] | 58 | </tr> |
---|
[447] | 59 | #filter None |
---|
[205] | 60 | $errorRow('vmtype', $err) |
---|
[447] | 61 | #end filter |
---|
[448] | 62 | <tr> |
---|
| 63 | <td>Clone image?</td> |
---|
| 64 | <td><input type="checkbox" name="clone_from" id="clone_from" value="ice3" onchange="onclone(event)"/> |
---|
| 65 | (experimental; 1-2 minutes, and you have an etch machine; root pw is 'password'.) |
---|
| 66 | <script type='text/javascript'>function onclone(e){ document.getElementById('cdromlist').value = ''; }</script></td> |
---|
| 67 | </tr> |
---|
| 68 | #filter None |
---|
| 69 | $errorRow('autoinstall', $err) |
---|
| 70 | #end filter |
---|
| 71 | <!--<tr> |
---|
[447] | 72 | <td>Autoinstall#slurp |
---|
| 73 | #filter None |
---|
| 74 | $helppopup('autoinstall')#slurp |
---|
| 75 | #end filter |
---|
| 76 | </td> |
---|
| 77 | <td><input type="radio" name="cd_or_auto" id="cd_or_auto_auto"> |
---|
| 78 | #filter None |
---|
| 79 | $autoList($defaults.cdrom, "document.getElementById('cd_or_auto_auto').checked = true;document.getElementById('cdromlist').value = ''") |
---|
[443] | 80 | (experimental; 1-2 minutes, and you have a machine; root pw is 'password'.) |
---|
[447] | 81 | #end filter |
---|
[443] | 82 | </input> |
---|
[448] | 83 | </tr>--> |
---|
[228] | 84 | <tr> |
---|
[443] | 85 | <td>Boot CD</td> |
---|
[447] | 86 | <td><input type="radio" name="cd_or_auto" id="cd_or_auto_cd" checked> |
---|
| 87 | #filter None |
---|
| 88 | $cdromList($defaults.cdrom, "document.getElementById('cd_or_auto_cd').checked = true;document.getElementById('autoinstalllist').value = ''") |
---|
| 89 | #end filter |
---|
| 90 | </td> |
---|
[443] | 91 | </input> |
---|
[340] | 92 | </tr> |
---|
| 93 | $errorRow('cdrom', $err) |
---|
[443] | 94 | $errorRow('cdrom', $err) |
---|
[340] | 95 | <tr> |
---|
[228] | 96 | <td>Owner</td> |
---|
| 97 | <td><input type="text" name="owner" value="$defaults.owner"/></td> |
---|
| 98 | </tr> |
---|
[447] | 99 | #filter None |
---|
[228] | 100 | $errorRow('owner', $err) |
---|
[447] | 101 | #end filter |
---|
[205] | 102 | </table> |
---|
| 103 | <input type="submit" class="button" value="Create it!"/> |
---|
| 104 | </form> |
---|
| 105 | #end if |
---|
| 106 | #end def |
---|
| 107 | |
---|
| 108 | #def machineRow($machine) |
---|
[113] | 109 | <tr> |
---|
| 110 | <td><a href="info?machine_id=$machine.machine_id">$machine.name</a></td> |
---|
| 111 | <td>${machine.memory}M</td> |
---|
| 112 | <td>$machine.owner</td> |
---|
[234] | 113 | <td>$machine.administrator</td> |
---|
[113] | 114 | #if $machine.nics |
---|
| 115 | #set $nic = $machine.nics[0] |
---|
| 116 | <td>$nic.ip</td> |
---|
| 117 | #else |
---|
| 118 | <td></td> |
---|
| 119 | #end if |
---|
[133] | 120 | <td>#slurp |
---|
[205] | 121 | #if $machine.uptime |
---|
[535] | 122 | ${datetime.timedelta(seconds=int(machine.uptime))}#slurp |
---|
[133] | 123 | #end if |
---|
| 124 | </td> |
---|
| 125 | <td>#slurp |
---|
[144] | 126 | #if $has_vnc[$machine] == True |
---|
[133] | 127 | <a href="vnc?machine_id=$machine.machine_id">Console</a>#slurp |
---|
[424] | 128 | #else if $has_vnc[$machine] != 'Off' |
---|
[447] | 129 | #filter None |
---|
[144] | 130 | $has_vnc[$machine] |
---|
[447] | 131 | #end filter |
---|
[133] | 132 | #end if |
---|
| 133 | </td> |
---|
[113] | 134 | <td> |
---|
[207] | 135 | <form action="command" method="post"> |
---|
| 136 | <input type="hidden" name="back" value="list"/> |
---|
[113] | 137 | <input type="hidden" name="machine_id" |
---|
| 138 | value="$machine.machine_id"/> |
---|
[205] | 139 | <input type="submit" class="button" name="action" value="#slurp |
---|
[228] | 140 | #if $machine.uptime then 'Power off' else 'Power on' |
---|
[205] | 141 | "/> |
---|
[113] | 142 | </form> |
---|
| 143 | </td> |
---|
| 144 | </tr> |
---|
[205] | 145 | #end def |
---|
| 146 | |
---|
| 147 | #def machineList($machines) |
---|
| 148 | <table> |
---|
| 149 | <tr> |
---|
[424] | 150 | <th>Name</th> |
---|
| 151 | <th>Memory</th> |
---|
[447] | 152 | <th>Owner#slurp |
---|
| 153 | #filter None |
---|
| 154 | $helppopup('owner')#slurp |
---|
| 155 | #end filter |
---|
| 156 | </th> |
---|
| 157 | <th>Administrator#slurp |
---|
| 158 | #filter None |
---|
| 159 | $helppopup('administrator')#slurp |
---|
| 160 | #end filter |
---|
| 161 | </th> |
---|
[424] | 162 | <th>IP</th> |
---|
| 163 | <th>Uptime</th> |
---|
| 164 | <th>VNC</th> |
---|
| 165 | <th></th> |
---|
| 166 | </tr> |
---|
[205] | 167 | #for $machine in $machines: |
---|
[447] | 168 | #filter None |
---|
[205] | 169 | $machineRow($machine) |
---|
[447] | 170 | #end filter |
---|
[113] | 171 | #end for |
---|
| 172 | </table> |
---|
[205] | 173 | #end def |
---|
| 174 | |
---|
| 175 | |
---|
| 176 | #def body |
---|
[423] | 177 | <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] | 178 | #if not $machines |
---|
| 179 | <p>You don't currently control any VMs.</p> |
---|
[144] | 180 | #end if |
---|
[207] | 181 | <p><a href="list">refresh</a></p> |
---|
[205] | 182 | <div id="machinelist"> |
---|
[447] | 183 | #filter None |
---|
[205] | 184 | $machineList($machines) |
---|
[447] | 185 | #end filter |
---|
[205] | 186 | </div> |
---|
[447] | 187 | #filter None |
---|
[425] | 188 | $createForm() |
---|
[447] | 189 | #end filter |
---|
[113] | 190 | #end def |
---|