Add missing block storage v2 'find_*' methods
These were present in v3 but not v2. Increasingly few people should be using v2 but it's nice to be complete. Change-Id: Ic2635b3c3eae5a735d79121fd17cb1fbdd07f9f0 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
parent
6b937b2c6c
commit
e350c80aca
@ -37,6 +37,28 @@ class Proxy(_base_proxy.BaseBlockStorageProxy):
|
|||||||
"""
|
"""
|
||||||
return self._get(_snapshot.Snapshot, snapshot)
|
return self._get(_snapshot.Snapshot, snapshot)
|
||||||
|
|
||||||
|
def find_snapshot(self, name_or_id, ignore_missing=True):
|
||||||
|
"""Find a single snapshot
|
||||||
|
|
||||||
|
:param snapshot: The name or ID a snapshot
|
||||||
|
: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``, None will
|
||||||
|
be returned when attempting to find a nonexistent resource.
|
||||||
|
|
||||||
|
:returns: One :class:`~openstack.block_storage.v2.snapshot.Snapshot` or
|
||||||
|
None.
|
||||||
|
:raises: :class:`~openstack.exceptions.ResourceNotFound`
|
||||||
|
when no resource can be found.
|
||||||
|
:raises: :class:`~openstack.exceptions.DuplicateResource` when multiple
|
||||||
|
resources are found.
|
||||||
|
"""
|
||||||
|
return self._find(
|
||||||
|
_snapshot.Snapshot,
|
||||||
|
name_or_id,
|
||||||
|
ignore_missing=ignore_missing,
|
||||||
|
)
|
||||||
|
|
||||||
def snapshots(self, details=True, **query):
|
def snapshots(self, details=True, **query):
|
||||||
"""Retrieve a generator of snapshots
|
"""Retrieve a generator of snapshots
|
||||||
|
|
||||||
@ -457,6 +479,26 @@ class Proxy(_base_proxy.BaseBlockStorageProxy):
|
|||||||
"""
|
"""
|
||||||
return self._get(_backup.Backup, backup)
|
return self._get(_backup.Backup, backup)
|
||||||
|
|
||||||
|
def find_backup(self, name_or_id, ignore_missing=True):
|
||||||
|
"""Find a single backup
|
||||||
|
|
||||||
|
:param snapshot: The name or ID a backup
|
||||||
|
:param bool ignore_missing: When set to ``False``
|
||||||
|
:class:`~openstack.exceptions.ResourceNotFound` will be raised
|
||||||
|
when the backup does not exist.
|
||||||
|
|
||||||
|
:returns: One :class:`~openstack.block_storage.v2.backup.Backup`
|
||||||
|
:raises: :class:`~openstack.exceptions.ResourceNotFound`
|
||||||
|
when no resource can be found.
|
||||||
|
:raises: :class:`~openstack.exceptions.DuplicateResource` when multiple
|
||||||
|
resources are found.
|
||||||
|
"""
|
||||||
|
return self._find(
|
||||||
|
_backup.Backup,
|
||||||
|
name_or_id,
|
||||||
|
ignore_missing=ignore_missing,
|
||||||
|
)
|
||||||
|
|
||||||
def create_backup(self, **attrs):
|
def create_backup(self, **attrs):
|
||||||
"""Create a new Backup from attributes with native API
|
"""Create a new Backup from attributes with native API
|
||||||
|
|
||||||
|
@ -220,6 +220,9 @@ class TestBackup(TestVolumeProxy):
|
|||||||
self.proxy._connection.has_service = mock.Mock(return_value=True)
|
self.proxy._connection.has_service = mock.Mock(return_value=True)
|
||||||
self.verify_get(self.proxy.get_backup, backup.Backup)
|
self.verify_get(self.proxy.get_backup, backup.Backup)
|
||||||
|
|
||||||
|
def test_backup_find(self):
|
||||||
|
self.verify_find(self.proxy.find_backup, backup.Backup)
|
||||||
|
|
||||||
def test_backup_delete(self):
|
def test_backup_delete(self):
|
||||||
# NOTE: mock has_service
|
# NOTE: mock has_service
|
||||||
self.proxy._connection = mock.Mock()
|
self.proxy._connection = mock.Mock()
|
||||||
@ -272,6 +275,9 @@ class TestSnapshot(TestVolumeProxy):
|
|||||||
def test_snapshot_get(self):
|
def test_snapshot_get(self):
|
||||||
self.verify_get(self.proxy.get_snapshot, snapshot.Snapshot)
|
self.verify_get(self.proxy.get_snapshot, snapshot.Snapshot)
|
||||||
|
|
||||||
|
def test_snapshot_find(self):
|
||||||
|
self.verify_find(self.proxy.find_snapshot, snapshot.Snapshot)
|
||||||
|
|
||||||
def test_snapshots_detailed(self):
|
def test_snapshots_detailed(self):
|
||||||
self.verify_list(self.proxy.snapshots, snapshot.SnapshotDetail,
|
self.verify_list(self.proxy.snapshots, snapshot.SnapshotDetail,
|
||||||
method_kwargs={"details": True, "query": 1},
|
method_kwargs={"details": True, "query": 1},
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
The ``find_snapshot`` and ``find_backup`` methods have been added to the
|
||||||
|
v2 block storage proxy API. These were previously only available for the v3
|
||||||
|
proxy API.
|
Loading…
x
Reference in New Issue
Block a user