Merge ~raharper/cloud-init:fix/sysconfig-distro-variant into cloud-init:master

Proposed by Ryan Harper
Status: Merged
Approved by: Ryan Harper
Approved revision: 68ad30679acb0be436b36c148faa2894d0efe9e7
Merge reported by: Server Team CI bot
Merged at revision: not available
Proposed branch: ~raharper/cloud-init:fix/sysconfig-distro-variant
Merge into: cloud-init:master
Diff against target: 52 lines (+20/-3)
2 files modified
cloudinit/net/sysconfig.py (+2/-3)
tests/unittests/test_net.py (+18/-0)
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve
Dan Watkins Approve
Review via email: mp+373277@code.launchpad.net

Commit message

sysconfig: use distro variant to check if available

The sysconfig renderer used the distro name directly which mean
some variants of distros were not considered supported. Fix this
by using util.system_info()['variant'] instead. Fix the list of
KNOWN_DISTROS value for redhat -> rhel.

LP: #1843584

To post a comment you must log in.
Revision history for this message
Dan Watkins (oddbloke) :
review: Needs Information
a1910c9... by Ryan Harper

Drop unrelated changes to util

Revision history for this message
Ryan Harper (raharper) wrote :

Yes, thanks. I've dropped that unrelated hunk.

Revision history for this message
Dan Watkins (oddbloke) wrote :

Thanks! Questions inline.

Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:a1910c946e4e06f3f66c4b59d6d7707b87402391
https://jenkins.ubuntu.com/server/job/cloud-init-ci/1180/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/1180//rebuild

review: Approve (continuous-integration)
68ad306... by Ryan Harper

Use only variant names in KNOWN_DISTROS

Revision history for this message
Ryan Harper (raharper) wrote :

Thanks, I updated KNOWN_DISTROS to just use variant names.

Revision history for this message
Dan Watkins (oddbloke) wrote :

Thanks!

review: Approve
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:68ad30679acb0be436b36c148faa2894d0efe9e7
https://jenkins.ubuntu.com/server/job/cloud-init-ci/1181/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/1181//rebuild

review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/cloudinit/net/sysconfig.py b/cloudinit/net/sysconfig.py
index be5dede..416c1c9 100644
--- a/cloudinit/net/sysconfig.py
+++ b/cloudinit/net/sysconfig.py
@@ -18,8 +18,7 @@ from .network_state import (
1818
19LOG = logging.getLogger(__name__)19LOG = logging.getLogger(__name__)
20NM_CFG_FILE = "/etc/NetworkManager/NetworkManager.conf"20NM_CFG_FILE = "/etc/NetworkManager/NetworkManager.conf"
21KNOWN_DISTROS = [21KNOWN_DISTROS = ['centos', 'fedora', 'rhel', 'suse']
22 'opensuse', 'sles', 'suse', 'redhat', 'fedora', 'centos']
2322
2423
25def _make_header(sep='#'):24def _make_header(sep='#'):
@@ -731,7 +730,7 @@ class Renderer(renderer.Renderer):
731def available(target=None):730def available(target=None):
732 sysconfig = available_sysconfig(target=target)731 sysconfig = available_sysconfig(target=target)
733 nm = available_nm(target=target)732 nm = available_nm(target=target)
734 return (util.get_linux_distro()[0] in KNOWN_DISTROS733 return (util.system_info()['variant'] in KNOWN_DISTROS
735 and any([nm, sysconfig]))734 and any([nm, sysconfig]))
736735
737736
diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py
index e578992..a093cf1 100644
--- a/tests/unittests/test_net.py
+++ b/tests/unittests/test_net.py
@@ -4158,6 +4158,24 @@ class TestNetRenderers(CiTestCase):
4158 m_distro.return_value = ('opensuse', None, None)4158 m_distro.return_value = ('opensuse', None, None)
4159 self.assertEqual('sysconfig', renderers.select(priority=None)[0])4159 self.assertEqual('sysconfig', renderers.select(priority=None)[0])
41604160
4161 @mock.patch("cloudinit.net.sysconfig.available_sysconfig")
4162 @mock.patch("cloudinit.util.get_linux_distro")
4163 def test_sysconfig_available_uses_variant_mapping(self, m_distro, m_avail):
4164 m_avail.return_value = True
4165 distro_values = [
4166 ('opensuse', '', ''),
4167 ('opensuse-leap', '', ''),
4168 ('opensuse-tumbleweed', '', ''),
4169 ('sles', '', ''),
4170 ('centos', '', ''),
4171 ('fedora', '', ''),
4172 ('redhat', '', ''),
4173 ]
4174 for (distro_name, distro_version, flavor) in distro_values:
4175 m_distro.return_value = (distro_name, distro_version, flavor)
4176 result = sysconfig.available()
4177 self.assertTrue(result)
4178
41614179
4162class TestGetInterfaces(CiTestCase):4180class TestGetInterfaces(CiTestCase):
4163 _data = {'bonds': ['bond1'],4181 _data = {'bonds': ['bond1'],

Subscribers

People subscribed via source and target branches