diff options
| author | Vishvananda Ishaya <vishvananda@gmail.com> | 2011-02-23 19:46:13 +0000 |
|---|---|---|
| committer | Tarmac <> | 2011-02-23 19:46:13 +0000 |
| commit | b2d474437c18df296758b79450abc909ce2c2e89 (patch) | |
| tree | 0287c65b667e7df2d3d61a4744d83e361056d978 /nova/api | |
| parent | 400bbd8c7d56543a5cebad25d078ec0331b07a3c (diff) | |
| parent | 48d4054e093a2faccbd819de8e9e02c03d28cda0 (diff) | |
| download | nova-b2d474437c18df296758b79450abc909ce2c2e89.tar.gz nova-b2d474437c18df296758b79450abc909ce2c2e89.tar.xz nova-b2d474437c18df296758b79450abc909ce2c2e89.zip | |
Fixes and optimizes filtering for describe_security_groups. Also adds a unit test.
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/ec2/cloud.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index 99b6d5cb6..e219fb30c 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, @@ -670,7 +675,8 @@ class CloudController(object): instances = [] for ec2_id in instance_id: internal_id = ec2_id_to_id(ec2_id) - instance = self.compute_api.get(context, internal_id) + instance = self.compute_api.get(context, + instance_id=internal_id) instances.append(instance) else: instances = self.compute_api.get_all(context, **kwargs) |
