diff options
| author | Vishvananda Ishaya <vishvananda@gmail.com> | 2011-02-22 18:02:25 -0800 |
|---|---|---|
| committer | Vishvananda Ishaya <vishvananda@gmail.com> | 2011-02-22 18:02:25 -0800 |
| commit | 828e3ea3f29f57767a4e25ad40b275c886cb7968 (patch) | |
| tree | ceb1d7815556cf3735a3dba1a79b0eb5fc86aa1b /nova/api | |
| parent | 2610a522d26351686612058a6da0300bce731112 (diff) | |
| download | nova-828e3ea3f29f57767a4e25ad40b275c886cb7968.tar.gz nova-828e3ea3f29f57767a4e25ad40b275c886cb7968.tar.xz nova-828e3ea3f29f57767a4e25ad40b275c886cb7968.zip | |
fix and optimize security group filtering
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/ec2/cloud.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index 882cdcfc9..fc9c13d91 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -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, |
