mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
Fix iptables target options with no arguments
For example: - name: test jump: CT notrack: '' ...
This commit is contained in:
parent
607169a01b
commit
914eb60d51
@ -405,7 +405,9 @@ def build_rule(table='filter', chain=None, command=None, position='', full=None,
|
||||
for after_jump_argument in after_jump_arguments:
|
||||
if after_jump_argument in kwargs:
|
||||
value = kwargs[after_jump_argument]
|
||||
if any(ws_char in str(value) for ws_char in string.whitespace):
|
||||
if value in (None, ''): # options without arguments
|
||||
after_jump.append('--{0}'.format(after_jump_argument))
|
||||
elif any(ws_char in str(value) for ws_char in string.whitespace):
|
||||
after_jump.append('--{0} "{1}"'.format(after_jump_argument, value))
|
||||
else:
|
||||
after_jump.append('--{0} {1}'.format(after_jump_argument, value))
|
||||
|
@ -128,7 +128,12 @@ class IptablesTestCase(TestCase):
|
||||
# Should allow no-arg jump options
|
||||
self.assertEqual(iptables.build_rule(jump='CLUSTERIP',
|
||||
**{'new': ''}),
|
||||
'--jump CLUSTERIP --new ')
|
||||
'--jump CLUSTERIP --new')
|
||||
|
||||
# Should allow no-arg jump options as None
|
||||
self.assertEqual(iptables.build_rule(jump='CT',
|
||||
**{'notrack': None}),
|
||||
'--jump CT --notrack')
|
||||
|
||||
# should build match-sets with single string
|
||||
self.assertEqual(iptables.build_rule(**{'match-set': 'src flag1,flag2'}),
|
||||
|
Loading…
Reference in New Issue
Block a user