def update_port(self, context, id, port): original_port = self.get_port(context, id) session = context.session port_updated = False with session.begin(subtransactions=True): # delete the port binding and read it with the new rules if ext_sg.SECURITYGROUPS in port["port"]: port["port"][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, id, port["port"][ext_sg.SECURITYGROUPS]) port_updated = True port = super(LinuxBridgePluginV2, self).update_port(context, id, port) self._extend_port_dict_security_group(context, port) if original_port["admin_state_up"] != port["admin_state_up"]: port_updated = True if original_port["fixed_ips"] != port["fixed_ips"] or not utils.compare_elements( original_port.get(ext_sg.SECURITYGROUPS), port.get(ext_sg.SECURITYGROUPS) ): self.notifier.security_groups_member_updated(context, port.get(ext_sg.SECURITYGROUPS)) if port_updated: self._notify_port_updated(context, port) return self._extend_port_dict_binding(context, port)
def update_port(self, context, port_id, port): original_port = self.get_port(context, port_id) session = context.session port_updated = False with session.begin(subtransactions=True): # delete the port binding and read it with the new rules if ext_sg.SECURITYGROUPS in port['port']: port['port'][ext_sg.SECURITYGROUPS] = ( self._get_security_groups_on_port(context, port)) self._delete_port_security_group_bindings(context, port_id) self._process_port_create_security_group( context, port_id, port['port'][ext_sg.SECURITYGROUPS]) port_updated = True port = super(BrocadePluginV2, self).update_port(context, port_id, port) self._extend_port_dict_security_group(context, port) if original_port['admin_state_up'] != port['admin_state_up']: port_updated = True if (original_port['fixed_ips'] != port['fixed_ips'] or not utils.compare_elements( original_port.get(ext_sg.SECURITYGROUPS), port.get(ext_sg.SECURITYGROUPS))): self.notifier.security_groups_member_updated( context, port.get(ext_sg.SECURITYGROUPS)) if port_updated: self._notify_port_updated(context, port) return self._extend_port_dict_binding(context, port)
def update_port(self, context, port_id, port): original_port = self.get_port(context, port_id) session = context.session port_updated = False with session.begin(subtransactions=True): # delete the port binding and read it with the new rules if ext_sg.SECURITYGROUPS in port['port']: port['port'][ext_sg.SECURITYGROUPS] = ( self._get_security_groups_on_port(context, port)) self._delete_port_security_group_bindings(context, port_id) # process_port_create_security_group also needs port id port['port']['id'] = port_id self._process_port_create_security_group( context, port['port'], port['port'][ext_sg.SECURITYGROUPS]) port_updated = True port = super(BrocadePluginV2, self).update_port( context, port_id, port) if original_port['admin_state_up'] != port['admin_state_up']: port_updated = True if (original_port['fixed_ips'] != port['fixed_ips'] or not utils.compare_elements( original_port.get(ext_sg.SECURITYGROUPS), port.get(ext_sg.SECURITYGROUPS))): self.notifier.security_groups_member_updated( context, port.get(ext_sg.SECURITYGROUPS)) if port_updated: self._notify_port_updated(context, port) return self._extend_port_dict_binding(context, port)
def is_security_group_member_updated(self, context, original_port, updated_port): """Check security group member updated or not. 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 if original_port["fixed_ips"] != updated_port["fixed_ips"] or not utils.compare_elements( original_port.get(ext_sg.SECURITYGROUPS), updated_port.get(ext_sg.SECURITYGROUPS) ): self.notify_security_groups_member_updated(context, updated_port) need_notify = True return need_notify
def is_security_group_member_updated(self, context, original_port, updated_port): """Check security group member updated or not. 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 if (original_port['fixed_ips'] != updated_port['fixed_ips'] or not utils.compare_elements( original_port.get(ext_sg.SECURITYGROUPS), updated_port.get(ext_sg.SECURITYGROUPS))): self.notify_security_groups_member_updated(context, updated_port) need_notify = True return need_notify