Implement openstack share properties show command
This commit adds openstack share show metadata command, which implements manila metadata-show functionality. Partially implements bp openstack-client-support. Updated with working unit test. Change-Id: Ibde82cf9c36be41403a0e68ecac17cb211725d84
This commit is contained in:
parent
4eec42711a
commit
c7bcec2969
|
@ -26,6 +26,9 @@ shares
|
|||
.. autoprogram-cliff:: openstack.share.v2
|
||||
:command: share unset
|
||||
|
||||
.. autoprogram-cliff:: openstack.share.v2
|
||||
:command: share properties show
|
||||
|
||||
.. autoprogram-cliff:: openstack.share.v2
|
||||
:command: share resize
|
||||
|
||||
|
@ -41,6 +44,7 @@ shares
|
|||
.. autoprogram-cliff:: openstack.share.v2
|
||||
:command: share export location list
|
||||
|
||||
|
||||
==================
|
||||
share access rules
|
||||
==================
|
||||
|
|
|
@ -1004,6 +1004,7 @@ class ShareExportLocationList(command.Lister):
|
|||
def get_parser(self, prog_name):
|
||||
parser = super(ShareExportLocationList, self).get_parser(
|
||||
prog_name)
|
||||
|
||||
parser.add_argument(
|
||||
'share',
|
||||
metavar="<share>",
|
||||
|
@ -1028,3 +1029,25 @@ class ShareExportLocationList(command.Lister):
|
|||
|
||||
return (list_of_keys, (oscutils.get_item_properties
|
||||
(s, list_of_keys) for s in export_locations))
|
||||
|
||||
|
||||
class ShowShareProperties(command.ShowOne):
|
||||
"""Show properties of a share"""
|
||||
_description = _("Show share properties")
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(ShowShareProperties, self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'share',
|
||||
metavar="<share>",
|
||||
help=_('Name or ID of share')
|
||||
)
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
share_client = self.app.client_manager.share
|
||||
share = apiutils.find_resource(
|
||||
share_client.shares, parsed_args.share)
|
||||
share_properties = share_client.shares.get_metadata(share)
|
||||
|
||||
return self.dict2columns(share_properties._info)
|
||||
|
|
|
@ -26,6 +26,7 @@ from manilaclient.api_versions import MAX_VERSION
|
|||
from manilaclient.common.apiclient import exceptions
|
||||
from manilaclient.common import cliutils
|
||||
from manilaclient.osc.v2 import share as osc_shares
|
||||
from manilaclient.tests.unit.osc import osc_fakes
|
||||
from manilaclient.tests.unit.osc import osc_utils
|
||||
from manilaclient.tests.unit.osc.v2 import fakes as manila_fakes
|
||||
|
||||
|
@ -1741,3 +1742,46 @@ class TestShareExportLocationList(TestShare):
|
|||
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertCountEqual(self.values, data)
|
||||
|
||||
|
||||
class TestShowShareProperties(TestShare):
|
||||
|
||||
properties = {
|
||||
'key1': 'value1',
|
||||
'key2': 'value2'
|
||||
}
|
||||
|
||||
def setUp(self):
|
||||
super(TestShowShareProperties, self).setUp()
|
||||
|
||||
self._share = manila_fakes.FakeShare.create_one_share(
|
||||
attrs={
|
||||
'metadata': osc_fakes.FakeResource(
|
||||
info=self.properties)
|
||||
}
|
||||
)
|
||||
self.shares_mock.get.return_value = self._share
|
||||
|
||||
self.shares_mock.get_metadata.return_value = self._share.metadata
|
||||
|
||||
# Get the command object to test
|
||||
self.cmd = osc_shares.ShowShareProperties(self.app, None)
|
||||
|
||||
self.datalist = tuple(self._share.metadata._info.values())
|
||||
self.columns = tuple(self._share.metadata._info.keys())
|
||||
|
||||
def test_share_show_properties(self):
|
||||
arglist = [
|
||||
self._share.id
|
||||
]
|
||||
verifylist = [
|
||||
("share", self._share.id)
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.shares_mock.get.assert_called_with(self._share.id)
|
||||
self.shares_mock.get_metadata.assert_called_with(self._share)
|
||||
|
||||
self.assertCountEqual(self.columns, columns)
|
||||
self.assertCountEqual(self.datalist, data)
|
||||
|
|
|
@ -46,6 +46,7 @@ openstack.share.v2 =
|
|||
share_abandon = manilaclient.osc.v2.share:AbandonShare
|
||||
share_export_location_show = manilaclient.osc.v2.share:ShareExportLocationShow
|
||||
share_export_location_list = manilaclient.osc.v2.share:ShareExportLocationList
|
||||
share_properties_show = manilaclient.osc.v2.share:ShowShareProperties
|
||||
share_access_create = manilaclient.osc.v2.share_access_rules:ShareAccessAllow
|
||||
share_access_delete = manilaclient.osc.v2.share_access_rules:ShareAccessDeny
|
||||
share_access_list = manilaclient.osc.v2.share_access_rules:ListShareAccess
|
||||
|
|
Loading…
Reference in New Issue