Deprecate all of the compute image proxy APIs
This is the only proxy API we support in SDK. We should stop doing that. For now, just deprecate it. Some examples are updated to use the image API. Change-Id: Id4905782e64998c7293625f22298bbce0baed82a Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
parent
0018c5df18
commit
6b937b2c6c
@ -56,7 +56,7 @@ def create_keypair(conn):
|
||||
def create_server(conn):
|
||||
print("Create Server:")
|
||||
|
||||
image = conn.compute.find_image(IMAGE_NAME)
|
||||
image = conn.image.find_image(IMAGE_NAME)
|
||||
flavor = conn.compute.find_flavor(FLAVOR_NAME)
|
||||
network = conn.network.find_network(NETWORK_NAME)
|
||||
keypair = create_keypair(conn)
|
||||
|
@ -23,7 +23,7 @@ https://docs.openstack.org/openstacksdk/latest/user/guides/compute.html
|
||||
def find_image(conn):
|
||||
print("Find Image:")
|
||||
|
||||
image = conn.compute.find_image(examples.connect.IMAGE_NAME)
|
||||
image = conn.image.find_image(examples.connect.IMAGE_NAME)
|
||||
|
||||
print(image)
|
||||
|
||||
|
@ -447,6 +447,11 @@ class Proxy(proxy.Proxy):
|
||||
|
||||
:returns: ``None``
|
||||
"""
|
||||
warnings.warn(
|
||||
'This API is a proxy to the image service and has been '
|
||||
'deprecated; use the image service proxy API instead',
|
||||
DeprecationWarning,
|
||||
)
|
||||
self._delete(_image.Image, image, ignore_missing=ignore_missing)
|
||||
|
||||
def find_image(self, name_or_id, ignore_missing=True):
|
||||
@ -460,6 +465,11 @@ class Proxy(proxy.Proxy):
|
||||
attempting to find a nonexistent resource.
|
||||
:returns: One :class:`~openstack.compute.v2.image.Image` or None
|
||||
"""
|
||||
warnings.warn(
|
||||
'This API is a proxy to the image service and has been '
|
||||
'deprecated; use the image service proxy API instead',
|
||||
DeprecationWarning,
|
||||
)
|
||||
return self._find(_image.Image, name_or_id,
|
||||
ignore_missing=ignore_missing)
|
||||
|
||||
@ -473,6 +483,11 @@ class Proxy(proxy.Proxy):
|
||||
:raises: :class:`~openstack.exceptions.ResourceNotFound`
|
||||
when no resource can be found.
|
||||
"""
|
||||
warnings.warn(
|
||||
'This API is a proxy to the image service and has been '
|
||||
'deprecated; use the image service proxy API instead',
|
||||
DeprecationWarning,
|
||||
)
|
||||
return self._get(_image.Image, image)
|
||||
|
||||
def images(self, details=True, **query):
|
||||
@ -487,8 +502,11 @@ class Proxy(proxy.Proxy):
|
||||
|
||||
:returns: A generator of image objects
|
||||
"""
|
||||
warnings.warn('This API is deprecated and may disappear shortly',
|
||||
DeprecationWarning)
|
||||
warnings.warn(
|
||||
'This API is a proxy to the image service and has been '
|
||||
'deprecated; use the image service proxy API instead',
|
||||
DeprecationWarning,
|
||||
)
|
||||
base_path = '/images/detail' if details else None
|
||||
return self._list(_image.Image, base_path=base_path, **query)
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import contextlib
|
||||
import datetime
|
||||
from unittest import mock
|
||||
import uuid
|
||||
@ -687,27 +688,51 @@ class TestCompute(TestComputeProxy):
|
||||
def test_extensions(self):
|
||||
self.verify_list(self.proxy.extensions, extension.Extension)
|
||||
|
||||
@contextlib.contextmanager
|
||||
def _check_image_proxy_deprecation_warning(self):
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
warnings.simplefilter("always")
|
||||
yield
|
||||
self.assertEqual(1, len(w))
|
||||
self.assertTrue(issubclass(w[-1].category, DeprecationWarning))
|
||||
self.assertIn(
|
||||
"This API is a proxy to the image service ",
|
||||
str(w[-1].message),
|
||||
)
|
||||
|
||||
def test_image_delete(self):
|
||||
with self._check_image_proxy_deprecation_warning():
|
||||
self.verify_delete(self.proxy.delete_image, image.Image, False)
|
||||
|
||||
def test_image_delete_ignore(self):
|
||||
with self._check_image_proxy_deprecation_warning():
|
||||
self.verify_delete(self.proxy.delete_image, image.Image, True)
|
||||
|
||||
def test_image_find(self):
|
||||
with self._check_image_proxy_deprecation_warning():
|
||||
self.verify_find(self.proxy.find_image, image.Image)
|
||||
|
||||
def test_image_get(self):
|
||||
with self._check_image_proxy_deprecation_warning():
|
||||
self.verify_get(self.proxy.get_image, image.Image)
|
||||
|
||||
def test_images_detailed(self):
|
||||
self.verify_list(self.proxy.images, image.ImageDetail,
|
||||
with self._check_image_proxy_deprecation_warning():
|
||||
self.verify_list(
|
||||
self.proxy.images,
|
||||
image.ImageDetail,
|
||||
method_kwargs={"details": True, "query": 1},
|
||||
expected_kwargs={"query": 1})
|
||||
expected_kwargs={"query": 1},
|
||||
)
|
||||
|
||||
def test_images_not_detailed(self):
|
||||
self.verify_list(self.proxy.images, image.Image,
|
||||
with self._check_image_proxy_deprecation_warning():
|
||||
self.verify_list(
|
||||
self.proxy.images,
|
||||
image.Image,
|
||||
method_kwargs={"details": False, "query": 1},
|
||||
expected_kwargs={"query": 1})
|
||||
expected_kwargs={"query": 1},
|
||||
)
|
||||
|
||||
def test_limits_get(self):
|
||||
self._verify(
|
||||
|
@ -0,0 +1,12 @@
|
||||
---
|
||||
deprecations:
|
||||
- |
|
||||
The following Compute service proxy methods are now deprecated:
|
||||
|
||||
* ``find_image``
|
||||
* ``get_image``
|
||||
* ``delete_image``
|
||||
* ``images``
|
||||
|
||||
These are proxy APIs for the Image service. You should use the Image
|
||||
service instead via the Image service proxy methods.
|
Loading…
Reference in New Issue
Block a user