Removed deprecated class LocalVLANMapping

VLAN mapping was separated from agent in change
I514c7632c1c26d6cfeb706fc5d829a46dcce3782
Please use new manager located in
neutron.plugins.ml2.drivers.openvswitch.agent.vlanmanager

Change-Id: Id6cc9c332c241602526d4c325ca4d1c80380b203
This commit is contained in:
Dariusz Smigiel 2016-09-29 20:02:44 +00:00 committed by Darek Smigiel
parent dc8ad65838
commit 4ec456d315
5 changed files with 7 additions and 66 deletions

View File

@ -223,40 +223,18 @@ class L2populationRpcCallBackTunnelMixin(L2populationRpcCallBackMixin):
''' '''
pass pass
def _get_lvm_getter(self, local_vlan_map): def get_agent_ports(self, fdb_entries):
def get_lvm_from_mapping(net_id, local_vlan_map):
"""This introduces backward compatibility with local_vlan_map, will
be removed in Ocata.
"""
try:
return local_vlan_map[net_id]
except KeyError:
raise vlanmanager.MappingNotFound(net_id=net_id)
def get_lvm_from_manager(net_id, local_vlan_map):
vlan_manager = vlanmanager.LocalVlanManager()
return vlan_manager.get(net_id)
if local_vlan_map is not None:
vlanmanager.deprecate_local_vlan_map_in_object(
"%s.get_agent_ports()" % self.__class__.__name__,
stacklevel_extra=1)
return get_lvm_from_mapping
return get_lvm_from_manager
def get_agent_ports(self, fdb_entries, local_vlan_map=None):
"""Generator to yield port info. """Generator to yield port info.
For each known (i.e found in VLAN manager) network in For each known (i.e found in VLAN manager) network in
fdb_entries, yield (lvm, fdb_entries[network_id]['ports']) pair. fdb_entries, yield (lvm, fdb_entries[network_id]['ports']) pair.
:param fdb_entries: l2pop fdb entries :param fdb_entries: l2pop fdb entries
:param local_vlan_map: Deprecated.
""" """
lvm_getter = self._get_lvm_getter(local_vlan_map) vlan_manager = vlanmanager.LocalVlanManager()
for network_id, values in fdb_entries.items(): for network_id, values in fdb_entries.items():
try: try:
lvm = lvm_getter(network_id, local_vlan_map) lvm = vlan_manager.get(network_id)
except vlanmanager.MappingNotFound: except vlanmanager.MappingNotFound:
continue continue
agent_ports = values.get('ports') agent_ports = values.get('ports')
@ -303,8 +281,7 @@ class L2populationRpcCallBackTunnelMixin(L2populationRpcCallBackMixin):
getattr(self, method)(context, values) getattr(self, method)(context, values)
@log_helpers.log_method_call @log_helpers.log_method_call
def fdb_chg_ip_tun(self, context, br, fdb_entries, local_ip, def fdb_chg_ip_tun(self, context, br, fdb_entries, local_ip):
local_vlan_map=None):
'''fdb update when an IP of a port is updated. '''fdb update when an IP of a port is updated.
The ML2 l2-pop mechanism driver sends an fdb update rpc message when an The ML2 l2-pop mechanism driver sends an fdb update rpc message when an
@ -328,12 +305,11 @@ class L2populationRpcCallBackTunnelMixin(L2populationRpcCallBackMixin):
PortInfo has .mac_address and .ip_address attrs. PortInfo has .mac_address and .ip_address attrs.
:param local_ip: local IP address of this agent. :param local_ip: local IP address of this agent.
:param local_vlan_map: Deprecated.
''' '''
lvm_getter = self._get_lvm_getter(local_vlan_map) vlan_manager = vlanmanager.LocalVlanManager()
for network_id, agent_ports in fdb_entries.items(): for network_id, agent_ports in fdb_entries.items():
try: try:
lvm = lvm_getter(network_id, local_vlan_map) lvm = vlan_manager.get(network_id)
except vlanmanager.MappingNotFound: except vlanmanager.MappingNotFound:
continue continue

View File

