6af34f
From f1836e78d20ef34b05b6aba002fc10a97eceb454 Mon Sep 17 00:00:00 2001
6af34f
From: Emanuele Giuseppe Esposito <eesposit@redhat.com>
6af34f
Date: Mon, 8 Aug 2022 10:08:50 +0200
6af34f
Subject: [PATCH 1/2] Revert "Add native NetworkManager support (#1224)"
6af34f
6af34f
RH-Author: Emanuele Giuseppe Esposito <eesposit@redhat.com>
6af34f
RH-MergeRequest: 81: Revert "Use Network-Manager and Netplan as default renderers for RHEL and Fedora (#1465)"
6af34f
RH-Commit: [1/2] 5b3e51502a89c2dcfbc97dc08a86b792454fedd3
6af34f
RH-Bugzilla: 2107464 2110066 2117526 2104393 2098624
6af34f
RH-Acked-by: Eduardo Otubo <otubo@redhat.com>
6af34f
RH-Acked-by: Vitaly Kuznetsov <vkuznets@redhat.com>
6af34f
RH-Acked-by: Mohamed Gamal Morsy <mmorsy@redhat.com>
6af34f
6af34f
NM is not yet stable, so we don't want to support it for now.
6af34f
This reverts commit 0d93e53fd05c44b62e3456b7580c9de8135e6b5a.
6af34f
6af34f
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
6af34f
---
6af34f
 cloudinit/cmd/devel/net_convert.py     |   14 +-
6af34f
 cloudinit/net/activators.py            |   25 +-
6af34f
 cloudinit/net/network_manager.py       |  377 -------
6af34f
 cloudinit/net/renderers.py             |    3 -
6af34f
 cloudinit/net/sysconfig.py             |   37 +-
6af34f
 tests/unittests/test_net.py            | 1268 +++---------------------
6af34f
 tests/unittests/test_net_activators.py |   93 +-
6af34f
 7 files changed, 193 insertions(+), 1624 deletions(-)
6af34f
 delete mode 100644 cloudinit/net/network_manager.py
6af34f
6af34f
diff --git a/cloudinit/cmd/devel/net_convert.py b/cloudinit/cmd/devel/net_convert.py
6af34f
index 647fe07b..18b1e7ff 100755
6af34f
--- a/cloudinit/cmd/devel/net_convert.py
6af34f
+++ b/cloudinit/cmd/devel/net_convert.py
6af34f
@@ -7,14 +7,7 @@ import os
6af34f
 import sys
6af34f
 
6af34f
 from cloudinit import distros, log, safeyaml
6af34f
-from cloudinit.net import (
6af34f
-    eni,
6af34f
-    netplan,
6af34f
-    network_manager,
6af34f
-    network_state,
6af34f
-    networkd,
6af34f
-    sysconfig,
6af34f
-)
6af34f
+from cloudinit.net import eni, netplan, network_state, networkd, sysconfig
6af34f
 from cloudinit.sources import DataSourceAzure as azure
6af34f
 from cloudinit.sources import DataSourceOVF as ovf
6af34f
 from cloudinit.sources.helpers import openstack
6af34f
@@ -81,7 +74,7 @@ def get_parser(parser=None):
6af34f
     parser.add_argument(
6af34f
         "-O",
6af34f
         "--output-kind",
6af34f
-        choices=["eni", "netplan", "networkd", "sysconfig", "network-manager"],
6af34f
+        choices=["eni", "netplan", "networkd", "sysconfig"],
6af34f
         required=True,
6af34f
         help="The network config format to emit",
6af34f
     )
6af34f
@@ -155,9 +148,6 @@ def handle_args(name, args):
6af34f
     elif args.output_kind == "sysconfig":
6af34f
         r_cls = sysconfig.Renderer
6af34f
         config = distro.renderer_configs.get("sysconfig")
6af34f
-    elif args.output_kind == "network-manager":
6af34f
-        r_cls = network_manager.Renderer
6af34f
-        config = distro.renderer_configs.get("network-manager")
6af34f
     else:
6af34f
         raise RuntimeError("Invalid output_kind")
6af34f
 
6af34f
diff --git a/cloudinit/net/activators.py b/cloudinit/net/activators.py
6af34f
index edbc0c06..e80c26df 100644
6af34f
--- a/cloudinit/net/activators.py
6af34f
+++ b/cloudinit/net/activators.py
6af34f
@@ -1,14 +1,15 @@
6af34f
 # This file is part of cloud-init. See LICENSE file for license information.
6af34f
 import logging
6af34f
+import os
6af34f
 from abc import ABC, abstractmethod
6af34f
 from typing import Iterable, List, Type
6af34f
 
6af34f
 from cloudinit import subp, util
6af34f
 from cloudinit.net.eni import available as eni_available
6af34f
 from cloudinit.net.netplan import available as netplan_available
6af34f
-from cloudinit.net.network_manager import available as nm_available
6af34f
 from cloudinit.net.network_state import NetworkState
6af34f
 from cloudinit.net.networkd import available as networkd_available
6af34f
+from cloudinit.net.sysconfig import NM_CFG_FILE
6af34f
 
6af34f
 LOG = logging.getLogger(__name__)
6af34f
 
6af34f
@@ -123,24 +124,20 @@ class IfUpDownActivator(NetworkActivator):
6af34f
 class NetworkManagerActivator(NetworkActivator):
6af34f
     @staticmethod
6af34f
     def available(target=None) -> bool:
6af34f
-        """Return true if NetworkManager can be used on this system."""
6af34f
-        return nm_available(target=target)
6af34f
+        """Return true if network manager can be used on this system."""
6af34f
+        config_present = os.path.isfile(
6af34f
+            subp.target_path(target, path=NM_CFG_FILE)
6af34f
+        )
6af34f
+        nmcli_present = subp.which("nmcli", target=target)
6af34f
+        return config_present and bool(nmcli_present)
6af34f
 
6af34f
     @staticmethod
6af34f
     def bring_up_interface(device_name: str) -> bool:
6af34f
-        """Bring up connection using nmcli.
6af34f
+        """Bring up interface using nmcli.
6af34f
 
6af34f
         Return True is successful, otherwise return False
6af34f
         """
6af34f
-        from cloudinit.net.network_manager import conn_filename
6af34f
-
6af34f
-        filename = conn_filename(device_name)
6af34f
-        cmd = ["nmcli", "connection", "load", filename]
6af34f
-        if _alter_interface(cmd, device_name):
6af34f
-            cmd = ["nmcli", "connection", "up", "filename", filename]
6af34f
-        else:
6af34f
-            _alter_interface(["nmcli", "connection", "reload"], device_name)
6af34f
-            cmd = ["nmcli", "connection", "up", "ifname", device_name]
6af34f
+        cmd = ["nmcli", "connection", "up", "ifname", device_name]
6af34f
         return _alter_interface(cmd, device_name)
6af34f
 
6af34f
     @staticmethod
6af34f
@@ -149,7 +146,7 @@ class NetworkManagerActivator(NetworkActivator):
6af34f
 
6af34f
         Return True is successful, otherwise return False
6af34f
         """
6af34f
-        cmd = ["nmcli", "device", "disconnect", device_name]
6af34f
+        cmd = ["nmcli", "connection", "down", device_name]
6af34f
         return _alter_interface(cmd, device_name)
6af34f
 
6af34f
 
