Skip to content

Commit

Permalink
Merge pull request #25252 from jfindlay/win_fire
Browse files Browse the repository at this point in the history
make args optional with default values in win_firewall.delete_rule
  • Loading branch information
thatch45 committed Jul 10, 2015
2 parents cd405b4 + bba556c commit a2860cb
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions salt/modules/win_firewall.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def enable(profile='allprofiles'):
return __salt__['cmd.run'](cmd, python_shell=False) == 'Ok.'


def get_rule(name="all"):
def get_rule(name='all'):
'''
.. versionadded:: 2015.5.0
Expand All @@ -89,19 +89,19 @@ def get_rule(name="all"):
.. code-block:: bash
salt '*' firewall.get_rule "MyAppPort"
salt '*' firewall.get_rule 'MyAppPort'
'''
ret = {}
cmd = ['netsh', 'advfirewall', 'firewall', 'show', 'rule', 'name={0}'.format(name)]
ret[name] = __salt__['cmd.run'](cmd, python_shell=False)

if ret[name].strip() == "No rules match the specified criteria.":
if ret[name].strip() == 'No rules match the specified criteria.':
ret = False

return ret


def add_rule(name, localport, protocol="tcp", action="allow", dir="in"):
def add_rule(name, localport, protocol='tcp', action='allow', dir='in'):
'''
.. versionadded:: 2015.5.0
Expand All @@ -111,7 +111,7 @@ def add_rule(name, localport, protocol="tcp", action="allow", dir="in"):
.. code-block:: bash
salt '*' firewall.add_rule "test" "8080" "tcp"
salt '*' firewall.add_rule 'test' '8080' 'tcp'
'''
cmd = ['netsh', 'advfirewall', 'firewall', 'add', 'rule',
'name={0}'.format(name),
Expand All @@ -122,15 +122,15 @@ def add_rule(name, localport, protocol="tcp", action="allow", dir="in"):
return __salt__['cmd.run'](cmd, python_shell=False) == 'Ok.'


def delete_rule(name, localport, protocol, dir):
def delete_rule(name, localport, protocol='tcp', dir='in'):
'''
Delete an existing firewall rule
CLI Example:
.. code-block:: bash
salt '*' firewall.delete_rule "test" "8080" "tcp" "in"
salt '*' firewall.delete_rule 'test' '8080' 'tcp' 'in'
'''
cmd = ['netsh', 'advfirewall', 'firewall', 'delete', 'rule',
'name={0}'.format(name),
Expand Down

0 comments on commit a2860cb

Please sign in to comment.