From 8c02be94674637fa8f883f1bbd49be70ccada6a6 Mon Sep 17 00:00:00 2001 From: Marcus Furlong Date: Fri, 6 Feb 2026 16:30:27 -0500 Subject: [PATCH] fix osrelease from rocky/alma/epel errata --- errata/sources/distros/alma.py | 4 +- errata/sources/distros/centos.py | 3 +- errata/sources/repos/yum.py | 36 ++++-- operatingsystems/tests/test_models.py | 144 ++++++++++++++++++++++ operatingsystems/utils.py | 33 ++++++ reports/tests/test_utils.py | 164 ++++++++++++++++++++++++++ reports/utils.py | 14 +-- 7 files changed, 380 insertions(+), 18 deletions(-) diff --git a/errata/sources/distros/alma.py b/errata/sources/distros/alma.py index 0091b8bf..d9e1dbf9 100644 --- a/errata/sources/distros/alma.py +++ b/errata/sources/distros/alma.py @@ -110,7 +110,9 @@ def process_alma_erratum(release, advisory): def add_alma_erratum_osreleases(e, release): """ Update OS Release for Alma Linux errata """ - osrelease = get_or_create_osrelease(name=f'Alma Linux {release}') + from operatingsystems.utils import normalize_el_osrelease + osrelease_name = normalize_el_osrelease(f'Alma Linux {release}') + osrelease = get_or_create_osrelease(name=osrelease_name) e.osreleases.add(osrelease) diff --git a/errata/sources/distros/centos.py b/errata/sources/distros/centos.py index 8f4aa4a1..d81453de 100644 --- a/errata/sources/distros/centos.py +++ b/errata/sources/distros/centos.py @@ -117,13 +117,14 @@ def add_centos_erratum_references(e, references): def parse_centos_errata_children(e, children): """ Parse errata children to obtain architecture, release and packages """ + from operatingsystems.utils import normalize_el_osrelease fixed_packages = set() for c in children: if c.tag == 'os_arch': pass elif c.tag == 'os_release': if accepted_centos_release([c.text]): - osrelease_name = f'CentOS {c.text}' + osrelease_name = normalize_el_osrelease(f'CentOS {c.text}') osrelease = get_or_create_osrelease(name=osrelease_name) e.osreleases.add(osrelease) elif c.tag == 'packages': diff --git a/errata/sources/repos/yum.py b/errata/sources/repos/yum.py index 8b6732c4..992830c4 100644 --- a/errata/sources/repos/yum.py +++ b/errata/sources/repos/yum.py @@ -20,7 +20,9 @@ from defusedxml import ElementTree from django.db import connections -from operatingsystems.utils import get_or_create_osrelease +from operatingsystems.utils import ( + get_or_create_osrelease, normalize_el_osrelease, +) from packages.models import Package from packages.utils import get_or_create_package from patchman.signals import pbar_start, pbar_update @@ -184,9 +186,25 @@ def get_osrelease_names(e, update): return osreleases +def get_existing_el_osreleases(major_version): + """ Returns existing OSReleases for EL-based distros matching the major version + """ + from operatingsystems.models import OSRelease + el_patterns = [ + f'Red Hat Enterprise Linux {major_version}', + f'CentOS Stream {major_version}', + f'CentOS {major_version}', + f'Rocky Linux {major_version}', + f'Alma Linux {major_version}', + f'Oracle Linux {major_version}', + ] + return list(OSRelease.objects.filter(name__in=el_patterns)) + + def add_updateinfo_osreleases(e, collection, osrelease_names): """ Adds OSRelease objects to an Erratum rocky and alma need some renaming + EPEL maps to existing EL-based OSReleases only """ if not osrelease_names: collection_name = collection.find('name') @@ -194,14 +212,14 @@ def add_updateinfo_osreleases(e, collection, osrelease_names): osrelease_name = collection_name.text osrelease_names.append(osrelease_name) for osrelease_name in osrelease_names: - if osrelease_name.startswith('almalinux'): - version = osrelease_name.split('-')[1] - osrelease_name = 'Alma Linux ' + version - elif osrelease_name.startswith('rocky-linux'): - version = osrelease_name.split('-')[2] - osrelease_name = 'Rocky Linux ' + version - elif osrelease_name in ['Amazon Linux', 'Amazon Linux AMI']: - osrelease_name = 'Amazon Linux 1' + if osrelease_name.startswith('Fedora EPEL'): + # "Fedora EPEL 10.0" → map to existing EL 10 OSReleases + version_str = osrelease_name.split()[-1] # "10.0" + major_version = version_str.split('.')[0] # "10" + for osrelease in get_existing_el_osreleases(major_version): + e.osreleases.add(osrelease) + continue + osrelease_name = normalize_el_osrelease(osrelease_name) osrelease = get_or_create_osrelease(name=osrelease_name) e.osreleases.add(osrelease) diff --git a/operatingsystems/tests/test_models.py b/operatingsystems/tests/test_models.py index bec9e1fa..64192c19 100644 --- a/operatingsystems/tests/test_models.py +++ b/operatingsystems/tests/test_models.py @@ -17,6 +17,150 @@ from django.test import TestCase, override_settings from operatingsystems.models import OSRelease, OSVariant +from operatingsystems.utils import normalize_el_osrelease + + +@override_settings( + CELERY_TASK_ALWAYS_EAGER=True, + CACHES={'default': {'BACKEND': 'django.core.cache.backends.locmem.LocMemCache'}} +) +class NormalizeELOSReleaseTests(TestCase): + """Tests for normalize_el_osrelease() function. + + This function normalizes EL-based distro names to major version only, + ensuring consistent OSRelease naming across errata and reports. + + Regression notes - OLD behavior that caused duplicate OSReleases: + - 'rocky-linux-10.1' -> 'Rocky Linux 10.1' (should be 'Rocky Linux 10') + - 'almalinux-10.1' -> 'Alma Linux 10.1' (should be 'Alma Linux 10') + - 'Rocky Linux 10.1' -> passed through unchanged (should be 'Rocky Linux 10') + - 'CentOS 7.9' -> passed through unchanged (should be 'CentOS 7') + """ + + # =========================================== + # REGRESSION TESTS - These were bugs before + # =========================================== + + def test_regression_rocky_dash_format_minor_stripped(self): + """REGRESSION: rocky-linux-10.1 was creating 'Rocky Linux 10.1' + + Old behavior: version = osrelease_name.split('-')[2] -> '10.1' + result = 'Rocky Linux 10.1' + New behavior: major_version = '10.1'.split('.')[0] -> '10' + result = 'Rocky Linux 10' + """ + # OLD (wrong): 'Rocky Linux 10.1' + # NEW (correct): 'Rocky Linux 10' + self.assertEqual(normalize_el_osrelease('rocky-linux-10.1'), 'Rocky Linux 10') + self.assertNotEqual(normalize_el_osrelease('rocky-linux-10.1'), 'Rocky Linux 10.1') + + def test_regression_alma_dash_format_minor_stripped(self): + """REGRESSION: almalinux-10.1 was creating 'Alma Linux 10.1' + + Old behavior: version = osrelease_name.split('-')[1] -> '10.1' + result = 'Alma Linux 10.1' + New behavior: major_version = '10.1'.split('.')[0] -> '10' + result = 'Alma Linux 10' + """ + # OLD (wrong): 'Alma Linux 10.1' + # NEW (correct): 'Alma Linux 10' + self.assertEqual(normalize_el_osrelease('almalinux-10.1'), 'Alma Linux 10') + self.assertNotEqual(normalize_el_osrelease('almalinux-10.1'), 'Alma Linux 10.1') + + def test_regression_rocky_human_format_minor_stripped(self): + """REGRESSION: 'Rocky Linux 10.1' was passed through unchanged + + Old behavior: no handling, passed through as 'Rocky Linux 10.1' + New behavior: normalized to 'Rocky Linux 10' + """ + # OLD (wrong): 'Rocky Linux 10.1' + # NEW (correct): 'Rocky Linux 10' + self.assertEqual(normalize_el_osrelease('Rocky Linux 10.1'), 'Rocky Linux 10') + self.assertNotEqual(normalize_el_osrelease('Rocky Linux 10.1'), 'Rocky Linux 10.1') + + def test_regression_centos_minor_stripped(self): + """REGRESSION: 'CentOS 7.9' was passed through unchanged + + Old behavior: no handling for human-readable format + New behavior: normalized to 'CentOS 7' + """ + # OLD (wrong): 'CentOS 7.9' + # NEW (correct): 'CentOS 7' + self.assertEqual(normalize_el_osrelease('CentOS 7.9'), 'CentOS 7') + self.assertNotEqual(normalize_el_osrelease('CentOS 7.9'), 'CentOS 7.9') + + # =========================================== + # STANDARD TESTS - Expected behavior + # =========================================== + + def test_rocky_linux_with_minor_version(self): + """Test Rocky Linux X.Y -> Rocky Linux X""" + self.assertEqual(normalize_el_osrelease('Rocky Linux 10.1'), 'Rocky Linux 10') + self.assertEqual(normalize_el_osrelease('Rocky Linux 9.3'), 'Rocky Linux 9') + + def test_rocky_linux_dash_format(self): + """Test rocky-linux-X.Y -> Rocky Linux X""" + self.assertEqual(normalize_el_osrelease('rocky-linux-10.1'), 'Rocky Linux 10') + self.assertEqual(normalize_el_osrelease('rocky-linux-9.3'), 'Rocky Linux 9') + + def test_alma_linux_with_minor_version(self): + """Test Alma Linux X.Y -> Alma Linux X""" + self.assertEqual(normalize_el_osrelease('Alma Linux 10.1'), 'Alma Linux 10') + self.assertEqual(normalize_el_osrelease('Alma Linux 9.3'), 'Alma Linux 9') + + def test_almalinux_dash_format(self): + """Test almalinux-X.Y -> Alma Linux X""" + self.assertEqual(normalize_el_osrelease('almalinux-10.1'), 'Alma Linux 10') + self.assertEqual(normalize_el_osrelease('almalinux-9.3'), 'Alma Linux 9') + + def test_almalinux_no_space(self): + """Test AlmaLinux X.Y -> AlmaLinux X""" + self.assertEqual(normalize_el_osrelease('AlmaLinux 10.1'), 'AlmaLinux 10') + + def test_centos_with_minor_version(self): + """Test CentOS X.Y -> CentOS X""" + self.assertEqual(normalize_el_osrelease('CentOS 7.9'), 'CentOS 7') + self.assertEqual(normalize_el_osrelease('CentOS 8.5'), 'CentOS 8') + + def test_rhel_with_minor_version(self): + """Test RHEL X.Y -> RHEL X""" + self.assertEqual(normalize_el_osrelease('RHEL 8.2'), 'RHEL 8') + self.assertEqual(normalize_el_osrelease('RHEL 9.1'), 'RHEL 9') + + def test_red_hat_enterprise_linux_with_minor_version(self): + """Test Red Hat Enterprise Linux X.Y -> Red Hat Enterprise Linux X""" + self.assertEqual( + normalize_el_osrelease('Red Hat Enterprise Linux 8.2'), + 'Red Hat Enterprise Linux 8' + ) + + def test_oracle_linux_with_minor_version(self): + """Test Oracle Linux X.Y -> Oracle Linux X""" + self.assertEqual(normalize_el_osrelease('Oracle Linux 8.1'), 'Oracle Linux 8') + + def test_amazon_linux_normalization(self): + """Test Amazon Linux -> Amazon Linux 1""" + self.assertEqual(normalize_el_osrelease('Amazon Linux'), 'Amazon Linux 1') + self.assertEqual(normalize_el_osrelease('Amazon Linux AMI'), 'Amazon Linux 1') + + # =========================================== + # NO-OP TESTS - Should remain unchanged + # =========================================== + + def test_major_version_only_unchanged(self): + """Test that major-version-only names are unchanged (no regression)""" + self.assertEqual(normalize_el_osrelease('Rocky Linux 10'), 'Rocky Linux 10') + self.assertEqual(normalize_el_osrelease('CentOS 7'), 'CentOS 7') + self.assertEqual(normalize_el_osrelease('RHEL 9'), 'RHEL 9') + self.assertEqual(normalize_el_osrelease('Alma Linux 9'), 'Alma Linux 9') + + def test_non_el_distros_unchanged(self): + """Test that non-EL distros are unchanged (no false positives)""" + self.assertEqual(normalize_el_osrelease('Ubuntu 22.04'), 'Ubuntu 22.04') + self.assertEqual(normalize_el_osrelease('Debian 12'), 'Debian 12') + self.assertEqual(normalize_el_osrelease('Fedora 39'), 'Fedora 39') + self.assertEqual(normalize_el_osrelease('Arch Linux'), 'Arch Linux') + self.assertEqual(normalize_el_osrelease('openSUSE Leap 15.5'), 'openSUSE Leap 15.5') @override_settings( diff --git a/operatingsystems/utils.py b/operatingsystems/utils.py index c66182be..2544117f 100644 --- a/operatingsystems/utils.py +++ b/operatingsystems/utils.py @@ -17,6 +17,39 @@ from django.db import IntegrityError +def normalize_el_osrelease(osrelease_name): + """Normalize EL-based distros to major version only. + e.g. 'Rocky Linux 10.1' -> 'Rocky Linux 10' + 'rocky-linux-10.1' -> 'Rocky Linux 10' + 'almalinux-10.1' -> 'Alma Linux 10' + """ + if osrelease_name.startswith('rocky-linux-'): + major_version = osrelease_name.split('-')[2].split('.')[0] + return f'Rocky Linux {major_version}' + elif osrelease_name.startswith('almalinux-'): + major_version = osrelease_name.split('-')[1].split('.')[0] + return f'Alma Linux {major_version}' + elif osrelease_name in ['Amazon Linux', 'Amazon Linux AMI']: + return 'Amazon Linux 1' + + el_distro_prefixes = [ + 'Rocky Linux', + 'Alma Linux', + 'AlmaLinux', + 'CentOS', + 'RHEL', + 'Red Hat Enterprise Linux', + 'Oracle Linux', + ] + for prefix in el_distro_prefixes: + if osrelease_name.startswith(prefix): + version_part = osrelease_name[len(prefix):].strip() + if '.' in version_part: + major_version = version_part.split('.')[0] + return f'{prefix} {major_version}' + return osrelease_name + + def get_or_create_osrelease(name, cpe_name=None, codename=None): """ Get or create OSRelease from OS details """ diff --git a/reports/tests/test_utils.py b/reports/tests/test_utils.py index f640d642..b139669b 100644 --- a/reports/tests/test_utils.py +++ b/reports/tests/test_utils.py @@ -537,3 +537,167 @@ def test_report_process_creates_osvariant(self): host = Host.objects.get(hostname='oshost.example.com') self.assertIsNotNone(host.osvariant) self.assertIn('Rocky', host.osvariant.name) + + +@override_settings( + CELERY_TASK_ALWAYS_EAGER=True, + CACHES={'default': {'BACKEND': 'django.core.cache.backends.locmem.LocMemCache'}} +) +class GetOSTests(TestCase): + """Tests for get_os() function - ensures osrelease/osvariant are created correctly. + + REGRESSION NOTES: + Old behavior used .split('.')[0] to extract major version: + osrelease_name = osvariant_name.split('.')[0] + + This works for most cases but the new normalize_el_osrelease() is more explicit. + These tests ensure we don't regress the reports behavior. + """ + + def setUp(self): + """Create test architecture.""" + self.arch = MachineArchitecture.objects.create(name='x86_64') + + def test_rocky_linux_osrelease_major_only(self): + """Test Rocky Linux 10.1 creates OSRelease 'Rocky Linux 10' + + OLD: 'Rocky Linux 10.1'.split('.')[0] = 'Rocky Linux 10' ✓ + NEW: normalize_el_osrelease('Rocky Linux 10.1') = 'Rocky Linux 10' ✓ + """ + from reports.utils import get_os + osvariant = get_os('Rocky Linux 10.1', self.arch) + self.assertEqual(osvariant.name, 'Rocky Linux 10.1') + self.assertEqual(osvariant.osrelease.name, 'Rocky Linux 10') + + def test_alma_linux_osrelease_major_only(self): + """Test AlmaLinux 9.3 creates OSRelease 'Alma Linux 9' + + OLD: 'Alma Linux 9.3'.split('.')[0] = 'Alma Linux 9' ✓ + NEW: normalize_el_osrelease('Alma Linux 9.3') = 'Alma Linux 9' ✓ + """ + from reports.utils import get_os + osvariant = get_os('AlmaLinux 9.3', self.arch) + self.assertEqual(osvariant.name, 'Alma Linux 9.3') + self.assertEqual(osvariant.osrelease.name, 'Alma Linux 9') + + def test_centos_osrelease_major_only(self): + """Test CentOS 7.9 creates OSRelease 'CentOS 7' + + OLD: 'CentOS 7.9'.split('.')[0] = 'CentOS 7' ✓ + NEW: normalize_el_osrelease('CentOS 7.9') = 'CentOS 7' ✓ + """ + from reports.utils import get_os + osvariant = get_os('CentOS 7.9', self.arch) + self.assertEqual(osvariant.name, 'CentOS 7.9') + self.assertEqual(osvariant.osrelease.name, 'CentOS 7') + + def test_centos_release_keyword_stripped(self): + """Test 'CentOS release 7.9' strips 'release' from osvariant""" + from reports.utils import get_os + osvariant = get_os('CentOS release 7.9', self.arch) + self.assertEqual(osvariant.name, 'CentOS 7.9') + self.assertEqual(osvariant.osrelease.name, 'CentOS 7') + + def test_rhel_osrelease_major_only(self): + """Test Red Hat Enterprise Linux 8.2 creates OSRelease major only + + OLD: 'Red Hat Enterprise Linux 8.2'.split('.')[0] = 'Red Hat Enterprise Linux 8' ✓ + NEW: normalize_el_osrelease('Red Hat Enterprise Linux 8.2') = 'Red Hat Enterprise Linux 8' ✓ + """ + from reports.utils import get_os + osvariant = get_os('Red Hat Enterprise Linux 8.2', self.arch) + self.assertEqual(osvariant.name, 'Red Hat Enterprise Linux 8.2') + self.assertEqual(osvariant.osrelease.name, 'Red Hat Enterprise Linux 8') + + def test_rhel_release_keyword_stripped(self): + """Test 'Red Hat Enterprise Linux release 8.2' strips 'release'""" + from reports.utils import get_os + osvariant = get_os('Red Hat Enterprise Linux release 8.2', self.arch) + self.assertEqual(osvariant.name, 'Red Hat Enterprise Linux 8.2') + self.assertEqual(osvariant.osrelease.name, 'Red Hat Enterprise Linux 8') + + def test_oracle_linux_osrelease_major_only(self): + """Test Oracle Linux Server 8.1 creates OSRelease 'Oracle Linux 8'""" + from reports.utils import get_os + osvariant = get_os('Oracle Linux Server 8.1', self.arch) + self.assertEqual(osvariant.name, 'Oracle Linux 8.1') + self.assertEqual(osvariant.osrelease.name, 'Oracle Linux 8') + + def test_fedora_osrelease_major_only(self): + """Test Fedora 39 stays as major version (no dot) + + OLD: 'Fedora 39'.split('.')[0] = 'Fedora 39' ✓ + NEW: normalize_el_osrelease('Fedora 39') = 'Fedora 39' ✓ + """ + from reports.utils import get_os + osvariant = get_os('Fedora 39', self.arch) + self.assertEqual(osvariant.name, 'Fedora 39') + self.assertEqual(osvariant.osrelease.name, 'Fedora 39') + + def test_fedora_release_keyword_stripped(self): + """Test 'Fedora release 39' strips 'release'""" + from reports.utils import get_os + osvariant = get_os('Fedora release 39', self.arch) + self.assertEqual(osvariant.name, 'Fedora 39') + self.assertEqual(osvariant.osrelease.name, 'Fedora 39') + + def test_ubuntu_unchanged(self): + """Test Ubuntu versions are NOT normalized (minor version matters)""" + from reports.utils import get_os + osvariant = get_os('Ubuntu 22.04.3 LTS', self.arch) + self.assertEqual(osvariant.name, 'Ubuntu 22.04.3 LTS') + self.assertEqual(osvariant.osrelease.name, 'Ubuntu 22.04 LTS') + + def test_debian_major_only(self): + """Test Debian uses major version only""" + from reports.utils import get_os + osvariant = get_os('Debian 12.0', self.arch) + self.assertEqual(osvariant.name, 'Debian 12.0') + self.assertEqual(osvariant.osrelease.name, 'Debian 12') + + def test_rocky_with_cpe(self): + """Test Rocky Linux with CPE in brackets""" + from reports.utils import get_os + osvariant = get_os('Rocky Linux 10.1 [cpe:/o:rocky:rocky:10]', self.arch) + self.assertEqual(osvariant.name, 'Rocky Linux 10.1') + self.assertEqual(osvariant.osrelease.name, 'Rocky Linux 10') + self.assertEqual(osvariant.osrelease.cpe_name, 'cpe:/o:rocky:rocky:10') + + def test_rocky_with_codename(self): + """Test Rocky Linux with codename in parentheses""" + from reports.utils import get_os + osvariant = get_os('Rocky Linux 10.1 (Red Quartz)', self.arch) + self.assertEqual(osvariant.name, 'Rocky Linux 10.1') + self.assertEqual(osvariant.osrelease.name, 'Rocky Linux 10') + self.assertEqual(osvariant.osrelease.codename, 'Red Quartz') + + def test_rocky_with_cpe_and_codename(self): + """Test Rocky Linux with both CPE and codename""" + from reports.utils import get_os + osvariant = get_os('Rocky Linux 10.1 (Red Quartz) [cpe:/o:rocky:rocky:10]', self.arch) + self.assertEqual(osvariant.name, 'Rocky Linux 10.1') + self.assertEqual(osvariant.osrelease.name, 'Rocky Linux 10') + self.assertEqual(osvariant.osrelease.codename, 'Red Quartz') + self.assertEqual(osvariant.osrelease.cpe_name, 'cpe:/o:rocky:rocky:10') + + def test_amazon_linux_ami(self): + """Test Amazon Linux AMI 2018.03 normalizes to Amazon Linux 1""" + from reports.utils import get_os + osvariant = get_os('Amazon Linux AMI 2018.03', self.arch) + self.assertEqual(osvariant.name, 'Amazon Linux 1') + self.assertEqual(osvariant.osrelease.name, 'Amazon Linux 1') + + def test_centos_stream(self): + """Test CentOS Stream 10 stays unchanged (no minor version)""" + from reports.utils import get_os + osvariant = get_os('CentOS Stream 10', self.arch) + self.assertEqual(osvariant.name, 'CentOS Stream 10') + # CentOS Stream starts with 'CentOS' so it goes through that path + self.assertEqual(osvariant.osrelease.name, 'CentOS Stream 10') + + def test_major_version_only_unchanged(self): + """Test that already-major-version names don't get mangled""" + from reports.utils import get_os + osvariant = get_os('Rocky Linux 10', self.arch) + self.assertEqual(osvariant.name, 'Rocky Linux 10') + self.assertEqual(osvariant.osrelease.name, 'Rocky Linux 10') diff --git a/reports/utils.py b/reports/utils.py index 7290c18d..0b4fe4e5 100644 --- a/reports/utils.py +++ b/reports/utils.py @@ -24,7 +24,7 @@ from hosts.models import HostRepo from modules.utils import get_or_create_module from operatingsystems.utils import ( - get_or_create_osrelease, get_or_create_osvariant, + get_or_create_osrelease, get_or_create_osvariant, normalize_el_osrelease, ) from packages.models import Package, PackageCategory from packages.utils import ( @@ -617,22 +617,22 @@ def get_os(os, arch): cpe_name = f"cpe:2.3:o:canonical:ubuntu_linux:{ubuntu_version}:*:*:*:{'lts' if lts else '*'}:*:*:*" elif os.startswith('AlmaLinux'): osvariant_name = os.replace('AlmaLinux', 'Alma Linux') - osrelease_name = osvariant_name.split('.')[0] + osrelease_name = normalize_el_osrelease(osvariant_name) elif os.startswith('Rocky'): osvariant_name = os - osrelease_name = osvariant_name.split('.')[0] + osrelease_name = normalize_el_osrelease(osvariant_name) elif os.startswith('Red Hat'): osvariant_name = os.replace(' release', '') - osrelease_name = osvariant_name.split('.')[0] + osrelease_name = normalize_el_osrelease(osvariant_name) elif os.startswith('Fedora'): osvariant_name = os.replace(' release', '') - osrelease_name = osvariant_name.split('.')[0] + osrelease_name = normalize_el_osrelease(osvariant_name) elif os.startswith('CentOS'): osvariant_name = os.replace(' release', '') - osrelease_name = osvariant_name.split('.')[0] + osrelease_name = normalize_el_osrelease(osvariant_name) elif os.startswith('Oracle'): osvariant_name = os.replace(' Server', '') - osrelease_name = osvariant_name.split('.')[0] + osrelease_name = normalize_el_osrelease(osvariant_name) elif os.startswith('Amazon Linux AMI 2018.03'): osrelease_name = osvariant_name = 'Amazon Linux 1'