summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2021-07-09 12:41:42 +0000
committerGerrit Code Review <review@openstack.org>2021-07-09 12:41:42 +0000
commitf55789181d4057902e20c0c27c7fbe368a08bce2 (patch)
treeeceebfc542b014abfb2724e11db6d542e7ba1f4f
parent32f2d3940d66d85cb5d9c56329f3476f50933d76 (diff)
parentbe4a514c8aea073a9188cfc878c9afcc9b03cb28 (diff)
downloadnova-f55789181d4057902e20c0c27c7fbe368a08bce2.tar.gz
Merge "[neutron] Get only ID and name of the SGs from Neutron" into stable/ussuri
-rw-r--r--nova/network/neutron.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/nova/network/neutron.py b/nova/network/neutron.py
index 745d522f8c..66194cb696 100644
--- a/nova/network/neutron.py
+++ b/nova/network/neutron.py
@@ -819,9 +819,15 @@ class API(base.Base):
# 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