diff options
author | Zuul <zuul@review.opendev.org> | 2021-08-09 15:04:48 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2021-08-09 15:04:48 +0000 |
commit | 32200feb78e3a4a8c5d205756007f3b6a3c12981 (patch) | |
tree | c925017c797ac6cded3731df31a44924890ab364 | |
parent | 0049f0370fcc8f1ff915b27ed20c3f3270b56e26 (diff) | |
parent | d27a662be6cee6c11f643f53ca2ce73bdcefa4ac (diff) | |
download | nova-32200feb78e3a4a8c5d205756007f3b6a3c12981.tar.gz |
Merge "[neutron] Get only ID and name of the SGs from Neutron" into stable/rockystable/rocky
-rw-r--r-- | nova/network/neutronv2/api.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/nova/network/neutronv2/api.py b/nova/network/neutronv2/api.py index 1884a4bf1a..b475aa7a80 100644 --- a/nova/network/neutronv2/api.py +++ b/nova/network/neutronv2/api.py @@ -797,9 +797,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 |