@@ -720,6 +720,12 @@ def get_parser(self, prog_name):
720720 '--retype-policy' ,
721721 metavar = '<retype-policy>' ,
722722 choices = ['never' , 'on-demand' ],
723+ help = argparse .SUPPRESS ,
724+ )
725+ parser .add_argument (
726+ '--migration-policy' ,
727+ metavar = '<migration-policy>' ,
728+ choices = ['never' , 'on-demand' ],
723729 help = _ (
724730 'Migration policy while re-typing volume '
725731 '("never" or "on-demand", default is "never" ) '
@@ -755,6 +761,15 @@ def take_action(self, parsed_args):
755761 volume = utils .find_resource (volume_client .volumes , parsed_args .volume )
756762
757763 result = 0
764+ if parsed_args .retype_policy :
765+ msg = _ (
766+ "The '--retype-policy' option has been deprecated in favor "
767+ "of '--migration-policy' option. The '--retype-policy' option "
768+ "will be removed in a future release. Please use "
769+ "'--migration-policy' instead."
770+ )
771+ self .log .warning (msg )
772+
758773 if parsed_args .size :
759774 try :
760775 if parsed_args .size <= volume .size :
@@ -848,11 +863,12 @@ def take_action(self, parsed_args):
848863 e ,
849864 )
850865 result += 1
866+ policy = parsed_args .migration_policy or parsed_args .retype_policy
851867 if parsed_args .type :
852868 # get the migration policy
853869 migration_policy = 'never'
854- if parsed_args . retype_policy :
855- migration_policy = parsed_args . retype_policy
870+ if policy :
871+ migration_policy = policy
856872 try :
857873 # find the volume type
858874 volume_type = utils .find_resource (
@@ -865,12 +881,14 @@ def take_action(self, parsed_args):
865881 except Exception as e :
866882 LOG .error (_ ("Failed to set volume type: %s" ), e )
867883 result += 1
868- elif parsed_args . retype_policy :
869- # If the "--retype -policy" is specified without "--type"
884+ elif policy :
885+ # If the "--migration -policy" is specified without "--type"
870886 LOG .warning (
871- _ (
872- "'--retype-policy' option will not work "
873- "without '--type' option"
887+ _ ("'%s' option will not work without '--type' option" )
888+ % (
889+ '--migration-policy'
890+ if parsed_args .migration_policy
891+ else '--retype-policy'
874892 )
875893 )
876894
0 commit comments