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
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):
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,
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)
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):
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):
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)
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
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)