Raise catachable error when VNC terminal fails to open.

Closes-Bug: #1724084

Change-Id: I29171925d5c59b2f4dbf0c6f2a731aa196ca3b72
This commit is contained in:
Tyler Blakeslee 2017-10-20 15:09:37 -04:00
parent fc1fe410ef
commit f0b4f6f951
2 changed files with 10 additions and 3 deletions

View File

@ -1673,7 +1673,7 @@ class TestPowerVMDriver(test.TestCase):
# Failure
mock_vterm.side_effect = pvm_exc.VNCBasedTerminalFailedToOpen(err='xx')
self.assertRaises(exc.InternalError, self.drv.get_vnc_console,
self.assertRaises(exc.ConsoleTypeUnavailable, self.drv.get_vnc_console,
mock.ANY, self.inst)
# 404

View File

@ -1742,10 +1742,17 @@ class PowerVMDriver(driver.ComputeDriver):
server_cert=server_cert, server_key=server_key)
except pvm_exc.HttpNotFound:
raise exception.InstanceNotFound(instance_id=instance.uuid)
except pvm_exc.Error:
except pvm_exc.Error as exc:
# Otherwise wrapper the error in an exception that can be handled
LOG.exception("Unable to open console.", instance=instance)
raise exception.InternalError(err=_("Unable to open console."))
msg = (_("VNC based terminal for instance %(instance_name)s "
"failed to open: %(exc_msg)s")
% {'instance_name': instance.name,
'exc_msg': exc.args[0]})
# Need to raise ConsoleTypeUnavailable with overwritten message
# because otherwise the exception will not be caught. It is
# disallowed to send a non-nova exception over the wire.
raise exception.ConsoleTypeUnavailable(msg)
# Note that the VNC viewer will wrap the internal_access_path with
# the HTTP content.