mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
Add _OS_NAME_MAP entry for Arch Linux
Without an entry for 'arch' in this dict, the pkg module fails to import for Arch Linux (pacman.py). Also, I fixed a couple of open filehandles in grains/core.py.
This commit is contained in:
parent
7edc280538
commit
c529d56c50
@ -167,12 +167,13 @@ def _memdata(osdata):
|
||||
meminfo = '/proc/meminfo'
|
||||
|
||||
if os.path.isfile(meminfo):
|
||||
for line in open(meminfo, 'r').readlines():
|
||||
comps = line.split(':')
|
||||
if not len(comps) > 1:
|
||||
continue
|
||||
if comps[0].strip() == 'MemTotal':
|
||||
grains['mem_total'] = int(comps[1].split()[0]) / 1024
|
||||
with open(meminfo, 'r') as f:
|
||||
for line in f:
|
||||
comps = line.rstrip('\n').split(':')
|
||||
if not len(comps) > 1:
|
||||
continue
|
||||
if comps[0].strip() == 'MemTotal':
|
||||
grains['mem_total'] = int(comps[1].split()[0]) / 1024
|
||||
elif osdata['kernel'] in ('FreeBSD', 'OpenBSD'):
|
||||
sysctl = salt.utils.which('sysctl')
|
||||
if sysctl:
|
||||
@ -414,6 +415,7 @@ _REPLACE_LINUX_RE = re.compile(r'linux', re.IGNORECASE)
|
||||
_OS_NAME_MAP = {
|
||||
'redhatente': 'RedHat',
|
||||
'gentoobase': 'Gentoo',
|
||||
'arch': 'Arch',
|
||||
}
|
||||
|
||||
# Map the 'os' grain to the 'os_family' grain
|
||||
@ -480,19 +482,20 @@ def os_data():
|
||||
except ImportError:
|
||||
# if the python library isn't available, default to regex
|
||||
if os.path.isfile('/etc/lsb-release'):
|
||||
for line in open('/etc/lsb-release').readlines():
|
||||
# Matches any possible format:
|
||||
# DISTRIB_ID="Ubuntu"
|
||||
# DISTRIB_ID='Mageia'
|
||||
# DISTRIB_ID=Fedora
|
||||
# DISTRIB_RELEASE='10.10'
|
||||
# DISTRIB_CODENAME='squeeze'
|
||||
# DISTRIB_DESCRIPTION='Ubuntu 10.10'
|
||||
regex = re.compile('^(DISTRIB_(?:ID|RELEASE|CODENAME|DESCRIPTION))=(?:\'|")?([\w\s\.-_]+)(?:\'|")?')
|
||||
match = regex.match(line)
|
||||
if match:
|
||||
# Adds: lsb_distrib_{id,release,codename,description}
|
||||
grains['lsb_{0}'.format(match.groups()[0].lower())] = match.groups()[1].rstrip()
|
||||
with open('/etc/lsb-release') as f:
|
||||
for line in f:
|
||||
# Matches any possible format:
|
||||
# DISTRIB_ID="Ubuntu"
|
||||
# DISTRIB_ID='Mageia'
|
||||
# DISTRIB_ID=Fedora
|
||||
# DISTRIB_RELEASE='10.10'
|
||||
# DISTRIB_CODENAME='squeeze'
|
||||
# DISTRIB_DESCRIPTION='Ubuntu 10.10'
|
||||
regex = re.compile('^(DISTRIB_(?:ID|RELEASE|CODENAME|DESCRIPTION))=(?:\'|")?([\w\s\.-_]+)(?:\'|")?')
|
||||
match = regex.match(line.rstrip('\n'))
|
||||
if match:
|
||||
# Adds: lsb_distrib_{id,release,codename,description}
|
||||
grains['lsb_{0}'.format(match.groups()[0].lower())] = match.groups()[1].rstrip()
|
||||
# Use the already intelligent platform module to get distro info
|
||||
(osname, osrelease, oscodename) = platform.linux_distribution(
|
||||
supported_dists=_supported_dists)
|
||||
|
Loading…
Reference in New Issue
Block a user