Merge "[QoS][L3] Use floating IP OVO QoS fields"
This commit is contained in:
commit
1b68aebaba
@ -37,6 +37,7 @@ from neutron_lib.plugins import directory
|
||||
from neutron_lib.plugins import utils as plugin_utils
|
||||
from neutron_lib import rpc as n_rpc
|
||||
from neutron_lib.services import base as base_services
|
||||
from neutron_lib.services.qos import constants as qos_const
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import uuidutils
|
||||
from sqlalchemy import orm
|
||||
@ -1413,6 +1414,8 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
|
||||
|
||||
floating_fixed_ip = external_ipv4_ips[0]
|
||||
floating_ip_address = floating_fixed_ip['ip_address']
|
||||
qos_policy_id = (fip.get(qos_const.QOS_POLICY_ID)
|
||||
if self._is_fip_qos_supported else None)
|
||||
floatingip_obj = l3_obj.FloatingIP(
|
||||
context,
|
||||
id=fip_id,
|
||||
@ -1421,7 +1424,8 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
|
||||
floating_network_id=fip['floating_network_id'],
|
||||
floating_ip_address=floating_ip_address,
|
||||
floating_port_id=external_port['id'],
|
||||
description=fip.get('description'))
|
||||
description=fip.get('description'),
|
||||
qos_policy_id=qos_policy_id)
|
||||
# Update association with internal port
|
||||
# and define external IP address
|
||||
assoc_result = self._update_fip_assoc(context, fip, floatingip_obj)
|
||||
@ -1431,8 +1435,6 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
|
||||
if self._is_dns_integration_supported:
|
||||
dns_data = self._process_dns_floatingip_create_precommit(
|
||||
context, floatingip_dict, fip)
|
||||
if self._is_fip_qos_supported:
|
||||
self._process_extra_fip_qos_create(context, fip_id, fip)
|
||||
|
||||
registry.publish(resources.FLOATING_IP,
|
||||
events.PRECOMMIT_CREATE,
|
||||
@ -1490,17 +1492,15 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
|
||||
old_floatingip = self._make_floatingip_dict(floatingip_obj)
|
||||
old_fixed_port_id = floatingip_obj.fixed_port_id
|
||||
assoc_result = self._update_fip_assoc(context, fip, floatingip_obj)
|
||||
if self._is_fip_qos_supported:
|
||||
floatingip_obj.qos_policy_id = fip.get(qos_const.QOS_POLICY_ID)
|
||||
|
||||
floatingip_obj.update()
|
||||
floatingip_dict = self._make_floatingip_dict(floatingip_obj)
|
||||
|
||||
if self._is_dns_integration_supported:
|
||||
dns_data = self._process_dns_floatingip_update_precommit(
|
||||
context, floatingip_dict)
|
||||
if self._is_fip_qos_supported:
|
||||
self._process_extra_fip_qos_update(context,
|
||||
floatingip_obj,
|
||||
fip,
|
||||
old_floatingip)
|
||||
floatingip_obj = l3_obj.FloatingIP.get_object(
|
||||
context, id=floatingip_obj.id)
|
||||
floatingip_db = floatingip_obj.db_obj
|
||||
|
@ -16,8 +16,6 @@ from neutron_lib.api.definitions import l3 as l3_apidef
|
||||
from neutron_lib.db import resource_extend
|
||||
from neutron_lib.services.qos import constants as qos_consts
|
||||
|
||||
from neutron.objects.qos import policy as policy_object
|
||||
|
||||
|
||||
@resource_extend.has_resource_extenders
|
||||
class FloatingQoSDbMixin(object):
|
||||
@ -33,37 +31,3 @@ class FloatingQoSDbMixin(object):
|
||||
fip_db.qos_network_policy_binding else None)
|
||||
fip_res[qos_consts.QOS_NETWORK_POLICY_ID] = qos_id
|
||||
return fip_res
|
||||
|
||||
def _create_fip_qos_db(self, context, fip_id, policy_id):
|
||||
policy = policy_object.QosPolicy.get_policy_obj(context, policy_id)
|
||||
policy.attach_floatingip(fip_id)
|
||||
|
||||
def _delete_fip_qos_db(self, context, fip_id, policy_id):
|
||||
policy = policy_object.QosPolicy.get_policy_obj(context, policy_id)
|
||||
policy.detach_floatingip(fip_id)
|
||||
|
||||
def _process_extra_fip_qos_create(self, context, fip_id, fip):
|
||||
qos_policy_id = fip.get(qos_consts.QOS_POLICY_ID)
|
||||
if not qos_policy_id:
|
||||
return
|
||||
self._create_fip_qos_db(context, fip_id, qos_policy_id)
|
||||
|
||||
def _process_extra_fip_qos_update(
|
||||
self, context, floatingip_obj, fip, old_floatingip):
|
||||
if qos_consts.QOS_POLICY_ID not in fip:
|
||||
# No qos_policy_id in API input, do nothing
|
||||
return
|
||||
|
||||
new_qos_policy_id = fip.get(qos_consts.QOS_POLICY_ID)
|
||||
old_qos_policy_id = old_floatingip.get(qos_consts.QOS_POLICY_ID)
|
||||
|
||||
if old_qos_policy_id == new_qos_policy_id:
|
||||
return
|
||||
if old_qos_policy_id:
|
||||
self._delete_fip_qos_db(context,
|
||||
floatingip_obj['id'],
|
||||
old_qos_policy_id)
|
||||
if not new_qos_policy_id:
|
||||
return
|
||||
self._create_fip_qos_db(
|
||||
context, floatingip_obj['id'], new_qos_policy_id)
|
||||
|
Loading…
Reference in New Issue
Block a user