fix and optimize security group filtering
This commit is contained in:
parent
2610a522d2
commit
828e3ea3f2
@ -318,14 +318,19 @@ class CloudController(object):
|
||||
|
||||
def describe_security_groups(self, context, group_name=None, **kwargs):
|
||||
self.compute_api.ensure_default_security_group(context)
|
||||
if context.is_admin:
|
||||
if group_name:
|
||||
groups = []
|
||||
for name in group_name:
|
||||
group = db.security_group_get_by_name(context,
|
||||
context.project_id,
|
||||
name)
|
||||
groups.append(group)
|
||||
elif context.is_admin:
|
||||
groups = db.security_group_get_all(context)
|
||||
else:
|
||||
groups = db.security_group_get_by_project(context,
|
||||
context.project_id)
|
||||
groups = [self._format_security_group(context, g) for g in groups]
|
||||
if not group_name is None:
|
||||
groups = [g for g in groups if g.name in group_name]
|
||||
|
||||
return {'securityGroupInfo':
|
||||
list(sorted(groups,
|
||||
|
Loading…
Reference in New Issue
Block a user