Merge "Remove deprecated get_random_mac()"
This commit is contained in:
commit
0376f8fbf2
|
@ -37,7 +37,6 @@ from eventlet.green import subprocess
|
||||||
import netaddr
|
import netaddr
|
||||||
from neutron_lib import constants as n_const
|
from neutron_lib import constants as n_const
|
||||||
from neutron_lib.utils import helpers
|
from neutron_lib.utils import helpers
|
||||||
from neutron_lib.utils import net
|
|
||||||
from oslo_concurrency import lockutils
|
from oslo_concurrency import lockutils
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_db import exception as db_exc
|
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)
|
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):
|
def get_dhcp_agent_device_id(network_id, host):
|
||||||
# Split host so as to always use only the hostname and
|
# Split host so as to always use only the hostname and
|
||||||
# not the domain name. This will guarantee consistency
|
# not the domain name. This will guarantee consistency
|
||||||
|
|
|
@ -23,6 +23,7 @@ from neutron_lib import constants
|
||||||
from neutron_lib import exceptions as n_exc
|
from neutron_lib import exceptions as n_exc
|
||||||
from neutron_lib.objects import exceptions
|
from neutron_lib.objects import exceptions
|
||||||
from neutron_lib.plugins import directory
|
from neutron_lib.plugins import directory
|
||||||
|
from neutron_lib.utils import net
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import helpers as log_helpers
|
from oslo_log import helpers as log_helpers
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
|
@ -100,7 +101,7 @@ class DVRDbMixin(ext_dvr.DVRMacAddressPluginBase):
|
||||||
@db_api.retry_if_session_inactive()
|
@db_api.retry_if_session_inactive()
|
||||||
def _create_dvr_mac_address_retry(self, context, host, base_mac):
|
def _create_dvr_mac_address_retry(self, context, host, base_mac):
|
||||||
with db_api.context_manager.writer.using(context):
|
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(
|
dvr_mac_binding = router.DVRMacAddress(
|
||||||
context, host=host, mac_address=netaddr.EUI(mac_address))
|
context, host=host, mac_address=netaddr.EUI(mac_address))
|
||||||
dvr_mac_binding.create()
|
dvr_mac_binding.create()
|
||||||
|
|
|
@ -20,7 +20,6 @@ import random
|
||||||
import time
|
import time
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
from debtcollector import removals
|
|
||||||
import fixtures
|
import fixtures
|
||||||
import mock
|
import mock
|
||||||
import netaddr
|
import netaddr
|
||||||
|
@ -247,16 +246,6 @@ def get_random_cidr(version=4):
|
||||||
return '2001:db8:%x::/%d' % (random.getrandbits(16), 64)
|
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():
|
def get_random_EUI():
|
||||||
return netaddr.EUI(
|
return netaddr.EUI(
|
||||||
net.get_random_mac(['fe', '16', '3e', '00', '00', '00'])
|
net.get_random_mac(['fe', '16', '3e', '00', '00', '00'])
|
||||||
|
|
|
@ -21,6 +21,7 @@ from neutron_lib.callbacks import resources
|
||||||
from neutron_lib import constants
|
from neutron_lib import constants
|
||||||
from neutron_lib import context
|
from neutron_lib import context
|
||||||
from neutron_lib.plugins import directory
|
from neutron_lib.plugins import directory
|
||||||
|
from neutron_lib.utils import net
|
||||||
|
|
||||||
from neutron.db import dvr_mac_db
|
from neutron.db import dvr_mac_db
|
||||||
from neutron.extensions import dvr
|
from neutron.extensions import dvr
|
||||||
|
@ -61,7 +62,7 @@ class DvrDbMixinTestCase(test_plugin.Ml2PluginV2TestCase):
|
||||||
|
|
||||||
def test__create_dvr_mac_address_success(self):
|
def test__create_dvr_mac_address_success(self):
|
||||||
entry = {'host': 'foo_host', 'mac_address': tools.get_random_EUI()}
|
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']
|
f.return_value = entry['mac_address']
|
||||||
expected = self.mixin._create_dvr_mac_address(
|
expected = self.mixin._create_dvr_mac_address(
|
||||||
self.ctx, entry['host'])
|
self.ctx, entry['host'])
|
||||||
|
@ -74,7 +75,7 @@ class DvrDbMixinTestCase(test_plugin.Ml2PluginV2TestCase):
|
||||||
|
|
||||||
non_unique_mac = tools.get_random_EUI()
|
non_unique_mac = tools.get_random_EUI()
|
||||||
self._create_dvr_mac_entry('foo_host_1', non_unique_mac)
|
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
|
f.return_value = non_unique_mac
|
||||||
self.assertRaises(dvr.MacAddressGenerationFailure,
|
self.assertRaises(dvr.MacAddressGenerationFailure,
|
||||||
self.mixin._create_dvr_mac_address,
|
self.mixin._create_dvr_mac_address,
|
||||||
|
|
|
@ -14,6 +14,7 @@ import abc
|
||||||
|
|
||||||
import netaddr
|
import netaddr
|
||||||
from neutron_lib import context
|
from neutron_lib import context
|
||||||
|
from neutron_lib.utils import net
|
||||||
from oslo_db import exception
|
from oslo_db import exception
|
||||||
from oslo_db.tests.sqlalchemy import base as test_base
|
from oslo_db.tests.sqlalchemy import base as test_base
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
|
@ -216,7 +217,8 @@ class MACAddressTestCase(SqlAlchemyTypesBaseTestCase):
|
||||||
self._add_row(id=uuidutils.generate_uuid(), mac=mac)
|
self._add_row(id=uuidutils.generate_uuid(), mac=mac)
|
||||||
obj = self._get_one(mac)
|
obj = self._get_one(mac)
|
||||||
self.assertEqual(mac, obj['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)
|
self._update_row(mac, random_mac)
|
||||||
obj = self._get_one(random_mac)
|
obj = self._get_one(random_mac)
|
||||||
self.assertEqual(random_mac, obj['mac'])
|
self.assertEqual(random_mac, obj['mac'])
|
||||||
|
|
Loading…
Reference in New Issue