source: package_branches/invirt-web/cherrypy-rebased/code/templates/list.mako @ 2670

Last change on this file since 2670 was 2668, checked in by broder, 15 years ago

Port list to Mako

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