diff options
| author | Sandy Walsh <sandy.walsh@rackspace.com> | 2011-02-14 14:50:29 -0800 |
|---|---|---|
| committer | Sandy Walsh <sandy.walsh@rackspace.com> | 2011-02-14 14:50:29 -0800 |
| commit | 19dc4751819b7ca3082b32b475435407e1a6edff (patch) | |
| tree | e7c52042aaaccd9ee2bf2dd3d139e6e2a5e66441 /nova/api | |
| parent | df9bf23ecda1f32fd31ebffc6013e2f60f7fd3fa (diff) | |
| parent | ef7768154324bbddb56d2c7d7a9d2e354b7d60cf (diff) | |
better filtering
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/ec2/__init__.py | 3 | ||||
| -rw-r--r-- | nova/api/ec2/cloud.py | 23 | ||||
| -rw-r--r-- | nova/api/openstack/auth.py | 2 | ||||
| -rw-r--r-- | nova/api/openstack/zones.py | 1 |
4 files changed, 24 insertions, 5 deletions
diff --git a/nova/api/ec2/__init__.py b/nova/api/ec2/__init__.py index ddcdc673c..1a06b3f01 100644 --- a/nova/api/ec2/__init__.py +++ b/nova/api/ec2/__init__.py @@ -21,7 +21,6 @@ Starting point for routing EC2 requests. """ import datetime -import routes import webob import webob.dec import webob.exc @@ -233,7 +232,7 @@ class Authorizer(wsgi.Middleware): super(Authorizer, self).__init__(application) self.action_roles = { 'CloudController': { - 'DescribeAvailabilityzones': ['all'], + 'DescribeAvailabilityZones': ['all'], 'DescribeRegions': ['all'], 'DescribeSnapshots': ['all'], 'DescribeKeyPairs': ['all'], diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index c80e1168a..16a3a4521 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -327,7 +327,9 @@ class CloudController(object): if not group_name is None: groups = [g for g in groups if g.name in group_name] - return {'securityGroupInfo': groups} + return {'securityGroupInfo': + list(sorted(groups, + key=lambda k: (k['ownerId'], k['groupName'])))} def _format_security_group(self, context, group): g = {} @@ -839,11 +841,26 @@ class CloudController(object): self.compute_api.update(context, instance_id=instance_id, **kwargs) return True + def _format_image(self, context, image): + """Convert from format defined by BaseImageService to S3 format.""" + i = {} + i['imageId'] = image.get('id') + i['kernelId'] = image.get('kernel_id') + i['ramdiskId'] = image.get('ramdisk_id') + i['imageOwnerId'] = image.get('owner_id') + i['imageLocation'] = image.get('location') + i['imageState'] = image.get('status') + i['type'] = image.get('type') + i['isPublic'] = image.get('is_public') + i['architecture'] = image.get('architecture') + return i + def describe_images(self, context, image_id=None, **kwargs): - # Note: image_id is a list! + # NOTE: image_id is a list! images = self.image_service.index(context) if image_id: - images = filter(lambda x: x['imageId'] in image_id, images) + images = filter(lambda x: x['id'] in image_id, images) + images = [self._format_image(context, i) for i in images] return {'imagesSet': images} def deregister_image(self, context, image_id, **kwargs): diff --git a/nova/api/openstack/auth.py b/nova/api/openstack/auth.py index 1dfdd5318..a383ef086 100644 --- a/nova/api/openstack/auth.py +++ b/nova/api/openstack/auth.py @@ -19,6 +19,7 @@ import datetime import hashlib import json import time +import logging import webob.exc import webob.dec @@ -78,6 +79,7 @@ class AuthMiddleware(wsgi.Middleware): except KeyError: return faults.Fault(webob.exc.HTTPUnauthorized()) + logging.debug("**** USERNAME %s, PASSWORD %s" % (username, key)) token, user = self._authorize_user(username, key, req) if user and token: res = webob.Response() diff --git a/nova/api/openstack/zones.py b/nova/api/openstack/zones.py index e84b38fa9..2c93c0c7b 100644 --- a/nova/api/openstack/zones.py +++ b/nova/api/openstack/zones.py @@ -55,6 +55,7 @@ class Controller(wsgi.Controller): """Return data about the given zone id""" zone_id = int(id) zone = db.zone_get(req.environ['nova.context'], zone_id) + zone = _filter_keys(zone, ('id', 'api_url')) return dict(zone=zone) def delete(self, req, id): |
