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
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):
@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
result = str(err)
else:
result = 'Success!'
+ if 'result' in d:
+ result = d['result']
if not back:
return d
if back == 'list':
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.')
</%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