use .get for os_family lookups

This commit is contained in:
Thomas S Hatch 2014-02-05 09:45:55 -07:00
parent 3ca6fee030
commit e0bf4982a3
2 changed files with 4 additions and 4 deletions

View File

@ -64,7 +64,7 @@ def _get_cron_cmdstr(user, path):
Returns a platform-specific format string, to be used to build a crontab
command.
'''
if __grains__['os_family'] == 'Solaris':
if __grains__.get('os_family') == 'Solaris':
return 'su - {0} -c "crontab {1}"'.format(user, path)
else:
return 'crontab -u {0} {1}'.format(user, path)
@ -103,7 +103,7 @@ def _write_cron_lines(user, lines):
path = salt.utils.mkstemp()
with salt.utils.fopen(path, 'w+') as fp_:
fp_.writelines(lines)
if __grains__['os_family'] == 'Solaris' and user != "root":
if __grains__.get('os_family') == 'Solaris' and user != "root":
__salt__['cmd.run']('chown {0} {1}'.format(user, path))
ret = __salt__['cmd.run_all'](_get_cron_cmdstr(user, path))
os.remove(path)
@ -130,7 +130,7 @@ def raw_cron(user):
salt '*' cron.raw_cron root
'''
if __grains__['os_family'] == 'Solaris':
if __grains__.get('os_family') == 'Solaris':
cmd = 'crontab -l {0}'.format(user)
else:
cmd = 'crontab -l -u {0}'.format(user)

View File

@ -77,7 +77,7 @@ def _get_cron_info():
elif __grains__['os'] == 'OpenBSD':
group = 'crontab'
crontab_dir = '/var/spool/incron'
elif __grains__['os_family'] == 'Solaris':
elif __grains__.get('os_family') == 'Solaris':
group = 'root'
crontab_dir = '/var/spool/incron'
else: