[2668] | 1 | <%page expression_filter="h"/> |
---|
| 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> |
---|
| 25 | ${self.fn.errorRow('create', err)} |
---|
| 26 | <tr> |
---|
| 27 | <td>Name</td> |
---|
| 28 | <td><input type="text" name="name" value="${defaults.name}"/>.${config.dns.domains[0]}</td> |
---|
| 29 | </tr> |
---|
| 30 | ${self.fn.errorRow('name', err)} |
---|
| 31 | <tr> |
---|
| 32 | <td>Description</td> |
---|
| 33 | <td><textarea name="description" rows="4" cols="60">${defaults.description}</textarea></td> |
---|
| 34 | </tr> |
---|
| 35 | ${self.fn.errorRow('description', err)} |
---|
| 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> |
---|
| 40 | ${self.fn.errorRow('memory', err)} |
---|
| 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> |
---|
| 45 | ${self.fn.errorRow('disk', err)} |
---|
| 46 | <tr> |
---|
| 47 | <td>HVM/ParaVM${self.fn.helppopup('HVM/ParaVM')}</td> |
---|
| 48 | <td> |
---|
| 49 | ${self.fn.vmTypeList(defaults.type)} |
---|
| 50 | </td> |
---|
| 51 | </tr> |
---|
| 52 | ${self.fn.errorRow('vmtype', err)} |
---|
| 53 | ${self.fn.errorRow('autoinstall', err)} |
---|
| 54 | <tr> |
---|
| 55 | <td>Autoinstall${self.fn.helppopup('Autoinstalls')}</td> |
---|
[2794] | 56 | <td><label><input type="radio" name="cd_or_auto" id="cd_or_auto_auto" |
---|
[2792] | 57 | onchange="$('cdromlist').value = ''; $('vmtype-linux').checked = true" /> |
---|
[2668] | 58 | ${self.fn.autoList(defaults.cdrom, "$('cd_or_auto_auto').checked = true;$('cdromlist').value = '';$('vmtype-linux').checked = true")} |
---|
| 59 | (experimental; 2-3 minutes, and you have a machine with empty root password.) |
---|
[2794] | 60 | </label></td> |
---|
[2668] | 61 | </tr> |
---|
| 62 | <tr> |
---|
| 63 | <td>Boot CD</td> |
---|
[2794] | 64 | <td><label><input type="radio" name="cd_or_auto" id="cd_or_auto_cd" checked="checked" |
---|
[2792] | 65 | onchange="$('autoinstalllist').value = ''; $('vmtype-linux-hvm').checked = true" /> |
---|
[2668] | 66 | ${self.fn.cdromList(defaults.cdrom, "$('cd_or_auto_cd').checked = true;$('autoinstalllist').value = '';$('vmtype-linux-hvm').checked = true")} |
---|
[2794] | 67 | </label></td> |
---|
[2668] | 68 | </tr> |
---|
| 69 | ${self.fn.errorRow('cdrom', err)} |
---|
| 70 | ${self.fn.errorRow('cdrom', err)} |
---|
| 71 | <tr> |
---|
| 72 | <td>Owner</td> |
---|
| 73 | <td><input type="text" name="owner" value="${defaults.owner}"/></td> |
---|
| 74 | </tr> |
---|
| 75 | ${self.fn.errorRow('owner', err)} |
---|
| 76 | </table> |
---|
| 77 | <input type="submit" class="button" value="Create it!"/><br /> |
---|
| 78 | Windows notes: ${self.fn.helppopup('Windows')} |
---|
| 79 | </form> |
---|
| 80 | % endif |
---|
| 81 | </%def> |
---|
| 82 | |
---|
[2796] | 83 | <%def name="machineRow(machine, dark)"> |
---|
| 84 | <tr\ |
---|
| 85 | % if dark: |
---|
| 86 | class="stripedrow" \ |
---|
| 87 | % endif |
---|
| 88 | > |
---|
[2668] | 89 | <td rowspan="2"> |
---|
[2687] | 90 | % if machine.uptime and installing[machine]: |
---|
| 91 | <img src="static/power_installing.png" alt="Installing..." /> |
---|
| 92 | % else: |
---|
[2684] | 93 | <form action="machine/${machine.machine_id}/command/${'shutdown' if machine.uptime else 'create'}" method="post"> |
---|
[2668] | 94 | <input type="hidden" name="back" value="list"/> |
---|
| 95 | <input type="hidden" name="machine_id" |
---|
| 96 | value="${machine.machine_id}"/> |
---|
[2684] | 97 | <input type="submit" class="power ${'on' if machine.uptime else 'off'}" name="action" value="${'Shutdown' if machine.uptime else 'Power on'}"\ |
---|
[2668] | 98 | % if machine.uptime: |
---|
| 99 | onclick="return confirm('Are you sure you want to power off this VM?');" |
---|
| 100 | % endif |
---|
| 101 | /> |
---|
| 102 | </form> |
---|
[2687] | 103 | % endif |
---|
[2668] | 104 | </td> |
---|
[2678] | 105 | <td><a href="machine/${machine.machine_id}">${machine.name}</a></td> |
---|
[2668] | 106 | <td>${machine.memory}M</td> |
---|
| 107 | <td>${machine.owner}</td> |
---|
| 108 | <td>${machine.administrator}</td> |
---|
| 109 | % if machine.nics: |
---|
[2719] | 110 | <td>${', '.join(nic.ip for nic in machine.nics)}</td> |
---|
[2668] | 111 | % else: |
---|
| 112 | <td></td> |
---|
| 113 | % endif |
---|
| 114 | <td>\ |
---|
| 115 | % if machine.uptime: |
---|
| 116 | ${datetime.timedelta(seconds=int(machine.uptime))}\ |
---|
| 117 | % endif |
---|
| 118 | </td> |
---|
| 119 | <td>\ |
---|
| 120 | % if has_vnc[machine] == True: |
---|
[2678] | 121 | <a href="machine/${machine.machine_id}/vnc">Console</a>\ |
---|
| 122 | % elif has_vnc[machine] == 'ParaVM': |
---|
| 123 | ParaVM${self.fn.helppopup("ParaVM Console")} |
---|
[2668] | 124 | % elif has_vnc[machine] != 'Off': |
---|
| 125 | ${has_vnc[machine]} |
---|
| 126 | % endif |
---|
| 127 | </td> |
---|
| 128 | </tr> |
---|
[2797] | 129 | <tr\ |
---|
| 130 | % if dark: |
---|
| 131 | class="stripedrow" \ |
---|
| 132 | % endif |
---|
| 133 | > |
---|
[2682] | 134 | <td colspan="7" style="padding-left: 1em; color: #666">${machine.description|self.fn.module.nl2br}</td> |
---|
[2668] | 135 | </tr> |
---|
| 136 | </%def> |
---|
| 137 | |
---|
| 138 | <%def name="machineList(machines)"> |
---|
| 139 | <table cellspacing="0" cellpadding="2"> |
---|
| 140 | <tr> |
---|
| 141 | <th></th> |
---|
| 142 | <th>Name</th> |
---|
| 143 | <th>Memory</th> |
---|
| 144 | <th>Owner${self.fn.helppopup('Owner')}</th> |
---|
| 145 | <th>Administrator${self.fn.helppopup('Administrator')}</th> |
---|
| 146 | <th>IP</th> |
---|
| 147 | <th>Uptime</th> |
---|
| 148 | <th>VNC</th> |
---|
| 149 | </tr> |
---|
[2796] | 150 | % for n, machine in enumerate(machines): |
---|
| 151 | ${machineRow(machine, (n%2)==0)} |
---|
[2668] | 152 | % endfor |
---|
| 153 | </table> |
---|
| 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()} |
---|