Add "consistency group set" command
Add "consistency group set" command in volume v2 (v2 only). Change-Id: I53116015388b7a4b0e15813f52c1246166bb0fc1 Implements: bp cinder-command-support Partial-Bug: #1613964
This commit is contained in:
parent
e05c8d7bb0
commit
4dc78e4265
@ -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)
|
||||
|
||||
|
@ -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',
|
||||
|
@ -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.")
|
||||
|
||||
|
4
releasenotes/notes/bug-1613964-86e0afe0e012a758.yaml
Normal file
4
releasenotes/notes/bug-1613964-86e0afe0e012a758.yaml
Normal file
@ -0,0 +1,4 @@
|
||||
---
|
||||
features:
|
||||
- Add ``consistency group set`` command in volume v2.
|
||||
[Bug `1613964 <https://bugs.launchpad.net/python-openstackclient/+bug/1613964>`_]
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user