Refactor xvp console

Small re-factoring of the xvp console mainly checking
to make sure that we catch exceptions when they haappen.

Change-Id: I0164111ffa4439d82ae26084433901236a4a2ddc
Signed-off-by: Chuck Short <chuck.short@canonical.com>
This commit is contained in:
Chuck Short 2012-12-16 08:56:05 -06:00
parent f04722ee22
commit bcfb4d4910

View File

@ -114,9 +114,13 @@ class XVPConsoleProxy(object):
self._xvp_restart()
def _write_conf(self, config):
LOG.debug(_('Re-wrote %s') % CONF.console_xvp_conf)
with open(CONF.console_xvp_conf, 'w') as cfile:
cfile.write(config)
try:
LOG.debug(_('Re-wrote %s') % CONF.console_xvp_conf)
with open(CONF.console_xvp_conf, 'w') as cfile:
cfile.write(config)
except IOError:
LOG.exception(_("Failed to write configuration file"))
raise
def _xvp_stop(self):
LOG.debug(_('Stopping xvp'))
@ -194,4 +198,6 @@ class XVPConsoleProxy(object):
#xvp will blow up on passwords that are too long (mdragon)
password = password[:maxlen]
out, err = utils.execute('xvp', flag, process_input=password)
if err:
raise exception.ProcessExecutionError(_("Failed to run xvp."))
return out.strip()