mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
Merge branch 'develop' of github.com:saltstack/salt into develop
This commit is contained in:
commit
ea7ef3a1ce
@ -45,6 +45,7 @@ def _kernel():
|
|||||||
grains['kernel'] = 'Unknown'
|
grains['kernel'] = 'Unknown'
|
||||||
return grains
|
return grains
|
||||||
|
|
||||||
|
|
||||||
def _windows_cpudata():
|
def _windows_cpudata():
|
||||||
'''
|
'''
|
||||||
Return the cpu information for Windows systems architecture
|
Return the cpu information for Windows systems architecture
|
||||||
@ -60,6 +61,7 @@ def _windows_cpudata():
|
|||||||
grains['cpu_model'] = platform.processor()
|
grains['cpu_model'] = platform.processor()
|
||||||
return grains
|
return grains
|
||||||
|
|
||||||
|
|
||||||
def _linux_cpudata():
|
def _linux_cpudata():
|
||||||
'''
|
'''
|
||||||
Return the cpu information for Linux systems architecture
|
Return the cpu information for Linux systems architecture
|
||||||
@ -114,8 +116,8 @@ def _freebsd_cpudata():
|
|||||||
|
|
||||||
if sysctl:
|
if sysctl:
|
||||||
machine_cmd = '{0} -n hw.machine'.format(sysctl)
|
machine_cmd = '{0} -n hw.machine'.format(sysctl)
|
||||||
ncpu_cmd = '{0} -n hw.ncpu'.format(sysctl)
|
ncpu_cmd = '{0} -n hw.ncpu'.format(sysctl)
|
||||||
model_cpu = '{0} -n hw.model'.format(sysctl)
|
model_cpu = '{0} -n hw.model'.format(sysctl)
|
||||||
grains['num_cpus'] = __salt__['cmd.run'](ncpu_cmd).strip()
|
grains['num_cpus'] = __salt__['cmd.run'](ncpu_cmd).strip()
|
||||||
grains['cpu_model'] = __salt__['cmd.run'](model_cpu).strip()
|
grains['cpu_model'] = __salt__['cmd.run'](model_cpu).strip()
|
||||||
grains['cpuarch'] = __salt__['cmd.run'](machine_cmd).strip()
|
grains['cpuarch'] = __salt__['cmd.run'](machine_cmd).strip()
|
||||||
@ -140,20 +142,20 @@ def _memdata(osdata):
|
|||||||
continue
|
continue
|
||||||
if comps[0].strip() == 'MemTotal':
|
if comps[0].strip() == 'MemTotal':
|
||||||
grains['mem_total'] = int(comps[1].split()[0]) / 1024
|
grains['mem_total'] = int(comps[1].split()[0]) / 1024
|
||||||
elif osdata['kernel'] in ('FreeBSD','OpenBSD'):
|
elif osdata['kernel'] in ('FreeBSD', 'OpenBSD'):
|
||||||
sysctl = salt.utils.which('sysctl')
|
sysctl = salt.utils.which('sysctl')
|
||||||
if sysctl:
|
if sysctl:
|
||||||
mem = __salt__['cmd.run']('{0} -n hw.physmem'.format(sysctl)).strip()
|
mem = __salt__['cmd.run']('{0} -n hw.physmem'.format(sysctl)).strip()
|
||||||
grains['mem_total'] = str(int(mem) / 1024 / 1024)
|
grains['mem_total'] = str(int(mem) / 1024 / 1024)
|
||||||
elif osdata['kernel'] == 'Windows':
|
elif osdata['kernel'] == 'Windows':
|
||||||
for line in __salt__['cmd.run']('SYSTEMINFO /FO LIST').split('\n'):
|
for line in __salt__['cmd.run']('SYSTEMINFO /FO LIST').split('\n'):
|
||||||
comps = line.split(':')
|
comps = line.split(':')
|
||||||
if not len(comps) > 1:
|
if not len(comps) > 1:
|
||||||
continue
|
continue
|
||||||
if comps[0].strip() == 'Total Physical Memory':
|
if comps[0].strip() == 'Total Physical Memory':
|
||||||
grains['mem_total'] = int(comps[1].split()[0].replace(',', ''))
|
# Windows XP use '.' as separator and Windows 2008 Server R2 use ','
|
||||||
break
|
grains['mem_total'] = int(comps[1].split()[0].replace('.', '').replace(',', ''))
|
||||||
|
break
|
||||||
return grains
|
return grains
|
||||||
|
|
||||||
|
|
||||||
@ -194,7 +196,7 @@ def _virtual(osdata):
|
|||||||
grains['virtual'] = 'VirtualBox'
|
grains['virtual'] = 'VirtualBox'
|
||||||
elif 'qemu' in model:
|
elif 'qemu' in model:
|
||||||
grains['virtual'] = 'kvm'
|
grains['virtual'] = 'kvm'
|
||||||
choices = ('Linux', 'OpenBSD', 'SunOS', 'HP-UX')
|
choices = ('Linux', 'OpenBSD', 'SunOS', 'HP-UX')
|
||||||
isdir = os.path.isdir
|
isdir = os.path.isdir
|
||||||
if osdata['kernel'] in choices:
|
if osdata['kernel'] in choices:
|
||||||
if isdir('/proc/vz'):
|
if isdir('/proc/vz'):
|
||||||
@ -246,7 +248,7 @@ def _virtual(osdata):
|
|||||||
grains['virtual'] = 'VMware'
|
grains['virtual'] = 'VMware'
|
||||||
if sysctl:
|
if sysctl:
|
||||||
model = __salt__['cmd.run']('{0} hw.model'.format(sysctl)).strip()
|
model = __salt__['cmd.run']('{0} hw.model'.format(sysctl)).strip()
|
||||||
jail = __salt__['cmd.run']('{0} -n security.jail.jailed'.format(sysctl)).strip()
|
jail = __salt__['cmd.run']('{0} -n security.jail.jailed'.format(sysctl)).strip()
|
||||||
if jail:
|
if jail:
|
||||||
grains['virtual_subtype'] = 'jail'
|
grains['virtual_subtype'] = 'jail'
|
||||||
if 'QEMU Virtual CPU' in model:
|
if 'QEMU Virtual CPU' in model:
|
||||||
@ -289,6 +291,7 @@ def _linux_platform_data(osdata):
|
|||||||
grains['oscodename'] = oscodename
|
grains['oscodename'] = oscodename
|
||||||
return grains
|
return grains
|
||||||
|
|
||||||
|
|
||||||
def _windows_platform_data(osdata):
|
def _windows_platform_data(osdata):
|
||||||
'''
|
'''
|
||||||
Use the platform module for as much as we can.
|
Use the platform module for as much as we can.
|
||||||
@ -510,6 +513,7 @@ def path():
|
|||||||
# path
|
# path
|
||||||
return {'path': os.environ['PATH'].strip()}
|
return {'path': os.environ['PATH'].strip()}
|
||||||
|
|
||||||
|
|
||||||
def pythonversion():
|
def pythonversion():
|
||||||
'''
|
'''
|
||||||
Return the Python version
|
Return the Python version
|
||||||
@ -518,6 +522,7 @@ def pythonversion():
|
|||||||
# pythonversion
|
# pythonversion
|
||||||
return {'pythonversion': list(sys.version_info)}
|
return {'pythonversion': list(sys.version_info)}
|
||||||
|
|
||||||
|
|
||||||
def pythonpath():
|
def pythonpath():
|
||||||
'''
|
'''
|
||||||
Return the Python path
|
Return the Python path
|
||||||
@ -526,6 +531,7 @@ def pythonpath():
|
|||||||
# pythonpath
|
# pythonpath
|
||||||
return {'pythonpath': sys.path}
|
return {'pythonpath': sys.path}
|
||||||
|
|
||||||
|
|
||||||
def saltpath():
|
def saltpath():
|
||||||
'''
|
'''
|
||||||
Return the path of the salt module
|
Return the path of the salt module
|
||||||
@ -535,6 +541,7 @@ def saltpath():
|
|||||||
path = os.path.abspath(os.path.join(__file__, os.path.pardir))
|
path = os.path.abspath(os.path.join(__file__, os.path.pardir))
|
||||||
return {'saltpath': os.path.dirname(path)}
|
return {'saltpath': os.path.dirname(path)}
|
||||||
|
|
||||||
|
|
||||||
def saltversion():
|
def saltversion():
|
||||||
'''
|
'''
|
||||||
Return the version of salt
|
Return the version of salt
|
||||||
@ -544,6 +551,7 @@ def saltversion():
|
|||||||
from salt import __version__
|
from salt import __version__
|
||||||
return {'saltversion': __version__}
|
return {'saltversion': __version__}
|
||||||
|
|
||||||
|
|
||||||
# Relatively complex mini-algorithm to iterate over the various
|
# Relatively complex mini-algorithm to iterate over the various
|
||||||
# sections of dmidecode output and return matches for specific
|
# sections of dmidecode output and return matches for specific
|
||||||
# lines containing data we want, but only in the right section.
|
# lines containing data we want, but only in the right section.
|
||||||
@ -567,7 +575,8 @@ def _dmidecode_data(regex_dict):
|
|||||||
|
|
||||||
# Look at every line for the right section
|
# Look at every line for the right section
|
||||||
for line in out.split('\n'):
|
for line in out.split('\n'):
|
||||||
if not line: continue
|
if not line:
|
||||||
|
continue
|
||||||
# We've found it, woohoo!
|
# We've found it, woohoo!
|
||||||
if re.match(section, line):
|
if re.match(section, line):
|
||||||
section_found = True
|
section_found = True
|
||||||
@ -584,7 +593,8 @@ def _dmidecode_data(regex_dict):
|
|||||||
grain = regex_dict[section][item]
|
grain = regex_dict[section][item]
|
||||||
# Skip to the next iteration if this grain
|
# Skip to the next iteration if this grain
|
||||||
# has been found in the dmidecode output.
|
# has been found in the dmidecode output.
|
||||||
if grain in ret: continue
|
if grain in ret:
|
||||||
|
continue
|
||||||
|
|
||||||
match = regex.match(line)
|
match = regex.match(line)
|
||||||
|
|
||||||
@ -633,6 +643,7 @@ def _hw_data(osdata):
|
|||||||
grains['productname'] = __salt__['cmd.run']('{0} smbios.system.product'.format(kenv)).strip()
|
grains['productname'] = __salt__['cmd.run']('{0} smbios.system.product'.format(kenv)).strip()
|
||||||
return grains
|
return grains
|
||||||
|
|
||||||
|
|
||||||
def get_server_id():
|
def get_server_id():
|
||||||
'''
|
'''
|
||||||
Provides an integer based on the FQDN of a machine.
|
Provides an integer based on the FQDN of a machine.
|
||||||
@ -640,4 +651,4 @@ def get_server_id():
|
|||||||
'''
|
'''
|
||||||
# Provides:
|
# Provides:
|
||||||
# server_id
|
# server_id
|
||||||
return { 'server_id': abs(hash(__opts__['id']) % 2**31) }
|
return {'server_id': abs(hash(__opts__['id']) % (2 ** 31))}
|
||||||
|
Loading…
Reference in New Issue
Block a user