Merge "Apply delete changes to volume proxy"

This commit is contained in:
Jenkins
2015-04-23 18:25:25 +00:00
committed by Gerrit Code Review
2 changed files with 70 additions and 0 deletions

View File

@@ -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)

View File

@@ -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)