Cap image API deprecated methods at 2.35
The image proxy API GET/DELETE methods are deprecated at microversion 2.36 and will return a 404 after that. This adds the wraps decorator to those python API methods so set the cap at 2.35 so rather than get a 404 you'll get a more uesful VersionNotFoundForAPIMethod. Note that set_meta and delete_meta are not decorated because we missed deprecating the image-metadata proxy API with the 2.36 microversion. That will be fixed in Ocata. Related to blueprint deprecate-api-proxies Change-Id: Ie65efadb5c65e8a624ffd0315a634accd49f1c30
This commit is contained in:
parent
4215e3fd2f
commit
20b721e1ad
@ -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:
|
||||
|
@ -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")
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user