]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Notify creation or deletion of dhcp port for security group
authorNachi Ueno <nachi@nttmcl.com>
Fri, 1 Mar 2013 00:46:52 +0000 (16:46 -0800)
committerNachi Ueno <nachi@nttmcl.com>
Wed, 6 Mar 2013 18:46:06 +0000 (10:46 -0800)
fixes bug 1103840

Change-Id: I8031bc607a874871a8081575bce1526b3453aff6

quantum/db/securitygroups_rpc_base.py
quantum/plugins/linuxbridge/lb_quantum_plugin.py
quantum/plugins/nec/nec_plugin.py
quantum/plugins/openvswitch/ovs_quantum_plugin.py
quantum/plugins/ryu/ryu_quantum_plugin.py

index 8d00a736c90099954aeeb00b99b6ff7229e3a513..c70af3574d62d0b2de7fab7a828f46d7a1d17f32 100644 (file)
@@ -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
index fa38b2229e1168eaa04d7393e220a08bc75169cd..2e4f4824db0da9a2175878c36006c95683020e17 100644 (file)
@@ -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,
index e662f80c5c43d424af04a98cbd00f3870bdfaac5..0a89bfff481b6d689197cdd10b0903e3508846eb 100644 (file)
@@ -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):
index 8fadc4e974a58bee238e2e1dd89b702917681d5d..941d6341f406f8bfd6b655da82d045b6863798f7 100644 (file)
@@ -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)
index d2253987f0d73adce9872bf782b23c4943571f08..06a50e0cd733f893470651bb8bbc314fdbb0dce1 100644 (file)
@@ -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)