6af34f
diff --git a/cloudinit/net/network_manager.py b/cloudinit/net/network_manager.py
6af34f
deleted file mode 100644
6af34f
index 79b0fe0b..00000000
6af34f
--- a/cloudinit/net/network_manager.py
6af34f
+++ /dev/null
6af34f
@@ -1,377 +0,0 @@
6af34f
-# Copyright 2022 Red Hat, Inc.
6af34f
-#
6af34f
-# Author: Lubomir Rintel <lkundrak@v3.sk>
6af34f
-# Fixes and suggestions contributed by James Falcon, Neal Gompa,
6af34f
-# Zbigniew Jędrzejewski-Szmek and Emanuele Giuseppe Esposito.
6af34f
-#
6af34f
-# This file is part of cloud-init. See LICENSE file for license information.
6af34f
-
6af34f
-import configparser
6af34f
-import io
6af34f
-import itertools
6af34f
-import os
6af34f
-import uuid
6af34f
-
6af34f
-from cloudinit import log as logging
6af34f
-from cloudinit import subp, util
6af34f
-
6af34f
-from . import renderer
6af34f
-from .network_state import is_ipv6_addr, subnet_is_ipv6
6af34f
-
6af34f
-NM_RUN_DIR = "/etc/NetworkManager"
6af34f
-NM_LIB_DIR = "/usr/lib/NetworkManager"
6af34f
-LOG = logging.getLogger(__name__)
6af34f
-
6af34f
-
6af34f
-class NMConnection:
6af34f
-    """Represents a NetworkManager connection profile."""
6af34f
-
6af34f
-    def __init__(self, con_id):
6af34f
-        """
6af34f
-        Initializes the connection with some very basic properties,
6af34f
-        notably the UUID so that the connection can be referred to.
6af34f
-        """
6af34f
-
6af34f
-        # Chosen by fair dice roll
6af34f
-        CI_NM_UUID = uuid.UUID("a3924cb8-09e0-43e9-890b-77972a800108")
6af34f
-
6af34f
-        self.config = configparser.ConfigParser()
6af34f
-        # Identity option name mapping, to achieve case sensitivity
6af34f
-        self.config.optionxform = str
6af34f
-
6af34f
-        self.config["connection"] = {
6af34f
-            "id": f"cloud-init {con_id}",
6af34f
-            "uuid": str(uuid.uuid5(CI_NM_UUID, con_id)),
6af34f
-        }
6af34f
-
6af34f
-        # This is not actually used anywhere, but may be useful in future
6af34f
-        self.config["user"] = {
6af34f
-            "org.freedesktop.NetworkManager.origin": "cloud-init"
6af34f
-        }
6af34f
-
6af34f
-    def _set_default(self, section, option, value):
6af34f
-        """
6af34f
-        Sets a property unless it's already set, ensuring the section
6af34f
-        exists.
6af34f
-        """
6af34f
-
6af34f
-        if not self.config.has_section(section):
6af34f
-            self.config[section] = {}
6af34f
-        if not self.config.has_option(section, option):
6af34f
-            self.config[section][option] = value
6af34f
-
6af34f
-    def _set_ip_method(self, family, subnet_type):
6af34f
-        """
6af34f
-        Ensures there's appropriate [ipv4]/[ipv6] for given family
6af34f
-        appropriate for given configuration type
6af34f
-        """
6af34f
-
6af34f
-        method_map = {
6af34f
-            "static": "manual",
6af34f
-            "dhcp6": "dhcp",
6af34f
-            "ipv6_slaac": "auto",
6af34f
-            "ipv6_dhcpv6-stateless": "auto",
6af34f
-            "ipv6_dhcpv6-stateful": "auto",
6af34f
-            "dhcp4": "auto",
6af34f
-            "dhcp": "auto",
6af34f
-        }
6af34f
-
6af34f
-        # Ensure we got an [ipvX] section
6af34f
-        self._set_default(family, "method", "disabled")
6af34f
-
6af34f
-        try:
6af34f
-            method = method_map[subnet_type]
6af34f
-        except KeyError:
6af34f
-            # What else can we do
6af34f
-            method = "auto"
6af34f
-            self.config[family]["may-fail"] = "true"
6af34f
-
6af34f
-        # Make sure we don't "downgrade" the method in case
6af34f
-        # we got conflicting subnets (e.g. static along with dhcp)
6af34f
-        if self.config[family]["method"] == "dhcp":
6af34f
-            return
6af34f
-        if self.config[family]["method"] == "auto" and method == "manual":
6af34f
-            return
6af34f
-
6af34f
-        self.config[family]["method"] = method
6af34f
-        self._set_default(family, "may-fail", "false")
6af34f
-        if family == "ipv6":
6af34f
-            self._set_default(family, "addr-gen-mode", "stable-privacy")
6af34f
-
6af34f
-    def _add_numbered(self, section, key_prefix, value):
6af34f
-        """
6af34f
-        Adds a numbered property, such as address<n> or route<n>, ensuring
6af34f
-        the appropriate value gets used for <n>.
6af34f
-        """
6af34f
-
6af34f
-        for index in itertools.count(1):
6af34f
-            key = f"{key_prefix}{index}"
6af34f
-            if not self.config.has_option(section, key):
6af34f
-                self.config[section][key] = value
6af34f
-                break
6af34f
-
6af34f
-    def _add_address(self, family, subnet):
6af34f
-        """
6af34f
-        Adds an ipv[46]address<n> property.
6af34f
-        """
6af34f
-
6af34f
-        value = subnet["address"] + "/" + str(subnet["prefix"])
6af34f
-        self._add_numbered(family, "address", value)
6af34f
-
6af34f
-    def _add_route(self, family, route):
6af34f
-        """
6af34f
-        Adds a ipv[46].route<n> property.
6af34f
-        """
6af34f
-
6af34f
-        value = route["network"] + "/" + str(route["prefix"])
6af34f
-        if "gateway" in route:
6af34f
-            value = value + "," + route["gateway"]
6af34f
-        self._add_numbered(family, "route", value)
6af34f
-
6af34f
-    def _add_nameserver(self, dns):
6af34f
-        """
6af34f
-        Extends the ipv[46].dns property with a name server.
6af34f
-        """
6af34f
-
6af34f
-        # FIXME: the subnet contains IPv4 and IPv6 name server mixed
6af34f
-        # together. We might be getting an IPv6 name server while
6af34f
-        # we're dealing with an IPv4 subnet. Sort this out by figuring
6af34f
-        # out the correct family and making sure a valid section exist.
6af34f
-        family = "ipv6" if is_ipv6_addr(dns) else "ipv4"
6af34f
-        self._set_default(family, "method", "disabled")
6af34f
-
6af34f
-        self._set_default(family, "dns", "")
6af34f
-        self.config[family]["dns"] = self.config[family]["dns"] + dns + ";"
6af34f
-
6af34f
-    def _add_dns_search(self, family, dns_search):
6af34f
-        """
6af34f
-        Extends the ipv[46].dns-search property with a name server.
6af34f
-        """
6af34f
-
6af34f
-        self._set_default(family, "dns-search", "")
6af34f
-        self.config[family]["dns-search"] = (
6af34f
-            self.config[family]["dns-search"] + ";".join(dns_search) + ";"
6af34f
-        )
6af34f
-
6af34f
-    def con_uuid(self):
6af34f
-        """
6af34f
-        Returns the connection UUID
6af34f
-        """
6af34f
-        return self.config["connection"]["uuid"]
6af34f
-
6af34f
-    def valid(self):
6af34f
-        """
6af34f
-        Can this be serialized into a meaningful connection profile?
6af34f
-        """
6af34f
-        return self.config.has_option("connection", "type")
6af34f
-
6af34f
-    @staticmethod
6af34f
-    def mac_addr(addr):
6af34f
-        """
6af34f
-        Sanitize a MAC address.
6af34f
-        """
6af34f
-        return addr.replace("-", ":").upper()
6af34f
-
6af34f
-    def render_interface(self, iface, renderer):
6af34f
-        """
6af34f
-        Integrate information from network state interface information
6af34f
-        into the connection. Most of the work is done here.
6af34f
-        """
6af34f
-
6af34f
-        # Initialize type & connectivity
6af34f
-        _type_map = {
6af34f
-            "physical": "ethernet",
6af34f
-            "vlan": "vlan",
6af34f
-            "bond": "bond",
6af34f
-            "bridge": "bridge",
6af34f
-            "infiniband": "infiniband",
6af34f
-            "loopback": None,
6af34f
-        }
6af34f
-
6af34f
-        if_type = _type_map[iface["type"]]
6af34f
-        if if_type is None:
6af34f
-            return
6af34f
-        if "bond-master" in iface:
6af34f
-            slave_type = "bond"
6af34f
-        else:
6af34f
-            slave_type = None
6af34f
-
6af34f
-        self.config["connection"]["type"] = if_type
6af34f
-        if slave_type is not None:
6af34f
-            self.config["connection"]["slave-type"] = slave_type
6af34f
-            self.config["connection"]["master"] = renderer.con_ref(
6af34f
-                iface[slave_type + "-master"]
6af34f
-            )
6af34f
-
6af34f
-        # Add type specific-section
6af34f
-        self.config[if_type] = {}
6af34f
-
6af34f
-        # These are the interface properties that map nicely
6af34f
-        # to NetworkManager properties
6af34f
-        _prop_map = {
6af34f
-            "bond": {
6af34f
-                "mode": "bond-mode",
6af34f
-                "miimon": "bond_miimon",
6af34f
-                "xmit_hash_policy": "bond-xmit-hash-policy",
6af34f
-                "num_grat_arp": "bond-num-grat-arp",
6af34f
-                "downdelay": "bond-downdelay",
6af34f
-                "updelay": "bond-updelay",
6af34f
-                "fail_over_mac": "bond-fail-over-mac",
6af34f
-                "primary_reselect": "bond-primary-reselect",
6af34f
-                "primary": "bond-primary",
6af34f
-            },
6af34f
-            "bridge": {
6af34f
-                "stp": "bridge_stp",
6af34f
-                "priority": "bridge_bridgeprio",
6af34f
-            },
6af34f
-            "vlan": {
6af34f
-                "id": "vlan_id",
6af34f
-            },
6af34f
-            "ethernet": {},
6af34f
-            "infiniband": {},
6af34f
-        }
6af34f
-
6af34f
-        device_mtu = iface["mtu"]
6af34f
-        ipv4_mtu = None
6af34f
-
6af34f
-        # Deal with Layer 3 configuration
6af34f
-        for subnet in iface["subnets"]:
6af34f
-            family = "ipv6" if subnet_is_ipv6(subnet) else "ipv4"
6af34f
-
6af34f
-            self._set_ip_method(family, subnet["type"])
6af34f
-            if "address" in subnet:
6af34f
-                self._add_address(family, subnet)
6af34f
-            if "gateway" in subnet:
6af34f
-                self.config[family]["gateway"] = subnet["gateway"]
6af34f
-            for route in subnet["routes"]:
6af34f
-                self._add_route(family, route)
6af34f
-            if "dns_nameservers" in subnet:
6af34f
-                for nameserver in subnet["dns_nameservers"]:
6af34f
-                    self._add_nameserver(nameserver)
6af34f
-            if "dns_search" in subnet:
6af34f
-                self._add_dns_search(family, subnet["dns_search"])
6af34f
-            if family == "ipv4" and "mtu" in subnet:
6af34f
-                ipv4_mtu = subnet["mtu"]
6af34f
-
6af34f
-        if ipv4_mtu is None:
6af34f
-            ipv4_mtu = device_mtu
6af34f
-        if not ipv4_mtu == device_mtu:
6af34f
-            LOG.warning(
6af34f
-                "Network config: ignoring %s device-level mtu:%s"
6af34f
-                " because ipv4 subnet-level mtu:%s provided.",
6af34f
-                iface["name"],
6af34f
-                device_mtu,
6af34f
-                ipv4_mtu,
6af34f
-            )
6af34f
-
6af34f
-        # Parse type-specific properties
6af34f
-        for nm_prop, key in _prop_map[if_type].items():
6af34f
-            if key not in iface:
6af34f
-                continue
6af34f
-            if iface[key] is None:
6af34f
-                continue
6af34f
-            if isinstance(iface[key], bool):
6af34f
-                self.config[if_type][nm_prop] = (
6af34f
-                    "true" if iface[key] else "false"
6af34f
-                )
6af34f
-            else:
6af34f
-                self.config[if_type][nm_prop] = str(iface[key])
6af34f
-
6af34f
-        # These ones need special treatment
6af34f
-        if if_type == "ethernet":
6af34f
-            if iface["wakeonlan"] is True:
6af34f
-                # NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC
6af34f
-                self.config["ethernet"]["wake-on-lan"] = str(0x40)
6af34f
-            if ipv4_mtu is not None:
6af34f
-                self.config["ethernet"]["mtu"] = str(ipv4_mtu)
6af34f
-            if iface["mac_address"] is not None:
6af34f
-                self.config["ethernet"]["mac-address"] = self.mac_addr(
6af34f
-                    iface["mac_address"]
6af34f
-                )
6af34f
-        if if_type == "vlan" and "vlan-raw-device" in iface:
6af34f
-            self.config["vlan"]["parent"] = renderer.con_ref(
6af34f
-                iface["vlan-raw-device"]
6af34f
-            )
6af34f
-        if if_type == "bridge":
6af34f
-            # Bridge is ass-backwards compared to bond
6af34f
-            for port in iface["bridge_ports"]:
6af34f
-                port = renderer.get_conn(port)
6af34f
-                port._set_default("connection", "slave-type", "bridge")
6af34f
-                port._set_default("connection", "master", self.con_uuid())
6af34f
-            if iface["mac_address"] is not None:
6af34f
-                self.config["bridge"]["mac-address"] = self.mac_addr(
6af34f
-                    iface["mac_address"]
6af34f
-                )
6af34f
-        if if_type == "infiniband" and ipv4_mtu is not None:
6af34f
-            self.config["infiniband"]["transport-mode"] = "datagram"
6af34f
-            self.config["infiniband"]["mtu"] = str(ipv4_mtu)
6af34f
-            if iface["mac_address"] is not None:
6af34f
-                self.config["infiniband"]["mac-address"] = self.mac_addr(
6af34f
-                    iface["mac_address"]
6af34f
-                )
6af34f
-
6af34f
-        # Finish up
6af34f
-        if if_type == "bridge" or not self.config.has_option(
6af34f
-            if_type, "mac-address"
6af34f
-        ):
6af34f
-            self.config["connection"]["interface-name"] = iface["name"]
6af34f
-
6af34f
-    def dump(self):
6af34f
-        """
6af34f
-        Stringify.
6af34f
-        """
6af34f
-
6af34f
-        buf = io.StringIO()
6af34f
-        self.config.write(buf, space_around_delimiters=False)
6af34f
-        header = "# Generated by cloud-init. Changes will be lost.\n\n"
6af34f
-        return header + buf.getvalue()
6af34f
-
6af34f
-
6af34f
-class Renderer(renderer.Renderer):
6af34f
-    """Renders network information in a NetworkManager keyfile format."""
6af34f
-
6af34f
-    def __init__(self, config=None):
6af34f
-        self.connections = {}
6af34f
-
6af34f
-    def get_conn(self, con_id):
6af34f
-        return self.connections[con_id]
6af34f
-
6af34f
-    def con_ref(self, con_id):
6af34f
-        if con_id in self.connections:
6af34f
-            return self.connections[con_id].con_uuid()
6af34f
-        else:
6af34f
-            # Well, what can we do...
6af34f
-            return con_id
6af34f
-
6af34f
-    def render_network_state(self, network_state, templates=None, target=None):
6af34f
-        # First pass makes sure there's NMConnections for all known
6af34f
-        # interfaces that have UUIDs that can be linked to from related
6af34f
-        # interfaces
6af34f
-        for iface in network_state.iter_interfaces():
6af34f
-            self.connections[iface["name"]] = NMConnection(iface["name"])
6af34f
-
6af34f
-        # Now render the actual interface configuration
6af34f
-        for iface in network_state.iter_interfaces():
6af34f
-            conn = self.connections[iface["name"]]
6af34f
-            conn.render_interface(iface, self)
6af34f
-
6af34f
-        # And finally write the files
6af34f
-        for con_id, conn in self.connections.items():
6af34f
-            if not conn.valid():
6af34f
-                continue
6af34f
-            name = conn_filename(con_id, target)
6af34f
-            util.write_file(name, conn.dump(), 0o600)
6af34f
-
6af34f
-
6af34f
-def conn_filename(con_id, target=None):
6af34f
-    target_con_dir = subp.target_path(target, NM_RUN_DIR)
6af34f
-    con_file = f"cloud-init-{con_id}.nmconnection"
6af34f
-    return f"{target_con_dir}/system-connections/{con_file}"
6af34f
-
6af34f
-
6af34f
-def available(target=None):
6af34f
-    target_nm_dir = subp.target_path(target, NM_LIB_DIR)
6af34f
-    return os.path.exists(target_nm_dir)
6af34f
-
6af34f
-
6af34f
-# vi: ts=4 expandtab
6af34f
diff --git a/cloudinit/net/renderers.py b/cloudinit/net/renderers.py
6af34f
index 7edc34b5..c755f04c 100644
6af34f
--- a/cloudinit/net/renderers.py
6af34f
+++ b/cloudinit/net/renderers.py
6af34f
@@ -8,7 +8,6 @@ from . import (
6af34f
     freebsd,
6af34f
     netbsd,
6af34f
     netplan,
6af34f
-    network_manager,
6af34f
     networkd,
6af34f
     openbsd,
6af34f
     renderer,
6af34f
@@ -20,7 +19,6 @@ NAME_TO_RENDERER = {
6af34f
     "freebsd": freebsd,
6af34f
     "netbsd": netbsd,
6af34f
     "netplan": netplan,
6af34f
-    "network-manager": network_manager,
6af34f
     "networkd": networkd,
6af34f
     "openbsd": openbsd,
6af34f
     "sysconfig": sysconfig,
6af34f
@@ -30,7 +28,6 @@ DEFAULT_PRIORITY = [
6af34f
     "eni",
6af34f
     "sysconfig",
6af34f
     "netplan",
6af34f
-    "network-manager",
6af34f
     "freebsd",
6af34f
     "netbsd",
6af34f
     "openbsd",
6af34f
diff --git a/cloudinit/net/sysconfig.py b/cloudinit/net/sysconfig.py
6af34f
index c3b0c795..362e8d19 100644
6af34f
--- a/cloudinit/net/sysconfig.py
6af34f
+++ b/cloudinit/net/sysconfig.py
6af34f
@@ -5,6 +5,8 @@ import io
6af34f
 import os
6af34f
 import re
6af34f
 
6af34f
+from configobj import ConfigObj
6af34f
+
6af34f
 from cloudinit import log as logging
6af34f
 from cloudinit import subp, util
6af34f
 from cloudinit.distros.parsers import networkmanager_conf, resolv_conf
6af34f
@@ -64,6 +66,24 @@ def _quote_value(value):
6af34f
         return value
6af34f
 
6af34f
 
6af34f
+def enable_ifcfg_rh(path):
6af34f
+    """Add ifcfg-rh to NetworkManager.cfg plugins if main section is present"""
6af34f
+    config = ConfigObj(path)
6af34f
+    if "main" in config:
6af34f
+        if "plugins" in config["main"]:
6af34f
+            if "ifcfg-rh" in config["main"]["plugins"]:
6af34f
+                return
6af34f
+        else:
6af34f
+            config["main"]["plugins"] = []
6af34f
+
6af34f
+        if isinstance(config["main"]["plugins"], list):
6af34f
+            config["main"]["plugins"].append("ifcfg-rh")
6af34f
+        else:
6af34f
+            config["main"]["plugins"] = [config["main"]["plugins"], "ifcfg-rh"]
6af34f
+        config.write()
6af34f
+        LOG.debug("Enabled ifcfg-rh NetworkManager plugins")
6af34f
+
6af34f
+
6af34f
 class ConfigMap(object):
6af34f
     """Sysconfig like dictionary object."""
6af34f
 
6af34f
@@ -1011,6 +1031,8 @@ class Renderer(renderer.Renderer):
6af34f
             netrules_content = self._render_persistent_net(network_state)
6af34f
             netrules_path = subp.target_path(target, self.netrules_path)
6af34f
             util.write_file(netrules_path, netrules_content, file_mode)
6af34f
+        if available_nm(target=target):
6af34f
+            enable_ifcfg_rh(subp.target_path(target, path=NM_CFG_FILE))
6af34f
 
6af34f
         sysconfig_path = subp.target_path(target, templates.get("control"))
6af34f
         # Distros configuring /etc/sysconfig/network as a file e.g. Centos
6af34f
@@ -1049,9 +1071,14 @@ def _supported_vlan_names(rdev, vid):
6af34f
 
6af34f
 
6af34f
 def available(target=None):
6af34f
-    if not util.system_info()["variant"] in KNOWN_DISTROS:
6af34f
-        return False
6af34f
+    sysconfig = available_sysconfig(target=target)
6af34f
+    nm = available_nm(target=target)
6af34f
+    return util.system_info()["variant"] in KNOWN_DISTROS and any(
6af34f
+        [nm, sysconfig]
6af34f
+    )
6af34f
+
6af34f
 
6af34f
+def available_sysconfig(target=None):
6af34f
     expected = ["ifup", "ifdown"]
6af34f
     search = ["/sbin", "/usr/sbin"]
6af34f
     for p in expected:
6af34f
@@ -1068,4 +1095,10 @@ def available(target=None):
6af34f
     return False
6af34f
 
6af34f
 
6af34f
+def available_nm(target=None):
6af34f
+    if not os.path.isfile(subp.target_path(target, path=NM_CFG_FILE)):
6af34f
+        return False
6af34f
+    return True
6af34f
+
6af34f
+
6af34f
 # vi: ts=4 expandtab
6af34f
diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py
6af34f
index ef21ad76..591241b3 100644
6af34f
--- a/tests/unittests/test_net.py
6af34f
+++ b/tests/unittests/test_net.py
6af34f
@@ -21,7 +21,6 @@ from cloudinit.net import (
6af34f
     interface_has_own_mac,
6af34f
     natural_sort_key,
6af34f
     netplan,
6af34f
-    network_manager,
6af34f
     network_state,
6af34f
     networkd,
6af34f
     renderers,
6af34f
@@ -612,37 +611,6 @@ dns = none
6af34f
                 ),
6af34f
             ),
6af34f
         ],
6af34f
-        "expected_network_manager": [
6af34f
-            (
6af34f
-                "".join(
6af34f
-                    [
6af34f
-                        "etc/NetworkManager/system-connections",
6af34f
-                        "/cloud-init-eth0.nmconnection",
6af34f
-                    ]
6af34f
-                ),
6af34f
-                """
6af34f
-# Generated by cloud-init. Changes will be lost.
6af34f
-
6af34f
-[connection]
6af34f
-id=cloud-init eth0
6af34f
-uuid=1dd9a779-d327-56e1-8454-c65e2556c12c
6af34f
-type=ethernet
6af34f
-
6af34f
-[user]
6af34f
-org.freedesktop.NetworkManager.origin=cloud-init
6af34f
-
6af34f
-[ethernet]
6af34f
-mac-address=FA:16:3E:ED:9A:59
6af34f
-
6af34f
-[ipv4]
6af34f
-method=manual
6af34f
-may-fail=false
6af34f
-address1=172.19.1.34/22
6af34f
-route1=0.0.0.0/0,172.19.3.254
6af34f
-
6af34f
-""".lstrip(),
6af34f
-            ),
6af34f
-        ],
6af34f
     },
