From a30f2cbb1bb0e4417609c136df55c1df61098716 Mon Sep 17 00:00:00 2001 From: Kevin Benton Date: Tue, 13 Jun 2017 22:04:07 -0700 Subject: [PATCH] Move info retrieval methods below notifier This is a simple code move within a class to prepare for a class separation in the following patches. TrivialFix Partially-Implements: blueprint push-notifications Change-Id: Ibe40973568f1c9def2ded2f3a750e3423f4bd416 --- neutron/db/securitygroups_rpc_base.py | 60 +++++++++++++-------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/neutron/db/securitygroups_rpc_base.py b/neutron/db/securitygroups_rpc_base.py index 82d5e628465..c3d6a199bb0 100644 --- a/neutron/db/securitygroups_rpc_base.py +++ b/neutron/db/securitygroups_rpc_base.py @@ -50,36 +50,6 @@ class SecurityGroupServerRpcMixin(sg_db.SecurityGroupDbMixin): """Trigger notification to other SG members on port changes.""" self.notify_security_groups_member_updated(context, port) - def get_port_from_device(self, context, device): - """Get port dict from device name on an agent. - - Subclass must provide this method or get_ports_from_devices. - - :param device: device name which identifies a port on the agent side. - What is specified in "device" depends on a plugin agent implementation. - For example, it is a port ID in OVS agent and netdev name in Linux - Bridge agent. - :return: port dict returned by DB plugin get_port(). In addition, - it must contain the following fields in the port dict returned. - - device - - security_groups - - security_group_rules, - - security_group_source_groups - - fixed_ips - """ - raise NotImplementedError(_("%s must implement get_port_from_device " - "or get_ports_from_devices.") - % self.__class__.__name__) - - def get_ports_from_devices(self, context, devices): - """Bulk method of get_port_from_device. - - Subclasses may override this to provide better performance for DB - queries, backend calls, etc. - """ - return [self.get_port_from_device(context, device) - for device in devices] - def create_security_group_rule(self, context, security_group_rule): rule = super(SecurityGroupServerRpcMixin, self).create_security_group_rule(context, @@ -175,6 +145,36 @@ class SecurityGroupServerRpcMixin(sg_db.SecurityGroupDbMixin): def notify_security_groups_member_updated(self, context, port): self.notify_security_groups_member_updated_bulk(context, [port]) + def get_port_from_device(self, context, device): + """Get port dict from device name on an agent. + + Subclass must provide this method or get_ports_from_devices. + + :param device: device name which identifies a port on the agent side. + What is specified in "device" depends on a plugin agent implementation. + For example, it is a port ID in OVS agent and netdev name in Linux + Bridge agent. + :return: port dict returned by DB plugin get_port(). In addition, + it must contain the following fields in the port dict returned. + - device + - security_groups + - security_group_rules, + - security_group_source_groups + - fixed_ips + """ + raise NotImplementedError(_("%s must implement get_port_from_device " + "or get_ports_from_devices.") + % self.__class__.__name__) + + def get_ports_from_devices(self, context, devices): + """Bulk method of get_port_from_device. + + Subclasses may override this to provide better performance for DB + queries, backend calls, etc. + """ + return [self.get_port_from_device(context, device) + for device in devices] + def security_group_info_for_ports(self, context, ports): sg_info = {'devices': ports, 'security_groups': {},