From: Quentin Smith Date: Sun, 27 May 2018 06:43:11 +0000 (-0400) Subject: Adjust text and show remctl output X-Git-Tag: 0.1.51~3 X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/invirt-web.git/commitdiff_plain/57121cedadec57f0323ceb72965bbdcf6fde517a?ds=inline Adjust text and show remctl output --- diff --git a/code/controls.py b/code/controls.py index a5f1693..0889d4c 100644 --- a/code/controls.py +++ b/code/controls.py @@ -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): diff --git a/code/main.py b/code/main.py index 0f77cee..cfee9f7 100755 --- a/code/main.py +++ b/code/main.py @@ -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.') diff --git a/code/templates/info.mako b/code/templates/info.mako index 8b51cdf..7bec8fd 100644 --- a/code/templates/info.mako +++ b/code/templates/info.mako @@ -49,11 +49,11 @@ Info on ${machine.name} % if renumber:
-

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:

+

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:

% 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
% endif