facts should now not be overriten with NA option unless they are NA

this way we don't need a break per distro that matched already with
the python default functions
pull/4420/head
Brian Coca 2015-06-11 00:48:40 -04:00
parent 4098e8283e
commit f174682e19
1 changed files with 12 additions and 9 deletions

View File

@ -417,13 +417,13 @@ class Facts(object):
self.facts['distribution_version'] = self.facts['distribution_version'] + '.' + release.group(1) self.facts['distribution_version'] = self.facts['distribution_version'] + '.' + release.group(1)
elif name == 'Debian': elif name == 'Debian':
data = get_file_content(path) data = get_file_content(path)
if 'Ubuntu' in data: if 'Debian' in data or 'Raspbian' in data:
break # Ubuntu gets correct info from python functions
elif 'Debian' in data or 'Raspbian' in data:
release = re.search("PRETTY_NAME=[^(]+ \(?([^)]+?)\)", data) release = re.search("PRETTY_NAME=[^(]+ \(?([^)]+?)\)", data)
if release: if release:
self.facts['distribution_release'] = release.groups()[0] self.facts['distribution_release'] = release.groups()[0]
break break
elif 'Ubuntu' in data:
break # Ubuntu gets correct info from python functions
elif name == 'Mandriva': elif name == 'Mandriva':
data = get_file_content(path) data = get_file_content(path)
if 'Mandriva' in data: if 'Mandriva' in data:
@ -438,12 +438,15 @@ class Facts(object):
elif name == 'NA': elif name == 'NA':
data = get_file_content(path) data = get_file_content(path)
for line in data.splitlines(): for line in data.splitlines():
distribution = re.search("^NAME=(.*)", line) if self.facts['distribution'] == 'NA':
if distribution: distribution = re.search("^NAME=(.*)", line)
self.facts['distribution'] = distribution.group(1).strip('"') if distribution:
version = re.search("^VERSION=(.*)", line) self.facts['distribution'] = distribution.group(1).strip('"')
if version: if self.facts['distribution_version'] == 'NA':
self.facts['distribution_version'] = version.group(1).strip('"') version = re.search("^VERSION=(.*)", line)
if version:
self.facts['distribution_version'] = version.group(1).strip('"')
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) release = re.search("^GROUP=(.*)", data)