Merge "Add export location information to share replica show command"
This commit is contained in:
commit
4ec4c58567
@ -16,6 +16,7 @@ from osc_lib import exceptions
|
||||
from osc_lib import utils as osc_utils
|
||||
|
||||
from manilaclient.common._i18n import _
|
||||
from manilaclient.common import cliutils
|
||||
from manilaclient.osc import utils
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -183,17 +184,34 @@ class ShowShareReplica(command.ShowOne):
|
||||
parser.add_argument(
|
||||
"replica",
|
||||
metavar="<replica>",
|
||||
help=_("ID of the share replica.")
|
||||
help=_("ID of the share replica. Available only for "
|
||||
"microversion >= 2.47. ")
|
||||
)
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
share_client = self.app.client_manager.share
|
||||
|
||||
replica = osc_utils.find_resource(
|
||||
share_client.share_replicas,
|
||||
replica = share_client.share_replicas.get(
|
||||
parsed_args.replica)
|
||||
|
||||
replica_export_locations = (
|
||||
share_client.share_replica_export_locations.list(
|
||||
share_replica=replica))
|
||||
|
||||
replica._info['export_locations'] = []
|
||||
for element_location in replica_export_locations:
|
||||
element_location._info.pop('links', None)
|
||||
replica._info['export_locations'].append(
|
||||
element_location._info)
|
||||
|
||||
if parsed_args.formatter == 'table':
|
||||
replica._info['export_locations'] = (
|
||||
cliutils.convert_dict_list_to_string(
|
||||
replica._info['export_locations']))
|
||||
|
||||
replica._info.pop('links', None)
|
||||
|
||||
return self.dict2columns(replica._info)
|
||||
|
||||
|
||||
|
@ -15,6 +15,8 @@ from unittest import mock
|
||||
from osc_lib import exceptions
|
||||
from osc_lib import utils as oscutils
|
||||
|
||||
from manilaclient.common import cliutils
|
||||
|
||||
from manilaclient.osc import utils
|
||||
from manilaclient.osc.v2 import share_replicas as osc_share_replicas
|
||||
|
||||
@ -33,6 +35,11 @@ class TestShareReplica(manila_fakes.TestShare):
|
||||
self.replicas_mock = self.app.client_manager.share.share_replicas
|
||||
self.replicas_mock.reset_mock()
|
||||
|
||||
self.replica_el_mock = (
|
||||
self.app.client_manager
|
||||
.share.share_replica_export_locations)
|
||||
self.replica_el_mock.reset_mock()
|
||||
|
||||
|
||||
class TestShareReplicaCreate(TestShareReplica):
|
||||
|
||||
@ -358,8 +365,20 @@ class TestShareReplicaShow(TestShareReplica):
|
||||
)
|
||||
self.replicas_mock.get.return_value = self.share_replica
|
||||
|
||||
self.replica_el_list = (
|
||||
manila_fakes.FakeShareExportLocation.
|
||||
create_share_export_locations(count=2)
|
||||
)
|
||||
|
||||
self.replica_el_mock.list.return_value = (
|
||||
self.replica_el_list)
|
||||
|
||||
self.cmd = osc_share_replicas.ShowShareReplica(self.app, None)
|
||||
|
||||
self.share_replica._info['export_locations'] = (
|
||||
cliutils.convert_dict_list_to_string(
|
||||
self.replica_el_list))
|
||||
|
||||
self.data = tuple(self.share_replica._info.values())
|
||||
self.columns = tuple(self.share_replica._info.keys())
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user