from neutron import manager
from neutron.openstack.common import timeutils
from neutron.plugins.ml2 import config as config
-from neutron.plugins.ml2.drivers.l2pop import constants as l2_consts
from neutron.plugins.ml2 import managers
from neutron.plugins.ml2 import rpc
from neutron.tests.unit import test_db_plugin as test_plugin
'start_flag': True
}
+L2_AGENT_5 = {
+ 'binary': 'neutron-ofagent-agent',
+ 'host': HOST + '_5',
+ 'topic': constants.L2_AGENT_TOPIC,
+ 'configurations': {'tunneling_ip': '20.0.0.5',
+ 'tunnel_types': [],
+ 'bridge_mappings': {'phys1': 'br'},
+ 'l2pop_network_types': ['vlan']},
+ 'agent_type': constants.AGENT_TYPE_OFA,
+ 'tunnel_type': [],
+ 'start_flag': True
+}
+
PLUGIN_NAME = 'neutron.plugins.ml2.plugin.Ml2Plugin'
NOTIFIER = 'neutron.plugins.ml2.rpc.AgentNotifierApi'
DEVICE_OWNER_COMPUTE = 'compute:None'
# driver apis.
config.cfg.CONF.set_override('mechanism_drivers',
['openvswitch', 'linuxbridge',
- 'l2population'],
+ 'ofagent', 'l2population'],
'ml2')
+ config.cfg.CONF.set_override('network_vlan_ranges',
+ ['phys1:1:100'],
+ 'ml2_type_vlan')
super(TestL2PopulationRpcTestCase, self).setUp(PLUGIN_NAME)
self.adminContext = context.get_admin_context()
self.notifier = rpc.AgentNotifierApi(topics.AGENT)
self.callbacks = rpc.RpcCallbacks(self.notifier, self.type_manager)
- self.orig_supported_agents = l2_consts.SUPPORTED_AGENT_TYPES
- l2_consts.SUPPORTED_AGENT_TYPES = [constants.AGENT_TYPE_OVS]
-
net_arg = {pnet.NETWORK_TYPE: 'vxlan',
pnet.SEGMENTATION_ID: '1'}
self._network = self._make_network(self.fmt, 'net1', True,
pnet.SEGMENTATION_ID,),
**net_arg)
+ net_arg = {pnet.NETWORK_TYPE: 'vlan',
+ pnet.PHYSICAL_NETWORK: 'phys1',
+ pnet.SEGMENTATION_ID: '2'}
+ self._network2 = self._make_network(self.fmt, 'net2', True,
+ arg_list=(pnet.NETWORK_TYPE,
+ pnet.PHYSICAL_NETWORK,
+ pnet.SEGMENTATION_ID,),
+ **net_arg)
+
notifier_patch = mock.patch(NOTIFIER)
notifier_patch.start()
uptime_patch = mock.patch(uptime, return_value=190)
uptime_patch.start()
- def tearDown(self):
- l2_consts.SUPPORTED_AGENT_TYPES = self.orig_supported_agents
- super(TestL2PopulationRpcTestCase, self).tearDown()
-
def _register_ml2_agents(self):
callback = agents_db.AgentExtRpcCallback()
callback.report_state(self.adminContext,
callback.report_state(self.adminContext,
agent_state={'agent_state': L2_AGENT_4},
time=timeutils.strtime())
+ callback.report_state(self.adminContext,
+ agent_state={'agent_state': L2_AGENT_5},
+ time=timeutils.strtime())
def test_fdb_add_called(self):
self._register_ml2_agents()
self.assertFalse(self.mock_fanout.called)
+ def test_fdb_add_called_for_l2pop_network_types(self):
+ self._register_ml2_agents()
+
+ host = HOST + '_5'
+ with self.subnet(network=self._network2) as subnet:
+ host_arg = {portbindings.HOST_ID: host}
+ with self.port(subnet=subnet,
+ device_owner=DEVICE_OWNER_COMPUTE,
+ arg_list=(portbindings.HOST_ID,),
+ **host_arg) as port1:
+ with self.port(subnet=subnet,
+ arg_list=(portbindings.HOST_ID,),
+ **host_arg):
+ p1 = port1['port']
+
+ device = 'tap' + p1['id']
+
+ self.mock_fanout.reset_mock()
+ self.callbacks.update_device_up(self.adminContext,
+ agent_id=host,
+ device=device)
+
+ p1_ips = [p['ip_address'] for p in p1['fixed_ips']]
+ expected = {'args':
+ {'fdb_entries':
+ {p1['network_id']:
+ {'ports':
+ {'20.0.0.5': [constants.FLOODING_ENTRY,
+ [p1['mac_address'],
+ p1_ips[0]]]},
+ 'network_type': 'vlan',
+ 'segment_id': 2}}},
+ 'namespace': None,
+ 'method': 'add_fdb_entries'}
+
+ self.mock_fanout.assert_called_with(
+ mock.ANY, expected, topic=self.fanout_topic)
+
def test_fdb_add_two_agents(self):
self._register_ml2_agents()