diff options
author | Zuul <zuul@review.opendev.org> | 2021-09-11 14:12:20 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2021-09-11 14:12:20 +0000 |
commit | 9cd02d3967c4f7984102edaa2e4870441c562fb0 (patch) | |
tree | a20a11a013be24a84c11ba2841f2ce113cd909c2 | |
parent | 677f528732ef8fa954962382e94b89c139483d90 (diff) | |
parent | eccc1b554bbd65bf3ce283869cc0f05f361f939a (diff) | |
download | nova-stable/queens.tar.gz |
Merge "[neutron] Get only ID and name of the SGs from Neutron" into stable/queensstable/queens
-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 6ec851f597..f57863eb28 100644 --- a/nova/network/neutronv2/api.py +++ b/nova/network/neutronv2/api.py @@ -716,9 +716,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 |