From 65a0cc41b1b9ead5acd3128a4a6202bb02e3a6e5 Mon Sep 17 00:00:00 2001 From: Brian Waldon Date: Fri, 9 Sep 2011 17:25:45 -0400 Subject: fixing image status mapping --- nova/api/openstack/views/images.py | 15 ++++++++------- nova/tests/api/openstack/test_images.py | 10 +++++----- 2 files changed, 13 insertions(+), 12 deletions(-) (limited to 'nova') diff --git a/nova/api/openstack/views/images.py b/nova/api/openstack/views/images.py index 21f1b2d3e..8983b2957 100644 --- a/nova/api/openstack/views/images.py +++ b/nova/api/openstack/views/images.py @@ -37,17 +37,18 @@ class ViewBuilder(object): def _format_status(self, image): """Update the status field to standardize format.""" status_mapping = { - 'pending': 'QUEUED', - 'decrypting': 'PREPARING', - 'untarring': 'SAVING', - 'available': 'ACTIVE', - 'killed': 'FAILED', + 'active': 'ACTIVE', + 'queued': 'SAVING', + 'saving': 'SAVING', + 'deleted': 'DELETED', + 'pending_delete': 'DELETED', + 'killed': 'ERROR', } try: - image['status'] = status_mapping[image['status']].upper() + image['status'] = status_mapping[image['status']] except KeyError: - image['status'] = image['status'].upper() + image['status'] = 'UNKNOWN' def _build_server(self, image, image_obj): """Indicates that you must use a ViewBuilder subclass.""" diff --git a/nova/tests/api/openstack/test_images.py b/nova/tests/api/openstack/test_images.py index 2a7cfc382..46f763d5e 100644 --- a/nova/tests/api/openstack/test_images.py +++ b/nova/tests/api/openstack/test_images.py @@ -407,7 +407,7 @@ class ImageControllerWithGlanceServiceTest(test.TestCase): "name": "queued snapshot", "updated": self.NOW_API_FORMAT, "created": self.NOW_API_FORMAT, - "status": "QUEUED", + "status": "SAVING", "progress": 0, 'server': { 'id': 42, @@ -603,7 +603,7 @@ class ImageControllerWithGlanceServiceTest(test.TestCase): 'name': 'queued snapshot', 'updated': self.NOW_API_FORMAT, 'created': self.NOW_API_FORMAT, - 'status': 'QUEUED', + 'status': 'SAVING', 'progress': 0, }, { @@ -627,7 +627,7 @@ class ImageControllerWithGlanceServiceTest(test.TestCase): 'name': 'killed snapshot', 'updated': self.NOW_API_FORMAT, 'created': self.NOW_API_FORMAT, - 'status': 'FAILED', + 'status': 'ERROR', 'progress': 0, }, { @@ -676,7 +676,7 @@ class ImageControllerWithGlanceServiceTest(test.TestCase): }, 'updated': self.NOW_API_FORMAT, 'created': self.NOW_API_FORMAT, - 'status': 'QUEUED', + 'status': 'SAVING', 'progress': 0, 'server': { 'id': 42, @@ -769,7 +769,7 @@ class ImageControllerWithGlanceServiceTest(test.TestCase): }, 'updated': self.NOW_API_FORMAT, 'created': self.NOW_API_FORMAT, - 'status': 'FAILED', + 'status': 'ERROR', 'progress': 0, 'server': { 'id': 42, -- cgit From 9b8e73d9ef1a5bd4efb460f3a0c033fc748ccdd9 Mon Sep 17 00:00:00 2001 From: Brian Waldon Date: Mon, 12 Sep 2011 14:22:46 -0400 Subject: adding tests for deleted and pending_delete statuses --- nova/tests/api/openstack/test_images.py | 96 ++++++++++++++++++++++++++++++--- 1 file changed, 89 insertions(+), 7 deletions(-) (limited to 'nova') diff --git a/nova/tests/api/openstack/test_images.py b/nova/tests/api/openstack/test_images.py index 46f763d5e..c63d1203a 100644 --- a/nova/tests/api/openstack/test_images.py +++ b/nova/tests/api/openstack/test_images.py @@ -365,7 +365,9 @@ class ImageControllerWithGlanceServiceTest(test.TestCase): {'id': 125, 'name': 'saving snapshot'}, {'id': 126, 'name': 'active snapshot'}, {'id': 127, 'name': 'killed snapshot'}, - {'id': 129, 'name': None}] + {'id': 128, 'name': 'deleted snapshot'}, + {'id': 129, 'name': 'pending_delete snapshot'}, + {'id': 131, 'name': None}] self.assertDictListMatch(response_list, expected) @@ -458,7 +460,7 @@ class ImageControllerWithGlanceServiceTest(test.TestCase): self.assertEqual(expected_image.toxml(), actual_image.toxml()) def test_get_image_xml_no_name(self): - request = webob.Request.blank('/v1.0/images/129') + request = webob.Request.blank('/v1.0/images/131') request.accept = "application/xml" response = request.get_response(fakes.wsgi_app()) @@ -466,7 +468,7 @@ class ImageControllerWithGlanceServiceTest(test.TestCase): expected_now = self.NOW_API_FORMAT expected_image = minidom.parseString(""" -