diff --git a/neutron/agent/linux/ip_lib.py b/neutron/agent/linux/ip_lib.py index 6e317947af4..feb5f6b400c 100644 --- a/neutron/agent/linux/ip_lib.py +++ b/neutron/agent/linux/ip_lib.py @@ -482,7 +482,7 @@ class IpRouteCommand(IpDeviceCommandBase): self._as_root([ip_version], tuple(args)) except RuntimeError as rte: with (excutils.save_and_reraise_exception()) as ctx: - if "Cannot find device" in rte.message: + if "Cannot find device" in str(rte): ctx.reraise = False raise exceptions.DeviceNotFoundError( device_name=self.name) diff --git a/neutron/agent/linux/utils.py b/neutron/agent/linux/utils.py index dc22a0e069b..6b2d6af7061 100644 --- a/neutron/agent/linux/utils.py +++ b/neutron/agent/linux/utils.py @@ -182,7 +182,7 @@ def find_child_pids(pid): # Unexpected errors are the responsibility of the caller with excutils.save_and_reraise_exception() as ctxt: # Exception has already been logged by execute - no_children_found = 'Exit code: 1' in e.message + no_children_found = 'Exit code: 1' in str(e) if no_children_found: ctxt.reraise = False return [] diff --git a/neutron/api/v2/resource.py b/neutron/api/v2/resource.py index dec23b00a2e..2fd66d1a4e9 100644 --- a/neutron/api/v2/resource.py +++ b/neutron/api/v2/resource.py @@ -179,7 +179,7 @@ def translate(translatable, locale): elif isinstance(translatable, webob.exc.HTTPError): translatable.detail = localize(translatable.detail, locale) elif isinstance(translatable, Exception): - translatable.message = localize(translatable.message, locale) + translatable.message = localize(translatable, locale) else: return localize(translatable, locale) return translatable diff --git a/neutron/cmd/sanity/checks.py b/neutron/cmd/sanity/checks.py index c31f5777dd0..d04f3a98a40 100644 --- a/neutron/cmd/sanity/checks.py +++ b/neutron/cmd/sanity/checks.py @@ -174,7 +174,7 @@ def ovsdb_native_supported(): except ImportError as ex: LOG.error(_LE("Failed to import required modules. Ensure that the " "python-openvswitch package is installed. Error: %s"), - ex.message) + ex) except Exception as ex: LOG.exception(six.text_type(ex)) diff --git a/neutron/plugins/embrane/agent/dispatcher.py b/neutron/plugins/embrane/agent/dispatcher.py index fb5101f88e7..8cee30ebb47 100644 --- a/neutron/plugins/embrane/agent/dispatcher.py +++ b/neutron/plugins/embrane/agent/dispatcher.py @@ -108,10 +108,10 @@ class Dispatcher(object): h_exc.BrokenInterface, h_exc.DvaCreationFailed, h_exc.DvaCreationPending, h_exc.BrokenDva, h_exc.ConfigurationFailed) as ex: - LOG.warning(p_con.error_map[type(ex)], ex.message) + LOG.warning(p_con.error_map[type(ex)], ex) transient_state = p_con.Status.ERROR except h_exc.DvaDeleteFailed as ex: - LOG.warning(p_con.error_map[type(ex)], ex.message) + LOG.warning(p_con.error_map[type(ex)], ex) transient_state = p_con.Status.DELETED finally: # if the returned transient state is None, no operations diff --git a/neutron/plugins/embrane/agent/operations/router_operations.py b/neutron/plugins/embrane/agent/operations/router_operations.py index 47d13a65459..932e03c20aa 100644 --- a/neutron/plugins/embrane/agent/operations/router_operations.py +++ b/neutron/plugins/embrane/agent/operations/router_operations.py @@ -60,7 +60,7 @@ def _create_dva_and_assign_address(api, tenant_id, neutron_router, neutron_router["admin_state_up"], ip_allocation_info) except h_exc.PreliminaryOperationsFailed as ex: - raise h_exc.BrokenInterface(err_msg=ex.message) + raise h_exc.BrokenInterface(err_msg=str(ex)) state = api.extract_dva_state(dva) return state @@ -110,7 +110,7 @@ def _grow_dva_iface_and_assign_address(api, tenant_id, neutron_router, neutron_router["admin_state_up"], ip_allocation_info) except h_exc.PreliminaryOperationsFailed as ex: - raise h_exc.BrokenInterface(err_msg=ex.message) + raise h_exc.BrokenInterface(err_msg=str(ex)) state = api.extract_dva_state(dva) return state @@ -127,7 +127,7 @@ def _shrink_dva_iface(api, tenant_id, neutron_router, port_id): return (p_con.Status.ACTIVE if neutron_router["admin_state_up"] else p_con.Status.READY) except h_exc.PreliminaryOperationsFailed as ex: - raise h_exc.BrokenInterface(err_msg=ex.message) + raise h_exc.BrokenInterface(err_msg=str(ex)) state = api.extract_dva_state(dva) return state diff --git a/neutron/tests/functional/agent/l3/test_namespace_manager.py b/neutron/tests/functional/agent/l3/test_namespace_manager.py index b85e03ba7ad..335796dc896 100755 --- a/neutron/tests/functional/agent/l3/test_namespace_manager.py +++ b/neutron/tests/functional/agent/l3/test_namespace_manager.py @@ -49,7 +49,7 @@ class NamespaceManagerTestFramework(base.BaseSudoTestCase): except RuntimeError as e: # If the namespace didn't exist when delete was attempted, mission # accomplished. Otherwise, re-raise the exception - if 'No such file or directory' not in e.message: + if 'No such file or directory' not in str(e): raise e def _namespace_exists(self, namespace): diff --git a/neutron/tests/tempest/common/accounts.py b/neutron/tests/tempest/common/accounts.py index 1fcef11881f..1a50e3caf8e 100644 --- a/neutron/tests/tempest/common/accounts.py +++ b/neutron/tests/tempest/common/accounts.py @@ -271,7 +271,7 @@ class NotLockingAccounts(Accounts): return getattr(user, cred_arg) != getattr(alt_user, cred_arg) except exceptions.InvalidCredentials as ic: msg = "At least one of the configured credentials is " \ - "not valid: %s" % ic.message + "not valid: %s" % ic raise exceptions.InvalidConfiguration(msg) else: # TODO(andreaf) Add a uniqueness check here diff --git a/neutron/tests/unit/agent/linux/test_ip_lib.py b/neutron/tests/unit/agent/linux/test_ip_lib.py index 51ac34cfe95..ea77ae5c914 100644 --- a/neutron/tests/unit/agent/linux/test_ip_lib.py +++ b/neutron/tests/unit/agent/linux/test_ip_lib.py @@ -793,7 +793,7 @@ class TestIpRouteCommand(TestIPCmdBase): 'dev', self.parent.name, 'table', self.table)) - def test_del_gateway(self): + def test_del_gateway_success(self): self.route_cmd.delete_gateway(self.gateway, table=self.table) self._assert_sudo([self.ip_version], ('del', 'default', @@ -801,6 +801,20 @@ class TestIpRouteCommand(TestIPCmdBase): 'dev', self.parent.name, 'table', self.table)) + def test_del_gateway_cannot_find_device(self): + self.parent._as_root.side_effect = RuntimeError("Cannot find device") + + exc = self.assertRaises(exceptions.DeviceNotFoundError, + self.route_cmd.delete_gateway, + self.gateway, table=self.table) + self.assertIn(self.parent.name, str(exc)) + + def test_del_gateway_other_error(self): + self.parent._as_root.side_effect = RuntimeError() + + self.assertRaises(RuntimeError, self.route_cmd.delete_gateway, + self.gateway, table=self.table) + def test_get_gateway(self): for test_case in self.test_cases: self.parent._run = mock.Mock(return_value=test_case['sample']) diff --git a/neutron/tests/unit/api/test_extensions.py b/neutron/tests/unit/api/test_extensions.py index 9a32e865f94..fdf35a29437 100644 --- a/neutron/tests/unit/api/test_extensions.py +++ b/neutron/tests/unit/api/test_extensions.py @@ -160,7 +160,7 @@ class ResourceExtensionTest(base.BaseTestCase): # Shouldn't be reached self.assertTrue(False) except webtest.AppError as e: - self.assertIn('501', e.message) + self.assertIn('501', str(e)) def test_resource_can_be_added_as_extension(self): res_ext = extensions.ResourceExtension( diff --git a/neutron/tests/unit/test_manager.py b/neutron/tests/unit/test_manager.py index a29a9d63b46..59ecb58a88e 100644 --- a/neutron/tests/unit/test_manager.py +++ b/neutron/tests/unit/test_manager.py @@ -77,7 +77,7 @@ class NeutronManagerTestCase(base.BaseTestCase): "DummyServicePlugin"]) cfg.CONF.set_override("core_plugin", DB_PLUGIN_KLASS) e = self.assertRaises(ValueError, manager.NeutronManager.get_instance) - self.assertIn(constants.DUMMY, e.message) + self.assertIn(constants.DUMMY, str(e)) def test_multiple_plugins_by_name_specified_for_service_type(self): cfg.CONF.set_override("service_plugins", ["dummy", "dummy"]) @@ -99,7 +99,7 @@ class NeutronManagerTestCase(base.BaseTestCase): "neutron.tests.unit.test_manager." "MultiServiceCorePlugin") e = self.assertRaises(ValueError, manager.NeutronManager.get_instance) - self.assertIn(constants.DUMMY, e.message) + self.assertIn(constants.DUMMY, str(e)) def test_core_plugin_supports_services(self): cfg.CONF.set_override("core_plugin",