Fix default share type resolution in OSC

This patch also fixes an incorrect docstring
in the share types SDK method.

Closes-Bug: #2030686
Change-Id: Iaea9746e6f4e133574f5504d906a49cc80fa4243
(cherry picked from commit a870c13cf1)
This commit is contained in:
Goutham Pacha Ravi 2023-08-08 16:16:01 -07:00
parent 4080d49426
commit ed34956613
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.