Getting the 'os' grain from CPE_NAME inside /etc/os-release for SUSE and openSUSE

This commit is contained in:
Pablo Suarez Hernandez 2016-06-09 12:41:31 +01:00 committed by Pablo Suárez Hernández
parent 64af4d4145
commit bc671336a7

View file

@ -1265,6 +1265,11 @@ def os_data():
grains['lsb_distrib_release'] = os_release['VERSION_ID']
if 'PRETTY_NAME' in os_release:
grains['lsb_distrib_codename'] = os_release['PRETTY_NAME']
if 'CPE_NAME' in os_release:
if ":suse:" in os_release['CPE_NAME']:
grains['os'] = "SUSE"
elif ":opensuse:" in os_release['CPE_NAME']:
grains['os'] = "SUSE"
elif os.path.isfile('/etc/SuSE-release'):
grains['lsb_distrib_id'] = 'SUSE'
version = ''
@ -1372,7 +1377,8 @@ def os_data():
shortname = distroname.replace(' ', '').lower()[:10]
# this maps the long names from the /etc/DISTRO-release files to the
# traditional short names that Salt has used.
grains['os'] = _OS_NAME_MAP.get(shortname, distroname)
if 'os' not in grains:
grains['os'] = _OS_NAME_MAP.get(shortname, distroname)
grains.update(_linux_cpudata())
grains.update(_linux_gpu_data())
elif grains['kernel'] == 'SunOS':