From e00c9ca2b14fb1a7b9233758aaa7cb4c95afb0ca Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Sun, 10 May 2020 08:06:16 -0500 Subject: [PATCH] Fix image owner field The field was owner in the original shade image normalize contract. It's also owner in glance, and in python-openstackclient. Unfortunately we've made a release with this set to owner_id, so what we need to do now is support this new owner_id thing else we'll break people. Change-Id: Ic074e4faed5cc391b8aff6b2e1a451f095d00024 --- openstack/image/v1/image.py | 4 +++- openstack/image/v2/image.py | 4 +++- openstack/tests/unit/image/v1/test_image.py | 1 + openstack/tests/unit/image/v2/test_image.py | 1 + 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/openstack/image/v1/image.py b/openstack/image/v1/image.py index 9fc7e7c08..c4905abfd 100644 --- a/openstack/image/v1/image.py +++ b/openstack/image/v1/image.py @@ -70,7 +70,9 @@ class Image(resource.Resource, _download.DownloadMixin): #: of images owned by others. name = resource.Body('name') #: The ID of the owner, or project, of the image. - owner_id = resource.Body('owner') + owner = resource.Body('owner', alias='owner_id') + #: The ID of the owner, or project, of the image. (backwards compat) + owner_id = resource.Body('owner', alias='owner') #: Properties, if any, that are associated with the image. properties = resource.Body('properties') #: The size of the image data, in bytes. diff --git a/openstack/image/v2/image.py b/openstack/image/v2/image.py index 3e0f223d2..a502e811f 100644 --- a/openstack/image/v2/image.py +++ b/openstack/image/v2/image.py @@ -88,7 +88,9 @@ class Image(resource.Resource, resource.TagMixin, _download.DownloadMixin): #: The name of the image. name = resource.Body('name') #: The ID of the owner, or project, of the image. - owner_id = resource.Body('owner') + owner = resource.Body('owner', alias='owner_id') + #: The ID of the owner, or project, of the image. (backwards compat) + owner_id = resource.Body('owner', alias='owner') # TODO(mordred) This is not how this works in v2. I mean, it's how it # should work, but it's not. We need to fix properties. They work right # in shade, so we can draw some logic from there. diff --git a/openstack/tests/unit/image/v1/test_image.py b/openstack/tests/unit/image/v1/test_image.py index 133c4232e..d593e727d 100644 --- a/openstack/tests/unit/image/v1/test_image.py +++ b/openstack/tests/unit/image/v1/test_image.py @@ -61,6 +61,7 @@ class TestImage(base.TestCase): self.assertEqual(EXAMPLE['min_disk'], sot.min_disk) self.assertEqual(EXAMPLE['min_ram'], sot.min_ram) self.assertEqual(EXAMPLE['name'], sot.name) + self.assertEqual(EXAMPLE['owner'], sot.owner) self.assertEqual(EXAMPLE['owner'], sot.owner_id) self.assertEqual(EXAMPLE['properties'], sot.properties) self.assertTrue(sot.is_protected) diff --git a/openstack/tests/unit/image/v2/test_image.py b/openstack/tests/unit/image/v2/test_image.py index 8d0cafed9..7bcf3f559 100644 --- a/openstack/tests/unit/image/v2/test_image.py +++ b/openstack/tests/unit/image/v2/test_image.py @@ -168,6 +168,7 @@ class TestImage(base.TestCase): self.assertEqual(EXAMPLE['disk_format'], sot.disk_format) self.assertEqual(EXAMPLE['min_disk'], sot.min_disk) self.assertEqual(EXAMPLE['name'], sot.name) + self.assertEqual(EXAMPLE['owner'], sot.owner) self.assertEqual(EXAMPLE['owner'], sot.owner_id) self.assertEqual(EXAMPLE['properties'], sot.properties) self.assertFalse(sot.is_protected)