From f6daf3ed080ccf859bf4cb0875b691c2950afc51 Mon Sep 17 00:00:00 2001 From: Hongbin Lu Date: Fri, 19 Oct 2018 03:04:04 +0000 Subject: [PATCH] Expose 'host' field via image API The 'host' field has been added to image table [1] and this commit expose this field via REST API so that API users can consume this field. [1] https://review.openstack.org/#/c/592871/ Change-Id: Ia5e38a049770ccacc8aa91d611129d3b42315549 --- zun/api/controllers/v1/views/images_view.py | 3 ++- zun/tests/unit/api/controllers/v1/test_images.py | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/zun/api/controllers/v1/views/images_view.py b/zun/api/controllers/v1/views/images_view.py index 9c8a5c645..634d3abfb 100644 --- a/zun/api/controllers/v1/views/images_view.py +++ b/zun/api/controllers/v1/views/images_view.py @@ -23,7 +23,8 @@ _basic_keys = ( 'tag', 'size', 'project_id', - 'image_pull_policy' + 'image_pull_policy', + 'host' ) diff --git a/zun/tests/unit/api/controllers/v1/test_images.py b/zun/tests/unit/api/controllers/v1/test_images.py index e6e98da6a..a7ff4f515 100644 --- a/zun/tests/unit/api/controllers/v1/test_images.py +++ b/zun/tests/unit/api/controllers/v1/test_images.py @@ -125,6 +125,8 @@ class TestImageController(api_base.FunctionalTest): self.assertEqual(1, len(actual_images)) self.assertEqual(test_image['uuid'], actual_images[0].get('uuid')) + self.assertEqual(test_image['host'], + actual_images[0].get('host')) @patch('zun.common.policy.enforce') @patch('zun.objects.Image.get_by_uuid') @@ -141,6 +143,8 @@ class TestImageController(api_base.FunctionalTest): self.assertEqual(200, response.status_int) self.assertEqual(test_image['uuid'], response.json['uuid']) + self.assertEqual(test_image['host'], + response.json['host']) @mock.patch('zun.common.policy.enforce', return_value=True) @patch('zun.objects.Image.list')