This patch ensures allowed address pairs bindings are refreshed
only when they actually change.
This will also avoid sending a notification to the agent if no
change actually occured.
Closes-Bug: #
1255145
Partial blueprint neutron-tempest-parallel
Change-Id: Iac2502586a0d215a29194590c16c2e1a064f943b
from sqlalchemy import orm
from neutron.api.v2 import attributes as attr
+from neutron.common import utils
from neutron.db import db_base_plugin_v2
from neutron.db import model_base
from neutron.db import models_v2
"""
return (addr_pair.ADDRESS_PAIRS in port['port'] and
not self._has_address_pairs(port))
+
+ def is_address_pairs_attribute_updated(self, port, update_attrs):
+ """Check if the address pairs attribute is being updated.
+
+ This method returns a flag which indicates whether there is an update
+ and therefore a port update notification should be sent to agents or
+ third party controllers.
+ """
+ new_pairs = update_attrs.get(addr_pair.ADDRESS_PAIRS)
+ if new_pairs and not utils.compare_elements(
+ port.get(addr_pair.ADDRESS_PAIRS), new_pairs):
+ return True
+ # Missing or unchanged address pairs in attributes mean no update
+ return False
original_port = super(Ml2Plugin, self).get_port(context, id)
updated_port = super(Ml2Plugin, self).update_port(context, id,
port)
- if addr_pair.ADDRESS_PAIRS in port['port']:
+ if self.is_address_pairs_attribute_updated(original_port, port):
self._delete_allowed_address_pairs(context, id)
self._process_create_allowed_address_pairs(
context, updated_port,
new_port = super(NECPluginV2, self).update_port(context, id, port)
portinfo_changed = self._process_portbindings_update(
context, port['port'], new_port)
- if addr_pair.ADDRESS_PAIRS in port['port']:
+ if self.is_address_pairs_attribute_updated(old_port, port):
self._delete_allowed_address_pairs(context, id)
self._process_create_allowed_address_pairs(
context, new_port,
context, id)
updated_port = super(OVSNeutronPluginV2, self).update_port(
context, id, port)
- if addr_pair.ADDRESS_PAIRS in port['port']:
+ if self.is_address_pairs_attribute_updated(original_port, port):
self._delete_allowed_address_pairs(context, id)
self._process_create_allowed_address_pairs(
context, updated_port,