Add show share type detail command
Since the show type detail API is available, So it is necessary to add the share type show command. Implements: blueprint support-show-type Change-Id: Ifd38af16a6f3bdbe0a39808d56dc79ff51d486d5
This commit is contained in:
parent
d4c581de4f
commit
388753fbfc
@ -830,6 +830,13 @@ class FakeHTTPClient(fakes.FakeHTTPClient):
|
||||
def get_types_default(self, **kw):
|
||||
return self.get_types_1(**kw)
|
||||
|
||||
def get_types_1234(self, **kw):
|
||||
return (200, {}, {
|
||||
'share_type': {'id': 1,
|
||||
'name': 'test-type-1',
|
||||
'extra_specs': {'test': 'test'},
|
||||
'required_extra_specs': {'test': 'test'}}})
|
||||
|
||||
def get_types(self, **kw):
|
||||
return (200, {}, {
|
||||
'share_types': [{'id': 1,
|
||||
|
@ -484,6 +484,10 @@ class ShellTest(test_utils.TestCase):
|
||||
self.run_command('share-instance-force-delete 1234')
|
||||
manager_mock.force_delete.assert_called_once_with(share_instance)
|
||||
|
||||
def test_type_show_details(self):
|
||||
self.run_command('type-show 1234')
|
||||
self.assert_called_anytime('GET', '/types/1234')
|
||||
|
||||
@mock.patch.object(cliutils, 'print_list', mock.Mock())
|
||||
def test_type_list(self):
|
||||
self.run_command('type-list')
|
||||
|
@ -117,6 +117,15 @@ class ShareTypeManager(base.ManagerWithFind):
|
||||
query_string = '?is_public=all'
|
||||
return self._list("/types%s" % query_string, "share_types")
|
||||
|
||||
def show(self, share_type):
|
||||
"""Get a share.
|
||||
|
||||
:param share: either share object or text with its ID.
|
||||
:rtype: :class:`Share`
|
||||
"""
|
||||
type_id = common_base.getid(share_type)
|
||||
return self._get("/types/%s" % type_id, "share_type")
|
||||
|
||||
def get(self, share_type="default"):
|
||||
"""Get a specific share type.
|
||||
|
||||
|
@ -151,6 +151,21 @@ def _find_share_instance(cs, instance):
|
||||
return apiclient_utils.find_resource(cs.share_instances, instance)
|
||||
|
||||
|
||||
def _print_type_show(stype, default_share_type=None):
|
||||
|
||||
is_default = 'YES' if stype == default_share_type else 'NO'
|
||||
stype_dict = {
|
||||
'id': stype.id,
|
||||
'name': stype.name,
|
||||
'visibility': _is_share_type_public(stype),
|
||||
'is_default': is_default,
|
||||
'description': None,
|
||||
'required_extra_specs': _print_type_required_extra_specs(stype),
|
||||
'optional_extra_specs': _print_type_optional_extra_specs(stype),
|
||||
}
|
||||
cliutils.print_dict(stype_dict)
|
||||
|
||||
|
||||
@api_versions.wraps("1.0", "2.8")
|
||||
def _print_share_instance(cs, instance):
|
||||
info = instance._info.copy()
|
||||
@ -3649,6 +3664,20 @@ def do_type_list(cs, args):
|
||||
columns=args.columns)
|
||||
|
||||
|
||||
@cliutils.arg(
|
||||
'share_type',
|
||||
metavar='<share_type>',
|
||||
help='Name or ID of the share type.')
|
||||
def do_type_show(cs, args):
|
||||
"""Show share type details."""
|
||||
share_type = cs.share_types.show(args.share_type)
|
||||
try:
|
||||
default = cs.share_types.get()
|
||||
except exceptions.NotFound:
|
||||
default = None
|
||||
_print_type_show(share_type, default_share_type=default)
|
||||
|
||||
|
||||
@cliutils.arg(
|
||||
'--columns',
|
||||
metavar='<columns>',
|
||||
|
@ -0,0 +1,3 @@
|
||||
---
|
||||
features:
|
||||
- Support show type details command.
|
Loading…
Reference in New Issue
Block a user