Skip to content

Commit 3478873

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "volume: Remove duplication from 'consistency group create' opts"
2 parents 365a7a2 + 4106926 commit 3478873

File tree

3 files changed

+41
-15
lines changed

3 files changed

+41
-15
lines changed

openstackclient/tests/unit/volume/v2/test_consistency_group.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ def test_consistency_group_create_from_source(self):
257257
self.new_consistency_group.name,
258258
]
259259
verifylist = [
260-
('consistency_group_source', self.new_consistency_group.id),
260+
('source', self.new_consistency_group.id),
261261
('description', self.new_consistency_group.description),
262262
('name', self.new_consistency_group.name),
263263
]
@@ -285,7 +285,7 @@ def test_consistency_group_create_from_snapshot(self):
285285
self.new_consistency_group.name,
286286
]
287287
verifylist = [
288-
('consistency_group_snapshot', self.consistency_group_snapshot.id),
288+
('snapshot', self.consistency_group_snapshot.id),
289289
('description', self.new_consistency_group.description),
290290
('name', self.new_consistency_group.name),
291291
]

openstackclient/volume/v2/consistency_group.py

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
"""Volume v2 consistency group action implementations"""
1616

17+
import argparse
1718
import logging
1819

1920
from osc_lib.cli import format_columns
@@ -90,35 +91,51 @@ def get_parser(self, prog_name):
9091
"name",
9192
metavar="<name>",
9293
nargs="?",
93-
help=_("Name of new consistency group (default to None)")
94+
help=_("Name of new consistency group (default to None)"),
9495
)
9596
exclusive_group = parser.add_mutually_exclusive_group(required=True)
9697
exclusive_group.add_argument(
9798
"--volume-type",
9899
metavar="<volume-type>",
99-
help=_("Volume type of this consistency group (name or ID)")
100+
help=_("Volume type of this consistency group (name or ID)"),
100101
)
102+
exclusive_group.add_argument(
103+
"--source",
104+
metavar="<consistency-group>",
105+
help=_("Existing consistency group (name or ID)"),
106+
)
107+
# NOTE(stephenfin): Legacy alias
101108
exclusive_group.add_argument(
102109
"--consistency-group-source",
103110
metavar="<consistency-group>",
104-
help=_("Existing consistency group (name or ID)")
111+
dest='source',
112+
help=argparse.SUPPRESS,
113+
)
114+
exclusive_group.add_argument(
115+
"--snapshot",
116+
metavar="<consistency-group-snapshot>",
117+
help=_("Existing consistency group snapshot (name or ID)"),
105118
)
119+
# NOTE(stephenfin): Legacy alias
106120
exclusive_group.add_argument(
107121
"--consistency-group-snapshot",
108122
metavar="<consistency-group-snapshot>",
109-
help=_("Existing consistency group snapshot (name or ID)")
123+
dest='snapshot',
124+
help=argparse.SUPPRESS,
110125
)
111126
parser.add_argument(
112127
"--description",
113128
metavar="<description>",
114-
help=_("Description of this consistency group")
129+
help=_("Description of this consistency group"),
115130
)
116131
parser.add_argument(
117132
"--availability-zone",
118133
metavar="<availability-zone>",
119-
help=_("Availability zone for this consistency group "
120-
"(not available if creating consistency group "
121-
"from source)"),
134+
help=_(
135+
"Availability zone for this consistency group "
136+
"(not available if creating consistency group "
137+
"from source)"
138+
),
122139
)
123140
return parser
124141

@@ -142,21 +159,23 @@ def take_action(self, parsed_args):
142159

143160
consistency_group_id = None
144161
consistency_group_snapshot = None
145-
if parsed_args.consistency_group_source:
162+
if parsed_args.source:
146163
consistency_group_id = utils.find_resource(
147164
volume_client.consistencygroups,
148-
parsed_args.consistency_group_source).id
149-
elif parsed_args.consistency_group_snapshot:
165+
parsed_args.source,
166+
).id
167+
elif parsed_args.snapshot:
150168
consistency_group_snapshot = utils.find_resource(
151169
volume_client.cgsnapshots,
152-
parsed_args.consistency_group_snapshot).id
170+
parsed_args.snapshot,
171+
).id
153172

154173
consistency_group = (
155174
volume_client.consistencygroups.create_from_src(
156175
consistency_group_snapshot,
157176
consistency_group_id,
158177
name=parsed_args.name,
159-
description=parsed_args.description
178+
description=parsed_args.description,
160179
)
161180
)
162181

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
upgrade:
3+
- |
4+
The ``--consistency-group-source`` and ``--consistency-group-snapshot``
5+
options for the ``consistency group create`` command have been renamed to
6+
``--source`` and ``--snapshot``, respectively. Aliases are provided for the
7+
older variants.

0 commit comments

Comments
 (0)