From 20189622fbed0b8f75d9e7efe3e16cbf44274453 Mon Sep 17 00:00:00 2001 From: Cameron Rudnick Date: Thu, 14 Nov 2013 22:30:09 -0600 Subject: [PATCH 1/2] Inverted rules are now recognized for the -A, -s, and -d parameters. --- salt/modules/iptables.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/salt/modules/iptables.py b/salt/modules/iptables.py index 6bebc8f127..84e65b49a5 100644 --- a/salt/modules/iptables.py +++ b/salt/modules/iptables.py @@ -268,6 +268,8 @@ def _parse_conf(conf_file=None, in_mem=False): parsed_args = vars(parser.parse_args(line.split())) ret_args = {} chain = parsed_args['append'] + if isinstance(chain, list): + chain = chain[0] for arg in parsed_args: if parsed_args[arg] and arg is not 'append': ret_args[arg] = parsed_args[arg] @@ -295,7 +297,7 @@ def _parser(): add_arg = parser.add_argument # COMMANDS - add_arg('-A', '--append', dest='append', action='append') + add_arg('-A', '--append', dest='append', action='append', nargs='*') add_arg('-D', '--delete', dest='delete', action='append') add_arg('-I', '--insert', dest='insert', action='append') add_arg('-R', '--replace', dest='replace', action='append') @@ -309,8 +311,8 @@ def _parser(): # PARAMETERS add_arg('-p', '--protocol', dest='protocol', action='append') - add_arg('-s', '--source', dest='source', action='append') - add_arg('-d', '--destination', dest='destination', action='append') + add_arg('-s', '--source', dest='source', action='append', nargs='*') + add_arg('-d', '--destination', dest='destination', action='append', nargs='*') add_arg('-j', '--jump', dest='jump', action='append') add_arg('-g', '--goto', dest='goto', action='append') add_arg('-i', '--in-interface', dest='in-interface', action='append') From 46977d7b40df04b9e034e454af377bbd70fbd74d Mon Sep 17 00:00:00 2001 From: Max Horlanchuk Date: Wed, 27 Nov 2013 15:28:09 +1100 Subject: [PATCH 2/2] Allow Facter to load Puppet-specific facts --- salt/modules/puppet.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/salt/modules/puppet.py b/salt/modules/puppet.py index 4900fb300b..21ff67cf68 100644 --- a/salt/modules/puppet.py +++ b/salt/modules/puppet.py @@ -166,7 +166,7 @@ def noop(*args, **kwargs): return run(*args, **kwargs) -def facts(): +def facts(puppet=False): ''' Run facter and return the results @@ -179,7 +179,8 @@ def facts(): _check_facter() ret = {} - output = __salt__['cmd.run']('facter') + opt_puppet = '--puppet' if puppet else '' + output = __salt__['cmd.run']('facter {0}'.format(opt_puppet)) # Loop over the facter output and properly # parse it into a nice dictionary for using @@ -194,7 +195,7 @@ def facts(): return ret -def fact(name): +def fact(name, puppet=False): ''' Run facter for a specific fact @@ -206,7 +207,8 @@ def fact(name): ''' _check_facter() - ret = __salt__['cmd.run']('facter {0}'.format(name)) + opt_puppet = '--puppet' if puppet else '' + ret = __salt__['cmd.run']('facter {0} {1}'.format(opt_puppet,name)) if not ret: return '' return ret