Merge ~raharper/cloud-init:fix/ubuntu-network-manager-sysconfig into cloud-init:master

Proposed by Ryan Harper
Status: Merged
Approved by: Ryan Harper
Approved revision: e6ad72c2447e5ff9462a435958aa8b9d7123dd04
Merge reported by: Server Team CI bot
Merged at revision: not available
Proposed branch: ~raharper/cloud-init:fix/ubuntu-network-manager-sysconfig
Merge into: cloud-init:master
Diff against target: 70 lines (+39/-2)
2 files modified
cloudinit/net/sysconfig.py (+4/-2)
tests/unittests/test_net.py (+35/-0)
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve
Dan Watkins Approve
Review via email: mp+364598@code.launchpad.net

Commit message

net/sysconfig: only indicate available on known sysconfig distros

Restrict the sysconfig renderer availabily to known distros.
Ubuntu/Debian systems may include network-manager but they do
not have support for reading sysconfig network output; that is
enabled via a Network-Manager plugin: ifcfg-rh which is not
available in Ubuntu/Debian.

LP: #1819994

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:f3cddcea4275d636c9fb5649bc76bf95a3ef3b5f
https://jenkins.ubuntu.com/server/job/cloud-init-ci/641/
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/641/rebuild

review: Approve (continuous-integration)
Revision history for this message
Dan Watkins (oddbloke) :
review: Needs Information
Revision history for this message
Ryan Harper (raharper) wrote :

I forgot to submit a comment from the original review, hopefully this will show up now.

Revision history for this message
Dan Watkins (oddbloke) :
review: Approve
e6ad72c... by Ryan Harper

Drop parens, unneeded.

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

PASSED: Continuous integration, rev:e6ad72c2447e5ff9462a435958aa8b9d7123dd04
https://jenkins.ubuntu.com/server/job/cloud-init-ci/687/
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/687/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 0998392..a47da0a 100644
--- a/cloudinit/net/sysconfig.py
+++ b/cloudinit/net/sysconfig.py
@@ -18,6 +18,8 @@ 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 = [
22 'opensuse', 'sles', 'suse', 'redhat', 'fedora', 'centos']
2123
2224
23def _make_header(sep='#'):25def _make_header(sep='#'):
@@ -717,8 +719,8 @@ class Renderer(renderer.Renderer):
717def available(target=None):719def available(target=None):
718 sysconfig = available_sysconfig(target=target)720 sysconfig = available_sysconfig(target=target)
719 nm = available_nm(target=target)721 nm = available_nm(target=target)
720722 return (util.get_linux_distro()[0] in KNOWN_DISTROS
721 return any([nm, sysconfig])723 and any([nm, sysconfig]))
722724
723725
724def available_sysconfig(target=None):726def available_sysconfig(target=None):
diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py
index ca6ef97..9db0156 100644
--- a/tests/unittests/test_net.py
+++ b/tests/unittests/test_net.py
@@ -3829,6 +3829,41 @@ class TestNetRenderers(CiTestCase):
3829 self.assertRaises(net.RendererNotFoundError, renderers.select,3829 self.assertRaises(net.RendererNotFoundError, renderers.select,
3830 priority=['sysconfig', 'eni'])3830 priority=['sysconfig', 'eni'])
38313831
3832 @mock.patch("cloudinit.net.renderers.netplan.available")
3833 @mock.patch("cloudinit.net.renderers.sysconfig.available_sysconfig")
3834 @mock.patch("cloudinit.net.renderers.sysconfig.available_nm")
3835 @mock.patch("cloudinit.net.renderers.eni.available")
3836 @mock.patch("cloudinit.net.renderers.sysconfig.util.get_linux_distro")
3837 def test_sysconfig_selected_on_sysconfig_enabled_distros(self, m_distro,
3838 m_eni, m_sys_nm,
3839 m_sys_scfg,
3840 m_netplan):
3841 """sysconfig only selected on specific distros (rhel/sles)."""
3842
3843 # Ubuntu with Network-Manager installed
3844 m_eni.return_value = False # no ifupdown (ifquery)
3845 m_sys_scfg.return_value = False # no sysconfig/ifup/ifdown
3846 m_sys_nm.return_value = True # network-manager is installed
3847 m_netplan.return_value = True # netplan is installed
3848 m_distro.return_value = ('ubuntu', None, None)
3849 self.assertEqual('netplan', renderers.select(priority=None)[0])
3850
3851 # Centos with Network-Manager installed
3852 m_eni.return_value = False # no ifupdown (ifquery)
3853 m_sys_scfg.return_value = False # no sysconfig/ifup/ifdown
3854 m_sys_nm.return_value = True # network-manager is installed
3855 m_netplan.return_value = False # netplan is not installed
3856 m_distro.return_value = ('centos', None, None)
3857 self.assertEqual('sysconfig', renderers.select(priority=None)[0])
3858
3859 # OpenSuse with Network-Manager installed
3860 m_eni.return_value = False # no ifupdown (ifquery)
3861 m_sys_scfg.return_value = False # no sysconfig/ifup/ifdown
3862 m_sys_nm.return_value = True # network-manager is installed
3863 m_netplan.return_value = False # netplan is not installed
3864 m_distro.return_value = ('opensuse', None, None)
3865 self.assertEqual('sysconfig', renderers.select(priority=None)[0])
3866
38323867
3833class TestGetInterfaces(CiTestCase):3868class TestGetInterfaces(CiTestCase):
3834 _data = {'bonds': ['bond1'],3869 _data = {'bonds': ['bond1'],

Subscribers

People subscribed via source and target branches