[2405] | 1 | <%page expression_filter="h"/> |
---|
[2395] | 2 | <%inherit file="skeleton.mako" /> |
---|
| 3 | <%! |
---|
| 4 | import datetime |
---|
| 5 | %> |
---|
| 6 | |
---|
| 7 | |
---|
| 8 | <%def name="title()"> |
---|
| 9 | VM List |
---|
| 10 | </%def> |
---|
| 11 | |
---|
| 12 | <%def name="createForm()"> |
---|
| 13 | % if cant_add_vm: |
---|
| 14 | <p>${cant_add_vm}</p> |
---|
| 15 | % else: |
---|
| 16 | <h2>Create a new VM</h2> |
---|
| 17 | % if err: |
---|
| 18 | <p class="error">We had a problem with your request:</p> |
---|
| 19 | % elif new_machine: |
---|
| 20 | <p>Congratulations! You successfully created a new VM called ${new_machine}.</p> |
---|
| 21 | % endif |
---|
| 22 | <form action="create" method="POST"> |
---|
| 23 | <input type="hidden" name="back" value="list"/> |
---|
| 24 | <table> |
---|
[2405] | 25 | ${self.fn.errorRow('create', err)} |
---|
[2395] | 26 | <tr> |
---|
| 27 | <td>Name</td> |
---|
| 28 | <td><input type="text" name="name" value="${defaults.name}"/>.${config.dns.domains[0]}</td> |
---|
| 29 | </tr> |
---|
[2405] | 30 | ${self.fn.errorRow('name', err)} |
---|
[2395] | 31 | <tr> |
---|
| 32 | <td>Description</td> |
---|
| 33 | <td><textarea name="description" rows="4" cols="60">${defaults.description}</textarea></td> |
---|
| 34 | </tr> |
---|
[2405] | 35 | ${self.fn.errorRow('description', err)} |
---|
[2395] | 36 | <tr> |
---|
| 37 | <td>Memory</td> |
---|
| 38 | <td><input type="text" name="memory" value="${defaults.memory}" size=3/> MiB (${max_memory} max)</td> |
---|
| 39 | </tr> |
---|
[2405] | 40 | ${self.fn.errorRow('memory', err)} |
---|
[2395] | 41 | <tr> |
---|
| 42 | <td>Disk</td> |
---|
| 43 | <td><input type="text" name="disksize" value="${defaults.disk}" size=3/> GiB (${"%0.1f" % (max_disk-0.05)} max)</td> |
---|
| 44 | </tr> |
---|
[2405] | 45 | ${self.fn.errorRow('disk', err)} |
---|
[2395] | 46 | <tr> |
---|
[2405] | 47 | <td>HVM/ParaVM${self.fn.helppopup('HVM/ParaVM')}</td> |
---|
[2395] | 48 | <td> |
---|
[2405] | 49 | ${self.fn.vmTypeList(defaults.type)} |
---|
[2395] | 50 | </td> |
---|
| 51 | </tr> |
---|
[2405] | 52 | ${self.fn.errorRow('vmtype', err)} |
---|
| 53 | ${self.fn.errorRow('autoinstall', err)} |
---|
[2395] | 54 | <tr> |
---|
[2405] | 55 | <td>Autoinstall${self.fn.helppopup('Autoinstalls')}</td> |
---|
[2395] | 56 | <td><input type="radio" name="cd_or_auto" id="cd_or_auto_auto" |
---|
| 57 | onchange="\$('cdromlist').value = ''; \$('vmtype-linux').checked = true"> |
---|
[2405] | 58 | ${self.fn.autoList(defaults.cdrom, "$('cd_or_auto_auto').checked = true;$('cdromlist').value = '';$('vmtype-linux').checked = true")} |
---|
[2395] | 59 | (experimental; 2-3 minutes, and you have a machine with empty root password.) |
---|
| 60 | </input> |
---|
| 61 | </tr> |
---|
| 62 | <tr> |
---|
| 63 | <td>Boot CD</td> |
---|
| 64 | <td><input type="radio" name="cd_or_auto" id="cd_or_auto_cd" checked="checked" |
---|
| 65 | onchange="\$('autoinstalllist').value = ''; \$('vmtype-linux-hvm').checked = true"> |
---|
[2405] | 66 | ${self.fn.cdromList(defaults.cdrom, "$('cd_or_auto_cd').checked = true;$('autoinstalllist').value = '';$('vmtype-linux-hvm').checked = true")} |
---|
[2395] | 67 | </td> |
---|
| 68 | </input> |
---|
| 69 | </tr> |
---|
[2405] | 70 | ${self.fn.errorRow('cdrom', err)} |
---|
| 71 | ${self.fn.errorRow('cdrom', err)} |
---|
[2395] | 72 | <tr> |
---|
| 73 | <td>Owner</td> |
---|
| 74 | <td><input type="text" name="owner" value="${defaults.owner}"/></td> |
---|
| 75 | </tr> |
---|
[2405] | 76 | ${self.fn.errorRow('owner', err)} |
---|
[2395] | 77 | </table> |
---|
| 78 | <input type="submit" class="button" value="Create it!"/><br /> |
---|
[2405] | 79 | Windows notes: ${self.fn.helppopup('Windows')} |
---|
[2395] | 80 | </form> |
---|
| 81 | % endif |
---|
| 82 | </%def> |
---|
| 83 | |
---|
| 84 | <%def name="machineRow(machine)"> |
---|
| 85 | <tr> |
---|
| 86 | <td rowspan="2"> |
---|
[2424] | 87 | % if machine.uptime and installing[machine]: |
---|
| 88 | <img src="static/power_installing.png" alt="Installing..." /> |
---|
| 89 | % else: |
---|
[2418] | 90 | <form action="machine/${machine.machine_id}/command/${'shutdown' if machine.uptime else 'create'}" method="post"> |
---|
[2395] | 91 | <input type="hidden" name="back" value="list"/> |
---|
| 92 | <input type="hidden" name="machine_id" |
---|
| 93 | value="${machine.machine_id}"/> |
---|
[2418] | 94 | <input type="submit" class="power ${'on' if machine.uptime else 'off'}" name="action" value="${'Shutdown' if machine.uptime else 'Power on'}"\ |
---|
[2395] | 95 | % if machine.uptime: |
---|
| 96 | onclick="return confirm('Are you sure you want to power off this VM?');" |
---|
| 97 | % endif |
---|
| 98 | /> |
---|
| 99 | </form> |
---|
[2424] | 100 | % endif |
---|
[2395] | 101 | </td> |
---|
[2413] | 102 | <td><a href="machine/${machine.machine_id}">${machine.name}</a></td> |
---|
[2395] | 103 | <td>${machine.memory}M</td> |
---|
| 104 | <td>${machine.owner}</td> |
---|
| 105 | <td>${machine.administrator}</td> |
---|
| 106 | % if machine.nics: |
---|
| 107 | <td>${', '.join(map(lambda x: x.ip, machine.nics))}</td> |
---|
| 108 | % else: |
---|
| 109 | <td></td> |
---|
| 110 | % endif |
---|
| 111 | <td>\ |
---|
| 112 | % if machine.uptime: |
---|
| 113 | ${datetime.timedelta(seconds=int(machine.uptime))}\ |
---|
| 114 | % endif |
---|
| 115 | </td> |
---|
| 116 | <td>\ |
---|
| 117 | % if has_vnc[machine] == True: |
---|
[2413] | 118 | <a href="machine/${machine.machine_id}/vnc">Console</a>\ |
---|
[2412] | 119 | % elif has_vnc[machine] == 'ParaVM': |
---|
| 120 | ParaVM${self.fn.helppopup("ParaVM Console")} |
---|
[2395] | 121 | % elif has_vnc[machine] != 'Off': |
---|
| 122 | ${has_vnc[machine]} |
---|
| 123 | % endif |
---|
| 124 | </td> |
---|
| 125 | </tr> |
---|
| 126 | <tr> |
---|
[2416] | 127 | <td colspan="7" style="padding-left: 1em; color: #666">${machine.description|self.fn.module.nl2br}</td> |
---|
[2395] | 128 | </tr> |
---|
| 129 | </%def> |
---|
| 130 | |
---|
| 131 | <%def name="machineList(machines)"> |
---|
| 132 | <table cellspacing="0" cellpadding="2"> |
---|
| 133 | <tr> |
---|
| 134 | <th></th> |
---|
| 135 | <th>Name</th> |
---|
| 136 | <th>Memory</th> |
---|
[2405] | 137 | <th>Owner${self.fn.helppopup('Owner')}</th> |
---|
| 138 | <th>Administrator${self.fn.helppopup('Administrator')}</th> |
---|
[2395] | 139 | <th>IP</th> |
---|
| 140 | <th>Uptime</th> |
---|
| 141 | <th>VNC</th> |
---|
| 142 | </tr> |
---|
| 143 | % for machine in machines: |
---|
| 144 | ${machineRow(machine)} |
---|
| 145 | % endfor |
---|
| 146 | </table> |
---|
| 147 | <script type="text/javascript" src="/static/stripe.js"></script> |
---|
| 148 | <script type="text/javascript"> |
---|
| 149 | document.observe("dom:loaded", function() { |
---|
| 150 | stripe(\$('machinelist').getElementsByTagName('table')[0], |
---|
| 151 | 'stripedrow'); |
---|
| 152 | }); |
---|
| 153 | </script> |
---|
| 154 | </%def> |
---|
| 155 | |
---|
| 156 | <p style="font-size: 125%;"><a href="http://${config.web.hostname}">What is XVM?</a></p> |
---|
| 157 | % if not machines: |
---|
| 158 | <p>You don't currently control any VMs.</p> |
---|
| 159 | % endif |
---|
| 160 | <p><a href="list">refresh</a></p> |
---|
| 161 | <div id="machinelist"> |
---|
| 162 | ${machineList(machines)} |
---|
| 163 | </div> |
---|
| 164 | ${createForm()} |
---|