@ -21,7 +21,6 @@ import signal
import sys import sys
import time import time
import debtcollector
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
@ -74,10 +73,6 @@ cfg.CONF.import_group('AGENT', 'neutron.plugins.ml2.drivers.openvswitch.'
cfg.CONF.import_group('OVS', 'neutron.plugins.ml2.drivers.openvswitch.agent.' cfg.CONF.import_group('OVS', 'neutron.plugins.ml2.drivers.openvswitch.agent.'
'common.config') 'common.config')
LocalVLANMapping = debtcollector.moves.moved_class(
vlanmanager.LocalVLANMapping, 'LocalVLANMapping', __name__,
version='Newton', removal_version='Ocata')
class _mac_mydialect(netaddr.mac_unix): class _mac_mydialect(netaddr.mac_unix):
word_fmt = '%.2x' word_fmt = '%.2x'
@ -296,12 +291,6 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
self.quitting_rpc_timeout = agent_conf.quitting_rpc_timeout self.quitting_rpc_timeout = agent_conf.quitting_rpc_timeout
@debtcollector.removals.removed_property(
version='Newton', removal_version='Ocata')
def local_vlan_map(self):
"""Provide backward compatibility with local_vlan_map attribute"""
return self.vlan_manager.mapping
def _parse_bridge_mappings(self, bridge_mappings): def _parse_bridge_mappings(self, bridge_mappings):
try: try:
return helpers.parse_mappings(bridge_mappings) return helpers.parse_mappings(bridge_mappings)
@ -402,16 +391,6 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
connection, constants.EXTENSION_DRIVER_TYPE, connection, constants.EXTENSION_DRIVER_TYPE,
self.agent_api) self.agent_api)
@debtcollector.moves.moved_method(
'get_net_uuid',
'OVSNeutronAgent.get_net_uuid() moved to vlanmanager.LocalVlanManager',
removal_version='Ocata')
def get_net_uuid(self, vif_id):
try:
return self.vlan_manager.get_net_uuid(vif_id)
except vlanmanager.VifIdNotFound:
pass
def port_update(self, context, **kwargs): def port_update(self, context, **kwargs):
port = kwargs.get('port') port = kwargs.get('port')
# Put the port identifier in the updated_ports set. # Put the port identifier in the updated_ports set.

View File

@ -13,19 +13,11 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import debtcollector
from neutron_lib import exceptions from neutron_lib import exceptions
from neutron._i18n import _ from neutron._i18n import _
def deprecate_local_vlan_map_in_object(object_name, stacklevel_extra=0):
debtcollector.deprecate(
"local_vlan_map argument for %s was deprecated." % object_name,
version="Newton", removal_version="Ocata",
stacklevel=4 + stacklevel_extra)
class VifIdNotFound(exceptions.NeutronException): class VifIdNotFound(exceptions.NeutronException):
message = _('VIF ID %(vif_id)s not found in any network managed by ' message = _('VIF ID %(vif_id)s not found in any network managed by '
'VLAN Manager') 'VLAN Manager')

View File

@ -221,7 +221,7 @@ class TestL2populationRpcCallBackTunnelMixin(
m_setup_entry_for_arp_reply = mock.Mock() m_setup_entry_for_arp_reply = mock.Mock()
self.fakeagent.setup_entry_for_arp_reply = m_setup_entry_for_arp_reply self.fakeagent.setup_entry_for_arp_reply = m_setup_entry_for_arp_reply
self.fakeagent.fdb_chg_ip_tun( self.fakeagent.fdb_chg_ip_tun(
'context', self.fakebr, self.upd_fdb_entry1, self.local_ip, {}) 'context', self.fakebr, self.upd_fdb_entry1, self.local_ip)
self.assertFalse(m_setup_entry_for_arp_reply.call_count) self.assertFalse(m_setup_entry_for_arp_reply.call_count)
def test__fdb_chg_ip_ip_is_local_ip(self): def test__fdb_chg_ip_ip_is_local_ip(self):

View File

@ -118,9 +118,3 @@ class TestLocalVlanManager(base.BaseTestCase):
def test_pop_non_existing_raises_exception(self): def test_pop_non_existing_raises_exception(self):
with testtools.ExpectedException(vlanmanager.MappingNotFound): with testtools.ExpectedException(vlanmanager.MappingNotFound):
self.vlan_manager.pop(1) self.vlan_manager.pop(1)
class TestDeprecationMessage(base.BaseTestCase):
def test_deprecation_message(self):
"""Test that calling function doesn't crash"""
vlanmanager.deprecate_local_vlan_map_in_object("foo")