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

Proposed by Ryan Harper on 2019-09-26
Status: Merged
Approved by: Ryan Harper on 2019-09-26
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 on 2019-09-26
Dan Watkins 2019-09-26 Approve on 2019-09-26
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.
review: Needs Information
a1910c9... by Ryan Harper on 2019-09-26

Drop unrelated changes to util

Ryan Harper (raharper) wrote :

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

Dan Watkins (daniel-thewatkins) wrote :

Thanks! Questions inline.

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 on 2019-09-26

Use only variant names in KNOWN_DISTROS

Ryan Harper (raharper) wrote :

Thanks, I updated KNOWN_DISTROS to just use variant names.

Dan Watkins (daniel-thewatkins) wrote :

Thanks!

review: Approve

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
1diff --git a/cloudinit/net/sysconfig.py b/cloudinit/net/sysconfig.py
2index be5dede..416c1c9 100644
3--- a/cloudinit/net/sysconfig.py
4+++ b/cloudinit/net/sysconfig.py
5@@ -18,8 +18,7 @@ from .network_state import (
6
7 LOG = logging.getLogger(__name__)
8 NM_CFG_FILE = "/etc/NetworkManager/NetworkManager.conf"
9-KNOWN_DISTROS = [
10- 'opensuse', 'sles', 'suse', 'redhat', 'fedora', 'centos']
11+KNOWN_DISTROS = ['centos', 'fedora', 'rhel', 'suse']
12
13
14 def _make_header(sep='#'):
15@@ -731,7 +730,7 @@ class Renderer(renderer.Renderer):
16 def available(target=None):
17 sysconfig = available_sysconfig(target=target)
18 nm = available_nm(target=target)
19- return (util.get_linux_distro()[0] in KNOWN_DISTROS
20+ return (util.system_info()['variant'] in KNOWN_DISTROS
21 and any([nm, sysconfig]))
22
23
24diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py
25index e578992..a093cf1 100644
26--- a/tests/unittests/test_net.py
27+++ b/tests/unittests/test_net.py
28@@ -4158,6 +4158,24 @@ class TestNetRenderers(CiTestCase):
29 m_distro.return_value = ('opensuse', None, None)
30 self.assertEqual('sysconfig', renderers.select(priority=None)[0])
31
32+ @mock.patch("cloudinit.net.sysconfig.available_sysconfig")
33+ @mock.patch("cloudinit.util.get_linux_distro")
34+ def test_sysconfig_available_uses_variant_mapping(self, m_distro, m_avail):
35+ m_avail.return_value = True
36+ distro_values = [
37+ ('opensuse', '', ''),
38+ ('opensuse-leap', '', ''),
39+ ('opensuse-tumbleweed', '', ''),
40+ ('sles', '', ''),
41+ ('centos', '', ''),
42+ ('fedora', '', ''),
43+ ('redhat', '', ''),
44+ ]
45+ for (distro_name, distro_version, flavor) in distro_values:
46+ m_distro.return_value = (distro_name, distro_version, flavor)
47+ result = sysconfig.available()
48+ self.assertTrue(result)
49+
50
51 class TestGetInterfaces(CiTestCase):
52 _data = {'bonds': ['bond1'],

Subscribers

People subscribed via source and target branches