diff --git a/novaclient/api_versions.py b/novaclient/api_versions.py index 4abea01a3..65e510b5c 100644 --- a/novaclient/api_versions.py +++ b/novaclient/api_versions.py @@ -374,6 +374,9 @@ def get_substitutions(func_name, api_version=None): return sorted(substitutions, key=lambda m: m.start_version) +# FIXME(mriedem): This breaks any ManagerWithFind.list method that has a +# 'detailed' kwarg since the ManagerWithFind.findall won't find the correct +# argspec from the wrapped list method. def wraps(start_version, end_version=None): start_version = APIVersion(start_version) if end_version: diff --git a/novaclient/tests/unit/v2/test_images.py b/novaclient/tests/unit/v2/test_images.py index bdafdf2cb..7b8b4c840 100644 --- a/novaclient/tests/unit/v2/test_images.py +++ b/novaclient/tests/unit/v2/test_images.py @@ -15,6 +15,8 @@ import warnings import mock +from novaclient import api_versions +from novaclient import exceptions from novaclient.tests.unit.fixture_data import client from novaclient.tests.unit.fixture_data import images as data from novaclient.tests.unit import utils @@ -96,3 +98,10 @@ class ImagesTest(utils.FixturedTestCase): self.assert_request_id(iml, fakes.FAKE_REQUEST_ID_LIST) self.assertEqual(1, len(iml)) self.assertEqual('My Server Backup', iml[0].name) + + def test_find_2_36(self): + """Tests that using the find method fails after microversion 2.35. + """ + self.cs.api_version = api_versions.APIVersion('2.36') + self.assertRaises(exceptions.VersionNotFoundForAPIMethod, + self.cs.images.find, name="CentOS 5.2") diff --git a/novaclient/v2/images.py b/novaclient/v2/images.py index d00abba1a..7371d4bea 100644 --- a/novaclient/v2/images.py +++ b/novaclient/v2/images.py @@ -21,6 +21,7 @@ import warnings from oslo_utils import uuidutils from six.moves.urllib import parse +from novaclient import api_versions from novaclient import base from novaclient import exceptions from novaclient.i18n import _ @@ -91,6 +92,7 @@ class ImageManager(base.ManagerWithFind): """ resource_class = Image + @api_versions.wraps('2.0', '2.35') def get(self, image): """ DEPRECATED: Get an image. @@ -113,6 +115,14 @@ class ImageManager(base.ManagerWithFind): :param marker: Begin returning images that appear later in the image list than that represented by this image id (optional). """ + # FIXME(mriedem): Should use the api_versions.wraps decorator but that + # breaks the ManagerWithFind.findall method which checks the argspec + # on this function looking for the 'detailed' arg, and it's getting + # tripped up if you use the wraps decorator. This is all deprecated for + # removal anyway so we probably don't care too much about this. + if self.api.api_version > api_versions.APIVersion('2.35'): + raise exceptions.VersionNotFoundForAPIMethod( + self.api.api_version, 'list') warnings.warn( 'The novaclient.v2.images module is deprecated and will be ' 'removed after Nova 15.0.0 is released. Use python-glanceclient ' @@ -129,6 +139,7 @@ class ImageManager(base.ManagerWithFind): query = '?%s' % parse.urlencode(params) if params else '' return self._list('/images%s%s' % (detail, query), 'images') + @api_versions.wraps('2.0', '2.35') def delete(self, image): """ DEPRECATED: Delete an image.