[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> |
---|
[621] | 28 | <td><input type="text" name="name" value="$defaults.name"/>.xvm.mit.edu</td> |
---|
[205] | 29 | </tr> |
---|
[447] | 30 | #filter None |
---|
[205] | 31 | $errorRow('name', $err) |
---|
[447] | 32 | #end filter |
---|
[205] | 33 | <tr> |
---|
[609] | 34 | <td>Description</td> |
---|
| 35 | <td><textarea name="description" rows="4" cols="60">$defaults.description</textarea></td> |
---|
| 36 | </tr> |
---|
| 37 | #filter None |
---|
| 38 | $errorRow('description', $err) |
---|
| 39 | #end filter |
---|
| 40 | <tr> |
---|
[205] | 41 | <td>Memory</td> |
---|
[229] | 42 | <td><input type="text" name="memory" value="$defaults.memory" size=3/> MiB ($max_memory max)</td> |
---|
[205] | 43 | </tr> |
---|
[447] | 44 | #filter None |
---|
[205] | 45 | $errorRow('memory', $err) |
---|
[447] | 46 | #end filter |
---|
[205] | 47 | <tr> |
---|
| 48 | <td>Disk</td> |
---|
[572] | 49 | <td><input type="text" name="disksize" value="$defaults.disk" size=3/> GiB (${"%0.1f" % ($max_disk-0.05)} max)</td> |
---|
[205] | 50 | </tr> |
---|
[447] | 51 | #filter None |
---|
[205] | 52 | $errorRow('disk', $err) |
---|
[447] | 53 | #end filter |
---|
[440] | 54 | <tr> |
---|
[447] | 55 | <td>HVM/ParaVM#slurp |
---|
| 56 | #filter None |
---|
[536] | 57 | $helppopup('HVM/ParaVM')#slurp |
---|
[447] | 58 | #end filter |
---|
| 59 | </td> |
---|
| 60 | <td> |
---|
| 61 | #filter None |
---|
| 62 | $vmTypeList($defaults.type) |
---|
| 63 | #end filter |
---|
| 64 | </td> |
---|
[440] | 65 | </tr> |
---|
[447] | 66 | #filter None |
---|
[205] | 67 | $errorRow('vmtype', $err) |
---|
[447] | 68 | #end filter |
---|
[448] | 69 | #filter None |
---|
| 70 | $errorRow('autoinstall', $err) |
---|
| 71 | #end filter |
---|
[629] | 72 | <tr> |
---|
[447] | 73 | <td>Autoinstall#slurp |
---|
| 74 | #filter None |
---|
[536] | 75 | $helppopup('Autoinstall')#slurp |
---|
[447] | 76 | #end filter |
---|
| 77 | </td> |
---|
| 78 | <td><input type="radio" name="cd_or_auto" id="cd_or_auto_auto"> |
---|
| 79 | #filter None |
---|
| 80 | $autoList($defaults.cdrom, "document.getElementById('cd_or_auto_auto').checked = true;document.getElementById('cdromlist').value = ''") |
---|
[443] | 81 | (experimental; 1-2 minutes, and you have a machine; root pw is 'password'.) |
---|
[447] | 82 | #end filter |
---|
[443] | 83 | </input> |
---|
[629] | 84 | </tr> |
---|
[228] | 85 | <tr> |
---|
[443] | 86 | <td>Boot CD</td> |
---|
[447] | 87 | <td><input type="radio" name="cd_or_auto" id="cd_or_auto_cd" checked> |
---|
| 88 | #filter None |
---|
| 89 | $cdromList($defaults.cdrom, "document.getElementById('cd_or_auto_cd').checked = true;document.getElementById('autoinstalllist').value = ''") |
---|
| 90 | #end filter |
---|
| 91 | </td> |
---|
[443] | 92 | </input> |
---|
[340] | 93 | </tr> |
---|
| 94 | $errorRow('cdrom', $err) |
---|
[443] | 95 | $errorRow('cdrom', $err) |
---|
[340] | 96 | <tr> |
---|
[228] | 97 | <td>Owner</td> |
---|
| 98 | <td><input type="text" name="owner" value="$defaults.owner"/></td> |
---|
| 99 | </tr> |
---|
[447] | 100 | #filter None |
---|
[228] | 101 | $errorRow('owner', $err) |
---|
[447] | 102 | #end filter |
---|
[205] | 103 | </table> |
---|
| 104 | <input type="submit" class="button" value="Create it!"/> |
---|
| 105 | </form> |
---|
| 106 | #end if |
---|
| 107 | #end def |
---|
| 108 | |
---|
| 109 | #def machineRow($machine) |
---|
[113] | 110 | <tr> |
---|
[618] | 111 | <td rowspan="2"> |
---|
| 112 | <form action="command" method="post"> |
---|
| 113 | <input type="hidden" name="back" value="list"/> |
---|
| 114 | <input type="hidden" name="machine_id" |
---|
| 115 | value="$machine.machine_id"/> |
---|
[639] | 116 | <input type="image" class="power #slurp |
---|
| 117 | #if $machine.uptime then 'on' else 'off' |
---|
| 118 | " name="action" value="#slurp |
---|
[618] | 119 | #if $machine.uptime then 'Power off' else 'Power on' |
---|
[639] | 120 | " src="#slurp |
---|
| 121 | #if $machine.uptime then 'static/power_button_on.png' else 'static/power_button_off.png' |
---|
[618] | 122 | "/> |
---|
| 123 | </form> |
---|
| 124 | </td> |
---|
[113] | 125 | <td><a href="info?machine_id=$machine.machine_id">$machine.name</a></td> |
---|
| 126 | <td>${machine.memory}M</td> |
---|
| 127 | <td>$machine.owner</td> |
---|
[234] | 128 | <td>$machine.administrator</td> |
---|
[113] | 129 | #if $machine.nics |
---|
| 130 | #set $nic = $machine.nics[0] |
---|
| 131 | <td>$nic.ip</td> |
---|
| 132 | #else |
---|
| 133 | <td></td> |
---|
| 134 | #end if |
---|
[133] | 135 | <td>#slurp |
---|
[205] | 136 | #if $machine.uptime |
---|
[535] | 137 | ${datetime.timedelta(seconds=int(machine.uptime))}#slurp |
---|
[133] | 138 | #end if |
---|
| 139 | </td> |
---|
| 140 | <td>#slurp |
---|
[144] | 141 | #if $has_vnc[$machine] == True |
---|
[133] | 142 | <a href="vnc?machine_id=$machine.machine_id">Console</a>#slurp |
---|
[424] | 143 | #else if $has_vnc[$machine] != 'Off' |
---|
[447] | 144 | #filter None |
---|
[144] | 145 | $has_vnc[$machine] |
---|
[447] | 146 | #end filter |
---|
[133] | 147 | #end if |
---|
| 148 | </td> |
---|
[113] | 149 | </tr> |
---|
[609] | 150 | <tr> |
---|
| 151 | <td colspan="7" style="padding-left: 1em; color: #666">$machine.description</td> |
---|
| 152 | </tr> |
---|
[205] | 153 | #end def |
---|
| 154 | |
---|
| 155 | #def machineList($machines) |
---|
[618] | 156 | <table cellspacing="0" cellpadding="2"> |
---|
[205] | 157 | <tr> |
---|
[618] | 158 | <th></th> |
---|
[424] | 159 | <th>Name</th> |
---|
| 160 | <th>Memory</th> |
---|
[447] | 161 | <th>Owner#slurp |
---|
| 162 | #filter None |
---|
[536] | 163 | $helppopup('Owner')#slurp |
---|
[447] | 164 | #end filter |
---|
| 165 | </th> |
---|
| 166 | <th>Administrator#slurp |
---|
| 167 | #filter None |
---|
[536] | 168 | $helppopup('Administrator')#slurp |
---|
[447] | 169 | #end filter |
---|
| 170 | </th> |
---|
[424] | 171 | <th>IP</th> |
---|
| 172 | <th>Uptime</th> |
---|
| 173 | <th>VNC</th> |
---|
| 174 | </tr> |
---|
[205] | 175 | #for $machine in $machines: |
---|
[447] | 176 | #filter None |
---|
[205] | 177 | $machineRow($machine) |
---|
[447] | 178 | #end filter |
---|
[113] | 179 | #end for |
---|
| 180 | </table> |
---|
[618] | 181 | <script type="text/javascript" src="/static/stripe.js"></script> |
---|
| 182 | <script type="text/javascript"> |
---|
| 183 | document.observe("dom:loaded", function() { |
---|
| 184 | stripe(\$('machinelist').getElementsByTagName('table')[0], |
---|
| 185 | 'stripedrow'); |
---|
| 186 | }); |
---|
| 187 | </script> |
---|
[205] | 188 | #end def |
---|
| 189 | |
---|
| 190 | |
---|
| 191 | #def body |
---|
[423] | 192 | <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] | 193 | #if not $machines |
---|
| 194 | <p>You don't currently control any VMs.</p> |
---|
[144] | 195 | #end if |
---|
[207] | 196 | <p><a href="list">refresh</a></p> |
---|
[205] | 197 | <div id="machinelist"> |
---|
[447] | 198 | #filter None |
---|
[205] | 199 | $machineList($machines) |
---|
[447] | 200 | #end filter |
---|
[205] | 201 | </div> |
---|
[447] | 202 | #filter None |
---|
[425] | 203 | $createForm() |
---|
[447] | 204 | #end filter |
---|
[113] | 205 | #end def |
---|