diff --git a/nova/exception.py b/nova/exception.py index 1d6077670920..40b82bf58345 100644 --- a/nova/exception.py +++ b/nova/exception.py @@ -832,6 +832,10 @@ class VifDetailsMissingMacvtapParameters(Invalid): " correct.") +class OvsConfigurationFailure(NovaException): + msg_fmt = _("OVS configuration failed with: %(inner_exception)s.") + + class DatastoreNotFound(NotFound): msg_fmt = _("Could not find the datastore reference(s) which the VM uses.") diff --git a/nova/network/linux_net.py b/nova/network/linux_net.py index da569b628fb0..e2f40ff3cbd9 100644 --- a/nova/network/linux_net.py +++ b/nova/network/linux_net.py @@ -1362,7 +1362,7 @@ def _ovs_vsctl(args): except Exception as e: LOG.error(_LE("Unable to execute %(cmd)s. Exception: %(exception)s"), {'cmd': full_args, 'exception': e}) - raise exception.AgentError(method=full_args) + raise exception.OvsConfigurationFailure(inner_exception=e) def create_ovs_vif_port(bridge, dev, iface_id, mac, instance_id, mtu=None): diff --git a/nova/tests/unit/network/test_linux_net.py b/nova/tests/unit/network/test_linux_net.py index 0e2b1d28a428..2cbe02b4d3ca 100644 --- a/nova/tests/unit/network/test_linux_net.py +++ b/nova/tests/unit/network/test_linux_net.py @@ -16,6 +16,7 @@ import calendar import datetime import os +import re import time import mock @@ -655,7 +656,7 @@ class LinuxNetworkTestCase(test.NoDBTestCase): self.flags(fake_network=False) def fake_execute(*args, **kwargs): - raise processutils.ProcessExecutionError('error') + raise processutils.ProcessExecutionError('specific_error') def fake_device_exists(*args, **kwargs): return False @@ -663,9 +664,16 @@ class LinuxNetworkTestCase(test.NoDBTestCase): self.stubs.Set(utils, 'execute', fake_execute) self.stubs.Set(linux_net, 'device_exists', fake_device_exists) driver = linux_net.LinuxOVSInterfaceDriver() - self.assertRaises(exception.AgentError, - driver.plug, {'uuid': 'fake_network_uuid'}, - 'fake_mac') + + exc = self.assertRaises(exception.OvsConfigurationFailure, + driver.plug, + {'uuid': 'fake_network_uuid'}, 'fake_mac') + self.assertRegex( + str(exc), + re.compile("OVS configuration failed with: .*specific_error.*", + re.DOTALL)) + self.assertIsInstance(exc.kwargs['inner_exception'], + processutils.ProcessExecutionError) def test_vlan_override(self): """Makes sure vlan_interface flag overrides network bridge_interface.