1515
1616"""Quota action implementations"""
1717
18+ import argparse
1819import itertools
1920import logging
2021import sys
@@ -621,20 +622,37 @@ def get_parser(self, prog_name):
621622 metavar = '<volume-type>' ,
622623 help = _ ('Set quotas for a specific <volume-type>' ),
623624 )
624- parser .add_argument (
625+ force_group = parser .add_mutually_exclusive_group ()
626+ force_group .add_argument (
625627 '--force' ,
626628 action = 'store_true' ,
629+ dest = 'force' ,
630+ # TODO(stephenfin): Change the default to False in Z or later
631+ default = None ,
627632 help = _ (
628- 'Force quota update (only supported by compute and network)'
633+ 'Force quota update (only supported by compute and network) '
634+ '(default for network)'
629635 ),
630636 )
631- parser .add_argument (
632- '--check-limit' ,
633- action = 'store_true' ,
637+ force_group .add_argument (
638+ '--no-force' ,
639+ action = 'store_false' ,
640+ dest = 'force' ,
641+ default = None ,
634642 help = _ (
635- 'Check quota limit when updating (only supported by network)'
643+ 'Do not force quota update '
644+ '(only supported by compute and network) '
645+ '(default for compute)'
636646 ),
637647 )
648+ # kept here for backwards compatibility/to keep the neutron folks happy
649+ force_group .add_argument (
650+ '--check-limit' ,
651+ action = 'store_false' ,
652+ dest = 'force' ,
653+ default = None ,
654+ help = argparse .SUPPRESS ,
655+ )
638656 return parser
639657
640658 def take_action (self , parsed_args ):
@@ -657,8 +675,8 @@ def take_action(self, parsed_args):
657675 if value is not None :
658676 compute_kwargs [k ] = value
659677
660- if parsed_args .force :
661- compute_kwargs ['force' ] = True
678+ if parsed_args .force is not None :
679+ compute_kwargs ['force' ] = parsed_args . force
662680
663681 volume_kwargs = {}
664682 for k , v in VOLUME_QUOTAS .items ():
@@ -669,10 +687,21 @@ def take_action(self, parsed_args):
669687 volume_kwargs [k ] = value
670688
671689 network_kwargs = {}
672- if parsed_args .check_limit :
673- network_kwargs ['check_limit' ] = True
674- if parsed_args .force :
690+ if parsed_args .force is True :
691+ # Unlike compute, network doesn't provide a simple boolean option.
692+ # Instead, it provides two options: 'force' and 'check_limit'
693+ # (a.k.a. 'not force')
675694 network_kwargs ['force' ] = True
695+ elif parsed_args .force is False :
696+ network_kwargs ['check_limit' ] = True
697+ else :
698+ msg = _ (
699+ "This command currently defaults to '--force' when modifying "
700+ "network quotas. This behavior will change in a future "
701+ "release. Consider explicitly providing '--force' or "
702+ "'--no-force' options to avoid changes in behavior."
703+ )
704+ self .log .warning (msg )
676705
677706 if self .app .client_manager .is_network_endpoint_enabled ():
678707 for k , v in NETWORK_QUOTAS .items ():
0 commit comments