diff options
author | Scott Moser <smoser@ubuntu.com> | 2018-07-20 16:59:41 +0000 |
---|---|---|
committer | Server Team CI Bot <josh.powers+server-team-bot@canonical.com> | 2018-07-20 16:59:41 +0000 |
commit | e3e05e769a11cd2cb18e71150b05873dac95c84b (patch) | |
tree | 9d82f1b9d5ac813b589c1c63c453aa6627032a9c /cloudinit/util.py | |
parent | d41cc82d11076a4f447ee13837ef2b0f7591642f (diff) | |
download | vyos-cloud-init-e3e05e769a11cd2cb18e71150b05873dac95c84b.tar.gz vyos-cloud-init-e3e05e769a11cd2cb18e71150b05873dac95c84b.zip |
get_linux_distro: add support for rhel via redhat-release.
Add examples and tests for RHEL values of redhat-release and os-release.
These examples were collected from IBMCloud images.
on rhel systems 'platform.dist()' returns 'redhat' rather than 'rhel'
so we have adjusted the response to align there.
Diffstat (limited to 'cloudinit/util.py')
-rw-r--r-- | cloudinit/util.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/cloudinit/util.py b/cloudinit/util.py index 8604db56..50680960 100644 --- a/cloudinit/util.py +++ b/cloudinit/util.py @@ -589,12 +589,15 @@ def _parse_redhat_release(release_file=None): return {} redhat_release = load_file(release_file) redhat_regex = ( - r'(?P<name>\S+) (Linux )?release (?P<version>[\d\.]+) ' + r'(?P<name>.+) release (?P<version>[\d\.]+) ' r'\((?P<codename>[^)]+)\)') match = re.match(redhat_regex, redhat_release) if match: group = match.groupdict() - return {'ID': group['name'].lower(), 'VERSION_ID': group['version'], + group['name'] = group['name'].lower().partition(' linux')[0] + if group['name'] == 'red hat enterprise': + group['name'] = 'redhat' + return {'ID': group['name'], 'VERSION_ID': group['version'], 'VERSION_CODENAME': group['codename']} return {} @@ -624,6 +627,8 @@ def get_linux_distro(): os_release.get('VERSION', '')) if match: flavor = match.groupdict()['codename'] + if distro_name == 'rhel': + distro_name = 'redhat' else: dist = ('', '', '') try: |