diff --git a/neutron/common/utils.py b/neutron/common/utils.py index 9a5612f9a9b..40e374cdf70 100644 --- a/neutron/common/utils.py +++ b/neutron/common/utils.py @@ -37,7 +37,6 @@ from eventlet.green import subprocess import netaddr from neutron_lib import constants as n_const from neutron_lib.utils import helpers -from neutron_lib.utils import net from oslo_concurrency import lockutils from oslo_config import cfg from oslo_db import exception as db_exc @@ -146,15 +145,6 @@ def log_opt_values(log): cfg.CONF.log_opt_values(log, logging.DEBUG) -@removals.remove( - message="Use get_random_mac from neutron_lib.utils.net", - version="Pike", - removal_version="Queens" -) -def get_random_mac(base_mac): - return net.get_random_mac(base_mac) - - def get_dhcp_agent_device_id(network_id, host): # Split host so as to always use only the hostname and # not the domain name. This will guarantee consistency diff --git a/neutron/db/dvr_mac_db.py b/neutron/db/dvr_mac_db.py index f67abc7c19d..aab7af38e03 100644 --- a/neutron/db/dvr_mac_db.py +++ b/neutron/db/dvr_mac_db.py @@ -23,6 +23,7 @@ from neutron_lib import constants from neutron_lib import exceptions as n_exc from neutron_lib.objects import exceptions from neutron_lib.plugins import directory +from neutron_lib.utils import net from oslo_config import cfg from oslo_log import helpers as log_helpers from oslo_log import log as logging @@ -100,7 +101,7 @@ class DVRDbMixin(ext_dvr.DVRMacAddressPluginBase): @db_api.retry_if_session_inactive() def _create_dvr_mac_address_retry(self, context, host, base_mac): with db_api.context_manager.writer.using(context): - mac_address = utils.get_random_mac(base_mac) + mac_address = net.get_random_mac(base_mac) dvr_mac_binding = router.DVRMacAddress( context, host=host, mac_address=netaddr.EUI(mac_address)) dvr_mac_binding.create() diff --git a/neutron/tests/tools.py b/neutron/tests/tools.py index 9fdbdc2f1f9..74a28174101 100644 --- a/neutron/tests/tools.py +++ b/neutron/tests/tools.py @@ -20,7 +20,6 @@ import random import time import warnings -from debtcollector import removals import fixtures import mock import netaddr @@ -247,16 +246,6 @@ def get_random_cidr(version=4): return '2001:db8:%x::/%d' % (random.getrandbits(16), 64) -@removals.remove( - message="Use get_random_mac from neutron_lib.utils.net", - version="Pike", - removal_version="Queens" -) -def get_random_mac(): - """Generate a random mac address starting with fe:16:3e""" - return net.get_random_mac(['fe', '16', '3e', '00', '00', '00']) - - def get_random_EUI(): return netaddr.EUI( net.get_random_mac(['fe', '16', '3e', '00', '00', '00']) diff --git a/neutron/tests/unit/db/test_dvr_mac_db.py b/neutron/tests/unit/db/test_dvr_mac_db.py index cd9aed5b499..8e04fce09dd 100644 --- a/neutron/tests/unit/db/test_dvr_mac_db.py +++ b/neutron/tests/unit/db/test_dvr_mac_db.py @@ -21,6 +21,7 @@ from neutron_lib.callbacks import resources from neutron_lib import constants from neutron_lib import context from neutron_lib.plugins import directory +from neutron_lib.utils import net from neutron.db import dvr_mac_db from neutron.extensions import dvr @@ -61,7 +62,7 @@ class DvrDbMixinTestCase(test_plugin.Ml2PluginV2TestCase): def test__create_dvr_mac_address_success(self): entry = {'host': 'foo_host', 'mac_address': tools.get_random_EUI()} - with mock.patch.object(dvr_mac_db.utils, 'get_random_mac') as f: + with mock.patch.object(net, 'get_random_mac') as f: f.return_value = entry['mac_address'] expected = self.mixin._create_dvr_mac_address( self.ctx, entry['host']) @@ -74,7 +75,7 @@ class DvrDbMixinTestCase(test_plugin.Ml2PluginV2TestCase): non_unique_mac = tools.get_random_EUI() self._create_dvr_mac_entry('foo_host_1', non_unique_mac) - with mock.patch.object(dvr_mac_db.utils, 'get_random_mac') as f: + with mock.patch.object(net, 'get_random_mac') as f: f.return_value = non_unique_mac self.assertRaises(dvr.MacAddressGenerationFailure, self.mixin._create_dvr_mac_address, diff --git a/neutron/tests/unit/db/test_sqlalchemytypes.py b/neutron/tests/unit/db/test_sqlalchemytypes.py index 73b2dfb851f..ebdd1c13f15 100644 --- a/neutron/tests/unit/db/test_sqlalchemytypes.py +++ b/neutron/tests/unit/db/test_sqlalchemytypes.py @@ -14,6 +14,7 @@ import abc import netaddr from neutron_lib import context +from neutron_lib.utils import net from oslo_db import exception from oslo_db.tests.sqlalchemy import base as test_base from oslo_utils import timeutils @@ -216,7 +217,8 @@ class MACAddressTestCase(SqlAlchemyTypesBaseTestCase): self._add_row(id=uuidutils.generate_uuid(), mac=mac) obj = self._get_one(mac) self.assertEqual(mac, obj['mac']) - random_mac = netaddr.EUI(tools.get_random_mac()) + random_mac = netaddr.EUI(net.get_random_mac( + ['fe', '16', '3e', '00', '00', '00'])) self._update_row(mac, random_mac) obj = self._get_one(random_mac) self.assertEqual(random_mac, obj['mac'])