diff --git a/doc/source/user/proxies/image_v2.rst b/doc/source/user/proxies/image_v2.rst index 9c283c67a..5327eaa55 100644 --- a/doc/source/user/proxies/image_v2.rst +++ b/doc/source/user/proxies/image_v2.rst @@ -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 diff --git a/openstack/image/v2/_proxy.py b/openstack/image/v2/_proxy.py index 0ea8fefd8..cf00639dd 100644 --- a/openstack/image/v2/_proxy.py +++ b/openstack/image/v2/_proxy.py @@ -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, diff --git a/openstack/image/v2/cache.py b/openstack/image/v2/cache.py index fdc8630e1..e63e954d5 100644 --- a/openstack/image/v2/cache.py +++ b/openstack/image/v2/cache.py @@ -25,6 +25,7 @@ class Cache(resource.Resource): base_path = '/cache' allow_fetch = True + allow_delete = True _max_microversion = '2.14' diff --git a/openstack/tests/unit/image/v2/test_cache.py b/openstack/tests/unit/image/v2/test_cache.py index 70c41294f..fc1cfc678 100644 --- a/openstack/tests/unit/image/v2/test_cache.py +++ b/openstack/tests/unit/image/v2/test_cache.py @@ -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) diff --git a/openstack/tests/unit/image/v2/test_proxy.py b/openstack/tests/unit/image/v2/test_proxy.py index 491e702fb..4a98e2632 100644 --- a/openstack/tests/unit/image/v2/test_proxy.py +++ b/openstack/tests/unit/image/v2/test_proxy.py @@ -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, + )