Skip to content

Commit 5a18f99

Browse files
rajatherestephenfin
authored andcommitted
volume: Deprecate '--retype-policy' in favor of '--migration-policy'
The '--retype-policy' option is used in the 'volume set' command to specify the migration policy during the retype operation. The '--retype-policy' option does not convey the correct meaning of its usage. The migration policy determines whether we are going to perform the migration in the retype operation or not and is not related to the actual retype which just changes the volume type of the volume. Change-Id: I2ea8fd3f5277bb3422ccae915d05e8ad44ff1912
1 parent 51f173c commit 5a18f99

2 files changed

Lines changed: 33 additions & 7 deletions

File tree

openstackclient/volume/v2/volume.py

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,12 @@ def get_parser(self, prog_name):
711711
'--retype-policy',
712712
metavar='<retype-policy>',
713713
choices=['never', 'on-demand'],
714+
help=argparse.SUPPRESS,
715+
)
716+
parser.add_argument(
717+
'--migration-policy',
718+
metavar='<migration-policy>',
719+
choices=['never', 'on-demand'],
714720
help=_(
715721
'Migration policy while re-typing volume '
716722
'("never" or "on-demand", default is "never" ) '
@@ -746,6 +752,15 @@ def take_action(self, parsed_args):
746752
volume = utils.find_resource(volume_client.volumes, parsed_args.volume)
747753

748754
result = 0
755+
if parsed_args.retype_policy:
756+
msg = _(
757+
"The '--retype-policy' option has been deprecated in favor "
758+
"of '--migration-policy' option. The '--retype-policy' option "
759+
"will be removed in a future release. Please use "
760+
"'--migration-policy' instead."
761+
)
762+
self.log.warning(msg)
763+
749764
if parsed_args.size:
750765
try:
751766
if parsed_args.size <= volume.size:
@@ -839,11 +854,12 @@ def take_action(self, parsed_args):
839854
e,
840855
)
841856
result += 1
857+
policy = parsed_args.migration_policy or parsed_args.retype_policy
842858
if parsed_args.type:
843859
# get the migration policy
844860
migration_policy = 'never'
845-
if parsed_args.retype_policy:
846-
migration_policy = parsed_args.retype_policy
861+
if policy:
862+
migration_policy = policy
847863
try:
848864
# find the volume type
849865
volume_type = utils.find_resource(
@@ -856,12 +872,14 @@ def take_action(self, parsed_args):
856872
except Exception as e:
857873
LOG.error(_("Failed to set volume type: %s"), e)
858874
result += 1
859-
elif parsed_args.retype_policy:
860-
# If the "--retype-policy" is specified without "--type"
875+
elif policy:
876+
# If the "--migration-policy" is specified without "--type"
861877
LOG.warning(
862-
_(
863-
"'--retype-policy' option will not work "
864-
"without '--type' option"
878+
_("'%s' option will not work without '--type' option")
879+
% (
880+
'--migration-policy'
881+
if parsed_args.migration_policy
882+
else '--retype-policy'
865883
)
866884
)
867885

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
upgrade:
3+
- |
4+
The ``volume set --retype-policy`` parameter has been renamed to
5+
``--migration-policy`` to better convey the correct meaning of the options
6+
usage. The migration policy determines whether we are going to perform the
7+
migration in the retype opearation or not and is not related to the actual
8+
retype which just changes the volume type of the volume.

0 commit comments

Comments
 (0)