Merge "volume: Remove duplication from 'consistency group create' opts"
This commit is contained in:
commit
3478873cff
@ -257,7 +257,7 @@ class TestConsistencyGroupCreate(TestConsistencyGroup):
|
|||||||
self.new_consistency_group.name,
|
self.new_consistency_group.name,
|
||||||
]
|
]
|
||||||
verifylist = [
|
verifylist = [
|
||||||
('consistency_group_source', self.new_consistency_group.id),
|
('source', self.new_consistency_group.id),
|
||||||
('description', self.new_consistency_group.description),
|
('description', self.new_consistency_group.description),
|
||||||
('name', self.new_consistency_group.name),
|
('name', self.new_consistency_group.name),
|
||||||
]
|
]
|
||||||
@ -285,7 +285,7 @@ class TestConsistencyGroupCreate(TestConsistencyGroup):
|
|||||||
self.new_consistency_group.name,
|
self.new_consistency_group.name,
|
||||||
]
|
]
|
||||||
verifylist = [
|
verifylist = [
|
||||||
('consistency_group_snapshot', self.consistency_group_snapshot.id),
|
('snapshot', self.consistency_group_snapshot.id),
|
||||||
('description', self.new_consistency_group.description),
|
('description', self.new_consistency_group.description),
|
||||||
('name', self.new_consistency_group.name),
|
('name', self.new_consistency_group.name),
|
||||||
]
|
]
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
"""Volume v2 consistency group action implementations"""
|
"""Volume v2 consistency group action implementations"""
|
||||||
|
|
||||||
|
import argparse
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from osc_lib.cli import format_columns
|
from osc_lib.cli import format_columns
|
||||||
@ -90,35 +91,51 @@ class CreateConsistencyGroup(command.ShowOne):
|
|||||||
"name",
|
"name",
|
||||||
metavar="<name>",
|
metavar="<name>",
|
||||||
nargs="?",
|
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 = parser.add_mutually_exclusive_group(required=True)
|
||||||
exclusive_group.add_argument(
|
exclusive_group.add_argument(
|
||||||
"--volume-type",
|
"--volume-type",
|
||||||
metavar="<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(
|
exclusive_group.add_argument(
|
||||||
"--consistency-group-source",
|
"--consistency-group-source",
|
||||||
metavar="<consistency-group>",
|
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(
|
exclusive_group.add_argument(
|
||||||
"--consistency-group-snapshot",
|
"--consistency-group-snapshot",
|
||||||
metavar="<consistency-group-snapshot>",
|
metavar="<consistency-group-snapshot>",
|
||||||
help=_("Existing consistency group snapshot (name or ID)")
|
dest='snapshot',
|
||||||
|
help=argparse.SUPPRESS,
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--description",
|
"--description",
|
||||||
metavar="<description>",
|
metavar="<description>",
|
||||||
help=_("Description of this consistency group")
|
help=_("Description of this consistency group"),
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--availability-zone",
|
"--availability-zone",
|
||||||
metavar="<availability-zone>",
|
metavar="<availability-zone>",
|
||||||
help=_("Availability zone for this consistency group "
|
help=_(
|
||||||
|
"Availability zone for this consistency group "
|
||||||
"(not available if creating consistency group "
|
"(not available if creating consistency group "
|
||||||
"from source)"),
|
"from source)"
|
||||||
|
),
|
||||||
)
|
)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
@ -142,21 +159,23 @@ class CreateConsistencyGroup(command.ShowOne):
|
|||||||
|
|
||||||
consistency_group_id = None
|
consistency_group_id = None
|
||||||
consistency_group_snapshot = None
|
consistency_group_snapshot = None
|
||||||
if parsed_args.consistency_group_source:
|
if parsed_args.source:
|
||||||
consistency_group_id = utils.find_resource(
|
consistency_group_id = utils.find_resource(
|
||||||
volume_client.consistencygroups,
|
volume_client.consistencygroups,
|
||||||
parsed_args.consistency_group_source).id
|
parsed_args.source,
|
||||||
elif parsed_args.consistency_group_snapshot:
|
).id
|
||||||
|
elif parsed_args.snapshot:
|
||||||
consistency_group_snapshot = utils.find_resource(
|
consistency_group_snapshot = utils.find_resource(
|
||||||
volume_client.cgsnapshots,
|
volume_client.cgsnapshots,
|
||||||
parsed_args.consistency_group_snapshot).id
|
parsed_args.snapshot,
|
||||||
|
).id
|
||||||
|
|
||||||
consistency_group = (
|
consistency_group = (
|
||||||
volume_client.consistencygroups.create_from_src(
|
volume_client.consistencygroups.create_from_src(
|
||||||
consistency_group_snapshot,
|
consistency_group_snapshot,
|
||||||
consistency_group_id,
|
consistency_group_id,
|
||||||
name=parsed_args.name,
|
name=parsed_args.name,
|
||||||
description=parsed_args.description
|
description=parsed_args.description,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -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.
|
Loading…
x
Reference in New Issue
Block a user