Added motd to pages
[invirt/packages/invirt-web.git] / code / templates / info.mako
1 <%page expression_filter="h"/>
2 <%inherit file="skeleton.mako" />
3
4 <%def name="title()">
5 Info on ${machine.name}
6 </%def>
7
8 %if os.path.exists("/etc/invirt/motd.html"):
9 <div class="result">
10 <p class="error">${open('/etc/invirt/motd.html').read()|n}</p>
11 </div>
12 %endif
13
14 <%def name="infoTable()">
15 <h2>Info</h2>
16 <table>
17   % for key, value in fields:
18   <tr><td>${key}:</td><td>${value}</td></tr>
19   % endfor
20   % if on:
21    % if 'monitoring' in config and len(config.monitoring) and 'baseuri' in config.monitoring[0]:
22     <tr><td>CPU history:</td><td><img src="${config.monitoring[0].baseuri}usage.cgi?type=cpu;uuid=${machine.uuid}" alt="Domain CPU usage" /></td></tr>
23    % endif
24   % endif
25 </table>
26 </%def>
27
28 <%def name="commands()">
29 % if on:
30  % if not machine.type.hvm:
31   Console access: type
32   <tt>ssh ${machine.name}@${config.console.hostname}</tt>
33   on Athena. <a href="https://xvm.scripts.mit.edu/wiki/SerialConsole">(more info)</a>
34  % elif has_vnc:
35   <strong><a href="machine/${machine.machine_id}/vnc">Get Console</a></strong>
36  % else:
37   VNC console not enabled; still booting?
38  % endif
39 % endif
40 <%def name="command_button(title, value, cdrom=False, extra='')">
41 <form action="machine/${machine.machine_id}/command/${value}" method="POST">
42   <input type="hidden" name="back" value="info" />
43   <input type="submit" class="button" name="action" value="${title}" ${extra | n}/>
44 % if cdrom:
45   Boot CD: ${self.fn.cdromList()}
46 % endif
47 </form>
48 </%def>
49   <div>
50         % if on:
51         ${command_button("Power off", "destroy")}
52         ${command_button("Shutdown", "shutdown")}
53         ${command_button("Reboot", "reboot", cdrom=True)}
54         % else:
55         ${command_button("Power on", "create", cdrom=True)}
56         % endif
57   </div>
58   <div>
59   ${command_button("Delete VM", "delete", extra='''onclick="return confirm('Are you sure that you want to delete this VM (\\\'%s\\\')?');"''' % (machine.name))}
60   </div>
61 </%def>
62
63 <%def name="modifyForm()">
64 % if err:
65 <p class="error">We had a problem with your request:</p>
66 % elif new_machine:
67 <p>Successfully modified.</p>
68 % endif
69 % if on:
70 (To edit ram, disk size, or machine name, turn off the machine first.)
71 % endif
72 <form action="machine/${machine.machine_id}/modify" method="POST">
73   <table>
74     <tr><td>Description:</td><td colspan="2"><textarea name="description" rows="4" cols="60">${defaults.description}</textarea></td></tr>
75     <tr><td>Owner${self.fn.helppopup("Owner")}:</td><td><input type="text" name="owner", value="${defaults.owner}"/></td></tr>
76 ${self.fn.errorRow('owner', err)}
77     <tr><td>Administrator${self.fn.helppopup("Administrator")}:</td><td><input type="text" name="admin", value="${defaults.administrator}"/></td></tr>
78 ${self.fn.errorRow('administrator', err)}
79     <tr><td>Contact email:</td><td><input type="text" name="contact" value="${defaults.contact}"/></td></tr>
80 ${self.fn.errorRow('contact', err)}
81 % if not on:
82     <tr><td>Machine Name:</td><td><input type="text" name="name" value="${defaults.name}"/>.${config.dns.domains[0]}</td></tr>
83 ${self.fn.errorRow('name', err)}
84     <tr>
85       <td>HVM/ParaVM${self.fn.helppopup('HVM/ParaVM')}</td>
86       <td>${self.fn.vmTypeList(defaults.type)}</td>
87     </tr>
88     <tr><td>Ram:</td><td><input type="text" size=3 name="memory" value="${defaults.memory}"/>MiB (max ${max_mem})</td></tr>
89 ${self.fn.errorRow('memory', err)}
90     <tr><td>Disk:</td><td><input type="text" size=3 name="disksize" value="${defaults.disk}"/>GiB (max ${max_disk})</td><td>WARNING: Modifying disk size may corrupt your data.</td></tr>
91 ${self.fn.errorRow('disk', err)}
92 % else:
93 ${self.fn.errorRow('name', err)}
94 ${self.fn.errorRow('memory', err)}
95 ${self.fn.errorRow('disk', err)}
96 % endif
97     <tr><td><input type="submit" class="button" name="action" value="Change"/></td></tr>
98   </table>
99 </form>
100 </%def>
101
102 <div id="info">
103   ${infoTable()}
104 </div>
105
106 <h2>Commands</h2>
107 <div id="commands">
108   ${commands()}
109 </div>
110 <h2>Settings</h2>
111 <div id="modify">
112   ${modifyForm()}
113 </div>