From c5ae9dd2789570ad0c885aa88ae08e0a24e41d52 Mon Sep 17 00:00:00 2001 From: Kevin Benton Date: Thu, 16 Oct 2014 21:21:15 -0700 Subject: [PATCH] Only fetch port_id from SG binding table Change a query to only retrieve the port_id instead of every column from the row of security group binding info. Partial-Bug: #1373851 Change-Id: I0fba9c9623898ee52590207ebbb728503bb59a5b (cherry picked from commit 6acadab5eb8b7b627e097a638d8486bef59a7f30) --- neutron/db/securitygroups_rpc_base.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/neutron/db/securitygroups_rpc_base.py b/neutron/db/securitygroups_rpc_base.py index 1dda6bb46..2f6606ad5 100644 --- a/neutron/db/securitygroups_rpc_base.py +++ b/neutron/db/securitygroups_rpc_base.py @@ -153,8 +153,7 @@ class SecurityGroupServerRpcMixin(sg_db.SecurityGroupDbMixin): 'sg_member_ips': {}} rules_in_db = self._select_rules_for_ports(context, ports) remote_security_group_info = {} - for (binding, rule_in_db) in rules_in_db: - port_id = binding['port_id'] + for (port_id, rule_in_db) in rules_in_db: remote_gid = rule_in_db.get('remote_group_id') security_group_id = rule_in_db.get('security_group_id') ethertype = rule_in_db['ethertype'] @@ -219,7 +218,7 @@ class SecurityGroupServerRpcMixin(sg_db.SecurityGroupDbMixin): sgr_sgid = sg_db.SecurityGroupRule.security_group_id - query = context.session.query(sg_db.SecurityGroupPortBinding, + query = context.session.query(sg_binding_port, sg_db.SecurityGroupRule) query = query.join(sg_db.SecurityGroupRule, sgr_sgid == sg_binding_sgid) @@ -417,8 +416,7 @@ class SecurityGroupServerRpcMixin(sg_db.SecurityGroupDbMixin): def security_group_rules_for_ports(self, context, ports): rules_in_db = self._select_rules_for_ports(context, ports) - for (binding, rule_in_db) in rules_in_db: - port_id = binding['port_id'] + for (port_id, rule_in_db) in rules_in_db: port = ports[port_id] direction = rule_in_db['direction'] rule_dict = { -- 2.45.2