summaryrefslogtreecommitdiff
path: root/cloudinit/util.py
diff options
context:
space:
mode:
authoreb3095 <45504889+eb3095@users.noreply.github.com>2021-07-21 16:48:05 -0400
committerGitHub <noreply@github.com>2021-07-21 15:48:05 -0500
commit4257e30ac4b8730af35c078f2df0a2234dd19ffa (patch)
tree83920051229a287f584a48cc16ac349dc4538d33 /cloudinit/util.py
parentf0ab1e64852d50f4fe0de84e0bca0ee8bb516a9f (diff)
downloadvyos-cloud-init-4257e30ac4b8730af35c078f2df0a2234dd19ffa.tar.gz
vyos-cloud-init-4257e30ac4b8730af35c078f2df0a2234dd19ffa.zip
Add VZLinux support (#951)
Virtuozzo Linux is a distro based off of CentOS 8, similar to Alma Linux and Rocky Linux.
Diffstat (limited to 'cloudinit/util.py')
-rw-r--r--cloudinit/util.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/cloudinit/util.py b/cloudinit/util.py
index 7995c6c8..3bed1aed 100644
--- a/cloudinit/util.py
+++ b/cloudinit/util.py
@@ -453,9 +453,19 @@ def _parse_redhat_release(release_file=None):
redhat_regex = (
r'(?P<name>.+) release (?P<version>[\d\.]+) '
r'\((?P<codename>[^)]+)\)')
+
+ # Virtuozzo deviates here
+ if "Virtuozzo" in redhat_release:
+ redhat_regex = r'(?P<name>.+) release (?P<version>[\d\.]+)'
+
match = re.match(redhat_regex, redhat_release)
if match:
group = match.groupdict()
+
+ # Virtuozzo has no codename in this file
+ if "Virtuozzo" in group['name']:
+ group['codename'] = group['name']
+
group['name'] = group['name'].lower().partition(' linux')[0]
if group['name'] == 'red hat enterprise':
group['name'] = 'redhat'
@@ -470,9 +480,11 @@ def get_linux_distro():
distro_version = ''
flavor = ''
os_release = {}
+ os_release_rhel = False
if os.path.exists('/etc/os-release'):
os_release = load_shell_content(load_file('/etc/os-release'))
if not os_release:
+ os_release_rhel = True
os_release = _parse_redhat_release()
if os_release:
distro_name = os_release.get('ID', '')
@@ -485,6 +497,9 @@ def get_linux_distro():
flavor = platform.machine()
elif distro_name == 'photon':
flavor = os_release.get('PRETTY_NAME', '')
+ elif distro_name == 'virtuozzo' and not os_release_rhel:
+ # Only use this if the redhat file is not parsed
+ flavor = os_release.get('PRETTY_NAME', '')
else:
flavor = os_release.get('VERSION_CODENAME', '')
if not flavor:
@@ -533,7 +548,7 @@ def system_info():
linux_dist = info['dist'][0].lower()
if linux_dist in (
'almalinux', 'alpine', 'arch', 'centos', 'debian', 'fedora',
- 'photon', 'rhel', 'rocky', 'suse'):
+ 'photon', 'rhel', 'rocky', 'suse', 'virtuozzo'):
var = linux_dist
elif linux_dist in ('ubuntu', 'linuxmint', 'mint'):
var = 'ubuntu'