Merge "Add find_share() for shared file system share resource"

This commit is contained in:
Zuul
2023-05-19 10:06:31 +00:00
committed by Gerrit Code Review
5 changed files with 30 additions and 2 deletions

View File

@@ -33,7 +33,7 @@ service.
.. autoclass:: openstack.shared_file_system.v2._proxy.Proxy
:noindex:
:members: shares, get_share, delete_share, update_share, create_share,
revert_share_to_snapshot, resize_share
revert_share_to_snapshot, resize_share, find_share
Shared File System Storage Pools

View File

@@ -109,6 +109,26 @@ class Proxy(proxy.Proxy):
base_path = '/shares/detail' if details else None
return self._list(_share.Share, base_path=base_path, **query)
def find_share(self, name_or_id, ignore_missing=True, **query):
"""Find a single share
:param name_or_id: The name or ID of a share.
:param bool ignore_missing: When set to ``False``
:class:`~openstack.exceptions.ResourceNotFound` will be
raised when the resource does not exist.
When set to ``True``, None will be returned when
attempting to find a nonexistent resource.
:param dict query: Any additional parameters to be passed into
underlying methods. such as query filters.
:returns: One :class:`~openstack.shared_file_system.v2.share.Share`
or None
"""
return self._find(
_share.Share, name_or_id, ignore_missing=ignore_missing, **query
)
def get_share(self, share_id):
"""Lists details of a single share

View File

@@ -24,9 +24,9 @@ class Share(resource.Resource):
allow_create = True
allow_fetch = True
allow_commit = True
allow_delete = True
allow_list = True
allow_head = False
allow_delete = True
#: Properties
#: The share instance access rules status. A valid value is active,

View File

@@ -36,6 +36,11 @@ class ShareTest(base.BaseSharedFileSystemTest):
assert isinstance(sot, _share.Share)
self.assertEqual(self.SHARE_ID, sot.id)
def test_find(self):
sot = self.user_cloud.share.find_share(name_or_id=self.SHARE_NAME)
assert isinstance(sot, _share.Share)
self.assertEqual(self.SHARE_ID, sot.id)
def test_list_share(self):
shares = self.user_cloud.share.shares(details=False)
self.assertGreater(len(list(shares)), 0)

View File

@@ -55,6 +55,9 @@ class TestSharedFileSystemShare(TestSharedFileSystemProxy):
def test_share_get(self):
self.verify_get(self.proxy.get_share, share.Share)
def test_share_find(self):
self.verify_find(self.proxy.find_share, share.Share)
def test_share_delete(self):
self.verify_delete(self.proxy.delete_share, share.Share, False)