summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordaizhiyong <zhiyong.dai@easystack.cn>2016-11-16 15:39:14 +0800
committerSteve Martinelli <s.martinelli@gmail.com>2016-12-02 20:45:13 +0000
commit1907220113efe9425a6cc7f52ce87dd4e82233c7 (patch)
treeec521752b5b52fab59d2c53608f9be6c0ae1ae3a
parent094e5189b7bd4a84b124d17a7c70e4f9aaf7ebc7 (diff)
downloadpython-openstackclient-1907220113efe9425a6cc7f52ce87dd4e82233c7.tar.gz
Add "consistency group show" command
Add "consistency group show" command in volume v2 (v2 only). Change-Id: If496eba2955c0aacd52600bb6fba39690ddd90cb Implements: bp cinder-command-support Partial-Bug: #1613964
-rw-r--r--doc/source/command-objects/consistency-group.rst17
-rw-r--r--openstackclient/tests/unit/volume/v2/test_consistency_group.py43
-rw-r--r--openstackclient/volume/v2/consistency_group.py21
-rw-r--r--releasenotes/notes/bug-1613964-837196399be16b3d.yaml2
-rw-r--r--setup.cfg1
5 files changed, 84 insertions, 0 deletions
diff --git a/doc/source/command-objects/consistency-group.rst b/doc/source/command-objects/consistency-group.rst
index 3ab68e90..46682a56 100644
--- a/doc/source/command-objects/consistency-group.rst
+++ b/doc/source/command-objects/consistency-group.rst
@@ -81,3 +81,20 @@ List consistency groups.
.. option:: --long
List additional fields in output
+
+consistency group show
+----------------------
+
+Display consistency group details.
+
+.. program:: consistency group show
+.. code:: bash
+
+ os consistency group show
+ <consistency-group>
+
+.. _consistency_group_show-consistency-group:
+.. describe:: <consistency-group>
+
+ Consistency group to display (name or ID)
+
diff --git a/openstackclient/tests/unit/volume/v2/test_consistency_group.py b/openstackclient/tests/unit/volume/v2/test_consistency_group.py
index 835d9960..5beb6ef2 100644
--- a/openstackclient/tests/unit/volume/v2/test_consistency_group.py
+++ b/openstackclient/tests/unit/volume/v2/test_consistency_group.py
@@ -353,3 +353,46 @@ class TestConsistencyGroupList(TestConsistencyGroup):
detailed=True, search_opts={'all_tenants': False})
self.assertEqual(self.columns_long, columns)
self.assertEqual(self.data_long, list(data))
+
+
+class TestConsistencyGroupShow(TestConsistencyGroup):
+ columns = (
+ 'availability_zone',
+ 'created_at',
+ 'description',
+ 'id',
+ 'name',
+ 'status',
+ 'volume_types',
+ )
+
+ def setUp(self):
+ super(TestConsistencyGroupShow, self).setUp()
+
+ self.consistency_group = (
+ volume_fakes.FakeConsistencyGroup.create_one_consistency_group())
+ self.data = (
+ self.consistency_group.availability_zone,
+ self.consistency_group.created_at,
+ self.consistency_group.description,
+ self.consistency_group.id,
+ self.consistency_group.name,
+ self.consistency_group.status,
+ self.consistency_group.volume_types,
+ )
+ self.consistencygroups_mock.get.return_value = self.consistency_group
+ self.cmd = consistency_group.ShowConsistencyGroup(self.app, None)
+
+ def test_consistency_group_show(self):
+ arglist = [
+ self.consistency_group.id
+ ]
+ verifylist = [
+ ("consistency_group", self.consistency_group.id)
+ ]
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+ columns, data = self.cmd.take_action(parsed_args)
+ self.consistencygroups_mock.get.assert_called_once_with(
+ self.consistency_group.id)
+ self.assertEqual(self.columns, columns)
+ self.assertEqual(self.data, data)
diff --git a/openstackclient/volume/v2/consistency_group.py b/openstackclient/volume/v2/consistency_group.py
index a90091a6..661bcbe5 100644
--- a/openstackclient/volume/v2/consistency_group.py
+++ b/openstackclient/volume/v2/consistency_group.py
@@ -23,6 +23,7 @@ import six
from openstackclient.i18n import _
+
LOG = logging.getLogger(__name__)
@@ -177,3 +178,23 @@ class ListConsistencyGroup(command.Lister):
s, columns,
formatters={'Volume Types': utils.format_list})
for s in consistency_groups))
+
+
+class ShowConsistencyGroup(command.ShowOne):
+ _description = _("Display consistency group details.")
+
+ def get_parser(self, prog_name):
+ parser = super(ShowConsistencyGroup, self).get_parser(prog_name)
+ parser.add_argument(
+ "consistency_group",
+ metavar="<consistency-group>",
+ help=_("Consistency group to display (name or ID)")
+ )
+ return parser
+
+ def take_action(self, parsed_args):
+ volume_client = self.app.client_manager.volume
+ consistency_group = utils.find_resource(
+ volume_client.consistencygroups,
+ parsed_args.consistency_group)
+ return zip(*sorted(six.iteritems(consistency_group._info)))
diff --git a/releasenotes/notes/bug-1613964-837196399be16b3d.yaml b/releasenotes/notes/bug-1613964-837196399be16b3d.yaml
index 1d404af5..40975094 100644
--- a/releasenotes/notes/bug-1613964-837196399be16b3d.yaml
+++ b/releasenotes/notes/bug-1613964-837196399be16b3d.yaml
@@ -4,3 +4,5 @@ features:
[Bug `1613964 <https://bugs.launchpad.net/python-openstackclient/+bug/1613964>`_]
- Add ``consistency group delete`` command in volume v2.
[Bug `1613964 <https://bugs.launchpad.net/python-openstackclient/+bug/1613964>`_]
+ - Add ``consistency group show`` command in volume v2.
+ [Bug `1613964 <https://bugs.launchpad.net/python-openstackclient/+bug/1613964>`_]
diff --git a/setup.cfg b/setup.cfg
index a42af75f..3bd487b3 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -511,6 +511,7 @@ openstack.volume.v2 =
consistency_group_create = openstackclient.volume.v2.consistency_group:CreateConsistencyGroup
consistency_group_delete = openstackclient.volume.v2.consistency_group:DeleteConsistencyGroup
consistency_group_list = openstackclient.volume.v2.consistency_group:ListConsistencyGroup
+ consistency_group_show = openstackclient.volume.v2.consistency_group:ShowConsistencyGroup
consistency_group_snapshot_create = openstackclient.volume.v2.consistency_group_snapshot:CreateConsistencyGroupSnapshot
consistency_group_snapshot_delete = openstackclient.volume.v2.consistency_group_snapshot:DeleteConsistencyGroupSnapshot