From 1d55217abfb720fd3a0c56b76f1b2ee0699e4651 Mon Sep 17 00:00:00 2001 From: Brian Curtin Date: Fri, 17 Apr 2015 14:50:55 -0500 Subject: [PATCH] Apply delete changes to volume proxy Change-Id: I726ea56763ba976d269584a07f4c4d40f60984d9 --- openstack/tests/unit/volume/v2/test_proxy.py | 23 ++++++++++ openstack/volume/v2/_proxy.py | 47 ++++++++++++++++++++ 2 files changed, 70 insertions(+) diff --git a/openstack/tests/unit/volume/v2/test_proxy.py b/openstack/tests/unit/volume/v2/test_proxy.py index 5e2fac69..753a53d2 100644 --- a/openstack/tests/unit/volume/v2/test_proxy.py +++ b/openstack/tests/unit/volume/v2/test_proxy.py @@ -12,6 +12,9 @@ from openstack.tests.unit import test_proxy_base from openstack.volume.v2 import _proxy +from openstack.volume.v2 import snapshot +from openstack.volume.v2 import type +from openstack.volume.v2 import volume class TestVolumeProxy(test_proxy_base.TestProxyBase): @@ -19,6 +22,26 @@ class TestVolumeProxy(test_proxy_base.TestProxyBase): super(TestVolumeProxy, self).setUp() self.proxy = _proxy.Proxy(self.session) + def test_snapshot_delete(self): + self.verify_delete2(snapshot.Snapshot, self.proxy.delete_snapshot, + False) + + def test_snapshot_delete_ignore(self): + self.verify_delete2(snapshot.Snapshot, self.proxy.delete_snapshot, + True) + + def test_type_delete(self): + self.verify_delete2(type.Type, self.proxy.delete_type, False) + + def test_type_delete_ignore(self): + self.verify_delete2(type.Type, self.proxy.delete_type, True) + + def test_volume_delete(self): + self.verify_delete2(volume.Volume, self.proxy.delete_volume, False) + + def test_volume_delete_ignore(self): + self.verify_delete2(volume.Volume, self.proxy.delete_volume, True) + def test_volume_get(self): self.verify_get('openstack.volume.v2.volume.Volume.get', self.proxy.get_volume) diff --git a/openstack/volume/v2/_proxy.py b/openstack/volume/v2/_proxy.py index 44a712c5..2a6b6047 100644 --- a/openstack/volume/v2/_proxy.py +++ b/openstack/volume/v2/_proxy.py @@ -11,6 +11,8 @@ # under the License. from openstack import proxy +from openstack.volume.v2 import snapshot +from openstack.volume.v2 import type from openstack.volume.v2 import volume @@ -18,3 +20,48 @@ class Proxy(proxy.BaseProxy): def get_volume(self, **data): return volume.Volume(data).get(self.session) + + def delete_snapshot(self, value, ignore_missing=True): + """Delete a snapshot + + :param value: The value can be either the ID of a snapshot or a + :class:`~openstack.volume.v2.snapshot.Snapshot` instance. + :param bool ignore_missing: When set to ``False`` + :class:`~openstack.exceptions.ResourceNotFound` will be + raised when the snapshot does not exist. + When set to ``True``, no exception will be set when + attempting to delete a nonexistent server. + + :returns: ``None`` + """ + self._delete(snapshot.Snapshot, value, ignore_missing) + + def delete_type(self, value, ignore_missing=True): + """Delete a type + + :param value: The value can be either the ID of a type or a + :class:`~openstack.volume.v2.type.Type` instance. + :param bool ignore_missing: When set to ``False`` + :class:`~openstack.exceptions.ResourceNotFound` will be + raised when the type does not exist. + When set to ``True``, no exception will be set when + attempting to delete a nonexistent server. + + :returns: ``None`` + """ + self._delete(type.Type, value, ignore_missing) + + def delete_volume(self, value, ignore_missing=True): + """Delete a volume + + :param value: The value can be either the ID of a volume or a + :class:`~openstack.volume.v2.volume.Volume` instance. + :param bool ignore_missing: When set to ``False`` + :class:`~openstack.exceptions.ResourceNotFound` will be + raised when the volume does not exist. + When set to ``True``, no exception will be set when + attempting to delete a nonexistent server. + + :returns: ``None`` + """ + self._delete(volume.Volume, value, ignore_missing)