from neutron.callbacks import registry
from neutron.callbacks import resources
from neutron.common import constants
+from neutron.common import utils
from neutron.db import api as db_api
from neutron.db import db_base_plugin_v2
from neutron.db import model_base
port['port'][ext_sg.SECURITYGROUPS] != [])):
return True
return False
+
+ def update_security_group_on_port(self, context, id, port,
+ original_port, updated_port):
+ """Update security groups on port.
+
+ This method returns a flag which indicates request notification
+ is required and does not perform notification itself.
+ It is because another changes for the port may require notification.
+ """
+ need_notify = False
+ port_updates = port['port']
+ if (ext_sg.SECURITYGROUPS in port_updates and
+ not utils.compare_elements(
+ original_port.get(ext_sg.SECURITYGROUPS),
+ port_updates[ext_sg.SECURITYGROUPS])):
+ # delete the port binding and read it with the new rules
+ port_updates[ext_sg.SECURITYGROUPS] = (
+ self._get_security_groups_on_port(context, port))
+ self._delete_port_security_group_bindings(context, id)
+ self._process_port_create_security_group(
+ context,
+ updated_port,
+ port_updates[ext_sg.SECURITYGROUPS])
+ need_notify = True
+ else:
+ updated_port[ext_sg.SECURITYGROUPS] = (
+ original_port[ext_sg.SECURITYGROUPS])
+ return need_notify
self.notifier.security_groups_rule_updated(context,
[rule['security_group_id']])
- def update_security_group_on_port(self, context, id, port,
- original_port, updated_port):
- """Update security groups on port.
-
- This method returns a flag which indicates request notification
- is required and does not perform notification itself.
- It is because another changes for the port may require notification.
- """
- need_notify = False
- port_updates = port['port']
- if (ext_sg.SECURITYGROUPS in port_updates and
- not utils.compare_elements(
- original_port.get(ext_sg.SECURITYGROUPS),
- port_updates[ext_sg.SECURITYGROUPS])):
- # delete the port binding and read it with the new rules
- port_updates[ext_sg.SECURITYGROUPS] = (
- self._get_security_groups_on_port(context, port))
- self._delete_port_security_group_bindings(context, id)
- self._process_port_create_security_group(
- context,
- updated_port,
- port_updates[ext_sg.SECURITYGROUPS])
- need_notify = True
- else:
- updated_port[ext_sg.SECURITYGROUPS] = (
- original_port[ext_sg.SECURITYGROUPS])
- return need_notify
-
def check_and_notify_security_group_member_changed(
self, context, original_port, updated_port):
sg_change = not utils.compare_elements(