From 7bc6ea8911e95c33b685c8f9b9a0e649f1ebbe93 Mon Sep 17 00:00:00 2001 From: Ricardo Carrillo Cruz Date: Fri, 11 Feb 2011 22:02:05 +0100 Subject: Added LOG line to describe groups function to find out what's going --- nova/api/ec2/cloud.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'nova/api') diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index c80e1168a..4dc074fd5 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -324,6 +324,8 @@ class CloudController(object): groups = db.security_group_get_by_project(context, context.project_id) groups = [self._format_security_group(context, g) for g in groups] + LOG.debug(_("Groups after format_security_group: %s"), + groups, context=context) if not group_name is None: groups = [g for g in groups if g.name in group_name] -- cgit From 635f6c9fb2bc3a09fac43832d1e57913ce893714 Mon Sep 17 00:00:00 2001 From: Ricardo Carrillo Cruz Date: Sat, 12 Feb 2011 21:32:58 +0100 Subject: Preliminary fix for issue, need more thorough testing before pushing to lp --- nova/api/ec2/cloud.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'nova/api') diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index 4dc074fd5..1d89b58cf 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -324,12 +324,11 @@ class CloudController(object): groups = db.security_group_get_by_project(context, context.project_id) groups = [self._format_security_group(context, g) for g in groups] - LOG.debug(_("Groups after format_security_group: %s"), - groups, context=context) if not group_name is None: groups = [g for g in groups if g.name in group_name] - return {'securityGroupInfo': groups} + return {'securityGroupInfo': + sorted(groups, key=lambda k: k['ownerId'])} def _format_security_group(self, context, group): g = {} -- cgit From 6f6a09216458ffdba17d1960bbad723a3e71e7b2 Mon Sep 17 00:00:00 2001 From: Devin Carlen Date: Sat, 12 Feb 2011 18:33:49 -0800 Subject: First attempt to make all image services use similar schemas --- nova/api/ec2/cloud.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'nova/api') diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index 00d044e95..f1d3ecdd3 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -836,11 +836,25 @@ class CloudController(object): self.compute_api.update(context, instance_id=instance_id, **kwargs) return True + def _format_image(self, context, image): + i = {} + i['imageId'] = image.get('id') + i['kernelId'] = image.get('kernel_id') + i['ramdiskId'] = image.get('ramdisk_id') + i['imageLocation'] = image.get('image_location') + i['imageOwnerId'] = image.get('image_owner_id') + i['imageState'] = image.get('image_state') + 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 = [self._format_image(context, i) for i in images] return {'imagesSet': images} def deregister_image(self, context, image_id, **kwargs): -- cgit From 07bff0f397b3b6463532f709daeb7a36ed4ad5b1 Mon Sep 17 00:00:00 2001 From: Devin Carlen Date: Sat, 12 Feb 2011 20:58:22 -0800 Subject: Made a few tweaks to format of S3 service implementation --- nova/api/ec2/cloud.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'nova/api') diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index b16503589..cc41ed4ae 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -844,9 +844,9 @@ class CloudController(object): i['imageId'] = image.get('id') i['kernelId'] = image.get('kernel_id') i['ramdiskId'] = image.get('ramdisk_id') - i['imageLocation'] = image.get('image_location') - i['imageOwnerId'] = image.get('image_owner_id') - i['imageState'] = image.get('image_state') + 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') @@ -856,7 +856,7 @@ class CloudController(object): # 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} -- cgit From abe00772e1b8eef361ff2ce614a4679603438228 Mon Sep 17 00:00:00 2001 From: Ricardo Carrillo Cruz Date: Sun, 13 Feb 2011 19:34:20 +0100 Subject: now sorting by project, then by group --- nova/api/ec2/cloud.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nova/api') diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index 1d89b58cf..41a7ac706 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -328,7 +328,7 @@ class CloudController(object): groups = [g for g in groups if g.name in group_name] return {'securityGroupInfo': - sorted(groups, key=lambda k: k['ownerId'])} + sorted(groups, key=lambda k: (k['ownerId'], k['groupName']))} def _format_security_group(self, context, group): g = {} -- cgit From 9f3d269c9b5b610846acbf4ba2bf6719577b199a Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Sun, 13 Feb 2011 10:45:20 -0800 Subject: fix typo in auth checking for describe_availability_zones --- nova/api/ec2/__init__.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'nova/api') 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'], -- cgit From 27139d33ec027bae4b247c1651bfe635a32f5ebf Mon Sep 17 00:00:00 2001 From: Devin Carlen Date: Sun, 13 Feb 2011 11:55:50 -0800 Subject: Added missing doc string and made a few style tweaks --- nova/api/ec2/cloud.py | 1 + 1 file changed, 1 insertion(+) (limited to 'nova/api') diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index cc41ed4ae..47cd8bf37 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -840,6 +840,7 @@ class CloudController(object): 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') -- cgit From 7713cb99635f3a06e298d4a504dc1249e5bf3232 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Sun, 13 Feb 2011 15:44:41 -0800 Subject: return a list instead of a generator from describe_groups --- nova/api/ec2/cloud.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'nova/api') diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index 41a7ac706..5d387d45d 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -328,7 +328,8 @@ class CloudController(object): groups = [g for g in groups if g.name in group_name] return {'securityGroupInfo': - sorted(groups, key=lambda k: (k['ownerId'], k['groupName']))} + list(sorted(groups, + key=lambda k: (k['ownerId'], k['groupName'])))} def _format_security_group(self, context, group): g = {} -- cgit From f1e536fb296c927a9fc953b1dfe24b9060a0387a Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Mon, 14 Feb 2011 19:51:51 -0500 Subject: Updates to that S3ImageService kernel_id and ramdisk_id mappings work with EC2 API. --- nova/api/ec2/cloud.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'nova/api') diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index 16a3a4521..6919cd8d2 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -883,6 +883,9 @@ class CloudController(object): % attribute) try: image = self.image_service.show(context, image_id) + image = self._format_image(context, + self.image_service.show(context, + image_id)) except IndexError: raise exception.ApiError(_('invalid id: %s') % image_id) result = {'image_id': image_id, 'launchPermission': []} -- cgit