Merge "Adds SDK support for `glance cache-delete`"

This commit is contained in:
Zuul 2023-03-24 11:18:51 +00:00 committed by Gerrit Code Review
commit cacd5d2f80
5 changed files with 29 additions and 0 deletions

View File

@ -82,3 +82,11 @@ Helpers
.. autoclass:: openstack.image.v2._proxy.Proxy
:noindex:
:members: wait_for_delete
Cache Operations
^^^^^^^^^^^^^^^^
.. autoclass:: openstack.image.v2._proxy.Proxy
:noindex:
:members: cache_delete_image

View File

@ -78,6 +78,19 @@ class Proxy(proxy.Proxy):
def get_image_cache(self):
return self._get(_cache.Cache, requires_id=False)
def cache_delete_image(self, image, ignore_missing=True):
"""Delete an image from cache.
:param image: The value can be either the name of an image or a
:class:`~openstack.image.v2.image.Image`
instance.
:param bool ignore_missing: When set to ``False``,
:class:`~openstack.exceptions.ResourceNotFound` will be raised when
the metadef namespace does not exist.
:returns: ``None``
"""
self._delete(_cache.Cache, image, ignore_missing=ignore_missing)
# ====== IMAGES ======
def create_image(
self,

View File

@ -25,6 +25,7 @@ class Cache(resource.Resource):
base_path = '/cache'
allow_fetch = True
allow_delete = True
_max_microversion = '2.14'

View File

@ -35,6 +35,7 @@ class TestCache(base.TestCase):
self.assertIsNone(sot.resource_key)
self.assertEqual('/cache', sot.base_path)
self.assertTrue(sot.allow_fetch)
self.assertTrue(sot.allow_delete)
def test_make_it(self):
sot = cache.Cache(**EXAMPLE)

View File

@ -895,3 +895,9 @@ class TestCache(TestImageProxy):
'requires_id': False
},
)
def test_cache_image_delete(self):
self.verify_delete(
self.proxy.cache_delete_image,
_cache.Cache,
)