Merge "Notify creation or deletion of dhcp port for security group"

This commit is contained in:
Jenkins 2013-03-07 07:23:41 +00:00 committed by Gerrit Code Review
commit 74c32a0b5c
5 changed files with 27 additions and 35 deletions

View 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

View 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,

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

View 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)

View 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)