Skip to content

Commit 692b06d

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "quota: Default network quotas to not force"
2 parents 97bded1 + da7eda6 commit 692b06d

4 files changed

Lines changed: 33 additions & 28 deletions

File tree

openstackclient/common/quota.py

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import sys
2121

2222
from osc_lib.command import command
23+
from osc_lib import exceptions
2324
from osc_lib import utils
2425

2526
from 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(

openstackclient/tests/functional/common/test_quota.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def test_quota_set_default(self):
137137
def _restore_quota_limit(self, resource, limit, project):
138138
self.openstack(f'quota set --{resource} {limit} {project}')
139139

140-
def test_quota_set_network_with_no_force(self):
140+
def test_quota_set_network(self):
141141
if not self.haz_network:
142142
self.skipTest('No Network service present')
143143
if not self.is_extension_enabled('quota-check-limit'):
@@ -172,7 +172,7 @@ def test_quota_set_network_with_no_force(self):
172172
self.assertRaises(
173173
exceptions.CommandFailed,
174174
self.openstack,
175-
'quota set --networks 1 --no-force ' + self.PROJECT_NAME,
175+
'quota set --networks 1 ' + self.PROJECT_NAME,
176176
)
177177

178178
def test_quota_set_network_with_force(self):

openstackclient/tests/unit/common/test_quota.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,7 @@ def test_quota_set(self):
522522
('security_groups', compute_fakes.secgroup_num),
523523
('server_groups', compute_fakes.servgroup_num),
524524
('server_group_members', compute_fakes.servgroup_members_num),
525+
('force', False),
525526
('project', self.projects[0].name),
526527
]
527528
self.app.client_manager.network_endpoint_enabled = False
@@ -682,12 +683,14 @@ def test_quota_set_network(self):
682683
('router', network_fakes.QUOTA['router']),
683684
('rbac_policy', network_fakes.QUOTA['rbac_policy']),
684685
('port', network_fakes.QUOTA['port']),
686+
('force', False),
685687
('project', self.projects[0].name),
686688
]
687689
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
688690

689691
result = self.cmd.take_action(parsed_args)
690692
kwargs = {
693+
'check_limit': True,
691694
'subnet': network_fakes.QUOTA['subnet'],
692695
'network': network_fakes.QUOTA['network'],
693696
'floatingip': network_fakes.QUOTA['floatingip'],
@@ -948,7 +951,6 @@ def test_quota_set_with_no_force(self):
948951

949952
kwargs_compute = {
950953
'cores': compute_fakes.core_num,
951-
'force': False,
952954
}
953955
kwargs_volume = {
954956
'volumes': volume_fakes.QUOTA['volumes'],
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
upgrade:
3+
- The ``openstack quota set`` command previously defaulted to ``--force``
4+
behavior for network quotas. This behavior has now changed and the command
5+
now defaults to ``--no-force`` behavior. Users should specify the
6+
``--force`` option if they wish to retain previous behavior.

0 commit comments

Comments
 (0)