mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
FreeBSD sysctl module now handels config_file parameter in show method
This commit is contained in:
parent
fbc87769b9
commit
da3ebf83e6
1 changed files with 24 additions and 10 deletions
|
@ -56,17 +56,31 @@ def show(config_file=False):
|
|||
)
|
||||
cmd = 'sysctl -ae'
|
||||
ret = {}
|
||||
out = __salt__['cmd.run'](cmd, output_loglevel='trace')
|
||||
comps = ['']
|
||||
for line in out.splitlines():
|
||||
if any([line.startswith('{0}.'.format(root)) for root in roots]):
|
||||
comps = line.split('=', 1)
|
||||
ret[comps[0]] = comps[1]
|
||||
elif comps[0]:
|
||||
ret[comps[0]] += '{0}\n'.format(line)
|
||||
else:
|
||||
continue
|
||||
return ret
|
||||
|
||||
if config_file:
|
||||
try:
|
||||
with salt.utils.fopen(config_file, 'r') as f:
|
||||
for line in f.readlines():
|
||||
l = line.strip()
|
||||
if l != "" and not l.startswith("#"):
|
||||
comps = line.split('=', 1)
|
||||
ret[comps[0]] = comps[1]
|
||||
return ret
|
||||
except (OSError, IOError):
|
||||
log.error('Could not open sysctl config file')
|
||||
return None
|
||||
else:
|
||||
out = __salt__['cmd.run'](cmd, output_loglevel='trace')
|
||||
for line in out.splitlines():
|
||||
if any([line.startswith('{0}.'.format(root)) for root in roots]):
|
||||
comps = line.split('=', 1)
|
||||
ret[comps[0]] = comps[1]
|
||||
elif comps[0]:
|
||||
ret[comps[0]] += '{0}\n'.format(line)
|
||||
else:
|
||||
continue
|
||||
return ret
|
||||
|
||||
|
||||
def get(name):
|
||||
|
|
Loading…
Add table
Reference in a new issue