6af34f
     {
6af34f
         "in_data": {
6af34f
@@ -1105,50 +1073,6 @@ NETWORK_CONFIGS = {
6af34f
                 USERCTL=no"""
6af34f
             ),
6af34f
         },
6af34f
-        "expected_network_manager": {
6af34f
-            "cloud-init-eth1.nmconnection": textwrap.dedent(
6af34f
-                """\
6af34f
-                # Generated by cloud-init. Changes will be lost.
6af34f
-
6af34f
-                [connection]
6af34f
-                id=cloud-init eth1
6af34f
-                uuid=3c50eb47-7260-5a6d-801d-bd4f587d6b58
6af34f
-                type=ethernet
6af34f
-
6af34f
-                [user]
6af34f
-                org.freedesktop.NetworkManager.origin=cloud-init
6af34f
-
6af34f
-                [ethernet]
6af34f
-                mac-address=CF:D6:AF:48:E8:80
6af34f
-
6af34f
-                """
6af34f
-            ),
6af34f
-            "cloud-init-eth99.nmconnection": textwrap.dedent(
6af34f
-                """\
6af34f
-                # Generated by cloud-init. Changes will be lost.
6af34f
-
6af34f
-                [connection]
6af34f
-                id=cloud-init eth99
6af34f
-                uuid=b1b88000-1f03-5360-8377-1a2205efffb4
6af34f
-                type=ethernet
6af34f
-
6af34f
-                [user]
6af34f
-                org.freedesktop.NetworkManager.origin=cloud-init
6af34f
-
6af34f
-                [ethernet]
6af34f
-                mac-address=C0:D6:9F:2C:E8:80
6af34f
-
6af34f
-                [ipv4]
6af34f
-                method=auto
6af34f
-                may-fail=false
6af34f
-                address1=192.168.21.3/24
6af34f
-                route1=0.0.0.0/0,65.61.151.37
6af34f
-                dns=8.8.8.8;8.8.4.4;
6af34f
-                dns-search=barley.maas;sach.maas;
6af34f
-
6af34f
-                """
6af34f
-            ),
6af34f
-        },
6af34f
         "yaml": textwrap.dedent(
6af34f
             """
6af34f
             version: 1
6af34f
@@ -1221,34 +1145,6 @@ NETWORK_CONFIGS = {
6af34f
                 STARTMODE=auto"""
6af34f
             )
6af34f
         },
6af34f
-        "expected_network_manager": {
6af34f
-            "cloud-init-iface0.nmconnection": textwrap.dedent(
6af34f
-                """\
6af34f
-                # Generated by cloud-init. Changes will be lost.
6af34f
-
6af34f
-                [connection]
6af34f
-                id=cloud-init iface0
6af34f
-                uuid=8ddfba48-857c-5e86-ac09-1b43eae0bf70
6af34f
-                type=ethernet
6af34f
-                interface-name=iface0
6af34f
-
6af34f
-                [user]
6af34f
-                org.freedesktop.NetworkManager.origin=cloud-init
6af34f
-
6af34f
-                [ethernet]
6af34f
-
6af34f
-                [ipv4]
6af34f
-                method=auto
6af34f
-                may-fail=false
6af34f
-
6af34f
-                [ipv6]
6af34f
-                method=dhcp
6af34f
-                may-fail=false
6af34f
-                addr-gen-mode=stable-privacy
6af34f
-
6af34f
-                """
6af34f
-            ),
6af34f
-        },
6af34f
         "yaml": textwrap.dedent(
6af34f
             """\
6af34f
             version: 1
6af34f
@@ -1351,37 +1247,6 @@ NETWORK_CONFIGS = {
6af34f
                 """
6af34f
             ),
6af34f
         },
6af34f
-        "expected_network_manager": {
6af34f
-            "cloud-init-iface0.nmconnection": textwrap.dedent(
6af34f
-                """\
6af34f
-                # Generated by cloud-init. Changes will be lost.
6af34f
-
6af34f
-                [connection]
6af34f
-                id=cloud-init iface0
6af34f
-                uuid=8ddfba48-857c-5e86-ac09-1b43eae0bf70
6af34f
-                type=ethernet
6af34f
-                interface-name=iface0
6af34f
-
6af34f
-                [user]
6af34f
-                org.freedesktop.NetworkManager.origin=cloud-init
6af34f
-
6af34f
-                [ethernet]
6af34f
-                mtu=9000
6af34f
-
6af34f
-                [ipv4]
6af34f
-                method=manual
6af34f
-                may-fail=false
6af34f
-                address1=192.168.14.2/24
6af34f
-
6af34f
-                [ipv6]
6af34f
-                method=manual
6af34f
-                may-fail=false
6af34f
-                addr-gen-mode=stable-privacy
6af34f
-                address1=2001:1::1/64
6af34f
-
6af34f
-                """
6af34f
-            ),
6af34f
-        },
6af34f
     },
6af34f
     "v6_and_v4": {
6af34f
         "expected_sysconfig_opensuse": {
6af34f
@@ -1392,34 +1257,6 @@ NETWORK_CONFIGS = {
6af34f
                 STARTMODE=auto"""
6af34f
             )
6af34f
         },
6af34f
-        "expected_network_manager": {
6af34f
-            "cloud-init-iface0.nmconnection": textwrap.dedent(
6af34f
-                """\
6af34f
-                # Generated by cloud-init. Changes will be lost.
6af34f
-
6af34f
-                [connection]
6af34f
-                id=cloud-init iface0
6af34f
-                uuid=8ddfba48-857c-5e86-ac09-1b43eae0bf70
6af34f
-                type=ethernet
6af34f
-                interface-name=iface0
6af34f
-
6af34f
-                [user]
6af34f
-                org.freedesktop.NetworkManager.origin=cloud-init
6af34f
-
6af34f
-                [ethernet]
6af34f
-
6af34f
-                [ipv6]
6af34f
-                method=dhcp
6af34f
-                may-fail=false
6af34f
-                addr-gen-mode=stable-privacy
6af34f
-
6af34f
-                [ipv4]
6af34f
-                method=auto
6af34f
-                may-fail=false
6af34f
-
6af34f
-                """
6af34f
-            ),
6af34f
-        },
6af34f
         "yaml": textwrap.dedent(
6af34f
             """\
6af34f
             version: 1
6af34f
@@ -1493,30 +1330,6 @@ NETWORK_CONFIGS = {
6af34f
                 """
6af34f
             ),
6af34f
         },
6af34f
-        "expected_network_manager": {
6af34f
-            "cloud-init-iface0.nmconnection": textwrap.dedent(
6af34f
-                """\
6af34f
-                # Generated by cloud-init. Changes will be lost.
6af34f
-
6af34f
-                [connection]
6af34f
-                id=cloud-init iface0
6af34f
-                uuid=8ddfba48-857c-5e86-ac09-1b43eae0bf70
6af34f
-                type=ethernet
6af34f
-                interface-name=iface0
6af34f
-
6af34f
-                [user]
6af34f
-                org.freedesktop.NetworkManager.origin=cloud-init
6af34f
-
6af34f
-                [ethernet]
6af34f
-
6af34f
-                [ipv6]
6af34f
-                method=dhcp
6af34f
-                may-fail=false
6af34f
-                addr-gen-mode=stable-privacy
6af34f
-
6af34f
-                """
6af34f
-            ),
6af34f
-        },
6af34f
     },
6af34f
     "dhcpv6_accept_ra": {
6af34f
         "expected_eni": textwrap.dedent(
6af34f
@@ -1724,30 +1537,6 @@ NETWORK_CONFIGS = {
6af34f
             """
6af34f
             ),
6af34f
         },
6af34f
-        "expected_network_manager": {
6af34f
-            "cloud-init-iface0.nmconnection": textwrap.dedent(
6af34f
-                """\
6af34f
-                # Generated by cloud-init. Changes will be lost.
6af34f
-
6af34f
-                [connection]
6af34f
-                id=cloud-init iface0
6af34f
-                uuid=8ddfba48-857c-5e86-ac09-1b43eae0bf70
6af34f
-                type=ethernet
6af34f
-                interface-name=iface0
6af34f
-
6af34f
-                [user]
6af34f
-                org.freedesktop.NetworkManager.origin=cloud-init
6af34f
-
6af34f
-                [ethernet]
6af34f
-
6af34f
-                [ipv6]
6af34f
-                method=auto
6af34f
-                may-fail=false
6af34f
-                addr-gen-mode=stable-privacy
6af34f
-
6af34f
-                """
6af34f
-            ),
6af34f
-        },
6af34f
     },
6af34f
     "static6": {
6af34f
         "yaml": textwrap.dedent(
6af34f
@@ -1836,30 +1625,6 @@ NETWORK_CONFIGS = {
6af34f
             """
6af34f
             ),
6af34f
         },
6af34f
-        "expected_network_manager": {
6af34f
-            "cloud-init-iface0.nmconnection": textwrap.dedent(
6af34f
-                """\
6af34f
-                # Generated by cloud-init. Changes will be lost.
6af34f
-
6af34f
-                [connection]
6af34f
-                id=cloud-init iface0
6af34f
-                uuid=8ddfba48-857c-5e86-ac09-1b43eae0bf70
6af34f
-                type=ethernet
6af34f
-                interface-name=iface0
6af34f
-
6af34f
-                [user]
6af34f
-                org.freedesktop.NetworkManager.origin=cloud-init
6af34f
-
6af34f
-                [ethernet]
6af34f
-
6af34f
-                [ipv6]
6af34f
-                method=auto
6af34f
-                may-fail=false
6af34f
-                addr-gen-mode=stable-privacy
6af34f
-
6af34f
-                """
6af34f
-            ),
6af34f
-        },
6af34f
     },
6af34f
     "dhcpv6_stateful": {
6af34f
         "expected_eni": textwrap.dedent(
6af34f
@@ -1959,29 +1724,6 @@ NETWORK_CONFIGS = {
6af34f
             """
6af34f
             ),
6af34f
         },
6af34f
-        "expected_network_manager": {
6af34f
-            "cloud-init-iface0.nmconnection": textwrap.dedent(
6af34f
-                """\
6af34f
-                # Generated by cloud-init. Changes will be lost.
6af34f
-
6af34f
-                [connection]
6af34f
-                id=cloud-init iface0
6af34f
-                uuid=8ddfba48-857c-5e86-ac09-1b43eae0bf70
6af34f
-                type=ethernet
6af34f
-                interface-name=iface0
6af34f
-
6af34f
-                [user]
6af34f
-                org.freedesktop.NetworkManager.origin=cloud-init
6af34f
-
6af34f
-                [ethernet]
6af34f
-
6af34f
-                [ipv4]
6af34f
-                method=auto
6af34f
-                may-fail=false
6af34f
-
6af34f
-                """
6af34f
-            ),
6af34f
-        },
6af34f
         "yaml_v2": textwrap.dedent(
6af34f
             """\
6af34f
             version: 2
6af34f
@@ -2035,30 +1777,6 @@ NETWORK_CONFIGS = {
6af34f
             """
6af34f
             ),
6af34f
         },
6af34f
-        "expected_network_manager": {
6af34f
-            "cloud-init-iface0.nmconnection": textwrap.dedent(
6af34f
-                """\
6af34f
-                # Generated by cloud-init. Changes will be lost.
6af34f
-
6af34f
-                [connection]
6af34f
-                id=cloud-init iface0
6af34f
-                uuid=8ddfba48-857c-5e86-ac09-1b43eae0bf70
6af34f
-                type=ethernet
6af34f
-                interface-name=iface0
6af34f
-
6af34f
-                [user]
6af34f
-                org.freedesktop.NetworkManager.origin=cloud-init
6af34f
-
6af34f
-                [ethernet]
6af34f
-                wake-on-lan=64
6af34f
-
6af34f
-                [ipv4]
6af34f
-                method=auto
6af34f
-                may-fail=false
6af34f
-
6af34f
-                """
6af34f
-            ),
6af34f
-        },
6af34f
         "yaml_v2": textwrap.dedent(
6af34f
             """\
6af34f
             version: 2
6af34f
@@ -2497,254 +2215,6 @@ pre-down route del -net 10.0.0.0/8 gw 11.0.0.1 metric 3 || true
6af34f
                 USERCTL=no"""
6af34f
             ),
6af34f
         },
6af34f
-        "expected_network_manager": {
6af34f
-            "cloud-init-eth3.nmconnection": textwrap.dedent(
6af34f
-                """\
6af34f
-                # Generated by cloud-init. Changes will be lost.
6af34f
-
6af34f
-                [connection]
6af34f
-                id=cloud-init eth3
6af34f
-                uuid=b7e95dda-7746-5bf8-bf33-6e5f3c926790
6af34f
-                type=ethernet
6af34f
-                slave-type=bridge
6af34f
-                master=dee46ce4-af7a-5e7c-aa08-b25533ae9213
6af34f
-
6af34f
-                [user]
6af34f
-                org.freedesktop.NetworkManager.origin=cloud-init
6af34f
-
6af34f
-                [ethernet]
6af34f
-                mac-address=66:BB:9F:2C:E8:80
6af34f
-
6af34f
-                """
6af34f
-            ),
6af34f
-            "cloud-init-eth5.nmconnection": textwrap.dedent(
6af34f
-                """\
6af34f
-                # Generated by cloud-init. Changes will be lost.
6af34f
-
6af34f
-                [connection]
6af34f
-                id=cloud-init eth5
6af34f
-                uuid=5fda13c7-9942-5e90-a41b-1d043bd725dc
6af34f
-                type=ethernet
6af34f
-
6af34f
-                [user]
6af34f
-                org.freedesktop.NetworkManager.origin=cloud-init
6af34f
-
6af34f
-                [ethernet]
6af34f
-                mac-address=98:BB:9F:2C:E8:8A
6af34f
-
6af34f
-                [ipv4]
6af34f
-                method=auto
6af34f
-                may-fail=false
6af34f
-
6af34f
-                """
6af34f
-            ),
6af34f
-            "cloud-init-ib0.nmconnection": textwrap.dedent(
6af34f
-                """\
6af34f
-                # Generated by cloud-init. Changes will be lost.
6af34f
-
6af34f
-                [connection]
6af34f
-                id=cloud-init ib0
6af34f
-                uuid=11a1dda7-78b4-5529-beba-d9b5f549ad7b
6af34f
-                type=infiniband
6af34f
-
6af34f
-                [user]
6af34f
-                org.freedesktop.NetworkManager.origin=cloud-init
6af34f
-
6af34f
-                [infiniband]
6af34f
-                transport-mode=datagram
6af34f
-                mtu=9000
6af34f
-                mac-address=A0:00:02:20:FE:80:00:00:00:00:00:00:EC:0D:9A:03:00:15:E2:C1
6af34f
-
6af34f
-                [ipv4]
6af34f
-                method=manual
6af34f
-                may-fail=false
6af34f
-                address1=192.168.200.7/24
6af34f
-
6af34f
-                """
6af34f
-            ),
6af34f
-            "cloud-init-bond0.200.nmconnection": textwrap.dedent(
6af34f
-                """\
6af34f
-                # Generated by cloud-init. Changes will be lost.
6af34f
-
6af34f
-                [connection]
6af34f
-                id=cloud-init bond0.200
6af34f
-                uuid=88984a9c-ff22-5233-9267-86315e0acaa7
6af34f
-                type=vlan
6af34f
-                interface-name=bond0.200
6af34f
-
6af34f
-                [user]
6af34f
-                org.freedesktop.NetworkManager.origin=cloud-init
6af34f
-
6af34f
-                [vlan]
6af34f
-                id=200
6af34f
-                parent=54317911-f840-516b-a10d-82cb4c1f075c
6af34f
-
6af34f
-                [ipv4]
6af34f
-                method=auto
6af34f
-                may-fail=false
6af34f
-
6af34f
-                """
6af34f
-            ),
6af34f
-            "cloud-init-eth0.nmconnection": textwrap.dedent(
6af34f
-                """\
6af34f
-                # Generated by cloud-init. Changes will be lost.
6af34f
-
6af34f
-                [connection]
6af34f
-                id=cloud-init eth0
6af34f
-                uuid=1dd9a779-d327-56e1-8454-c65e2556c12c
6af34f
-                type=ethernet
6af34f
-
6af34f
-                [user]
6af34f
-                org.freedesktop.NetworkManager.origin=cloud-init
6af34f
-
6af34f
-                [ethernet]
6af34f
-                mac-address=C0:D6:9F:2C:E8:80
6af34f
-
6af34f
-                """
6af34f
-            ),
6af34f
-            "cloud-init-eth4.nmconnection": textwrap.dedent(
6af34f
-                """\
6af34f
-                # Generated by cloud-init. Changes will be lost.
6af34f
-
6af34f
-                [connection]
6af34f
-                id=cloud-init eth4
6af34f
-                uuid=e27e4959-fb50-5580-b9a4-2073554627b9
6af34f
-                type=ethernet
6af34f
-                slave-type=bridge
6af34f
-                master=dee46ce4-af7a-5e7c-aa08-b25533ae9213
6af34f
-
6af34f
-                [user]
6af34f
-                org.freedesktop.NetworkManager.origin=cloud-init
6af34f
-
6af34f
-                [ethernet]
6af34f
-                mac-address=98:BB:9F:2C:E8:80
6af34f
-
6af34f
-                """
6af34f
-            ),
6af34f
-            "cloud-init-eth1.nmconnection": textwrap.dedent(
6af34f
-                """\
6af34f
-                # Generated by cloud-init. Changes will be lost.
6af34f
-
6af34f
-                [connection]
6af34f
-                id=cloud-init eth1
6af34f
-                uuid=3c50eb47-7260-5a6d-801d-bd4f587d6b58
6af34f
-                type=ethernet
6af34f
-                slave-type=bond
6af34f
-                master=54317911-f840-516b-a10d-82cb4c1f075c
6af34f
-
6af34f
-                [user]
6af34f
-                org.freedesktop.NetworkManager.origin=cloud-init
6af34f
-
6af34f
-                [ethernet]
6af34f
-                mac-address=AA:D6:9F:2C:E8:80
6af34f
-
6af34f
-                """
6af34f
-            ),
6af34f
-            "cloud-init-br0.nmconnection": textwrap.dedent(
6af34f
-                """\
6af34f
-                # Generated by cloud-init. Changes will be lost.
6af34f
-
6af34f
-                [connection]
6af34f
-                id=cloud-init br0
6af34f
-                uuid=dee46ce4-af7a-5e7c-aa08-b25533ae9213
6af34f
-                type=bridge
6af34f
-                interface-name=br0
6af34f
-
6af34f
-                [user]
6af34f
-                org.freedesktop.NetworkManager.origin=cloud-init
6af34f
-
6af34f
-                [bridge]
6af34f
-                stp=false
6af34f
-                priority=22
6af34f
-                mac-address=BB:BB:BB:BB:BB:AA
6af34f
-
6af34f
-                [ipv4]
6af34f
-                method=manual
6af34f
-                may-fail=false
6af34f
-                address1=192.168.14.2/24
6af34f
-
6af34f
-                [ipv6]
6af34f
-                method=manual
6af34f
-                may-fail=false
6af34f
-                addr-gen-mode=stable-privacy
6af34f
-                address1=2001:1::1/64
6af34f
-                route1=::/0,2001:4800:78ff:1b::1
6af34f
-
6af34f
-                """
6af34f
-            ),
6af34f
-            "cloud-init-eth0.101.nmconnection": textwrap.dedent(
6af34f
-                """\
6af34f
-                # Generated by cloud-init. Changes will be lost.
6af34f
-
6af34f
-                [connection]
6af34f
-                id=cloud-init eth0.101
6af34f
-                uuid=b5acec5e-db80-5935-8b02-0d5619fc42bf
6af34f
-                type=vlan
6af34f
-                interface-name=eth0.101
6af34f
-
6af34f
-                [user]
6af34f
-                org.freedesktop.NetworkManager.origin=cloud-init
6af34f
-
6af34f
-                [vlan]
6af34f
-                id=101
6af34f
-                parent=1dd9a779-d327-56e1-8454-c65e2556c12c
6af34f
-
6af34f
-                [ipv4]
6af34f
-                method=manual
6af34f
-                may-fail=false
6af34f
-                address1=192.168.0.2/24
6af34f
-                gateway=192.168.0.1
6af34f
-                dns=192.168.0.10;10.23.23.134;
6af34f
-                dns-search=barley.maas;sacchromyces.maas;brettanomyces.maas;
6af34f
-                address2=192.168.2.10/24
6af34f
-
6af34f
-                """
6af34f
-            ),
6af34f
-            "cloud-init-bond0.nmconnection": textwrap.dedent(
6af34f
-                """\
6af34f
-                # Generated by cloud-init. Changes will be lost.
6af34f
-
6af34f
-                [connection]
6af34f
-                id=cloud-init bond0
6af34f
-                uuid=54317911-f840-516b-a10d-82cb4c1f075c
6af34f
-                type=bond
6af34f
-                interface-name=bond0
6af34f
-
6af34f
-                [user]
6af34f
-                org.freedesktop.NetworkManager.origin=cloud-init
6af34f
-
6af34f
-                [bond]
6af34f
-                mode=active-backup
6af34f
-                miimon=100
6af34f
-                xmit_hash_policy=layer3+4
6af34f
-
6af34f
-                [ipv6]
6af34f
-                method=dhcp
6af34f
-                may-fail=false
6af34f
-                addr-gen-mode=stable-privacy
6af34f
-
6af34f
-                """
6af34f
-            ),
6af34f
-            "cloud-init-eth2.nmconnection": textwrap.dedent(
6af34f
-                """\
6af34f
-                # Generated by cloud-init. Changes will be lost.
6af34f
-
6af34f
-                [connection]
6af34f
-                id=cloud-init eth2
6af34f
-                uuid=5559a242-3421-5fdd-896e-9cb8313d5804
6af34f
-                type=ethernet
6af34f
-                slave-type=bond
6af34f
-                master=54317911-f840-516b-a10d-82cb4c1f075c
6af34f
-
6af34f
-                [user]
6af34f
-                org.freedesktop.NetworkManager.origin=cloud-init
6af34f
-
6af34f
-                [ethernet]
6af34f
-                mac-address=C0:BB:9F:2C:E8:80
6af34f
-
6af34f
-                """
6af34f
-            ),
6af34f
-        },
6af34f
         "yaml": textwrap.dedent(
6af34f
             """
6af34f
             version: 1
6af34f
@@ -2933,10 +2403,10 @@ pre-down route del -net 10.0.0.0/8 gw 11.0.0.1 metric 3 || true
6af34f
                   - type: static
6af34f
                     address: 2001:1::1/92
6af34f
                     routes:
6af34f
-                        - gateway: 2001:67c:1562::1
6af34f
+                        - gateway: 2001:67c:1562:1
6af34f
                           network: 2001:67c:1
6af34f
                           netmask: "ffff:ffff::"
6af34f
-                        - gateway: 3001:67c:15::1
6af34f
+                        - gateway: 3001:67c:1562:1
6af34f
                           network: 3001:67c:1
6af34f
                           netmask: "ffff:ffff::"
6af34f
                           metric: 10000
6af34f
@@ -2981,10 +2451,10 @@ pre-down route del -net 10.0.0.0/8 gw 11.0.0.1 metric 3 || true
6af34f
                      -   to: 10.1.3.0/24
6af34f
                          via: 192.168.0.3
6af34f
                      -   to: 2001:67c:1/32
6af34f
-                         via: 2001:67c:1562::1
6af34f
+                         via: 2001:67c:1562:1
6af34f
                      -   metric: 10000
6af34f
                          to: 3001:67c:1/32
6af34f
-                         via: 3001:67c:15::1
6af34f
+                         via: 3001:67c:1562:1
6af34f
         """
6af34f
         ),
6af34f
         "expected_eni": textwrap.dedent(
6af34f
@@ -3044,11 +2514,11 @@ iface bond0 inet static
6af34f
 # control-alias bond0
6af34f
 iface bond0 inet6 static
6af34f
     address 2001:1::1/92
6af34f
-    post-up route add -A inet6 2001:67c:1/32 gw 2001:67c:1562::1 || true
6af34f
-    pre-down route del -A inet6 2001:67c:1/32 gw 2001:67c:1562::1 || true
6af34f
-    post-up route add -A inet6 3001:67c:1/32 gw 3001:67c:15::1 metric 10000 \
6af34f
+    post-up route add -A inet6 2001:67c:1/32 gw 2001:67c:1562:1 || true
6af34f
+    pre-down route del -A inet6 2001:67c:1/32 gw 2001:67c:1562:1 || true
6af34f
+    post-up route add -A inet6 3001:67c:1/32 gw 3001:67c:1562:1 metric 10000 \
6af34f
 || true
6af34f
-    pre-down route del -A inet6 3001:67c:1/32 gw 3001:67c:15::1 metric 10000 \
6af34f
+    pre-down route del -A inet6 3001:67c:1/32 gw 3001:67c:1562:1 metric 10000 \
6af34f
 || true
6af34f
         """
6af34f
         ),
6af34f
@@ -3091,8 +2561,8 @@ iface bond0 inet6 static
6af34f
                 -   to: 2001:67c:1562:8007::1/64
6af34f
                     via: 2001:67c:1562:8007::aac:40b2
6af34f
                 -   metric: 10000
6af34f
-                    to: 3001:67c:15:8007::1/64
6af34f
-                    via: 3001:67c:15:8007::aac:40b2
6af34f
+                    to: 3001:67c:1562:8007::1/64
6af34f
+                    via: 3001:67c:1562:8007::aac:40b2
6af34f
             """
6af34f
         ),
6af34f
         "expected_netplan-v2": textwrap.dedent(
6af34f
@@ -3124,8 +2594,8 @@ iface bond0 inet6 static
6af34f
                      -   to: 2001:67c:1562:8007::1/64
6af34f
                          via: 2001:67c:1562:8007::aac:40b2
6af34f
                      -   metric: 10000
6af34f
-                         to: 3001:67c:15:8007::1/64
6af34f
-                         via: 3001:67c:15:8007::aac:40b2
6af34f
+                         to: 3001:67c:1562:8007::1/64
6af34f
+                         via: 3001:67c:1562:8007::aac:40b2
6af34f
              ethernets:
6af34f
                  eth0:
6af34f
                      match:
6af34f
@@ -3224,8 +2694,8 @@ iface bond0 inet6 static
6af34f
                 """\
6af34f
         # Created by cloud-init on instance boot automatically, do not edit.
6af34f
         #
6af34f
-        2001:67c:1/32 via 2001:67c:1562::1  dev bond0
6af34f
-        3001:67c:1/32 via 3001:67c:15::1 metric 10000 dev bond0
6af34f
+        2001:67c:1/32 via 2001:67c:1562:1  dev bond0
6af34f
+        3001:67c:1/32 via 3001:67c:1562:1 metric 10000 dev bond0
6af34f
             """
6af34f
             ),
6af34f
             "route-bond0": textwrap.dedent(
6af34f
@@ -3248,88 +2718,6 @@ iface bond0 inet6 static
6af34f
         """
6af34f
             ),
6af34f
         },
6af34f
-        "expected_network_manager": {
6af34f
-            "cloud-init-bond0s0.nmconnection": textwrap.dedent(
6af34f
-                """\
6af34f
-                # Generated by cloud-init. Changes will be lost.
6af34f
-
6af34f
-                [connection]
6af34f
-                id=cloud-init bond0s0
6af34f
-                uuid=09d0b5b9-67e7-5577-a1af-74d1cf17a71e
6af34f
-                type=ethernet
6af34f
-                slave-type=bond
6af34f
-                master=54317911-f840-516b-a10d-82cb4c1f075c
6af34f
-
6af34f
-                [user]
6af34f
-                org.freedesktop.NetworkManager.origin=cloud-init
6af34f
-
6af34f
-                [ethernet]
6af34f
-                mac-address=AA:BB:CC:DD:E8:00
6af34f
-
6af34f
-                """
6af34f
-            ),
6af34f
-            "cloud-init-bond0s1.nmconnection": textwrap.dedent(
6af34f
-                """\
6af34f
-                # Generated by cloud-init. Changes will be lost.
6af34f
-
6af34f
-                [connection]
6af34f
-                id=cloud-init bond0s1
6af34f
-                uuid=4d9aca96-b515-5630-ad83-d13daac7f9d0
6af34f
-                type=ethernet
6af34f
-                slave-type=bond
6af34f
-                master=54317911-f840-516b-a10d-82cb4c1f075c
6af34f
-
6af34f
-                [user]
6af34f
-                org.freedesktop.NetworkManager.origin=cloud-init
6af34f
-
6af34f
-                [ethernet]
6af34f
-                mac-address=AA:BB:CC:DD:E8:01
6af34f
-
6af34f
-                """
6af34f
-            ),
6af34f
-            "cloud-init-bond0.nmconnection": textwrap.dedent(
6af34f
-                """\
6af34f
-                # Generated by cloud-init. Changes will be lost.
6af34f
-
6af34f
-                [connection]
6af34f
-                id=cloud-init bond0
6af34f
-                uuid=54317911-f840-516b-a10d-82cb4c1f075c
6af34f
-                type=bond
6af34f
-                interface-name=bond0
6af34f
-
6af34f
-                [user]
6af34f
-                org.freedesktop.NetworkManager.origin=cloud-init
6af34f
-
6af34f
-                [bond]
6af34f
-                mode=active-backup
6af34f
-                miimon=100
6af34f
-                xmit_hash_policy=layer3+4
6af34f
-                num_grat_arp=5
6af34f
-                downdelay=10
6af34f
-                updelay=20
6af34f
-                fail_over_mac=active
6af34f
-                primary_reselect=always
6af34f
-                primary=bond0s0
6af34f
-
6af34f
-                [ipv4]
6af34f
-                method=manual
6af34f
-                may-fail=false
6af34f
-                address1=192.168.0.2/24
6af34f
-                gateway=192.168.0.1
6af34f
-                route1=10.1.3.0/24,192.168.0.3
6af34f
-                address2=192.168.1.2/24
6af34f
-
6af34f
-                [ipv6]
6af34f
-                method=manual
6af34f
-                may-fail=false
6af34f
-                addr-gen-mode=stable-privacy
6af34f
-                address1=2001:1::1/92
6af34f
-                route1=2001:67c:1/32,2001:67c:1562::1
6af34f
-                route2=3001:67c:1/32,3001:67c:15::1
6af34f
-
6af34f
-                """
6af34f
-            ),
6af34f
-        },
6af34f
     },
6af34f
     "vlan": {
6af34f
         "yaml": textwrap.dedent(
6af34f
@@ -3413,58 +2801,6 @@ iface bond0 inet6 static
6af34f
                 VLAN=yes"""
6af34f
             ),
6af34f
         },
6af34f
-        "expected_network_manager": {
6af34f
-            "cloud-init-en0.99.nmconnection": textwrap.dedent(
6af34f
-                """\
6af34f
-                # Generated by cloud-init. Changes will be lost.
6af34f
-
6af34f
-                [connection]
6af34f
-                id=cloud-init en0.99
6af34f
-                uuid=f594e2ed-f107-51df-b225-1dc530a5356b
6af34f
-                type=vlan
6af34f
-                interface-name=en0.99
6af34f
-
6af34f
-                [user]
6af34f
-                org.freedesktop.NetworkManager.origin=cloud-init
6af34f
-
6af34f
-                [vlan]
6af34f
-                id=99
6af34f
-                parent=e0ca478b-8d84-52ab-8fae-628482c629b5
6af34f
-
6af34f
-                [ipv4]
6af34f
-                method=manual
6af34f
-                may-fail=false
6af34f
-                address1=192.168.2.2/24
6af34f
-                address2=192.168.1.2/24
6af34f
-                gateway=192.168.1.1
6af34f
-
6af34f
-                [ipv6]
6af34f
-                method=manual
6af34f
-                may-fail=false
6af34f
-                addr-gen-mode=stable-privacy
6af34f
-                address1=2001:1::bbbb/96
6af34f
-                route1=::/0,2001:1::1
6af34f
-
6af34f
-                """
6af34f
-            ),
6af34f
-            "cloud-init-en0.nmconnection": textwrap.dedent(
6af34f
-                """\
6af34f
-                # Generated by cloud-init. Changes will be lost.
6af34f
-
6af34f
-                [connection]
6af34f
-                id=cloud-init en0
6af34f
-                uuid=e0ca478b-8d84-52ab-8fae-628482c629b5
6af34f
-                type=ethernet
6af34f
-
6af34f
-                [user]
6af34f
-                org.freedesktop.NetworkManager.origin=cloud-init
6af34f
-
6af34f
-                [ethernet]
6af34f
-                mac-address=AA:BB:CC:DD:E8:00
6af34f
-
6af34f
-                """
6af34f
-            ),
6af34f
-        },
6af34f
     },
6af34f
     "bridge": {
6af34f
         "yaml": textwrap.dedent(
6af34f
@@ -3573,82 +2909,6 @@ iface bond0 inet6 static
6af34f
                 """
6af34f
             ),
6af34f
         },
6af34f
-        "expected_network_manager": {
6af34f
-            "cloud-init-br0.nmconnection": textwrap.dedent(
6af34f
-                """\
6af34f
-                # Generated by cloud-init. Changes will be lost.
6af34f
-
6af34f
-                [connection]
6af34f
-                id=cloud-init br0
6af34f
-                uuid=dee46ce4-af7a-5e7c-aa08-b25533ae9213
6af34f
-                type=bridge
6af34f
-                interface-name=br0
6af34f
-
6af34f
-                [user]
6af34f
-                org.freedesktop.NetworkManager.origin=cloud-init
6af34f
-
6af34f
-                [bridge]
6af34f
-                stp=false
6af34f
-                priority=22
6af34f
-
6af34f
-                [ipv4]
6af34f
-                method=manual
6af34f
-                may-fail=false
6af34f
-                address1=192.168.2.2/24
6af34f
-
6af34f
-                """
6af34f
-            ),
6af34f
-            "cloud-init-eth0.nmconnection": textwrap.dedent(
6af34f
-                """\
6af34f
-                # Generated by cloud-init. Changes will be lost.
6af34f
-
6af34f
-                [connection]
6af34f
-                id=cloud-init eth0
6af34f
-                uuid=1dd9a779-d327-56e1-8454-c65e2556c12c
6af34f
-                type=ethernet
6af34f
-                slave-type=bridge
6af34f
-                master=dee46ce4-af7a-5e7c-aa08-b25533ae9213
6af34f
-
6af34f
-                [user]
6af34f
-                org.freedesktop.NetworkManager.origin=cloud-init
6af34f
-
6af34f
-                [ethernet]
6af34f
-                mac-address=52:54:00:12:34:00
6af34f
-
6af34f
-                [ipv6]
6af34f
-                method=manual
6af34f
-                may-fail=false
6af34f
-                addr-gen-mode=stable-privacy
6af34f
-                address1=2001:1::100/96
6af34f
-
6af34f
-                """
6af34f
-            ),
6af34f
-            "cloud-init-eth1.nmconnection": textwrap.dedent(
6af34f
-                """\
6af34f
-                # Generated by cloud-init. Changes will be lost.
6af34f
-
6af34f
-                [connection]
6af34f
-                id=cloud-init eth1
6af34f
-                uuid=3c50eb47-7260-5a6d-801d-bd4f587d6b58
6af34f
-                type=ethernet
6af34f
-                slave-type=bridge
6af34f
-                master=dee46ce4-af7a-5e7c-aa08-b25533ae9213
6af34f
-
6af34f
-                [user]
6af34f
-                org.freedesktop.NetworkManager.origin=cloud-init
6af34f
-
6af34f
-                [ethernet]
6af34f
-                mac-address=52:54:00:12:34:01
6af34f
-
6af34f
-                [ipv6]
6af34f
-                method=manual
6af34f
-                may-fail=false
6af34f
-                addr-gen-mode=stable-privacy
6af34f
-                address1=2001:1::101/96
6af34f
-
6af34f
-                """
6af34f
-            ),
6af34f
-        },
6af34f
     },
6af34f
     "manual": {
6af34f
         "yaml": textwrap.dedent(
6af34f
@@ -3777,92 +3037,25 @@ iface bond0 inet6 static
6af34f
                 """
6af34f
             ),
6af34f
         },
6af34f
-        "expected_network_manager": {
6af34f
-            "cloud-init-eth0.nmconnection": textwrap.dedent(
6af34f
-                """\
6af34f
-                # Generated by cloud-init. Changes will be lost.
6af34f
-
6af34f
-                [connection]
6af34f
-                id=cloud-init eth0
6af34f
-                uuid=1dd9a779-d327-56e1-8454-c65e2556c12c
6af34f
-                type=ethernet
6af34f
+    },
6af34f
+}
6af34f
 
6af34f
-                [user]
6af34f
-                org.freedesktop.NetworkManager.origin=cloud-init
6af34f
 
6af34f
-                [ethernet]
6af34f
-                mac-address=52:54:00:12:34:00
6af34f
-
6af34f
-                [ipv4]
6af34f
-                method=manual
6af34f
-                may-fail=false
6af34f
-                address1=192.168.1.2/24
6af34f
-
6af34f
-                """
6af34f
-            ),
6af34f
-            "cloud-init-eth1.nmconnection": textwrap.dedent(
6af34f
-                """\
6af34f
-                # Generated by cloud-init. Changes will be lost.
6af34f
-
6af34f
-                [connection]
6af34f
-                id=cloud-init eth1
6af34f
-                uuid=3c50eb47-7260-5a6d-801d-bd4f587d6b58
6af34f
-                type=ethernet
6af34f
-
6af34f
-                [user]
6af34f
-                org.freedesktop.NetworkManager.origin=cloud-init
6af34f
-
6af34f
-                [ethernet]
6af34f
-                mtu=1480
6af34f
-                mac-address=52:54:00:12:34:AA
6af34f
-
6af34f
-                [ipv4]
6af34f
-                method=auto
6af34f
-                may-fail=true
6af34f
-
6af34f
-                """
6af34f
-            ),
6af34f
-            "cloud-init-eth2.nmconnection": textwrap.dedent(
6af34f
-                """\
6af34f
-                # Generated by cloud-init. Changes will be lost.
6af34f
-
6af34f
-                [connection]
6af34f
-                id=cloud-init eth2
6af34f
-                uuid=5559a242-3421-5fdd-896e-9cb8313d5804
6af34f
-                type=ethernet
6af34f
-
6af34f
-                [user]
6af34f
-                org.freedesktop.NetworkManager.origin=cloud-init
6af34f
-
6af34f
-                [ethernet]
6af34f
-                mac-address=52:54:00:12:34:FF
6af34f
-
6af34f
-                [ipv4]
6af34f
-                method=auto
6af34f
-                may-fail=true
6af34f
-
6af34f
-                """
6af34f
-            ),
6af34f
-        },
6af34f
-    },
6af34f
-}
6af34f
-
6af34f
-
6af34f
-CONFIG_V1_EXPLICIT_LOOPBACK = {
6af34f
-    "version": 1,
6af34f
-    "config": [
6af34f
-        {
6af34f
-            "name": "eth0",
6af34f
-            "type": "physical",
6af34f
-            "subnets": [{"control": "auto", "type": "dhcp"}],
6af34f
-        },
6af34f
-        {
6af34f
-            "name": "lo",
6af34f
-            "type": "loopback",
6af34f
-            "subnets": [{"control": "auto", "type": "loopback"}],
6af34f
-        },
6af34f
-    ],
6af34f
-}
6af34f
+CONFIG_V1_EXPLICIT_LOOPBACK = {
6af34f
+    "version": 1,
6af34f
+    "config": [
6af34f
+        {
6af34f
+            "name": "eth0",
6af34f
+            "type": "physical",
6af34f
+            "subnets": [{"control": "auto", "type": "dhcp"}],
6af34f
+        },
6af34f
+        {
6af34f
+            "name": "lo",
6af34f
+            "type": "loopback",
6af34f
+            "subnets": [{"control": "auto", "type": "loopback"}],
6af34f
+        },
6af34f
+    ],
6af34f
+}
6af34f
 
6af34f
 
6af34f
 CONFIG_V1_SIMPLE_SUBNET = {
6af34f
@@ -4304,6 +3497,7 @@ class TestRhelSysConfigRendering(CiTestCase):
6af34f
 
6af34f
     with_logs = True
6af34f
 
6af34f
+    nm_cfg_file = "/etc/NetworkManager/NetworkManager.conf"
6af34f
     scripts_dir = "/etc/sysconfig/network-scripts"
6af34f
     header = (
6af34f
         "# Created by cloud-init on instance boot automatically, "
6af34f
@@ -4878,6 +4072,78 @@ USERCTL=no
6af34f
         self._compare_files_to_expected(entry[self.expected_name], found)
6af34f
         self._assert_headers(found)
6af34f
 
6af34f
+    def test_check_ifcfg_rh(self):
6af34f
+        """ifcfg-rh plugin is added NetworkManager.conf if conf present."""
6af34f
+        render_dir = self.tmp_dir()
6af34f
+        nm_cfg = subp.target_path(render_dir, path=self.nm_cfg_file)
6af34f
+        util.ensure_dir(os.path.dirname(nm_cfg))
6af34f
+
6af34f
+        # write a template nm.conf, note plugins is a list here
6af34f
+        with open(nm_cfg, "w") as fh:
6af34f
+            fh.write("# test_check_ifcfg_rh\n[main]\nplugins=foo,bar\n")
6af34f
+        self.assertTrue(os.path.exists(nm_cfg))
6af34f
+
6af34f
+        # render and read
6af34f
+        entry = NETWORK_CONFIGS["small"]
6af34f
+        found = self._render_and_read(
6af34f
+            network_config=yaml.load(entry["yaml"]), dir=render_dir
6af34f
+        )
6af34f
+        self._compare_files_to_expected(entry[self.expected_name], found)
6af34f
+        self._assert_headers(found)
6af34f
+
6af34f
+        # check ifcfg-rh is in the 'plugins' list
6af34f
+        config = sysconfig.ConfigObj(nm_cfg)
6af34f
+        self.assertIn("ifcfg-rh", config["main"]["plugins"])
6af34f
+
6af34f
+    def test_check_ifcfg_rh_plugins_string(self):
6af34f
+        """ifcfg-rh plugin is append when plugins is a string."""
6af34f
+        render_dir = self.tmp_path("render")
6af34f
+        os.makedirs(render_dir)
6af34f
+        nm_cfg = subp.target_path(render_dir, path=self.nm_cfg_file)
6af34f
+        util.ensure_dir(os.path.dirname(nm_cfg))
6af34f
+
6af34f
+        # write a template nm.conf, note plugins is a value here
6af34f
+        util.write_file(nm_cfg, "# test_check_ifcfg_rh\n[main]\nplugins=foo\n")
6af34f
+
6af34f
+        # render and read
6af34f
+        entry = NETWORK_CONFIGS["small"]
6af34f
+        found = self._render_and_read(
6af34f
+            network_config=yaml.load(entry["yaml"]), dir=render_dir
6af34f
+        )
6af34f
+        self._compare_files_to_expected(entry[self.expected_name], found)
6af34f
+        self._assert_headers(found)
6af34f
+
6af34f
+        # check raw content has plugin
6af34f
+        nm_file_content = util.load_file(nm_cfg)
6af34f
+        self.assertIn("ifcfg-rh", nm_file_content)
6af34f
+
6af34f
+        # check ifcfg-rh is in the 'plugins' list
6af34f
+        config = sysconfig.ConfigObj(nm_cfg)
6af34f
+        self.assertIn("ifcfg-rh", config["main"]["plugins"])
6af34f
+
6af34f
+    def test_check_ifcfg_rh_plugins_no_plugins(self):
6af34f
+        """enable_ifcfg_plugin creates plugins value if missing."""
6af34f
+        render_dir = self.tmp_path("render")
6af34f
+        os.makedirs(render_dir)
6af34f
+        nm_cfg = subp.target_path(render_dir, path=self.nm_cfg_file)
6af34f
+        util.ensure_dir(os.path.dirname(nm_cfg))
6af34f
+
6af34f
+        # write a template nm.conf, note plugins is missing
6af34f
+        util.write_file(nm_cfg, "# test_check_ifcfg_rh\n[main]\n")
6af34f
+        self.assertTrue(os.path.exists(nm_cfg))
6af34f
+
6af34f
+        # render and read
6af34f
+        entry = NETWORK_CONFIGS["small"]
6af34f
+        found = self._render_and_read(
6af34f
+            network_config=yaml.load(entry["yaml"]), dir=render_dir
6af34f
+        )
6af34f
+        self._compare_files_to_expected(entry[self.expected_name], found)
6af34f
+        self._assert_headers(found)
6af34f
+
6af34f
+        # check ifcfg-rh is in the 'plugins' list
6af34f
+        config = sysconfig.ConfigObj(nm_cfg)
6af34f
+        self.assertIn("ifcfg-rh", config["main"]["plugins"])
6af34f
+
6af34f
     def test_netplan_dhcp_false_disable_dhcp_in_state(self):
6af34f
         """netplan config with dhcp[46]: False should not add dhcp in state"""
6af34f
         net_config = yaml.load(NETPLAN_DHCP_FALSE)
6af34f
@@ -5433,281 +4699,6 @@ STARTMODE=auto
6af34f
         self._assert_headers(found)
6af34f
 
6af34f
 
6af34f
-@mock.patch(
6af34f
-    "cloudinit.net.is_openvswitch_internal_interface",
6af34f
-    mock.Mock(return_value=False),
6af34f
-)
6af34f
-class TestNetworkManagerRendering(CiTestCase):
6af34f
-
6af34f
-    with_logs = True
6af34f
-
6af34f
-    scripts_dir = "/etc/NetworkManager/system-connections"
6af34f
-
6af34f
-    expected_name = "expected_network_manager"
6af34f
-
6af34f
-    def _get_renderer(self):
6af34f
-        return network_manager.Renderer()
6af34f
-
6af34f
-    def _render_and_read(self, network_config=None, state=None, dir=None):
6af34f
-        if dir is None:
6af34f
-            dir = self.tmp_dir()
6af34f
-
6af34f
-        if network_config:
6af34f
-            ns = network_state.parse_net_config_data(network_config)
6af34f
-        elif state:
6af34f
-            ns = state
6af34f
-        else:
6af34f
-            raise ValueError("Expected data or state, got neither")
6af34f
-
6af34f
-        renderer = self._get_renderer()
6af34f
-        renderer.render_network_state(ns, target=dir)
6af34f
-        return dir2dict(dir)
6af34f
-
6af34f
-    def _compare_files_to_expected(self, expected, found):
6af34f
-        orig_maxdiff = self.maxDiff
6af34f
-        expected_d = dict(
6af34f
-            (os.path.join(self.scripts_dir, k), v) for k, v in expected.items()
6af34f
-        )
6af34f
-
6af34f
-        try:
6af34f
-            self.maxDiff = None
6af34f
-            self.assertEqual(expected_d, found)
6af34f
-        finally:
6af34f
-            self.maxDiff = orig_maxdiff
6af34f
-
6af34f
-    @mock.patch("cloudinit.net.util.get_cmdline", return_value="root=myroot")
6af34f
-    @mock.patch("cloudinit.net.sys_dev_path")
6af34f
-    @mock.patch("cloudinit.net.read_sys_net")
6af34f
-    @mock.patch("cloudinit.net.get_devicelist")
6af34f
-    def test_default_generation(
6af34f
-        self,
6af34f
-        mock_get_devicelist,
6af34f
-        mock_read_sys_net,
6af34f
-        mock_sys_dev_path,
6af34f
-        m_get_cmdline,
6af34f
-    ):
6af34f
-        tmp_dir = self.tmp_dir()
6af34f
-        _setup_test(
6af34f
-            tmp_dir, mock_get_devicelist, mock_read_sys_net, mock_sys_dev_path
6af34f
-        )
6af34f
-
6af34f
-        network_cfg = net.generate_fallback_config()
6af34f
-        ns = network_state.parse_net_config_data(
6af34f
-            network_cfg, skip_broken=False
6af34f
-        )
6af34f
-
6af34f
-        render_dir = os.path.join(tmp_dir, "render")
6af34f
-        os.makedirs(render_dir)
6af34f
-
6af34f
-        renderer = self._get_renderer()
6af34f
-        renderer.render_network_state(ns, target=render_dir)
6af34f
-
6af34f
-        found = dir2dict(render_dir)
6af34f
-        self._compare_files_to_expected(
6af34f
-            {
6af34f
-                "cloud-init-eth1000.nmconnection": textwrap.dedent(
6af34f
-                    """\
6af34f
-                # Generated by cloud-init. Changes will be lost.
6af34f
-
6af34f
-                [connection]
6af34f
-                id=cloud-init eth1000
6af34f
-                uuid=8c517500-0c95-5308-9c8a-3092eebc44eb
6af34f
-                type=ethernet
6af34f
-
6af34f
-                [user]
6af34f
-                org.freedesktop.NetworkManager.origin=cloud-init
6af34f
-
6af34f
-                [ethernet]
6af34f
-                mac-address=07:1C:C6:75:A4:BE
6af34f
-
6af34f
-                [ipv4]
6af34f
-                method=auto
6af34f
-                may-fail=false
6af34f
-
6af34f
-                """
6af34f
-                ),
6af34f
-            },
6af34f
-            found,
6af34f
-        )
6af34f
-
6af34f
-    def test_openstack_rendering_samples(self):
6af34f
-        for os_sample in OS_SAMPLES:
6af34f
-            render_dir = self.tmp_dir()
6af34f
-            ex_input = os_sample["in_data"]
6af34f
-            ex_mac_addrs = os_sample["in_macs"]
6af34f
-            network_cfg = openstack.convert_net_json(
6af34f
-                ex_input, known_macs=ex_mac_addrs
6af34f
-            )
6af34f
-            ns = network_state.parse_net_config_data(
6af34f
-                network_cfg, skip_broken=False
6af34f
-            )
6af34f
-            renderer = self._get_renderer()
6af34f
-            # render a multiple times to simulate reboots
6af34f
-            renderer.render_network_state(ns, target=render_dir)
6af34f
-            renderer.render_network_state(ns, target=render_dir)
6af34f
-            renderer.render_network_state(ns, target=render_dir)
6af34f
-            for fn, expected_content in os_sample.get(self.expected_name, []):
6af34f
-                with open(os.path.join(render_dir, fn)) as fh:
6af34f
-                    self.assertEqual(expected_content, fh.read())
6af34f
-
6af34f
-    def test_network_config_v1_samples(self):
6af34f
-        ns = network_state.parse_net_config_data(CONFIG_V1_SIMPLE_SUBNET)
6af34f
-        render_dir = self.tmp_path("render")
6af34f
-        os.makedirs(render_dir)
6af34f
-        renderer = self._get_renderer()
6af34f
-        renderer.render_network_state(ns, target=render_dir)
6af34f
-        found = dir2dict(render_dir)
6af34f
-        self._compare_files_to_expected(
6af34f
-            {
6af34f
-                "cloud-init-interface0.nmconnection": textwrap.dedent(
6af34f
-                    """\
6af34f
-                # Generated by cloud-init. Changes will be lost.
6af34f
-
6af34f
-                [connection]
6af34f
-                id=cloud-init interface0
6af34f
-                uuid=8b6862ed-dbd6-5830-93f7-a91451c13828
6af34f
-                type=ethernet
6af34f
-
6af34f
-                [user]
6af34f
-                org.freedesktop.NetworkManager.origin=cloud-init
6af34f
-
6af34f
-                [ethernet]
6af34f
-                mac-address=52:54:00:12:34:00
6af34f
-
6af34f
-                [ipv4]
6af34f
-                method=manual
6af34f
-                may-fail=false
6af34f
-                address1=10.0.2.15/24
6af34f
-                gateway=10.0.2.2
6af34f
-
6af34f
-                """
6af34f
-                ),
6af34f
-            },
6af34f
-            found,
6af34f
-        )
6af34f
-
6af34f
-    def test_config_with_explicit_loopback(self):
6af34f
-        render_dir = self.tmp_path("render")
6af34f
-        os.makedirs(render_dir)
6af34f
-        ns = network_state.parse_net_config_data(CONFIG_V1_EXPLICIT_LOOPBACK)
6af34f
-        renderer = self._get_renderer()
6af34f
-        renderer.render_network_state(ns, target=render_dir)
6af34f
-        found = dir2dict(render_dir)
6af34f
-        self._compare_files_to_expected(
6af34f
-            {
6af34f
-                "cloud-init-eth0.nmconnection": textwrap.dedent(
6af34f
-                    """\
6af34f
-                # Generated by cloud-init. Changes will be lost.
6af34f
-
6af34f
-                [connection]
6af34f
-                id=cloud-init eth0
6af34f
-                uuid=1dd9a779-d327-56e1-8454-c65e2556c12c
6af34f
-                type=ethernet
6af34f
-                interface-name=eth0
6af34f
-
6af34f
-                [user]
6af34f
-                org.freedesktop.NetworkManager.origin=cloud-init
6af34f
-
6af34f
-                [ethernet]
6af34f
-
6af34f
-                [ipv4]
6af34f
-                method=auto
6af34f
-                may-fail=false
6af34f
-
6af34f
-                """
6af34f
-                ),
6af34f
-            },
6af34f
-            found,
6af34f
-        )
6af34f
-
6af34f
-    def test_bond_config(self):
6af34f
-        entry = NETWORK_CONFIGS["bond"]
6af34f
-        found = self._render_and_read(network_config=yaml.load(entry["yaml"]))
6af34f
-        self._compare_files_to_expected(entry[self.expected_name], found)
6af34f
-
6af34f
-    def test_vlan_config(self):
6af34f
-        entry = NETWORK_CONFIGS["vlan"]
6af34f
-        found = self._render_and_read(network_config=yaml.load(entry["yaml"]))
6af34f
-        self._compare_files_to_expected(entry[self.expected_name], found)
6af34f
-
6af34f
-    def test_bridge_config(self):
6af34f
-        entry = NETWORK_CONFIGS["bridge"]
6af34f
-        found = self._render_and_read(network_config=yaml.load(entry["yaml"]))
6af34f
-        self._compare_files_to_expected(entry[self.expected_name], found)
6af34f
-
6af34f
-    def test_manual_config(self):
6af34f
-        entry = NETWORK_CONFIGS["manual"]
6af34f
-        found = self._render_and_read(network_config=yaml.load(entry["yaml"]))
6af34f
-        self._compare_files_to_expected(entry[self.expected_name], found)
6af34f
-
6af34f
-    def test_all_config(self):
6af34f
-        entry = NETWORK_CONFIGS["all"]
6af34f
-        found = self._render_and_read(network_config=yaml.load(entry["yaml"]))
6af34f
-        self._compare_files_to_expected(entry[self.expected_name], found)
6af34f
-        self.assertNotIn(
6af34f
-            "WARNING: Network config: ignoring eth0.101 device-level mtu",
6af34f
-            self.logs.getvalue(),
6af34f
-        )
6af34f
-
6af34f
-    def test_small_config(self):
6af34f
-        entry = NETWORK_CONFIGS["small"]
6af34f
-        found = self._render_and_read(network_config=yaml.load(entry["yaml"]))
6af34f
-        self._compare_files_to_expected(entry[self.expected_name], found)
6af34f
-
6af34f
-    def test_v4_and_v6_static_config(self):
6af34f
-        entry = NETWORK_CONFIGS["v4_and_v6_static"]
6af34f
-        found = self._render_and_read(network_config=yaml.load(entry["yaml"]))
6af34f
-        self._compare_files_to_expected(entry[self.expected_name], found)
6af34f
-        expected_msg = (
6af34f
-            "WARNING: Network config: ignoring iface0 device-level mtu:8999"
6af34f
-            " because ipv4 subnet-level mtu:9000 provided."
6af34f
-        )
6af34f
-        self.assertIn(expected_msg, self.logs.getvalue())
6af34f
-
6af34f
-    def test_dhcpv6_only_config(self):
6af34f
-        entry = NETWORK_CONFIGS["dhcpv6_only"]
6af34f
-        found = self._render_and_read(network_config=yaml.load(entry["yaml"]))
6af34f
-        self._compare_files_to_expected(entry[self.expected_name], found)
6af34f
-
6af34f
-    def test_simple_render_ipv6_slaac(self):
6af34f
-        entry = NETWORK_CONFIGS["ipv6_slaac"]
6af34f
-        found = self._render_and_read(network_config=yaml.load(entry["yaml"]))
6af34f
-        self._compare_files_to_expected(entry[self.expected_name], found)
6af34f
-
6af34f
-    def test_dhcpv6_stateless_config(self):
6af34f
-        entry = NETWORK_CONFIGS["dhcpv6_stateless"]
6af34f
-        found = self._render_and_read(network_config=yaml.load(entry["yaml"]))
6af34f
-        self._compare_files_to_expected(entry[self.expected_name], found)
6af34f
-
6af34f
-    def test_wakeonlan_disabled_config_v2(self):
6af34f
-        entry = NETWORK_CONFIGS["wakeonlan_disabled"]
6af34f
-        found = self._render_and_read(
6af34f
-            network_config=yaml.load(entry["yaml_v2"])
6af34f
-        )
6af34f
-        self._compare_files_to_expected(entry[self.expected_name], found)
6af34f
-
6af34f
-    def test_wakeonlan_enabled_config_v2(self):
6af34f
-        entry = NETWORK_CONFIGS["wakeonlan_enabled"]
6af34f
-        found = self._render_and_read(
6af34f
-            network_config=yaml.load(entry["yaml_v2"])
6af34f
-        )
6af34f
-        self._compare_files_to_expected(entry[self.expected_name], found)
6af34f
-
6af34f
-    def test_render_v4_and_v6(self):
6af34f
-        entry = NETWORK_CONFIGS["v4_and_v6"]
6af34f
-        found = self._render_and_read(network_config=yaml.load(entry["yaml"]))
6af34f
-        self._compare_files_to_expected(entry[self.expected_name], found)
6af34f
-
6af34f
-    def test_render_v6_and_v4(self):
6af34f
-        entry = NETWORK_CONFIGS["v6_and_v4"]
6af34f
-        found = self._render_and_read(network_config=yaml.load(entry["yaml"]))
6af34f
-        self._compare_files_to_expected(entry[self.expected_name], found)
6af34f
-
6af34f
-
6af34f
-@mock.patch(
6af34f
-    "cloudinit.net.is_openvswitch_internal_interface",
6af34f
-    mock.Mock(return_value=False),
6af34f
-)
6af34f
 class TestEniNetRendering(CiTestCase):
6af34f
     @mock.patch("cloudinit.net.util.get_cmdline", return_value="root=myroot")
6af34f
     @mock.patch("cloudinit.net.sys_dev_path")
6af34f
@@ -7145,9 +6136,9 @@ class TestNetworkdRoundTrip(CiTestCase):
6af34f
 
6af34f
 class TestRenderersSelect:
6af34f
     @pytest.mark.parametrize(
6af34f
-        "renderer_selected,netplan,eni,sys,network_manager,networkd",
6af34f
+        "renderer_selected,netplan,eni,nm,scfg,sys,networkd",
6af34f
         (
6af34f
-            # -netplan -ifupdown -sys -network-manager -networkd raises error
6af34f
+            # -netplan -ifupdown -nm -scfg -sys raises error
6af34f
             (
6af34f
                 net.RendererNotFoundError,
6af34f
                 False,
6af34f
@@ -7155,51 +6146,52 @@ class TestRenderersSelect:
6af34f
                 False,
6af34f
                 False,
6af34f
                 False,
6af34f
+                False,
6af34f
             ),
6af34f
-            # -netplan +ifupdown -sys -nm -networkd selects eni
6af34f
-            ("eni", False, True, False, False, False),
6af34f
-            # +netplan +ifupdown -sys -nm -networkd selects eni
6af34f
-            ("eni", True, True, False, False, False),
6af34f
-            # +netplan -ifupdown -sys -nm -networkd selects netplan
6af34f
-            ("netplan", True, False, False, False, False),
6af34f
-            # +netplan -ifupdown -sys -nm -networkd selects netplan
6af34f
-            ("netplan", True, False, False, False, False),
6af34f
-            # -netplan -ifupdown +sys -nm -networkd selects sysconfig
6af34f
-            ("sysconfig", False, False, True, False, False),
6af34f
-            # -netplan -ifupdown +sys +nm -networkd selects sysconfig
6af34f
-            ("sysconfig", False, False, True, True, False),
6af34f
-            # -netplan -ifupdown -sys +nm -networkd selects nm
6af34f
-            ("network-manager", False, False, False, True, False),
6af34f
-            # -netplan -ifupdown -sys +nm +networkd selects nm
6af34f
-            ("network-manager", False, False, False, True, True),
6af34f
-            # -netplan -ifupdown -sys -nm +networkd selects networkd
6af34f
-            ("networkd", False, False, False, False, True),
6af34f
+            # -netplan +ifupdown -nm -scfg -sys selects eni
6af34f
+            ("eni", False, True, False, False, False, False),
6af34f
+            # +netplan +ifupdown -nm -scfg -sys selects eni
6af34f
+            ("eni", True, True, False, False, False, False),
6af34f
+            # +netplan -ifupdown -nm -scfg -sys selects netplan
6af34f
+            ("netplan", True, False, False, False, False, False),
6af34f
+            # Ubuntu with Network-Manager installed
6af34f
+            # +netplan -ifupdown +nm -scfg -sys selects netplan
6af34f
+            ("netplan", True, False, True, False, False, False),
6af34f
+            # Centos/OpenSuse with Network-Manager installed selects sysconfig
6af34f
+            # -netplan -ifupdown +nm -scfg +sys selects netplan
6af34f
+            ("sysconfig", False, False, True, False, True, False),
6af34f
+            # -netplan -ifupdown -nm -scfg -sys +networkd selects networkd
6af34f
+            ("networkd", False, False, False, False, False, True),
6af34f
         ),
6af34f
     )
6af34f
     @mock.patch("cloudinit.net.renderers.networkd.available")
6af34f
-    @mock.patch("cloudinit.net.renderers.network_manager.available")
6af34f
     @mock.patch("cloudinit.net.renderers.netplan.available")
6af34f
     @mock.patch("cloudinit.net.renderers.sysconfig.available")
6af34f
+    @mock.patch("cloudinit.net.renderers.sysconfig.available_sysconfig")
6af34f
+    @mock.patch("cloudinit.net.renderers.sysconfig.available_nm")
6af34f
     @mock.patch("cloudinit.net.renderers.eni.available")
6af34f
     def test_valid_renderer_from_defaults_depending_on_availability(
6af34f
         self,
6af34f
         m_eni_avail,
6af34f
+        m_nm_avail,
6af34f
+        m_scfg_avail,
6af34f
         m_sys_avail,
6af34f
         m_netplan_avail,
6af34f
-        m_network_manager_avail,
6af34f
         m_networkd_avail,
6af34f
         renderer_selected,
6af34f
         netplan,
6af34f
         eni,
6af34f
+        nm,
6af34f
+        scfg,
6af34f
         sys,
6af34f
-        network_manager,
6af34f
         networkd,
6af34f
     ):
6af34f
         """Assert proper renderer per DEFAULT_PRIORITY given availability."""
6af34f
         m_eni_avail.return_value = eni  # ifupdown pkg presence
6af34f
+        m_nm_avail.return_value = nm  # network-manager presence
6af34f
+        m_scfg_avail.return_value = scfg  # sysconfig presence
6af34f
         m_sys_avail.return_value = sys  # sysconfig/ifup/down presence
6af34f
         m_netplan_avail.return_value = netplan  # netplan presence
6af34f
-        m_network_manager_avail.return_value = network_manager  # NM presence
6af34f
         m_networkd_avail.return_value = networkd  # networkd presence
6af34f
         if isinstance(renderer_selected, str):
6af34f
             (renderer_name, _rnd_class) = renderers.select(
6af34f
@@ -7257,7 +6249,7 @@ class TestNetRenderers(CiTestCase):
6af34f
             priority=["sysconfig", "eni"],
6af34f
         )
6af34f
 
6af34f
-    @mock.patch("cloudinit.net.sysconfig.available")
6af34f
+    @mock.patch("cloudinit.net.sysconfig.available_sysconfig")
6af34f
     @mock.patch("cloudinit.util.system_info")
6af34f
     def test_sysconfig_available_uses_variant_mapping(self, m_info, m_avail):
6af34f
         m_avail.return_value = True
6af34f
diff --git a/tests/unittests/test_net_activators.py b/tests/unittests/test_net_activators.py
6af34f
index 4525c49c..3c29e2f7 100644
6af34f
--- a/tests/unittests/test_net_activators.py
6af34f
+++ b/tests/unittests/test_net_activators.py
6af34f
@@ -41,20 +41,18 @@ NETPLAN_CALL_LIST = [
6af34f
 
6af34f
 @pytest.fixture
6af34f
 def available_mocks():
6af34f
-    mocks = namedtuple("Mocks", "m_which, m_file, m_exists")
6af34f
+    mocks = namedtuple("Mocks", "m_which, m_file")
6af34f
     with patch("cloudinit.subp.which", return_value=True) as m_which:
6af34f
         with patch("os.path.isfile", return_value=True) as m_file:
6af34f
-            with patch("os.path.exists", return_value=True) as m_exists:
6af34f
-                yield mocks(m_which, m_file, m_exists)
6af34f
+            yield mocks(m_which, m_file)
6af34f
 
6af34f
 
6af34f
 @pytest.fixture
6af34f
 def unavailable_mocks():
6af34f
-    mocks = namedtuple("Mocks", "m_which, m_file, m_exists")
6af34f
+    mocks = namedtuple("Mocks", "m_which, m_file")
6af34f
     with patch("cloudinit.subp.which", return_value=False) as m_which:
6af34f
         with patch("os.path.isfile", return_value=False) as m_file:
6af34f
-            with patch("os.path.exists", return_value=False) as m_exists:
6af34f
-                yield mocks(m_which, m_file, m_exists)
6af34f
+            yield mocks(m_which, m_file)
6af34f
 
6af34f
 
6af34f
 class TestSearchAndSelect:
6af34f
@@ -115,6 +113,10 @@ NETPLAN_AVAILABLE_CALLS = [
6af34f
     (("netplan",), {"search": ["/usr/sbin", "/sbin"], "target": None}),
6af34f
 ]
6af34f
 
6af34f
+NETWORK_MANAGER_AVAILABLE_CALLS = [
6af34f
+    (("nmcli",), {"target": None}),
6af34f
+]
6af34f
+
6af34f
 NETWORKD_AVAILABLE_CALLS = [
6af34f
     (("ip",), {"search": ["/usr/sbin", "/bin"], "target": None}),
6af34f
     (("systemctl",), {"search": ["/usr/sbin", "/bin"], "target": None}),
6af34f
@@ -126,6 +128,7 @@ NETWORKD_AVAILABLE_CALLS = [
6af34f
     [
6af34f
         (IfUpDownActivator, IF_UP_DOWN_AVAILABLE_CALLS),
6af34f
         (NetplanActivator, NETPLAN_AVAILABLE_CALLS),
6af34f
+        (NetworkManagerActivator, NETWORK_MANAGER_AVAILABLE_CALLS),
6af34f
         (NetworkdActivator, NETWORKD_AVAILABLE_CALLS),
6af34f
     ],
6af34f
 )
6af34f
@@ -141,72 +144,8 @@ IF_UP_DOWN_BRING_UP_CALL_LIST = [
6af34f
 ]
6af34f
 
6af34f
 NETWORK_MANAGER_BRING_UP_CALL_LIST = [
6af34f
-    (
6af34f
-        (
6af34f
-            [
6af34f
-                "nmcli",
6af34f
-                "connection",
6af34f
-                "load",
6af34f
-                "".join(
6af34f
-                    [
6af34f
-                        "/etc/NetworkManager/system-connections",
6af34f
-                        "/cloud-init-eth0.nmconnection",
6af34f
-                    ]
6af34f
-                ),
6af34f
-            ],
6af34f
-        ),
6af34f
-        {},
6af34f
-    ),
6af34f
-    (
6af34f
-        (
6af34f
-            [
6af34f
-                "nmcli",
6af34f
-                "connection",
6af34f
-                "up",
6af34f
-                "filename",
6af34f
-                "".join(
6af34f
-                    [
6af34f
-                        "/etc/NetworkManager/system-connections",
6af34f
-                        "/cloud-init-eth0.nmconnection",
6af34f
-                    ]
6af34f
-                ),
6af34f
-            ],
6af34f
-        ),
6af34f
-        {},
6af34f
-    ),
6af34f
-    (
6af34f
-        (
6af34f
-            [
6af34f
-                "nmcli",
6af34f
-                "connection",
6af34f
-                "load",
6af34f
-                "".join(
6af34f
-                    [
6af34f
-                        "/etc/NetworkManager/system-connections",
6af34f
-                        "/cloud-init-eth1.nmconnection",
6af34f
-                    ]
6af34f
-                ),
6af34f
-            ],
6af34f
-        ),
6af34f
-        {},
6af34f
-    ),
6af34f
-    (
6af34f
-        (
6af34f
-            [
6af34f
-                "nmcli",
6af34f
-                "connection",
6af34f
-                "up",
6af34f
-                "filename",
6af34f
-                "".join(
6af34f
-                    [
6af34f
-                        "/etc/NetworkManager/system-connections",
6af34f
-                        "/cloud-init-eth1.nmconnection",
6af34f
-                    ]
6af34f
-                ),
6af34f
-            ],
6af34f
-        ),
6af34f
-        {},
6af34f
-    ),
6af34f
+    ((["nmcli", "connection", "up", "ifname", "eth0"],), {}),
6af34f
+    ((["nmcli", "connection", "up", "ifname", "eth1"],), {}),
6af34f
 ]
6af34f
 
6af34f
 NETWORKD_BRING_UP_CALL_LIST = [
6af34f
@@ -230,11 +169,9 @@ class TestActivatorsBringUp:
6af34f
     def test_bring_up_interface(
6af34f
         self, m_subp, activator, expected_call_list, available_mocks
6af34f
     ):
6af34f
-        index = 0
6af34f
         activator.bring_up_interface("eth0")
6af34f
-        for call in m_subp.call_args_list:
6af34f
-            assert call == expected_call_list[index]
6af34f
-            index += 1
6af34f
+        assert len(m_subp.call_args_list) == 1
6af34f
+        assert m_subp.call_args_list[0] == expected_call_list[0]
6af34f
 
6af34f
     @patch("cloudinit.subp.subp", return_value=("", ""))
6af34f
     def test_bring_up_interfaces(
6af34f
@@ -271,8 +208,8 @@ IF_UP_DOWN_BRING_DOWN_CALL_LIST = [
6af34f
 ]
6af34f
 
6af34f
 NETWORK_MANAGER_BRING_DOWN_CALL_LIST = [
6af34f
-    ((["nmcli", "device", "disconnect", "eth0"],), {}),
6af34f
-    ((["nmcli", "device", "disconnect", "eth1"],), {}),
6af34f
+    ((["nmcli", "connection", "down", "eth0"],), {}),
6af34f
+    ((["nmcli", "connection", "down", "eth1"],), {}),
6af34f
 ]
6af34f
 
6af34f
 NETWORKD_BRING_DOWN_CALL_LIST = [
6af34f
-- 
6af34f
2.27.0
6af34f