]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Only fetch port_id from SG binding table
authorKevin Benton <blak111@gmail.com>
Fri, 17 Oct 2014 04:21:15 +0000 (21:21 -0700)
committerKevin Benton <kevinbenton@buttewifi.com>
Wed, 22 Oct 2014 09:47:02 +0000 (09:47 +0000)
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

index 1dda6bb46982325494e504fe61dc7a072f0b7802..2f6606ad566f06e09fe61f157e50ab09a5e9e590 100644 (file)
@@ -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 = {