diff --git a/quantum/db/securitygroups_rpc_base.py b/quantum/db/securitygroups_rpc_base.py index 5894f74cb1..78a4c7e7b7 100644 --- a/quantum/db/securitygroups_rpc_base.py +++ b/quantum/db/securitygroups_rpc_base.py @@ -96,11 +96,28 @@ class SecurityGroupServerRpcMixin(sg_db.SecurityGroupDbMixin): not utils.compare_elements( original_port.get(ext_sg.SECURITYGROUPS), updated_port.get(ext_sg.SECURITYGROUPS))): - self.notifier.security_groups_member_updated( - context, updated_port.get(ext_sg.SECURITYGROUPS)) + self.notify_security_groups_member_updated( + context, updated_port) need_notify = True return need_notify + def notify_security_groups_member_updated(self, context, port): + """ notify update event of security group members + + The agent setups the iptables rule to allow + ingress packet from the dhcp server (as a part of provider rules), + so we need to notify an update of dhcp server ip + address to the plugin agent. + security_groups_provider_updated() just notifies that an event + occurs and the plugin agent fetches the update provider + rule in the other RPC call (security_group_rules_for_devices). + """ + if port['device_owner'] == q_const.DEVICE_OWNER_DHCP: + self.notifier.security_groups_provider_updated(context) + else: + self.notifier.security_groups_member_updated( + context, port.get(ext_sg.SECURITYGROUPS)) + class SecurityGroupServerRpcCallbackMixin(object): """A mix-in that enable SecurityGroup agent diff --git a/quantum/plugins/linuxbridge/lb_quantum_plugin.py b/quantum/plugins/linuxbridge/lb_quantum_plugin.py index fa38b2229e..2e4f4824db 100644 --- a/quantum/plugins/linuxbridge/lb_quantum_plugin.py +++ b/quantum/plugins/linuxbridge/lb_quantum_plugin.py @@ -506,11 +506,7 @@ class LinuxBridgePluginV2(db_base_plugin_v2.QuantumDbPluginV2, self._process_port_create_security_group( context, port['id'], sgids) self._extend_port_dict_security_group(context, port) - if port['device_owner'] == q_const.DEVICE_OWNER_DHCP: - self.notifier.security_groups_provider_updated(context) - else: - self.notifier.security_groups_member_updated( - context, port.get(ext_sg.SECURITYGROUPS)) + self.notify_security_groups_member_updated(context, port) return self._extend_port_dict_binding(context, port) def update_port(self, context, id, port): @@ -548,8 +544,7 @@ class LinuxBridgePluginV2(db_base_plugin_v2.QuantumDbPluginV2, self._delete_port_security_group_bindings(context, id) super(LinuxBridgePluginV2, self).delete_port(context, id) - self.notifier.security_groups_member_updated( - context, port.get(ext_sg.SECURITYGROUPS)) + self.notify_security_groups_member_updated(context, port) def _notify_port_updated(self, context, port): binding = db.get_network_binding(context.session, diff --git a/quantum/plugins/nec/nec_plugin.py b/quantum/plugins/nec/nec_plugin.py index e662f80c5c..0a89bfff48 100644 --- a/quantum/plugins/nec/nec_plugin.py +++ b/quantum/plugins/nec/nec_plugin.py @@ -383,14 +383,7 @@ class NECPluginV2(nec_plugin_base.NECPluginV2Base, self._process_port_create_security_group( context, port['id'], sgids) self._extend_port_dict_security_group(context, port) - # Note: In order to allow dhcp packets, - # changes for dhcp ip should be notifified - if port['device_owner'] == q_const.DEVICE_OWNER_DHCP: - self.notifier.security_groups_provider_updated(context) - else: - self.notifier.security_groups_member_updated( - context, port.get(ext_sg.SECURITYGROUPS)) - + self.notify_security_groups_member_updated(context, port) self._update_resource_status(context, "port", port['id'], OperationalStatus.BUILD) self.activate_port_if_ready(context, port) @@ -455,8 +448,7 @@ class NECPluginV2(nec_plugin_base.NECPluginV2Base, self.disassociate_floatingips(context, id) self._delete_port_security_group_bindings(context, id) super(NECPluginV2, self).delete_port(context, id) - self.notifier.security_groups_member_updated( - context, port.get(ext_sg.SECURITYGROUPS)) + self.notify_security_groups_member_updated(context, port) def get_port(self, context, id, fields=None): with context.session.begin(subtransactions=True): diff --git a/quantum/plugins/openvswitch/ovs_quantum_plugin.py b/quantum/plugins/openvswitch/ovs_quantum_plugin.py index 8fadc4e974..941d6341f4 100644 --- a/quantum/plugins/openvswitch/ovs_quantum_plugin.py +++ b/quantum/plugins/openvswitch/ovs_quantum_plugin.py @@ -569,13 +569,7 @@ class OVSQuantumPluginV2(db_base_plugin_v2.QuantumDbPluginV2, self._process_port_create_security_group( context, port['id'], sgids) self._extend_port_dict_security_group(context, port) - #Note(nati): In order to allow dhcp packets, - # changes for dhcp ip should be notifified - if port['device_owner'] == q_const.DEVICE_OWNER_DHCP: - self.notifier.security_groups_provider_updated(context) - else: - self.notifier.security_groups_member_updated( - context, port.get(ext_sg.SECURITYGROUPS)) + self.notify_security_groups_member_updated(context, port) return self._extend_port_dict_binding(context, port) def get_port(self, context, id, fields=None): @@ -641,5 +635,4 @@ class OVSQuantumPluginV2(db_base_plugin_v2.QuantumDbPluginV2, self._delete_port_security_group_bindings(context, id) super(OVSQuantumPluginV2, self).delete_port(context, id) - self.notifier.security_groups_member_updated( - context, port.get(ext_sg.SECURITYGROUPS)) + self.notify_security_groups_member_updated(context, port) diff --git a/quantum/plugins/ryu/ryu_quantum_plugin.py b/quantum/plugins/ryu/ryu_quantum_plugin.py index d2253987f0..06a50e0cd7 100644 --- a/quantum/plugins/ryu/ryu_quantum_plugin.py +++ b/quantum/plugins/ryu/ryu_quantum_plugin.py @@ -198,11 +198,7 @@ class RyuQuantumPluginV2(db_base_plugin_v2.QuantumDbPluginV2, self._process_port_create_security_group( context, port['id'], sgids) self._extend_port_dict_security_group(context, port) - if port['device_owner'] == q_const.DEVICE_OWNER_DHCP: - self.notifier.security_groups_provider_updated(context) - else: - self.notifier.security_groups_member_updated( - context, port.get(ext_sg.SECURITYGROUPS)) + self.notify_security_groups_member_updated(context, port) self.iface_client.create_network_id(port['id'], port['network_id']) return port @@ -218,8 +214,7 @@ class RyuQuantumPluginV2(db_base_plugin_v2.QuantumDbPluginV2, self._delete_port_security_group_bindings(context, id) super(RyuQuantumPluginV2, self).delete_port(context, id) - self.notifier.security_groups_member_updated( - context, port.get(ext_sg.SECURITYGROUPS)) + self.notify_security_groups_member_updated(context, port) def update_port(self, context, id, port): deleted = port['port'].get('deleted', False)