Clean up grain lookups from #10202

This commit is contained in:
Thomas S Hatch 2014-02-07 22:15:21 -07:00
parent e937a85fe2
commit 9e968dd297

View File

@ -122,7 +122,6 @@ def destroy(device):
except CommandExecutionError:
return False
os = __salt__['grains.items']()['os']
stop_cmd = 'mdadm --stop {0}'.format(device)
zero_cmd = 'mdadm --zero-superblock {0}'
@ -131,7 +130,7 @@ def destroy(device):
__salt__['cmd.retcode'](zero_cmd.format(number['device']))
# Remove entry from config file:
if os == 'Ubuntu' or os == 'Debian':
if __grains__.get('os_family') == 'Debian':
cfg_file = '/etc/mdadm/mdadm.conf'
else:
cfg_file = '/etc/mdadm.conf'
@ -226,7 +225,7 @@ def create(*args):
def save_config():
"""
'''
Save RAID configuration to config file.
Same as:
@ -241,12 +240,11 @@ def save_config():
salt '*' raid.save_config
"""
os = __salt__['grains.items']()['os']
'''
scan = __salt__['cmd.run']('mdadm --detail --scan').split()
# Issue with mdadm and ubuntu
# REF: http://askubuntu.com/questions/209702/why-is-my-raid-dev-md1-showing-up-as-dev-md126-is-mdadm-conf-being-ignored
if os == 'Ubuntu':
if __grains__['os'] == 'Ubuntu':
buggy_ubuntu_tags = ['name', 'metadata']
for bad_tag in buggy_ubuntu_tags:
for i, elem in enumerate(scan):
@ -254,7 +252,7 @@ def save_config():
del scan[i]
scan = ' '.join(scan)
if os == 'Ubuntu' or os == 'Debian':
if __grains__.get('os_family') == 'Debian':
cfg_file = '/etc/mdadm/mdadm.conf'
else:
cfg_file = '/etc/mdadm.conf'