Use same instance of iptables_manager in L2 agent and extensions
This commit adds common_agent_extension class which is agent API for L2 extension drivers used e.g. by Linuxbridge agent. This is necessary to be able to use instance of iptables_manager used in firewall driver also in L2 extension drivers (like qos). This patch refactors little bit iptables_manager code to make possible to initialize e.g. mangle or nat table on demand, even if iptables is created as "state_less" Change-Id: I3b66e49b7f176124e8aea3eb96d0d465f1ab1ea0 Closes-Bug: #1736674changes/65/527965/6
parent
59e2c40f14
commit
cbee0f9f88
@ -0,0 +1,32 @@
|
||||
# Copyright 2017 OVH SAS
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
|
||||
class LinuxbridgeAgentExtensionAPI(object):
|
||||
'''Implements the Agent API for L2 agent.
|
||||
|
||||
Extensions can gain access to this API by overriding the consume_api
|
||||
method which has been added to the AgentExtension class.
|
||||
'''
|
||||
|
||||
def __init__(self, iptables_manager):
|
||||
super(LinuxbridgeAgentExtensionAPI, self).__init__()
|
||||
self.iptables_manager = iptables_manager
|
||||
|
||||
def get_iptables_manager(self):
|
||||
"""Allows extensions to get an iptables manager, used by agent,
|
||||
to use for managing extension specific iptables rules
|
||||
"""
|
||||
return self.iptables_manager
|
@ -0,0 +1,33 @@
|
||||
# Copyright 2017 OVH SAS
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import mock
|
||||
|
||||
from neutron.plugins.ml2.drivers.linuxbridge.agent import \
|
||||
linuxbridge_agent_extension_api as ext_api
|
||||
from neutron.tests import base
|
||||
|
||||
|
||||
class TestLinuxbridgeAgentExtensionAPI(base.BaseTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestLinuxbridgeAgentExtensionAPI, self).setUp()
|
||||
self.iptables_manager = mock.Mock()
|
||||
self.extension_api = ext_api.LinuxbridgeAgentExtensionAPI(
|
||||
self.iptables_manager)
|
||||
|
||||
def test_get_iptables_manager(self):
|
||||
self.assertEqual(self.iptables_manager,
|
||||
self.extension_api.get_iptables_manager())
|
@ -0,0 +1,12 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
L2 agents based on ``ML2`` ``_common_agent`` have now the L2 extension API
|
||||
available. This API can be used by L2 extension drivers to request
|
||||
resources from the L2 agent.
|
||||
It is used, for example, to pass an instance of the ``IptablesManager``
|
||||
to the ``Linuxbridge`` L2 agent ``QoS extension driver``.
|
||||
fixes:
|
||||
- |
|
||||
Fixes bug 1736674, security group rules are now properly applied
|
||||
by ``Linuxbridge L2 agent`` with ``QoS extension driver`` enabled.
|
Loading…
Reference in New Issue