Adjust text and show remctl output
authorQuentin Smith <quentin@mit.edu>
Sun, 27 May 2018 06:43:11 +0000 (02:43 -0400)
committerQuentin Smith <quentin@mit.edu>
Sun, 27 May 2018 07:03:49 +0000 (03:03 -0400)
code/controls.py
code/main.py
code/templates/info.mako

index a5f1693..0889d4c 100644 (file)
@@ -223,6 +223,7 @@ def deleteVM(machine):
 
 def commandResult(username, state, command_name, machine_id, fields):
     start_time = 0
+    result = None
     machine = validation.Validate(username, state, machine_id=machine_id).machine
     action = command_name
     cdrom = fields.get('cdrom') or None
@@ -274,10 +275,14 @@ def commandResult(username, state, command_name, machine_id, fields):
                 raise CodeError('ERROR on remctl')
     elif action == 'delete':
         deleteVM(machine)
+    elif action == 'renumber':
+        result = remctl('control', machine.name, 'renumber')
 
     d = dict(user=username,
              command=action,
              machine=machine)
+    if result:
+        d['result'] = result
     return d
 
 def resizeDisk(machine_name, disk_name, new_size):
index 0f77cee..cfee9f7 100755 (executable)
@@ -279,12 +279,14 @@ console will suffer artifacts.
 
         @cherrypy.expose
         @cherrypy.tools.mako(filename="/info.mako")
-        def info(self, machine_id):
+        def info(self, machine_id, result=None):
             """Handler for info on a single VM."""
             machine = validation.Validate(cherrypy.request.login,
                                           cherrypy.request.state,
                                           machine_id=machine_id).machine
             d = infoDict(cherrypy.request.login, cherrypy.request.state, machine)
+            if result:
+                d['result'] = result
             return d
         index = info
 
@@ -377,6 +379,8 @@ console will suffer artifacts.
                 result = str(err)
             else:
                 result = 'Success!'
+                if 'result' in d:
+                    result = d['result']
                 if not back:
                     return d
             if back == 'list':
@@ -384,8 +388,10 @@ console will suffer artifacts.
                 raise cherrypy.InternalRedirect('/list?result=%s'
                                                 % urllib.quote(result))
             elif back == 'info':
-                raise cherrypy.HTTPRedirect(cherrypy.request.base
-                                            + '/machine/%d/' % machine_id,
+                url = cherrypy.request.base + '/machine/%d/' % machine_id
+                if result:
+                    url += '?result='+urllib.quote(result)
+                raise cherrypy.HTTPRedirect(url,
                                             status=303)
             else:
                 raise InvalidInput('back', back, 'Not a known back page.')
index 8b51cdf..7bec8fd 100644 (file)
@@ -49,11 +49,11 @@ Info on ${machine.name}
 </%def>
   % if renumber:
   <div>
-  <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>
+  <p>This machine's IP address is slated to be changed. 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>
     % if on:
-    ${command_button("Power cycle and renumber", "renumber")
+    ${command_button("Power cycle and renumber", "renumber", extra='''onclick="return confirm('Are you sure that you want to power this VM off and on again?');"''')}
     % else:
-    ${command_button("Renumber", "renumber")
+    ${command_button("Renumber", "renumber")}
     % endif
   </div>
   % endif