Add button to trigger renumbering
[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     <tr><td>Network history:</td><td><img src="${config.monitoring[0].baseuri}usage.cgi?type=net;uuid=${machine.uuid}" alt="Domain network usage" /></td></tr>
24    % endif
25   % endif
26 </table>
27 </%def>
28
29 <%def name="commands()">
30 % if on:
31  % if not machine.type.hvm:
32   Console access: type
33   <tt>ssh ${machine.name}@${config.console.hostname}</tt>
34   on Athena. <a href="https://xvm.scripts.mit.edu/wiki/SerialConsole">(more info)</a>
35  % elif has_vnc:
36   <strong><a href="machine/${machine.machine_id}/vnc">Get Console</a></strong>
37  % else:
38   VNC console not enabled; still booting?
39  % endif
40 % endif
41 <%def name="command_button(title, value, cdrom=False, extra='')">
42 <form action="machine/${machine.machine_id}/command/${value}" method="POST">
43   <input type="hidden" name="back" value="info" />
44   <input type="submit" class="button" name="action" value="${title}" ${extra | n}/>
45 % if cdrom:
46   Boot CD: ${self.fn.cdromList()}
47 % endif
48 </form>
49 </%def>
50   % if renumber:
51   <div>
52   <p>This machine's IP address is slated for removal. Your machine's new IP address, netmask, and gateway are shown above. Please configure your machine for DHCP or update the machine's configuration and then press this button:</p>
53     % if on:
54     ${command_button("Power cycle and renumber", "renumber")
55     % else:
56     ${command_button("Renumber", "renumber")
57     % endif
58   </div>
59   % endif
60   <div>
61         % if on:
62         ${command_button("Power off", "destroy")}
63         ${command_button("Shutdown", "shutdown")}
64         ${command_button("Reboot", "reboot", cdrom=True)}
65         % else:
66         ${command_button("Power on", "create", cdrom=True)}
67         % endif
68   </div>
69   <div>
70   ${command_button("Delete VM", "delete", extra='''onclick="return confirm('Are you sure that you want to delete this VM (\\\'%s\\\')?');"''' % (machine.name))}
71   </div>
72 </%def>
73
74 <%def name="modifyForm()">
75 % if err:
76 <p class="error">We had a problem with your request:</p>
77 % elif new_machine:
78 <p>Successfully modified.</p>
79 % endif
80 % if on:
81 (To edit ram, disk size, or machine name, turn off the machine first.)
82 % endif
83 <form action="machine/${machine.machine_id}/modify" method="POST">
84   <table>
85     <tr><td>Description:</td><td colspan="2"><textarea name="description" rows="4" cols="60">${defaults.description}</textarea></td></tr>
86     <tr><td>Owner${self.fn.helppopup("Owner")}:</td><td><input type="text" name="owner", value="${defaults.owner}"/></td></tr>
87 ${self.fn.errorRow('owner', err)}
88     <tr><td>Administrator${self.fn.helppopup("Administrator")}:</td><td><input type="text" name="admin", value="${defaults.administrator}"/></td></tr>
89 ${self.fn.errorRow('administrator', err)}
90     <tr><td>Contact email:</td><td><input type="text" name="contact" value="${defaults.contact}"/></td></tr>
91 ${self.fn.errorRow('contact', err)}
92 % if not on:
93     <tr><td>Machine Name:</td><td><input type="text" name="name" value="${defaults.name}"/>.${config.dns.domains[0]}</td></tr>
94 ${self.fn.errorRow('name', err)}
95     <tr>
96       <td>HVM/ParaVM${self.fn.helppopup('HVM/ParaVM')}</td>
97       <td>${self.fn.vmTypeList(defaults.type)}</td>
98     </tr>
99     <tr><td>Ram:</td><td><input type="text" size=3 name="memory" value="${defaults.memory}"/>MiB (max ${max_mem})</td></tr>
100 ${self.fn.errorRow('memory', err)}
101     <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>
102 ${self.fn.errorRow('disk', err)}
103 % else:
104 ${self.fn.errorRow('name', err)}
105 ${self.fn.errorRow('memory', err)}
106 ${self.fn.errorRow('disk', err)}
107 % endif
108     <tr><td><input type="submit" class="button" name="action" value="Change"/></td></tr>
109   </table>
110 </form>
111 </%def>
112
113 <div id="info">
114   ${infoTable()}
115 </div>
116
117 <h2>Commands</h2>
118 <div id="commands">
119   ${commands()}
120 </div>
121 <h2>Settings</h2>
122 <div id="modify">
123   ${modifyForm()}
124 </div>