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

Last change on this file since 2404 was 2403, checked in by quentin, 15 years ago

Use global imports for Mako templates

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