Merge "Add port forwarding floating IP QoS"

This commit is contained in:
Zuul 2019-02-01 18:31:33 +00:00 committed by Gerrit Code Review
commit a159a7294d
7 changed files with 61 additions and 5 deletions

View File

@ -248,7 +248,8 @@ class FipQosAgentExtension(qos_base.L3QosAgentExtensionBase,
"for router: %s", router_info.router_id)
return
floating_ips = router_info.get_floating_ips()
floating_ips = (router_info.get_floating_ips() +
router_info.get_port_forwarding_fips())
current_fips = self.fip_qos_map.router_floating_ips.get(
router_info.router_id, set())
new_fips = set()

View File

@ -166,6 +166,10 @@ class RouterInfo(object):
"""Filter Floating IPs to be hosted on this agent."""
return self.router.get(lib_constants.FLOATINGIP_KEY, [])
def get_port_forwarding_fips(self):
"""Get router port forwarding floating IPs."""
return self.router.get('_pf_floatingips', [])
def floating_forward_rules(self, fip):
fixed_ip = fip['fixed_ip_address']
floating_ip = fip['floating_ip_address']

View File

@ -47,6 +47,9 @@ from neutron.services.portforwarding.common import exceptions as pf_exc
LOG = logging.getLogger(__name__)
# Move to neutron-lib someday.
PORT_FORWARDING_FLOATINGIP_KEY = '_pf_floatingips'
def make_result_with_fields(f):
@functools.wraps(f)
@ -511,18 +514,25 @@ class PortForwardingPlugin(fip_pf.PortForwardingPluginBase):
router_ids = [router.get('id') for router in routers]
router_pf_fip_set = collections.defaultdict(set)
fip_pfs = collections.defaultdict(set)
router_fip = collections.defaultdict(set)
router_fip_ids = collections.defaultdict(set)
item_pf_fields = pf.PortForwarding.get_port_forwarding_obj_by_routers(
context, router_ids)
for router_id, fip_addr, pf_id, fip_id in item_pf_fields:
router_pf_fip_set[router_id].add(utils.ip_to_cidr(fip_addr, 32))
fip_pfs[fip_id].add(pf_id)
router_fip[router_id].add(fip_id)
router_fip_ids[router_id].add(fip_id)
for router in routers:
if router['id'] in router_fip:
if router['id'] in router_fip_ids:
router['port_forwardings_fip_set'] = router_pf_fip_set[
router['id']]
router['fip_managed_by_port_forwardings'] = router_fip[
router['fip_managed_by_port_forwardings'] = router_fip_ids[
router['id']]
router_pf_fips_info = router.get(
PORT_FORWARDING_FLOATINGIP_KEY, [])
for fip_id in router_fip_ids[router['id']]:
fip = self.l3_plugin.get_floatingip(context, fip_id)
router_pf_fips_info.append(fip)
router[PORT_FORWARDING_FLOATINGIP_KEY] = router_pf_fips_info

View File

@ -59,6 +59,7 @@ def prepare_router_data(ip_version=lib_constants.IP_VERSION_4,
extra_routes=False, dual_stack=False, enable_gw=True,
v6_ext_gw_with_sub=True,
snat_bound_fip=False,
enable_pf_floating_ip=False,
**kwargs):
fixed_ips = []
subnets = []
@ -143,6 +144,19 @@ def prepare_router_data(ip_version=lib_constants.IP_VERSION_4,
router_fips.append(fip)
router[lib_constants.FLOATINGIP_KEY] = router_fips
pf_fips = []
if enable_pf_floating_ip:
fip = {'id': _uuid(),
'port_id': _uuid(),
'status': 'DOWN',
'floating_ip_address': '19.4.4.4',
'fixed_ip_address': '10.0.0.3'}
qos_policy_id = kwargs.get(qos_consts.QOS_POLICY_ID)
if qos_policy_id:
fip[qos_consts.QOS_POLICY_ID] = qos_policy_id
pf_fips.append(fip)
router['_pf_floatingips'] = pf_fips
router_append_interface(router, count=num_internal_ports,
ip_version=ip_version, dual_stack=dual_stack)
if enable_ha:

View File

@ -174,6 +174,23 @@ class TestL3AgentFipQosExtension(L3AgentFipQoSExtensionTestFramework):
self._test_centralized_routers(enable_ha=True,
ingress=False, egress=True)
def _test_router_with_pf_fips_qos(self, enable_ha):
router_info = self.generate_router_info(
enable_ha=enable_ha,
enable_pf_floating_ip=True,
qos_policy_id=TEST_POLICY_ID1)
ri = self.manage_router(self.agent, router_info)
self._assert_bandwidth_limit_rule_is_set(
ri, '19.4.4.4', self.test_bw_limit_rule_1)
self._assert_bandwidth_limit_rule_is_set(
ri, '19.4.4.4', self.test_bw_limit_rule_2)
def test_ha_router_with_pf_fips_qos(self):
self._test_router_with_pf_fips_qos(enable_ha=True)
def test_legacy_router_with_pf_fips_qos(self):
self._test_router_with_pf_fips_qos(enable_ha=False)
class TestL3AgentFipQosExtensionDVR(
test_dvr_router.TestDvrRouter,

View File

@ -109,6 +109,7 @@ class L3AgentTestFramework(base.BaseSudoTestCase):
enable_fip=True, enable_snat=True,
num_internal_ports=1,
dual_stack=False, v6_ext_gw_with_sub=True,
enable_pf_floating_ip=False,
qos_policy_id=None):
if ip_version == constants.IP_VERSION_6 and not dual_stack:
enable_snat = False
@ -125,6 +126,8 @@ class L3AgentTestFramework(base.BaseSudoTestCase):
dual_stack=dual_stack,
v6_ext_gw_with_sub=(
v6_ext_gw_with_sub),
enable_pf_floating_ip=(
enable_pf_floating_ip),
qos_policy_id=qos_policy_id)
def _test_conntrack_disassociate_fip(self, ha):

View File

@ -0,0 +1,7 @@
---
features:
- |
L3 agent supports QoS bandwidth limit functionality for port
forwarding floating IPs now. If floating IP has binding QoS
policy (with bandwidth limit rules), the traffic bandwidth
will be limited.