Merge "Fix default share type resolution in OSC"

This commit is contained in:
Zuul 2023-10-02 19:27:40 +00:00 committed by Gerrit Code Review
commit 64f58141bb
4 changed files with 15 additions and 5 deletions

View File

@ -205,8 +205,8 @@ class CreateShare(command.ShowOne):
parsed_args.share_type).id
elif not parsed_args.snapshot_id:
try:
share_type = apiutils.find_resource(
share_client.share_types, 'default').id
share_type = share_client.share_types.get(
share_type='default').id
except apiclient_exceptions.CommandError:
msg = ("There is no default share type available. You must "
"pick a valid share type to create a share.")

View File

@ -372,6 +372,8 @@ class TestShareCreate(TestShare):
osc_exceptions.CommandError,
self.cmd.take_action,
parsed_args)
self.share_types_mock.get.assert_called_once_with(
share_type='default')
@ddt.data('None', 'NONE', 'none')
def test_create_share_with_the_name_none(self, name):

View File

@ -122,10 +122,10 @@ class ShareTypeManager(base.ManagerWithFind):
return self._list("/types%s" % query_string, "share_types")
def show(self, share_type):
"""Get a share.
"""Get a share type.
:param share: either share object or text with its ID.
:rtype: :class:`Share`
:param share type: either share type object or text with its ID.
:rtype: :class:`ShareType`
"""
type_id = base.getid(share_type)
return self._get("/types/%s" % type_id, "share_type")

View File

@ -0,0 +1,8 @@
---
fixes:
- |
Fixed default share type lookup associated with the "openstack share
create" command. The lookup now resolves default share types correctly
even on environments where the default type isn't named "default". See
`launchpad bug #2030686 <https://launchpad.net/bugs/2030686>`_ for more
details.