diff options
-rw-r--r-- | cloudinit/net/sysconfig.py | 5 | ||||
-rw-r--r-- | tests/unittests/test_net.py | 18 |
2 files changed, 20 insertions, 3 deletions
diff --git a/cloudinit/net/sysconfig.py b/cloudinit/net/sysconfig.py index be5dede7..416c1c97 100644 --- a/cloudinit/net/sysconfig.py +++ b/cloudinit/net/sysconfig.py @@ -18,8 +18,7 @@ from .network_state import ( LOG = logging.getLogger(__name__) NM_CFG_FILE = "/etc/NetworkManager/NetworkManager.conf" -KNOWN_DISTROS = [ - 'opensuse', 'sles', 'suse', 'redhat', 'fedora', 'centos'] +KNOWN_DISTROS = ['centos', 'fedora', 'rhel', 'suse'] def _make_header(sep='#'): @@ -731,7 +730,7 @@ class Renderer(renderer.Renderer): def available(target=None): sysconfig = available_sysconfig(target=target) nm = available_nm(target=target) - return (util.get_linux_distro()[0] in KNOWN_DISTROS + return (util.system_info()['variant'] in KNOWN_DISTROS and any([nm, sysconfig])) diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py index e5789924..a093cf10 100644 --- a/tests/unittests/test_net.py +++ b/tests/unittests/test_net.py @@ -4158,6 +4158,24 @@ class TestNetRenderers(CiTestCase): m_distro.return_value = ('opensuse', None, None) self.assertEqual('sysconfig', renderers.select(priority=None)[0]) + @mock.patch("cloudinit.net.sysconfig.available_sysconfig") + @mock.patch("cloudinit.util.get_linux_distro") + def test_sysconfig_available_uses_variant_mapping(self, m_distro, m_avail): + m_avail.return_value = True + distro_values = [ + ('opensuse', '', ''), + ('opensuse-leap', '', ''), + ('opensuse-tumbleweed', '', ''), + ('sles', '', ''), + ('centos', '', ''), + ('fedora', '', ''), + ('redhat', '', ''), + ] + for (distro_name, distro_version, flavor) in distro_values: + m_distro.return_value = (distro_name, distro_version, flavor) + result = sysconfig.available() + self.assertTrue(result) + class TestGetInterfaces(CiTestCase): _data = {'bonds': ['bond1'], |