summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2021-07-17 06:58:47 +0000
committerGerrit Code Review <review@openstack.org>2021-07-17 06:58:47 +0000
commit456b3d050131bc29ce16140ec21d5a532bf1ff94 (patch)
tree1e23ebb973fae3a196c056a20e19aee5827154bf
parent5fa8718fe57e59b178d081e2068109151fdc3926 (diff)
parent9b24ff384e336d3369b796427d34787872d9a08e (diff)
downloadnova-456b3d050131bc29ce16140ec21d5a532bf1ff94.tar.gz
Merge "[neutron] Get only ID and name of the SGs from Neutron" into stable/stein
-rw-r--r--nova/network/neutronv2/api.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/nova/network/neutronv2/api.py b/nova/network/neutronv2/api.py
index 8a60291910..2f4e39b1cb 100644
--- a/nova/network/neutronv2/api.py
+++ b/nova/network/neutronv2/api.py
@@ -828,9 +828,15 @@ class API(base_api.NetworkAPI):
# TODO(arosen) Should optimize more to do direct query for security
# group if len(security_groups) == 1
if len(security_groups):
+ # NOTE(slaweq): fields other than name and id aren't really needed
+ # so asking only about those fields will allow Neutron to not
+ # prepare list of rules for each found security group. That may
+ # speed processing of this request a lot in case when tenant has
+ # got many security groups
+ sg_fields = ['id', 'name']
search_opts = {'tenant_id': instance.project_id}
user_security_groups = neutron.list_security_groups(
- **search_opts).get('security_groups')
+ fields=sg_fields, **search_opts).get('security_groups')
for security_group in security_groups:
name_match = None