summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/source/command-objects/consistency-group.rst27
-rw-r--r--openstackclient/tests/unit/volume/v2/test_consistency_group.py64
-rw-r--r--openstackclient/volume/v2/consistency_group.py39
-rw-r--r--releasenotes/notes/bug-1613964-86e0afe0e012a758.yaml4
-rw-r--r--setup.cfg1
5 files changed, 133 insertions, 2 deletions
diff --git a/doc/source/command-objects/consistency-group.rst b/doc/source/command-objects/consistency-group.rst
index 46682a56..cd972035 100644
--- a/doc/source/command-objects/consistency-group.rst
+++ b/doc/source/command-objects/consistency-group.rst
@@ -82,6 +82,32 @@ List consistency groups.
List additional fields in output
+consistency group set
+---------------------
+
+Set consistency group properties.
+
+.. program:: consistency group set
+ .. code:: bash
+
+ os consistency group set
+ [--name <name>]
+ [--description <description>]
+ <consistency-group>
+
+.. option:: --name <name>
+
+ New consistency group name
+
+.. option:: --description <description>
+
+ New consistency group description
+
+.. _consistency_group_set-consistency-group:
+.. describe:: <consistency-group>
+
+ Consistency group to modify (name or ID)
+
consistency group show
----------------------
@@ -97,4 +123,3 @@ Display consistency group details.
.. 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 5beb6ef2..8a997e18 100644
--- a/openstackclient/tests/unit/volume/v2/test_consistency_group.py
+++ b/openstackclient/tests/unit/volume/v2/test_consistency_group.py
@@ -355,6 +355,70 @@ class TestConsistencyGroupList(TestConsistencyGroup):
self.assertEqual(self.data_long, list(data))
+class TestConsistencyGroupSet(TestConsistencyGroup):
+
+ consistency_group = (
+ volume_fakes.FakeConsistencyGroup.create_one_consistency_group())
+
+ def setUp(self):
+ super(TestConsistencyGroupSet, self).setUp()
+
+ self.consistencygroups_mock.get.return_value = (
+ self.consistency_group)
+ # Get the command object to test
+ self.cmd = consistency_group.SetConsistencyGroup(self.app, None)
+
+ def test_consistency_group_set_name(self):
+ new_name = 'new_name'
+ arglist = [
+ '--name', new_name,
+ self.consistency_group.id,
+ ]
+ verifylist = [
+ ('name', new_name),
+ ('description', None),
+ ('consistency_group', self.consistency_group.id),
+ ]
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ result = self.cmd.take_action(parsed_args)
+
+ # Set expected values
+ kwargs = {
+ 'name': new_name,
+ }
+ self.consistencygroups_mock.update.assert_called_once_with(
+ self.consistency_group.id,
+ **kwargs
+ )
+ self.assertIsNone(result)
+
+ def test_consistency_group_set_description(self):
+ new_description = 'new_description'
+ arglist = [
+ '--description', new_description,
+ self.consistency_group.id,
+ ]
+ verifylist = [
+ ('name', None),
+ ('description', new_description),
+ ('consistency_group', self.consistency_group.id),
+ ]
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ result = self.cmd.take_action(parsed_args)
+
+ # Set expected values
+ kwargs = {
+ 'description': new_description,
+ }
+ self.consistencygroups_mock.update.assert_called_once_with(
+ self.consistency_group.id,
+ **kwargs
+ )
+ self.assertIsNone(result)
+
+
class TestConsistencyGroupShow(TestConsistencyGroup):
columns = (
'availability_zone',
diff --git a/openstackclient/volume/v2/consistency_group.py b/openstackclient/volume/v2/consistency_group.py
index 661bcbe5..f77da59b 100644
--- a/openstackclient/volume/v2/consistency_group.py
+++ b/openstackclient/volume/v2/consistency_group.py
@@ -151,7 +151,7 @@ class ListConsistencyGroup(command.Lister):
parser.add_argument(
'--all-projects',
action="store_true",
- help=_('Show detail for all projects. Admin only. '
+ help=_('Show details for all projects. Admin only. '
'(defaults to False)')
)
parser.add_argument(
@@ -180,6 +180,43 @@ class ListConsistencyGroup(command.Lister):
for s in consistency_groups))
+class SetConsistencyGroup(command.Command):
+ _description = _("Set consistency group properties")
+
+ def get_parser(self, prog_name):
+ parser = super(SetConsistencyGroup, self).get_parser(prog_name)
+ parser.add_argument(
+ 'consistency_group',
+ metavar='<consistency-group>',
+ help=_('Consistency group to modify (name or ID)')
+ )
+ parser.add_argument(
+ '--name',
+ metavar='<name>',
+ help=_('New consistency group name'),
+ )
+ parser.add_argument(
+ '--description',
+ metavar='<description>',
+ help=_('New consistency group description'),
+ )
+ return parser
+
+ def take_action(self, parsed_args):
+ volume_client = self.app.client_manager.volume
+ kwargs = {}
+ if parsed_args.name:
+ kwargs['name'] = parsed_args.name
+ if parsed_args.description:
+ kwargs['description'] = parsed_args.description
+ if kwargs:
+ consistency_group_id = utils.find_resource(
+ volume_client.consistencygroups,
+ parsed_args.consistency_group).id
+ volume_client.consistencygroups.update(
+ consistency_group_id, **kwargs)
+
+
class ShowConsistencyGroup(command.ShowOne):
_description = _("Display consistency group details.")
diff --git a/releasenotes/notes/bug-1613964-86e0afe0e012a758.yaml b/releasenotes/notes/bug-1613964-86e0afe0e012a758.yaml
new file mode 100644
index 00000000..461c2f68
--- /dev/null
+++ b/releasenotes/notes/bug-1613964-86e0afe0e012a758.yaml
@@ -0,0 +1,4 @@
+---
+features:
+ - Add ``consistency group set`` command in volume v2.
+ [Bug `1613964 <https://bugs.launchpad.net/python-openstackclient/+bug/1613964>`_]
diff --git a/setup.cfg b/setup.cfg
index 2bbbb5ae..7f76cd44 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -518,6 +518,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_set = openstackclient.volume.v2.consistency_group:SetConsistencyGroup
consistency_group_show = openstackclient.volume.v2.consistency_group:ShowConsistencyGroup
consistency_group_snapshot_create = openstackclient.volume.v2.consistency_group_snapshot:CreateConsistencyGroupSnapshot