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