Use RESTful URLs for commands
authorQuentin Smith <quentin@mit.edu>
Mon, 10 Aug 2009 00:13:20 +0000 (20:13 -0400)
committerQuentin Smith <quentin@mit.edu>
Mon, 10 Aug 2009 00:13:20 +0000 (20:13 -0400)
svn path=/package_branches/invirt-web/cherrypy-rebased/; revision=2683

code/static/style.css
code/templates/info.mako

index 49fe8e2..a764e17 100644 (file)
@@ -104,3 +104,7 @@ tr.stripedrow {
 #machinelist td, #machinelist th {
   padding: 0.1em 0.5em;
 }
+
+form {
+    display: inline;
+}
index 5af29bb..b98e7c2 100644 (file)
@@ -26,24 +26,26 @@ Info on ${machine.name}
   VNC console not enabled; still booting?
  % endif
 % endif
-<form action="command" method="POST">
-  <input type="hidden" name="back" value="info"/>
-  <input type="hidden" name="machine_id" value="${machine.machine_id}"/>
+<%def name="command_button(title, value, cdrom=False, extra='')">
+<form action="machine/${machine.machine_id}/command/${value}" method="POST">
+  <input type="hidden" name="back" value="machine/${machine.machine_id}/info" />
+  <input type="submit" class="button" name="action" value="${title}" ${extra | n}/>
+% if cdrom:
+  Boot CD: ${self.fn.cdromList()}
+% endif
+</form>
+</%def>
   <div>
        % if on:
-       <button type="submit" class="button" name="action" value="Power off">Power off (hard)</button>
-       <button type="submit" class="button" name="action" value="Shutdown">Shut down</button>
-       <input type="submit" class="button" name="action" value="Reboot"/>
+       ${command_button("Power off", "destroy")}
+       ${command_button("Shutdown", "shutdown")}
+       ${command_button("Reboot", "reboot", cdrom=True)}
        % else:
-       <input type="submit" class="button" name="action" value="Power on"/>
+       ${command_button("Power on", "create", cdrom=True)}
        % endif
   </div>
   <div>
-    Boot CD:
-${self.fn.cdromList()}
-  </div>
-  <div>
-      <input type="submit" class="button" name="action" value="Delete VM" onclick="return confirm('Are you sure that you want to delete this VM?');"/>
+       ${command_button("Delete VM", "delete", extra='''onclick="return confirm('Are you sure that you want to delete this VM?');"''')}
   </div>
 </form>
 </%def>