summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Riedemann <mriedem@us.ibm.com>2016-08-19 15:00:40 -0400
committerMatt Riedemann <mriedem@us.ibm.com>2016-08-19 16:25:07 -0400
commit20b721e1ad434cdebe1a4aa34cca8d1e2772fdcf (patch)
treea24d5a417cc061e4cbbc2529965f219749e68b09
parent4215e3fd2f0a32e5f6b5f05aa4f4656efee384d2 (diff)
downloadpython-novaclient-20b721e1ad434cdebe1a4aa34cca8d1e2772fdcf.tar.gz
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
-rw-r--r--novaclient/api_versions.py3
-rw-r--r--novaclient/tests/unit/v2/test_images.py9
-rw-r--r--novaclient/v2/images.py11
3 files changed, 23 insertions, 0 deletions
diff --git a/novaclient/api_versions.py b/novaclient/api_versions.py
index 4abea01a..65e510b5 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 bdafdf2c..7b8b4c84 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 d00abba1..7371d4be 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.