diff --git a/neutron/common/config.py b/neutron/common/config.py index 0ed50919138..e9eca9b27ba 100644 --- a/neutron/common/config.py +++ b/neutron/common/config.py @@ -63,7 +63,10 @@ core_opts = [ "octet is not 00, it will also be used. The others " "will be randomly generated.")), cfg.IntOpt('mac_generation_retries', default=16, - help=_("How many times Neutron will retry MAC generation")), + deprecated_for_removal=True, + help=_("How many times Neutron will retry MAC generation. This " + "option is now obsolete and so is deprecated to be " + "removed in the Ocata release.")), cfg.BoolOpt('allow_bulk', default=True, help=_("Allow the usage of the bulk API")), cfg.BoolOpt('allow_pagination', default=api.DEFAULT_ALLOW_PAGINATION, diff --git a/neutron/db/dvr_mac_db.py b/neutron/db/dvr_mac_db.py index 08cceb3ac47..715e05ef51c 100644 --- a/neutron/db/dvr_mac_db.py +++ b/neutron/db/dvr_mac_db.py @@ -28,6 +28,7 @@ from neutron.callbacks import events from neutron.callbacks import registry from neutron.callbacks import resources from neutron.common import utils +from neutron.db import api as db_api from neutron.db import model_base from neutron.db import models_v2 from neutron.extensions import dvr as ext_dvr @@ -115,8 +116,7 @@ class DVRDbMixin(ext_dvr.DVRMacAddressPluginBase): def _create_dvr_mac_address(self, context, host): """Create DVR mac address for a given host.""" base_mac = cfg.CONF.dvr_base_mac.split(':') - max_retries = cfg.CONF.mac_generation_retries - for attempt in reversed(range(max_retries)): + for attempt in reversed(range(db_api.MAX_RETRIES)): try: with context.session.begin(subtransactions=True): mac_address = utils.get_random_mac(base_mac) @@ -135,7 +135,8 @@ class DVRDbMixin(ext_dvr.DVRMacAddressPluginBase): LOG.debug("Generated DVR mac %(mac)s exists." " Remaining attempts %(attempts_left)s.", {'mac': mac_address, 'attempts_left': attempt}) - LOG.error(_LE("MAC generation error after %s attempts"), max_retries) + LOG.error(_LE("MAC generation error after %s attempts"), + db_api.MAX_RETRIES) raise ext_dvr.MacAddressGenerationFailure(host=host) def get_dvr_mac_address_list(self, context): diff --git a/neutron/tests/unit/db/test_dvr_mac_db.py b/neutron/tests/unit/db/test_dvr_mac_db.py index 397488aecee..1af3c29bd81 100644 --- a/neutron/tests/unit/db/test_dvr_mac_db.py +++ b/neutron/tests/unit/db/test_dvr_mac_db.py @@ -69,15 +69,12 @@ class DvrDbMixinTestCase(test_plugin.Ml2PluginV2TestCase): self.assertEqual(expected, entry) def test__create_dvr_mac_address_retries_exceeded_retry_logic(self): - new_retries = 8 - cfg.CONF.set_override('mac_generation_retries', new_retries) self._create_dvr_mac_entry('foo_host_1', 'non_unique_mac') with mock.patch.object(dvr_mac_db.utils, 'get_random_mac') as f: f.return_value = 'non_unique_mac' self.assertRaises(dvr.MacAddressGenerationFailure, self.mixin._create_dvr_mac_address, self.ctx, "foo_host_2") - self.assertEqual(new_retries, f.call_count) def test_mac_not_cleared_on_agent_delete_event_with_remaining_agents(self): plugin = manager.NeutronManager.get_plugin()