fix tests for SLES and CoreOS

* include #15230
pull/15420/head
Robin Roth 9 years ago committed by Robin Roth
parent 3c883d8a6d
commit 2b104fe6ad

@ -126,8 +126,8 @@ class Facts(object):
('/etc/alpine-release', 'Alpine'), ('/etc/alpine-release', 'Alpine'),
('/etc/release', 'Solaris'), ('/etc/release', 'Solaris'),
('/etc/arch-release', 'Archlinux'), ('/etc/arch-release', 'Archlinux'),
('/etc/SuSE-release', 'SuSE'),
('/etc/os-release', 'SuSE'), ('/etc/os-release', 'SuSE'),
('/etc/SuSE-release', 'SuSE'),
('/etc/gentoo-release', 'Gentoo'), ('/etc/gentoo-release', 'Gentoo'),
('/etc/os-release', 'Debian'), ('/etc/os-release', 'Debian'),
('/etc/lsb-release', 'Mandriva'), ('/etc/lsb-release', 'Mandriva'),
@ -459,7 +459,7 @@ class Facts(object):
self.facts['distribution_release'] = release.groups()[0] self.facts['distribution_release'] = release.groups()[0]
elif 'enterprise' in data.lower() and 'VERSION_ID' in line: elif 'enterprise' in data.lower() and 'VERSION_ID' in line:
release = re.search('^VERSION_ID="?[0-9]+\.?([0-9]*)"?', line) # SLES doesn't got funny release names release = re.search('^VERSION_ID="?[0-9]+\.?([0-9]*)"?', line) # SLES doesn't got funny release names
if release.group(1): if release and release.group(1):
release = release.group(1) release = release.group(1)
else: else:
release = "0" # no minor number, so it is the first release release = "0" # no minor number, so it is the first release
@ -521,9 +521,11 @@ class Facts(object):
if self.facts['distribution'].lower() == 'coreos': if self.facts['distribution'].lower() == 'coreos':
data = get_file_content('/etc/coreos/update.conf') data = get_file_content('/etc/coreos/update.conf')
release = re.search("^GROUP=(.*)", data) if data:
if release: release = re.search("^GROUP=(.*)", data)
self.facts['distribution_release'] = release.group(1).strip('"') if release:
self.facts['distribution_release'] = release.group(1).strip('"')
else: else:
self.facts['distribution'] = name self.facts['distribution'] = name
machine_id = get_file_content("/var/lib/dbus/machine-id") or get_file_content("/etc/machine-id") machine_id = get_file_content("/var/lib/dbus/machine-id") or get_file_content("/etc/machine-id")

@ -113,9 +113,9 @@ class TestModuleUtilsFactsDistribution(unittest.TestCase):
"name": "SLES 11.3", "name": "SLES 11.3",
"input": { "input": {
"/etc/SuSE-release":""" "/etc/SuSE-release":"""
SUSE Linux Enterprise Server 11 (x86_64) SUSE Linux Enterprise Server 11 (x86_64)
VERSION = 11 VERSION = 11
PATCHLEVEL = 3 PATCHLEVEL = 3
""" """
}, },
"platform.dist": ['SuSE', '11', 'x86_64'], "platform.dist": ['SuSE', '11', 'x86_64'],
@ -130,18 +130,18 @@ class TestModuleUtilsFactsDistribution(unittest.TestCase):
"name": "SLES 11.4", "name": "SLES 11.4",
"input": { "input": {
"/etc/SuSE-release":""" "/etc/SuSE-release":"""
SUSE Linux Enterprise Server 11 (x86_64) SUSE Linux Enterprise Server 11 (x86_64)
VERSION = 11 VERSION = 11
PATCHLEVEL = 4 PATCHLEVEL = 4
""", """,
"/etc/os-release":""" "/etc/os-release":"""
NAME="SLES" NAME="SLES"
VERSION="11.4" VERSION="11.4"
VERSION_ID="11.4" VERSION_ID="11.4"
PRETTY_NAME="SUSE Linux Enterprise Server 11 SP4" PRETTY_NAME="SUSE Linux Enterprise Server 11 SP4"
ID="sles" ID="sles"
ANSI_COLOR="0;32" ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:suse:sles:11:4" CPE_NAME="cpe:/o:suse:sles:11:4"
""", """,
}, },
"platform.dist": ['SuSE', '11', 'x86_64'], "platform.dist": ['SuSE', '11', 'x86_64'],

Loading…
Cancel
Save