summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2023-02-22 12:32:11 +0000
committerGerrit Code Review <review@openstack.org>2023-02-22 12:32:11 +0000
commit3478873cff2fa072de067b2d0a43da57aca1f4b2 (patch)
tree59729716d1d173b7e6e85123c8c89e73c1d4327a
parent365a7a24f55291e42f71b735fc3b6511a6ef451b (diff)
parent4106926fa65622dc33e7322832394aedb47f95ad (diff)
downloadpython-openstackclient-3478873cff2fa072de067b2d0a43da57aca1f4b2.tar.gz
Merge "volume: Remove duplication from 'consistency group create' opts"
-rw-r--r--openstackclient/tests/unit/volume/v2/test_consistency_group.py4
-rw-r--r--openstackclient/volume/v2/consistency_group.py45
-rw-r--r--releasenotes/notes/consistency-group-create-opts-aliases-e1c2f1498e9b1d3d.yaml7
3 files changed, 41 insertions, 15 deletions
diff --git a/openstackclient/tests/unit/volume/v2/test_consistency_group.py b/openstackclient/tests/unit/volume/v2/test_consistency_group.py
index 7ef4a08e..c5537ed8 100644
--- a/openstackclient/tests/unit/volume/v2/test_consistency_group.py
+++ b/openstackclient/tests/unit/volume/v2/test_consistency_group.py
@@ -257,7 +257,7 @@ class TestConsistencyGroupCreate(TestConsistencyGroup):
self.new_consistency_group.name,
]
verifylist = [
- ('consistency_group_source', self.new_consistency_group.id),
+ ('source', self.new_consistency_group.id),
('description', self.new_consistency_group.description),
('name', self.new_consistency_group.name),
]
@@ -285,7 +285,7 @@ class TestConsistencyGroupCreate(TestConsistencyGroup):
self.new_consistency_group.name,
]
verifylist = [
- ('consistency_group_snapshot', self.consistency_group_snapshot.id),
+ ('snapshot', self.consistency_group_snapshot.id),
('description', self.new_consistency_group.description),
('name', self.new_consistency_group.name),
]
diff --git a/openstackclient/volume/v2/consistency_group.py b/openstackclient/volume/v2/consistency_group.py
index c50a1b5b..77da6f64 100644
--- a/openstackclient/volume/v2/consistency_group.py
+++ b/openstackclient/volume/v2/consistency_group.py
@@ -14,6 +14,7 @@
"""Volume v2 consistency group action implementations"""
+import argparse
import logging
from osc_lib.cli import format_columns
@@ -90,35 +91,51 @@ class CreateConsistencyGroup(command.ShowOne):
"name",
metavar="<name>",
nargs="?",
- help=_("Name of new consistency group (default to None)")
+ help=_("Name of new consistency group (default to None)"),
)
exclusive_group = parser.add_mutually_exclusive_group(required=True)
exclusive_group.add_argument(
"--volume-type",
metavar="<volume-type>",
- help=_("Volume type of this consistency group (name or ID)")
+ help=_("Volume type of this consistency group (name or ID)"),
)
exclusive_group.add_argument(
+ "--source",
+ metavar="<consistency-group>",
+ help=_("Existing consistency group (name or ID)"),
+ )
+ # NOTE(stephenfin): Legacy alias
+ exclusive_group.add_argument(
"--consistency-group-source",
metavar="<consistency-group>",
- help=_("Existing consistency group (name or ID)")
+ dest='source',
+ help=argparse.SUPPRESS,
+ )
+ exclusive_group.add_argument(
+ "--snapshot",
+ metavar="<consistency-group-snapshot>",
+ help=_("Existing consistency group snapshot (name or ID)"),
)
+ # NOTE(stephenfin): Legacy alias
exclusive_group.add_argument(
"--consistency-group-snapshot",
metavar="<consistency-group-snapshot>",
- help=_("Existing consistency group snapshot (name or ID)")
+ dest='snapshot',
+ help=argparse.SUPPRESS,
)
parser.add_argument(
"--description",
metavar="<description>",
- help=_("Description of this consistency group")
+ help=_("Description of this consistency group"),
)
parser.add_argument(
"--availability-zone",
metavar="<availability-zone>",
- help=_("Availability zone for this consistency group "
- "(not available if creating consistency group "
- "from source)"),
+ help=_(
+ "Availability zone for this consistency group "
+ "(not available if creating consistency group "
+ "from source)"
+ ),
)
return parser
@@ -142,21 +159,23 @@ class CreateConsistencyGroup(command.ShowOne):
consistency_group_id = None
consistency_group_snapshot = None
- if parsed_args.consistency_group_source:
+ if parsed_args.source:
consistency_group_id = utils.find_resource(
volume_client.consistencygroups,
- parsed_args.consistency_group_source).id
- elif parsed_args.consistency_group_snapshot:
+ parsed_args.source,
+ ).id
+ elif parsed_args.snapshot:
consistency_group_snapshot = utils.find_resource(
volume_client.cgsnapshots,
- parsed_args.consistency_group_snapshot).id
+ parsed_args.snapshot,
+ ).id
consistency_group = (
volume_client.consistencygroups.create_from_src(
consistency_group_snapshot,
consistency_group_id,
name=parsed_args.name,
- description=parsed_args.description
+ description=parsed_args.description,
)
)
diff --git a/releasenotes/notes/consistency-group-create-opts-aliases-e1c2f1498e9b1d3d.yaml b/releasenotes/notes/consistency-group-create-opts-aliases-e1c2f1498e9b1d3d.yaml
new file mode 100644
index 00000000..191f020f
--- /dev/null
+++ b/releasenotes/notes/consistency-group-create-opts-aliases-e1c2f1498e9b1d3d.yaml
@@ -0,0 +1,7 @@
+---
+upgrade:
+ - |
+ The ``--consistency-group-source`` and ``--consistency-group-snapshot``
+ options for the ``consistency group create`` command have been renamed to
+ ``--source`` and ``--snapshot``, respectively. Aliases are provided for the
+ older variants.