source: trunk/packages/invirt-web/code/templates/list.mako @ 2792

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

The <input /> tag is always empty, so having a separate closing
</input> tag is meaningless.

File size: 5.0 KB
Line 
1<%page expression_filter="h"/>
2<%inherit file="skeleton.mako" />
3<%!
4        import datetime
5%>
6
7
8<%def name="title()">
9VM 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>
56          <td><input type="radio" name="cd_or_auto" id="cd_or_auto_auto"
57                 onchange="$('cdromlist').value = ''; $('vmtype-linux').checked = true" />
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.)
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${self.fn.cdromList(defaults.cdrom, "$('cd_or_auto_cd').checked = true;$('autoinstalllist').value = '';$('vmtype-linux-hvm').checked = true")}
66</td>
67        </tr>
68        ${self.fn.errorRow('cdrom', err)}
69        ${self.fn.errorRow('cdrom', err)}
70        <tr>
71          <td>Owner</td>
72          <td><input type="text" name="owner" value="${defaults.owner}"/></td>
73        </tr>
74        ${self.fn.errorRow('owner', err)}
75      </table>
76      <input type="submit" class="button" value="Create it!"/><br />
77      Windows notes: ${self.fn.helppopup('Windows')}
78    </form>
79% endif
80</%def>
81
82<%def name="machineRow(machine)">
83      <tr>
84        <td rowspan="2">
85        % if machine.uptime and installing[machine]:
86        <img src="static/power_installing.png" alt="Installing..." />
87        % else:
88          <form action="machine/${machine.machine_id}/command/${'shutdown' if machine.uptime else 'create'}" 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="${'Shutdown' 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          % endif
99        </td>
100        <td><a href="machine/${machine.machine_id}">${machine.name}</a></td>
101        <td>${machine.memory}M</td>
102        <td>${machine.owner}</td>
103        <td>${machine.administrator}</td>
104% if machine.nics:
105        <td>${', '.join(nic.ip for nic in machine.nics)}</td>
106% else:
107        <td></td>
108% endif
109<td>\
110% if machine.uptime:
111${datetime.timedelta(seconds=int(machine.uptime))}\
112% endif
113</td>
114        <td>\
115% if has_vnc[machine] == True:
116<a href="machine/${machine.machine_id}/vnc">Console</a>\
117% elif has_vnc[machine] == 'ParaVM':
118ParaVM${self.fn.helppopup("ParaVM Console")}
119% elif has_vnc[machine] != 'Off':
120${has_vnc[machine]}
121% endif
122</td>
123      </tr>
124      <tr>
125        <td colspan="7" style="padding-left: 1em; color: #666">${machine.description|self.fn.module.nl2br}</td>
126      </tr>
127</%def>
128
129<%def name="machineList(machines)">
130    <table cellspacing="0" cellpadding="2">
131      <tr>
132        <th></th>
133        <th>Name</th>
134        <th>Memory</th>
135        <th>Owner${self.fn.helppopup('Owner')}</th>
136        <th>Administrator${self.fn.helppopup('Administrator')}</th>
137        <th>IP</th>
138        <th>Uptime</th>
139        <th>VNC</th>
140      </tr>
141% for machine in machines:
142        ${machineRow(machine)}
143% endfor
144    </table>
145    <script type="text/javascript" src="/static/stripe.js"></script>
146    <script type="text/javascript">
147        document.observe("dom:loaded", function() {
148            stripe($('machinelist').getElementsByTagName('table')[0],
149                   'stripedrow');
150        });
151    </script>
152</%def>
153
154<p style="font-size: 125%;"><a href="http://${config.web.hostname}">What is XVM?</a></p>
155% if not machines:
156<p>You don't currently control any VMs.</p>  
157% endif
158    <p><a href="list">refresh</a></p>
159    <div id="machinelist">
160    ${machineList(machines)}
161    </div>
162${createForm()}
Note: See TracBrowser for help on using the repository browser.