Skip to content

Commit 4c4d081

Browse files
committed
[FWaaS] Deprecate --share and --enable options in the Unset commands
This patch deprecates options "--share", "--enable" and "--enable-rule" from the UnsetFirewall{Group,Policy,Rule} commands. Options "--no-share", "--disable", "--disable-rule" provided by the SetFirewall{Group,Policy,Rule} commands should be used instead. Change-Id: I4175df7911cb1a024df8aea99e09f2d7d28f9c65 Signed-off-by: Slawek Kaplonski <skaplons@redhat.com>
1 parent 28b470b commit 4c4d081

6 files changed

Lines changed: 68 additions & 9 deletions

File tree

openstackclient/network/v2/fwaas/group.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,11 +403,17 @@ def get_parser(self, prog_name: str) -> argparse.ArgumentParser:
403403
'--share',
404404
action='store_true',
405405
help=_(
406+
'(Deprecated) Use "firewall group set --no-share" instead. '
406407
'Restrict use of the firewall group to the current project'
407408
),
408409
)
409410
parser.add_argument(
410-
'--enable', action='store_true', help=_('Disable firewall group')
411+
'--enable',
412+
action='store_true',
413+
help=_(
414+
'(Deprecated) Use "firewall group set --disable" instead. '
415+
'Disable firewall group'
416+
),
411417
)
412418
return parser
413419

@@ -420,8 +426,16 @@ def _get_attrs(
420426
if parsed_args.egress_firewall_policy:
421427
attrs['egress_firewall_policy_id'] = None
422428
if parsed_args.share:
429+
LOG.warning(
430+
'The --share option is deprecated, please use '
431+
'"firewall group set --no-share" instead.'
432+
)
423433
attrs['shared'] = False
424434
if parsed_args.enable:
435+
LOG.warning(
436+
'The --enable option is deprecated, please use '
437+
'"firewall group set --disable" instead.'
438+
)
425439
attrs['admin_state_up'] = False
426440
if parsed_args.port:
427441
old = client.find_firewall_group(

openstackclient/network/v2/fwaas/policy.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,7 @@ def get_parser(self, prog_name: str) -> argparse.ArgumentParser:
468468
'--share',
469469
action='store_true',
470470
help=_(
471+
'(Deprecated) Use "firewall policy set --no-share" instead. '
471472
'Restrict use of the firewall policy to the current project'
472473
),
473474
)
@@ -494,6 +495,10 @@ def _get_attrs(
494495
if parsed_args.audited:
495496
attrs['audited'] = False
496497
if parsed_args.share:
498+
LOG.warning(
499+
'The --share option is deprecated, please use '
500+
'"firewall policy set --no-share" instead.'
501+
)
497502
attrs['shared'] = False
498503
return attrs
499504

openstackclient/network/v2/fwaas/rule.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -501,10 +501,18 @@ def get_parser(self, prog_name: str) -> argparse.ArgumentParser:
501501
parser.add_argument(
502502
'--share',
503503
action='store_true',
504-
help=_('Restrict use of the firewall rule to the current project'),
504+
help=_(
505+
'(Deprecated) Use "firewall rule set --no-share" instead. '
506+
'Restrict use of the firewall rule to the current project'
507+
),
505508
)
506509
parser.add_argument(
507-
'--enable-rule', action='store_true', help=_('Disable this rule')
510+
'--enable-rule',
511+
action='store_true',
512+
help=_(
513+
'(Deprecated) Use "firewall rule set --disable-rule" instead. '
514+
'Disable this rule'
515+
),
508516
)
509517

510518
parser.add_argument(
@@ -533,8 +541,16 @@ def _get_attrs(
533541
if parsed_args.destination_port:
534542
attrs['destination_port'] = None
535543
if parsed_args.share:
544+
LOG.warning(
545+
'The --share option is deprecated, please use '
546+
'"firewall rule set --no-share" instead.'
547+
)
536548
attrs['shared'] = False
537549
if parsed_args.enable_rule:
550+
LOG.warning(
551+
'The --enable-rule option is deprecated, please use '
552+
'"firewall rule set --disable-rule" instead.'
553+
)
538554
attrs['enabled'] = False
539555
if parsed_args.source_firewall_group:
540556
attrs['source_firewall_group_id'] = None

openstackclient/tests/unit/network/v2/fwaas/test_group.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,12 @@ def test_unset_shared(self):
792792
('share', True),
793793
]
794794
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
795-
result = self.cmd.take_action(parsed_args)
795+
with mock.patch.object(fwaas_group.LOG, 'warning') as mock_warning:
796+
result = self.cmd.take_action(parsed_args)
797+
mock_warning.assert_called_once_with(
798+
'The --share option is deprecated, please use '
799+
'"firewall group set --no-share" instead.'
800+
)
796801
self.mocked.assert_called_once_with(target, **{'shared': False})
797802
self.assertIsNone(result)
798803

@@ -841,7 +846,12 @@ def test_unset_enable(self):
841846
('enable', True),
842847
]
843848
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
844-
result = self.cmd.take_action(parsed_args)
849+
with mock.patch.object(fwaas_group.LOG, 'warning') as mock_warning:
850+
result = self.cmd.take_action(parsed_args)
851+
mock_warning.assert_called_once_with(
852+
'The --enable option is deprecated, please use '
853+
'"firewall group set --disable" instead.'
854+
)
845855
self.mocked.assert_called_once_with(
846856
target, **{'admin_state_up': False}
847857
)

openstackclient/tests/unit/network/v2/fwaas/test_policy.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,12 @@ def test_unset_shared(self):
781781
('share', True),
782782
]
783783
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
784-
result = self.cmd.take_action(parsed_args)
784+
with mock.patch.object(fwaas_policy.LOG, 'warning') as mock_warning:
785+
result = self.cmd.take_action(parsed_args)
786+
mock_warning.assert_called_once_with(
787+
'The --share option is deprecated, please use '
788+
'"firewall policy set --no-share" instead.'
789+
)
785790
self.mocked.assert_called_once_with(target, **{'shared': False})
786791
self.assertIsNone(result)
787792

openstackclient/tests/unit/network/v2/fwaas/test_rule.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,12 @@ def test_unset_shared(self):
798798
('share', True),
799799
]
800800
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
801-
result = self.cmd.take_action(parsed_args)
801+
with mock.patch.object(fwaas_rule.LOG, 'warning') as mock_warning:
802+
result = self.cmd.take_action(parsed_args)
803+
mock_warning.assert_called_once_with(
804+
'The --share option is deprecated, please use '
805+
'"firewall rule set --no-share" instead.'
806+
)
802807
self.mocked.assert_called_once_with(target, **{'shared': False})
803808
self.assertIsNone(result)
804809

@@ -899,8 +904,12 @@ def test_unset_enable_rule(self):
899904
('enable_rule', True),
900905
]
901906
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
902-
result = self.cmd.take_action(parsed_args)
903-
907+
with mock.patch.object(fwaas_rule.LOG, 'warning') as mock_warning:
908+
result = self.cmd.take_action(parsed_args)
909+
mock_warning.assert_called_once_with(
910+
'The --enable-rule option is deprecated, please use '
911+
'"firewall rule set --disable-rule" instead.'
912+
)
904913
self.mocked.assert_called_once_with(target, **{'enabled': False})
905914
self.assertIsNone(result)
906915

0 commit comments

Comments
 (0)