2020import sys
2121
2222from osc_lib .command import command
23+ from osc_lib import exceptions
2324from osc_lib import utils
2425
2526from openstackclient .i18n import _
@@ -506,30 +507,27 @@ def get_parser(self, prog_name):
506507 '--force' ,
507508 action = 'store_true' ,
508509 dest = 'force' ,
509- # TODO(stephenfin): Change the default to False in Z or later
510- default = None ,
510+ default = False ,
511511 help = _ (
512- 'Force quota update (only supported by compute and network) '
513- '(default for network)'
512+ 'Force quota update (only supported by compute and network)'
514513 ),
515514 )
516515 force_group .add_argument (
517516 '--no-force' ,
518517 action = 'store_false' ,
519518 dest = 'force' ,
520- default = None ,
519+ default = False ,
521520 help = _ (
522521 'Do not force quota update '
523- '(only supported by compute and network) '
524- '(default for compute)'
522+ '(only supported by compute and network) (default)'
525523 ),
526524 )
527525 # kept here for backwards compatibility/to keep the neutron folks happy
528526 force_group .add_argument (
529527 '--check-limit' ,
530528 action = 'store_false' ,
531529 dest = 'force' ,
532- default = None ,
530+ default = False ,
533531 help = argparse .SUPPRESS ,
534532 )
535533 return parser
@@ -545,6 +543,12 @@ def take_action(self, parsed_args):
545543 )
546544 self .log .warning (msg )
547545
546+ if (
547+ parsed_args .quota_class or parsed_args .default
548+ ) and parsed_args .force :
549+ msg = _ ('--force cannot be used with --class or --default' )
550+ raise exceptions .CommandError (msg )
551+
548552 compute_client = self .app .client_manager .compute
549553 volume_client = self .app .client_manager .volume
550554
@@ -554,7 +558,7 @@ def take_action(self, parsed_args):
554558 if value is not None :
555559 compute_kwargs [k ] = value
556560
557- if parsed_args .force is not None :
561+ if parsed_args .force is True :
558562 compute_kwargs ['force' ] = parsed_args .force
559563
560564 volume_kwargs = {}
@@ -566,22 +570,6 @@ def take_action(self, parsed_args):
566570 volume_kwargs [k ] = value
567571
568572 network_kwargs = {}
569- if parsed_args .force is True :
570- # Unlike compute, network doesn't provide a simple boolean option.
571- # Instead, it provides two options: 'force' and 'check_limit'
572- # (a.k.a. 'not force')
573- network_kwargs ['force' ] = True
574- elif parsed_args .force is False :
575- network_kwargs ['check_limit' ] = True
576- else :
577- msg = _ (
578- "This command currently defaults to '--force' when modifying "
579- "network quotas. This behavior will change in a future "
580- "release. Consider explicitly providing '--force' or "
581- "'--no-force' options to avoid changes in behavior."
582- )
583- self .log .warning (msg )
584-
585573 if self .app .client_manager .is_network_endpoint_enabled ():
586574 for k , v in NETWORK_QUOTAS .items ():
587575 value = getattr (parsed_args , k , None )
@@ -593,6 +581,15 @@ def take_action(self, parsed_args):
593581 if value is not None :
594582 compute_kwargs [k ] = value
595583
584+ if network_kwargs :
585+ if parsed_args .force is True :
586+ # Unlike compute, network doesn't provide a simple boolean
587+ # option. Instead, it provides two options: 'force' and
588+ # 'check_limit' (a.k.a. 'not force')
589+ network_kwargs ['force' ] = True
590+ else :
591+ network_kwargs ['check_limit' ] = True
592+
596593 if parsed_args .quota_class or parsed_args .default :
597594 if compute_kwargs :
598595 compute_client .quota_classes .update (
0 commit comments