From 75052a7afc56d5e737f4e51c1035fe7793f956e6 Mon Sep 17 00:00:00 2001 From: Pavel Kholkin Date: Wed, 7 Dec 2016 19:10:25 +0300 Subject: [PATCH] [proxy-api] microversion 2.39 deprecates image-metadata proxy API Almost all proxy APIs were deprecated in microversion 2.36. But the sub-resource image-metadata of image was forgotten to deprecate. This patch deprecates the image-metdata API from 2.39. Image commands were already deprecated since 2.36 in I450917f7fcbfe0a3ea7921c82af9863e80cb40a1 Implements blueprint deprecate-image-meta-proxy-api Change-Id: Idd4cd1d1fec13f9e5f89dc419b57e094c9ad4b3b --- novaclient/__init__.py | 2 +- .../tests/functional/v2/test_image_meta.py | 40 +++++++++++++++++++ novaclient/tests/unit/v2/test_images.py | 16 ++++++++ novaclient/tests/unit/v2/test_shell.py | 6 ++- novaclient/v2/images.py | 2 + ...image-meta-proxy-api-1483b75cf73b021e.yaml | 6 +++ 6 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 novaclient/tests/functional/v2/test_image_meta.py create mode 100644 releasenotes/notes/bp-deprecate-image-meta-proxy-api-1483b75cf73b021e.yaml diff --git a/novaclient/__init__.py b/novaclient/__init__.py index 99d9f4a74..85cadcf62 100644 --- a/novaclient/__init__.py +++ b/novaclient/__init__.py @@ -25,4 +25,4 @@ API_MIN_VERSION = api_versions.APIVersion("2.1") # when client supported the max version, and bumped sequentially, otherwise # the client may break due to server side new version may include some # backward incompatible change. -API_MAX_VERSION = api_versions.APIVersion("2.38") +API_MAX_VERSION = api_versions.APIVersion("2.39") diff --git a/novaclient/tests/functional/v2/test_image_meta.py b/novaclient/tests/functional/v2/test_image_meta.py new file mode 100644 index 000000000..4f0a41a54 --- /dev/null +++ b/novaclient/tests/functional/v2/test_image_meta.py @@ -0,0 +1,40 @@ +# Copyright 2016 Mirantis, Inc. +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from novaclient.tests.functional import base + + +class TestImageMetaV239(base.ClientTestBase): + """Functional tests for image-meta proxy API.""" + + # 'image-metadata' proxy API was deprecated in 2.39 but the CLI should + # fallback to 2.35 and emit a warning. + COMPUTE_API_VERSION = "2.39" + + def test_command_deprecation(self): + output = self.nova('image-meta %s set test_key=test_value' % + self.image.id, merge_stderr=True) + self.assertIn('is deprecated', output) + + output = self.nova('image-meta %s delete test_key' % + self.image.id, merge_stderr=True) + self.assertIn('is deprecated', output) + + def test_limits(self): + """Tests that 2.39 won't return 'maxImageMeta' resource limit and + the CLI output won't show it. + """ + output = self.nova('limits') + # assert that MaxImageMeta isn't in the table output + self.assertRaises(ValueError, self._get_value_from_the_table, + output, 'maxImageMeta') diff --git a/novaclient/tests/unit/v2/test_images.py b/novaclient/tests/unit/v2/test_images.py index 7b8b4c840..00116a1a6 100644 --- a/novaclient/tests/unit/v2/test_images.py +++ b/novaclient/tests/unit/v2/test_images.py @@ -105,3 +105,19 @@ class ImagesTest(utils.FixturedTestCase): self.cs.api_version = api_versions.APIVersion('2.36') self.assertRaises(exceptions.VersionNotFoundForAPIMethod, self.cs.images.find, name="CentOS 5.2") + + def test_delete_meta_2_39(self): + """Tests that 'delete_meta' method fails after microversion 2.39. + """ + self.cs.api_version = api_versions.APIVersion('2.39') + self.assertRaises(exceptions.VersionNotFoundForAPIMethod, + self.cs.images.delete_meta, 1, + {'test_key': 'test_value'}) + + def test_set_meta_2_39(self): + """Tests that 'set_meta' method fails after microversion 2.39. + """ + self.cs.api_version = api_versions.APIVersion('2.39') + self.assertRaises(exceptions.VersionNotFoundForAPIMethod, + self.cs.images.set_meta, 1, + {'test_key': 'test_value'}) diff --git a/novaclient/tests/unit/v2/test_shell.py b/novaclient/tests/unit/v2/test_shell.py index b11f6218a..d825dce75 100644 --- a/novaclient/tests/unit/v2/test_shell.py +++ b/novaclient/tests/unit/v2/test_shell.py @@ -1127,8 +1127,9 @@ class ShellTest(utils.TestCase): {'metadata': {'test_key': 'test_value'}}) def test_image_meta_del(self): - self.run_command('image-meta %s delete test_key=test_value' % - FAKE_UUID_1) + _out, err = self.run_command('image-meta %s delete test_key' % + FAKE_UUID_1) + self.assertIn('Command image-meta is deprecated', err) self.assert_called('DELETE', '/images/%s/metadata/test_key' % FAKE_UUID_1) @@ -3097,6 +3098,7 @@ class ShellTest(utils.TestCase): 34, # doesn't require any changes in novaclient 37, # There are no versioned wrapped shell method changes for this 38, # doesn't require any changes in novaclient + 39, # There are no versioned wrapped shell method changes for this ]) versions_supported = set(range(0, novaclient.API_MAX_VERSION.ver_minor + 1)) diff --git a/novaclient/v2/images.py b/novaclient/v2/images.py index 7371d4bea..8d17e6bca 100644 --- a/novaclient/v2/images.py +++ b/novaclient/v2/images.py @@ -156,6 +156,7 @@ class ImageManager(base.ManagerWithFind): 'or python-openstacksdk instead.', DeprecationWarning) return self._delete("/images/%s" % base.getid(image)) + @api_versions.wraps('2.0', '2.38') def set_meta(self, image, metadata): """ DEPRECATED: Set an images metadata @@ -171,6 +172,7 @@ class ImageManager(base.ManagerWithFind): return self._create("/images/%s/metadata" % base.getid(image), body, "metadata") + @api_versions.wraps('2.0', '2.38') def delete_meta(self, image, keys): """ DEPRECATED: Delete metadata from an image diff --git a/releasenotes/notes/bp-deprecate-image-meta-proxy-api-1483b75cf73b021e.yaml b/releasenotes/notes/bp-deprecate-image-meta-proxy-api-1483b75cf73b021e.yaml new file mode 100644 index 000000000..6d8e76c11 --- /dev/null +++ b/releasenotes/notes/bp-deprecate-image-meta-proxy-api-1483b75cf73b021e.yaml @@ -0,0 +1,6 @@ +--- +upgrade: + - Starting from microversion 2.39 'image-metadata' proxy API in Nova is + deprecated and python API bindings will not work, although 'image-meta' + CLI commands will still work, because of the fallback on the CLI to + version 2.35.