Change the operatingsystem grain to be os, typing operatingsystem all

the time ticks me off
This commit is contained in:
Thomas S Hatch 2011-04-30 16:34:22 -06:00
parent 24352c6652
commit 69eebfbbf1
5 changed files with 29 additions and 29 deletions

View File

@ -63,7 +63,7 @@ class SaltCMD(object):
help='Instead of using shell globs to evaluate the target'\
+ ' use a grain value to identify targets, the syntax'\
+ ' for the target is the grain key followed by a pcre'\
+ ' regular expresion:\n"operatingsystem:Arch.*"')
+ ' regular expresion:\n"os:Arch.*"')
parser.add_option('-X',
'--exsel',
default=False,
@ -253,7 +253,7 @@ class SaltCP(object):
help='Instead of using shell globs to evaluate the target'\
+ ' use a grain value to identify targets, the syntax'\
+ ' for the target is the grains key followed by a pcre'\
+ ' regular expresion:\n"operatingsystem:Arch.*"')
+ ' regular expresion:\n"os:Arch.*"')
parser.add_option('-c',
'--config',
default='/etc/salt/master',

View File

@ -64,56 +64,56 @@ def os_data():
grains.update(_cpuarch())
if grains['kernel'] == 'Linux':
if os.path.isfile('/etc/arch-release'):
grains['operatingsystem'] = 'Arch'
grains['os'] = 'Arch'
elif os.path.isfile('/etc/debian_version'):
grains['operatingsystem'] = 'Debian'
grains['os'] = 'Debian'
elif os.path.isfile('/etc/gentoo-version'):
grains['operatingsystem'] = 'Gentoo'
grains['os'] = 'Gentoo'
elif os.path.isfile('/etc/fedora-version'):
grains['operatingsystem'] = 'Fedora'
grains['os'] = 'Fedora'
elif os.path.isfile('/etc/mandriva-version'):
grains['operatingsystem'] = 'Mandriva'
grains['os'] = 'Mandriva'
elif os.path.isfile('/etc/mandrake-version'):
grains['operatingsystem'] = 'Mandrake'
grains['os'] = 'Mandrake'
elif os.path.isfile('/etc/meego-version'):
grains['operatingsystem'] = 'MeeGo'
grains['os'] = 'MeeGo'
elif os.path.isfile('/etc/vmware-version'):
grains['operatingsystem'] = 'VMWareESX'
grains['os'] = 'VMWareESX'
elif os.path.isfile('/etc/bluewhite64-version'):
grains['operatingsystem'] = 'Bluewhite64'
grains['os'] = 'Bluewhite64'
elif os.path.isfile('/etc/slamd64-version'):
grains['operatingsystem'] = 'Slamd64'
grains['os'] = 'Slamd64'
elif os.path.isfile('/etc/slackware-version'):
grains['operatingsystem'] = 'Slackware'
grains['os'] = 'Slackware'
elif os.path.isfile('/etc/enterprise-release'):
if os.path.isfile('/etc/ovs-release'):
grains['operatingsystem'] = 'OVS'
grains['os'] = 'OVS'
else:
grains['operatingsystem'] = 'OEL'
grains['os'] = 'OEL'
elif os.path.isfile('/etc/redhat-release'):
data = open('/etc/redhat-release', 'r').read()
if data.count('centos'):
grains['operatingsystem'] = 'CentOS'
grains['os'] = 'CentOS'
elif data.count('scientific'):
grains['operatingsystem'] = 'Scientific'
grains['os'] = 'Scientific'
else:
grains['operatingsystem'] = 'RedHat'
grains['os'] = 'RedHat'
elif os.path.isfile('/etc/SuSE-release'):
data = open('/etc/SuSE-release', 'r').read()
if data.count('SUSE LINUX Enterprise Server'):
grains['operatingsystem'] = 'SLES'
grains['os'] = 'SLES'
elif data.count('SUSE LINUX Enterprise Desktop'):
grains['operatingsystem'] = 'SLED'
grains['os'] = 'SLED'
elif data.count('openSUSE'):
grains['operatingsystem'] = 'openSUSE'
grains['os'] = 'openSUSE'
else:
grains['operatingsystem'] = 'SUSE'
grains['os'] = 'SUSE'
elif grains['kernel'] == 'sunos':
grains['operatingsystem'] = 'Solaris'
grains['os'] = 'Solaris'
elif grains['kernel'] == 'VMkernel':
grains['operatingsystem'] = 'ESXi'
grains['os'] = 'ESXi'
else:
grains['operatingsystem'] = kernel
grains['os'] = kernel
# Load the virtual machine info

View File

@ -16,7 +16,7 @@ def item(key):
Return a singe component of the grains data
CLI Example:
salt '*' grains.item operatingsystem
salt '*' grains.item os
'''
if __grains__.has_key(key):
return __grains__[key]

View File

@ -20,7 +20,7 @@ def _map_cmd(cmd, args=[]):
'''
if args:
args = [args]
pro = grainmap[__grains__['operatingsystem']]
pro = grainmap[__grains__['os']]
return getattr(getattr(salt.modules, pro), cmd)(*args)
def list_pkgs():

View File

@ -17,7 +17,7 @@ def start(svc):
'''
Start the specified service
'''
cmd = os.path.join(grainmap[__grains__['operatingsystem']],
cmd = os.path.join(grainmap[__grains__['os']],
svc + ' start')
return not subprocess.call(cmd, shell=True)
@ -25,7 +25,7 @@ def stop(svc):
'''
Stop the specified service
'''
cmd = os.path.join(grainmap[__grains__['operatingsystem']],
cmd = os.path.join(grainmap[__grains__['os']],
svc + ' stop')
return not subprocess.call(cmd, shell=True)