Raise proper exception in case of vif plug errors
The Nova Compute manager expects a VirtualInterfacePlugException exception to be raised when a vif plug fails. This particularly affects the service initialization step. If we're raising an exception other than the above mentioned one, the exception won't be cought, in which case the Nova Compute service will stop. This change ensures that we're raising the expected exception if vif plugging fails. Change-Id: Ibaa405577d4fa06f27fdd9440aca49be0c620af5 Closes-bug: #1736392
This commit is contained in:
parent
810a29f677
commit
6adc5cf4d4
|
@ -1017,7 +1017,12 @@ class VMOps(object):
|
|||
def plug_vifs(self, instance, network_info):
|
||||
if network_info:
|
||||
for vif in network_info:
|
||||
self._vif_driver.plug(instance, vif)
|
||||
try:
|
||||
self._vif_driver.plug(instance, vif)
|
||||
except Exception as exc:
|
||||
LOG.exception("Failed to plug vif: '%s'.",
|
||||
vif, instance=instance)
|
||||
raise exception.VirtualInterfacePlugException(exc)
|
||||
|
||||
def unplug_vifs(self, instance, network_info):
|
||||
if network_info:
|
||||
|
|
|
@ -1598,6 +1598,18 @@ class VMOpsTestCase(test_base.HyperVBaseTestCase):
|
|||
network_info=mock_network_info)
|
||||
self._vmops._vif_driver.plug.assert_has_calls(calls)
|
||||
|
||||
def test_plug_vifs_failed(self):
|
||||
mock_instance = fake_instance.fake_instance_obj(self.context)
|
||||
fake_vif1 = {'id': mock.sentinel.ID1,
|
||||
'type': mock.sentinel.vif_type1}
|
||||
mock_network_info = [fake_vif1]
|
||||
|
||||
self._vmops._vif_driver.plug.side_effect = exception.NovaException
|
||||
|
||||
self.assertRaises(exception.VirtualInterfacePlugException,
|
||||
self._vmops.plug_vifs,
|
||||
mock_instance, mock_network_info)
|
||||
|
||||
def test_unplug_vifs(self):
|
||||
mock_instance = fake_instance.fake_instance_obj(self.context)
|
||||
fake_vif1 = {'id': mock.sentinel.ID1,
|
||||
|
|
Loading…
Reference in New Issue