

def add_rule(name, localport, protocol='tcp', action='allow', dir='in'):
    "\n    .. versionadded:: 2015.5.0\n\n    Add a new firewall rule\n\n    CLI Example:\n\n    .. code-block:: bash\n\n        salt '*' firewall.add_rule 'test' '8080' 'tcp'\n        salt '*' firewall.add_rule 'test' '1' 'icmpv4'\n\n    "
    cmd = ['netsh', 'advfirewall', 'firewall', 'add', 'rule', 'name={0}'.format(name), 'protocol={0}'.format(protocol), 'dir={0}'.format(dir), 'action={0}'.format(action)]
    if (('icmpv4' not in protocol) and ('icmpv6' not in protocol)):
        cmd.append('localport={0}'.format(localport))
    ret = __salt__['cmd.run'](cmd, python_shell=False)
    if isinstance(ret, six.string_types):
        return (ret.strip() == 'Ok.')
    else:
        log.error('firewall.add_rule failed: {0}'.format(cmd))
        return False

dataset/ETHPy150Open saltstack/salt/salt/modules/win_firewall.py add_rule/VarMisuse@150/330 `ret`->`cmd`