diff options
Diffstat (limited to 'cloudinit/util.py')
-rw-r--r-- | cloudinit/util.py | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/cloudinit/util.py b/cloudinit/util.py index 575a1fef..2045a6ab 100644 --- a/cloudinit/util.py +++ b/cloudinit/util.py @@ -533,42 +533,45 @@ def get_linux_distro(): return (distro_name, distro_version, flavor) -@lru_cache() -def system_info(): - info = { - 'platform': platform.platform(), - 'system': platform.system(), - 'release': platform.release(), - 'python': platform.python_version(), - 'uname': list(platform.uname()), - 'dist': get_linux_distro() - } +def _get_variant(info): system = info['system'].lower() - var = 'unknown' + variant = 'unknown' if system == "linux": linux_dist = info['dist'][0].lower() if linux_dist in ( 'almalinux', 'alpine', 'arch', 'centos', 'cloudlinux', - 'debian', 'eurolinux', 'fedora', 'openEuler', 'photon', + 'debian', 'eurolinux', 'fedora', 'openeuler', 'photon', 'rhel', 'rocky', 'suse', 'virtuozzo'): - var = linux_dist + variant = linux_dist elif linux_dist in ('ubuntu', 'linuxmint', 'mint'): - var = 'ubuntu' + variant = 'ubuntu' elif linux_dist == 'redhat': - var = 'rhel' + variant = 'rhel' elif linux_dist in ( 'opensuse', 'opensuse-tumbleweed', 'opensuse-leap', 'sles', 'sle_hpc'): - var = 'suse' + variant = 'suse' else: - var = 'linux' + variant = 'linux' elif system in ( 'windows', 'darwin', "freebsd", "netbsd", "openbsd", "dragonfly"): - var = system + variant = system + + return variant - info['variant'] = var +@lru_cache() +def system_info(): + info = { + 'platform': platform.platform(), + 'system': platform.system(), + 'release': platform.release(), + 'python': platform.python_version(), + 'uname': list(platform.uname()), + 'dist': get_linux_distro() + } + info['variant'] = _get_variant(info) return info |