- get_ports_by_subnet
- get_agent_gateway_port
Needed by the agent when operating in DVR/DVR_SNAT mode
+ 1.3 - Get the list of activated services
"""
topic=self.topic,
version='1.2')
+ def get_service_plugin_list(self, context):
+ """Make a call to get the list of activated services."""
+ return self.call(context,
+ self.make_msg('get_service_plugin_list'),
+ topic=self.topic,
+ version='1.3')
+
class RouterInfo(object):
self.removed_routers = set()
self.sync_progress = False
+ # Get the list of service plugins from Neutron Server
+ self.neutron_service_plugins = (
+ self.plugin_rpc.get_service_plugin_list(self.context))
self._clean_stale_namespaces = self.conf.use_namespaces
# dvr data
net_id)
return net_id
+ def get_service_plugin_list(self, context, **kwargs):
+ plugins = manager.NeutronManager.get_service_plugins()
+ return plugins.keys()
+
def update_floatingip_statuses(self, context, router_id, fip_statuses):
"""Update operational status for a floating IP."""
l3_plugin = manager.NeutronManager.get_service_plugins()[
LOG.debug(_("Initializing firewall agent"))
self.conf = conf
fwaas_driver_class_path = cfg.CONF.fwaas.driver
- self.fwaas_enabled = cfg.CONF.fwaas.enabled
+ fwaas_enabled = cfg.CONF.fwaas.enabled
+ fwaas_plugin_configured = (constants.FIREWALL
+ in self.neutron_service_plugins)
+ if fwaas_plugin_configured and not fwaas_enabled:
+ msg = _("FWaaS plugin is configured in the server side, but "
+ "FWaaS is disabled in L3-agent.")
+ LOG.error(msg)
+ raise SystemExit(1)
+
+ self.fwaas_enabled = fwaas_enabled and fwaas_plugin_configured
if self.fwaas_enabled:
try:
self.fwaas_driver = importutils.import_object(
class L3RouterPluginRpcCallbacks(n_rpc.RpcCallback,
l3_rpc_base.L3RpcCallbackMixin):
- RPC_API_VERSION = '1.2'
+ RPC_API_VERSION = '1.3'
# history
# 1.2 Added methods for DVR support
+ # 1.3 Added a method that returns the list of activated services
class L3RouterPlugin(common_db_mixin.CommonDbMixin,
class FWaasAgent(firewall_l3_agent.FWaaSL3AgentRpcCallback, FWaasHelper):
+ neutron_service_plugins = []
+
def __init__(self, conf=None):
super(FWaasAgent, self).__init__(conf)
+class FWaasTestAgent(firewall_l3_agent.FWaaSL3AgentRpcCallback, FWaasHelper):
+ def __init__(self, conf=None):
+ self.neutron_service_plugins = [constants.FIREWALL]
+ super(FWaasTestAgent, self).__init__(conf)
+
+
class TestFwaasL3AgentRpcCallback(base.BaseTestCase):
def setUp(self):
super(TestFwaasL3AgentRpcCallback, self).setUp()
self.api = FWaasAgent(self.conf)
self.api.fwaas_driver = test_firewall_agent_api.NoopFwaasDriver()
+ def test_missing_fw_config(self):
+ self.conf.fwaas_enabled = False
+ self.assertRaises(SystemExit, FWaasTestAgent, self.conf)
+
def test_create_firewall(self):
fake_firewall = {'id': 0}
with mock.patch.object(
self.mock_ip = mock.MagicMock()
ip_cls.return_value = self.mock_ip
+ mock.patch('neutron.agent.l3_agent.L3PluginApi').start()
+
self.looping_call_p = mock.patch(
'neutron.openstack.common.loopingcall.FixedIntervalLoopingCall')
self.looping_call_p.start()
self.mock_ip = mock.MagicMock()
ip_cls.return_value = self.mock_ip
+ mock.patch('neutron.agent.l3_agent.L3PluginApi').start()
+
self.looping_call_p = mock.patch(
'neutron.openstack.common.loopingcall.FixedIntervalLoopingCall')
self.looping_call_p.start()
l3pluginApi_cls = mock.patch(
'neutron.agent.l3_agent.L3PluginApi').start()
- self.plugin_api = mock.Mock()
+ self.plugin_api = mock.MagicMock()
l3pluginApi_cls.return_value = self.plugin_api
looping_call_p = mock.patch(
self.l3pluginApi_cls_p = mock.patch(
'neutron.agent.l3_agent.L3PluginApi')
l3pluginApi_cls = self.l3pluginApi_cls_p.start()
- self.plugin_api = mock.Mock()
+ self.plugin_api = mock.MagicMock()
l3pluginApi_cls.return_value = self.plugin_api
self.looping_call_p = mock.patch(
l3_plugin_p = mock.patch(
'neutron.agent.l3_agent.L3PluginApi')
l3_plugin_cls = l3_plugin_p.start()
- l3_plugin_cls.return_value = mock.Mock()
+ l3_plugin_cls.return_value = mock.MagicMock()
self.external_process_p = mock.patch(
'neutron.agent.linux.external_process.ProcessManager'