Skip to content

Commit a5ce4d8

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "[neutron] Get only ID and name of the SGs from Neutron" into stable/wallaby
2 parents 79707c6 + 4f49545 commit a5ce4d8

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

nova/network/neutron.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -802,9 +802,15 @@ def _process_security_groups(self, instance, neutron, security_groups):
802802
# TODO(arosen) Should optimize more to do direct query for security
803803
# group if len(security_groups) == 1
804804
if len(security_groups):
805+
# NOTE(slaweq): fields other than name and id aren't really needed
806+
# so asking only about those fields will allow Neutron to not
807+
# prepare list of rules for each found security group. That may
808+
# speed processing of this request a lot in case when tenant has
809+
# got many security groups
810+
sg_fields = ['id', 'name']
805811
search_opts = {'tenant_id': instance.project_id}
806812
user_security_groups = neutron.list_security_groups(
807-
**search_opts).get('security_groups')
813+
fields=sg_fields, **search_opts).get('security_groups')
808814

809815
for security_group in security_groups:
810816
name_match = None

0 commit comments

Comments
 (0)