summaryrefslogtreecommitdiffstats
path: root/os_net_config
diff options
context:
space:
mode:
Diffstat (limited to 'os_net_config')
-rw-r--r--os_net_config/impl_ifcfg.py5
-rw-r--r--os_net_config/objects.py142
-rw-r--r--os_net_config/tests/test_impl_ifcfg.py36
3 files changed, 124 insertions, 59 deletions
diff --git a/os_net_config/impl_ifcfg.py b/os_net_config/impl_ifcfg.py
index 84a5139..cf3b257 100644
--- a/os_net_config/impl_ifcfg.py
+++ b/os_net_config/impl_ifcfg.py
@@ -142,7 +142,10 @@ class IfcfgNetConfig(os_net_config.NetConfig):
data += "HOTPLUG=yes\n"
else:
data += "HOTPLUG=no\n"
- data += "NM_CONTROLLED=no\n"
+ if base_opt.nm_controlled:
+ data += "NM_CONTROLLED=yes\n"
+ else:
+ data += "NM_CONTROLLED=no\n"
if not base_opt.dns_servers and not base_opt.use_dhcp:
data += "PEERDNS=no\n"
if isinstance(base_opt, objects.Vlan):
diff --git a/os_net_config/objects.py b/os_net_config/objects.py
index 3136be0..944aecd 100644
--- a/os_net_config/objects.py
+++ b/os_net_config/objects.py
@@ -181,7 +181,7 @@ class _BaseOpts(object):
def __init__(self, name, use_dhcp=False, use_dhcpv6=False, addresses=None,
routes=None, mtu=None, primary=False, nic_mapping=None,
persist_mapping=False, defroute=True, dhclient_args=None,
- dns_servers=None):
+ dns_servers=None, nm_controlled=False):
addresses = addresses or []
routes = routes or []
dns_servers = dns_servers or []
@@ -209,6 +209,7 @@ class _BaseOpts(object):
self.defroute = defroute
self.dhclient_args = dhclient_args
self.dns_servers = dns_servers
+ self.nm_controlled = nm_controlled
self.bridge_name = None # internal
self.linux_bridge_name = None # internal
self.ivs_bridge_name = None # internal
@@ -244,6 +245,7 @@ class _BaseOpts(object):
mtu = json.get('mtu', None)
dhclient_args = json.get('dhclient_args')
dns_servers = json.get('dns_servers')
+ nm_controlled = json.get('nm_controlled')
primary = strutils.bool_from_string(str(json.get('primary', False)))
addresses = []
routes = []
@@ -274,11 +276,11 @@ class _BaseOpts(object):
if include_primary:
return (use_dhcp, use_dhcpv6, addresses, routes, mtu, primary,
nic_mapping, persist_mapping, defroute, dhclient_args,
- dns_servers)
+ dns_servers, nm_controlled)
else:
return (use_dhcp, use_dhcpv6, addresses, routes, mtu,
nic_mapping, persist_mapping, defroute, dhclient_args,
- dns_servers)
+ dns_servers, nm_controlled)
class Interface(_BaseOpts):
@@ -287,14 +289,16 @@ class Interface(_BaseOpts):
def __init__(self, name, use_dhcp=False, use_dhcpv6=False, addresses=None,
routes=None, mtu=None, primary=False, nic_mapping=None,
persist_mapping=False, defroute=True, dhclient_args=None,
- dns_servers=None, ethtool_opts=None, hotplug=False):
+ dns_servers=None, nm_controlled=False, ethtool_opts=None,
+ hotplug=False):
addresses = addresses or []
routes = routes or []
dns_servers = dns_servers or []
super(Interface, self).__init__(name, use_dhcp, use_dhcpv6, addresses,
routes, mtu, primary, nic_mapping,
persist_mapping, defroute,
- dhclient_args, dns_servers)
+ dhclient_args, dns_servers,
+ nm_controlled)
self.ethtool_opts = ethtool_opts
self.hotplug = hotplug
@@ -318,7 +322,7 @@ class Vlan(_BaseOpts):
def __init__(self, device, vlan_id, use_dhcp=False, use_dhcpv6=False,
addresses=None, routes=None, mtu=None, primary=False,
nic_mapping=None, persist_mapping=False, defroute=True,
- dhclient_args=None, dns_servers=None):
+ dhclient_args=None, dns_servers=None, nm_controlled=False):
addresses = addresses or []
routes = routes or []
dns_servers = dns_servers or []
@@ -326,7 +330,7 @@ class Vlan(_BaseOpts):
super(Vlan, self).__init__(name, use_dhcp, use_dhcpv6, addresses,
routes, mtu, primary, nic_mapping,
persist_mapping, defroute, dhclient_args,
- dns_servers)
+ dns_servers, nm_controlled)
self.vlan_id = int(vlan_id)
mapped_nic_names = _mapped_nics(nic_mapping)
@@ -350,7 +354,7 @@ class IvsInterface(_BaseOpts):
def __init__(self, vlan_id, name='ivs', use_dhcp=False, use_dhcpv6=False,
addresses=None, routes=None, mtu=1500, primary=False,
nic_mapping=None, persist_mapping=False, defroute=True,
- dhclient_args=None, dns_servers=None):
+ dhclient_args=None, dns_servers=None, nm_controlled=False):
addresses = addresses or []
routes = routes or []
dns_servers = dns_servers or []
@@ -359,7 +363,7 @@ class IvsInterface(_BaseOpts):
addresses, routes, mtu, primary,
nic_mapping, persist_mapping,
defroute, dhclient_args,
- dns_servers)
+ dns_servers, nm_controlled)
self.vlan_id = int(vlan_id)
@staticmethod
@@ -376,7 +380,8 @@ class NfvswitchInternal(_BaseOpts):
def __init__(self, vlan_id, name='nfvswitch', use_dhcp=False,
use_dhcpv6=False, addresses=None, routes=None, mtu=1500,
primary=False, nic_mapping=None, persist_mapping=False,
- defroute=True, dhclient_args=None, dns_servers=None):
+ defroute=True, dhclient_args=None, dns_servers=None,
+ nm_controlled=False):
addresses = addresses or []
routes = routes or []
dns_servers = dns_servers or []
@@ -385,7 +390,8 @@ class NfvswitchInternal(_BaseOpts):
use_dhcpv6, addresses, routes,
mtu, primary, nic_mapping,
persist_mapping, defroute,
- dhclient_args, dns_servers)
+ dhclient_args, dns_servers,
+ nm_controlled)
self.vlan_id = int(vlan_id)
@staticmethod
@@ -403,7 +409,7 @@ class OvsBridge(_BaseOpts):
routes=None, mtu=None, members=None, ovs_options=None,
ovs_extra=None, nic_mapping=None, persist_mapping=False,
defroute=True, dhclient_args=None, dns_servers=None,
- fail_mode=None):
+ nm_controlled=False, fail_mode=None):
addresses = addresses or []
routes = routes or []
members = members or []
@@ -411,7 +417,8 @@ class OvsBridge(_BaseOpts):
super(OvsBridge, self).__init__(name, use_dhcp, use_dhcpv6, addresses,
routes, mtu, False, nic_mapping,
persist_mapping, defroute,
- dhclient_args, dns_servers)
+ dhclient_args, dns_servers,
+ nm_controlled)
self.members = members
self.ovs_options = ovs_options
ovs_extra = ovs_extra or []
@@ -436,7 +443,8 @@ class OvsBridge(_BaseOpts):
name = _get_required_field(json, 'name', 'OvsBridge')
(use_dhcp, use_dhcpv6, addresses, routes, mtu, nic_mapping,
persist_mapping, defroute,
- dhclient_args, dns_servers) = _BaseOpts.base_opts_from_json(
+ dhclient_args, dns_servers,
+ nm_controlled) = _BaseOpts.base_opts_from_json(
json, include_primary=False)
ovs_options = json.get('ovs_options')
ovs_extra = json.get('ovs_extra', [])
@@ -461,7 +469,7 @@ class OvsBridge(_BaseOpts):
ovs_extra=ovs_extra, nic_mapping=nic_mapping,
persist_mapping=persist_mapping, defroute=defroute,
dhclient_args=dhclient_args, dns_servers=dns_servers,
- fail_mode=fail_mode)
+ nm_controlled=nm_controlled, fail_mode=fail_mode)
class OvsUserBridge(_BaseOpts):
@@ -471,12 +479,12 @@ class OvsUserBridge(_BaseOpts):
routes=None, mtu=None, members=None, ovs_options=None,
ovs_extra=None, nic_mapping=None, persist_mapping=False,
defroute=True, dhclient_args=None, dns_servers=None,
- fail_mode=None):
+ nm_controlled=False, fail_mode=None):
super(OvsUserBridge, self).__init__(name, use_dhcp, use_dhcpv6,
addresses, routes, mtu, False,
nic_mapping, persist_mapping,
defroute, dhclient_args,
- dns_servers)
+ dns_servers, nm_controlled)
self.members = members or []
self.ovs_options = ovs_options
ovs_extra = ovs_extra or []
@@ -503,7 +511,8 @@ class OvsUserBridge(_BaseOpts):
name = _get_required_field(json, 'name', 'OvsUserBridge')
(use_dhcp, use_dhcpv6, addresses, routes, mtu, nic_mapping,
persist_mapping, defroute,
- dhclient_args, dns_servers) = _BaseOpts.base_opts_from_json(
+ dhclient_args, dns_servers,
+ nm_controlled) = _BaseOpts.base_opts_from_json(
json, include_primary=False)
ovs_options = json.get('ovs_options')
ovs_extra = json.get('ovs_extra', [])
@@ -528,7 +537,8 @@ class OvsUserBridge(_BaseOpts):
ovs_extra=ovs_extra, nic_mapping=nic_mapping,
persist_mapping=persist_mapping,
defroute=defroute, dhclient_args=dhclient_args,
- dns_servers=dns_servers, fail_mode=fail_mode)
+ dns_servers=dns_servers,
+ nm_controlled=nm_controlled, fail_mode=fail_mode)
class LinuxBridge(_BaseOpts):
@@ -537,7 +547,7 @@ class LinuxBridge(_BaseOpts):
def __init__(self, name, use_dhcp=False, use_dhcpv6=False, addresses=None,
routes=None, mtu=None, members=None, nic_mapping=None,
persist_mapping=False, defroute=True, dhclient_args=None,
- dns_servers=None):
+ dns_servers=None, nm_controlled=False):
addresses = addresses or []
routes = routes or []
members = members or []
@@ -545,7 +555,8 @@ class LinuxBridge(_BaseOpts):
super(LinuxBridge, self).__init__(name, use_dhcp, use_dhcpv6,
addresses, routes, mtu, False,
nic_mapping, persist_mapping,
- defroute, dhclient_args, dns_servers)
+ defroute, dhclient_args, dns_servers,
+ nm_controlled)
self.members = members
for member in self.members:
member.linux_bridge_name = name
@@ -564,7 +575,7 @@ class LinuxBridge(_BaseOpts):
name = _get_required_field(json, 'name', 'LinuxBridge')
(use_dhcp, use_dhcpv6, addresses, routes, mtu, nic_mapping,
persist_mapping, defroute, dhclient_args,
- dns_servers) = _BaseOpts.base_opts_from_json(
+ dns_servers, nm_controlled) = _BaseOpts.base_opts_from_json(
json, include_primary=False)
members = []
@@ -583,7 +594,8 @@ class LinuxBridge(_BaseOpts):
members=members, nic_mapping=nic_mapping,
persist_mapping=persist_mapping, defroute=defroute,
dhclient_args=dhclient_args,
- dns_servers=dns_servers)
+ dns_servers=dns_servers,
+ nm_controlled=nm_controlled)
class IvsBridge(_BaseOpts):
@@ -602,7 +614,7 @@ class IvsBridge(_BaseOpts):
def __init__(self, name='ivs', use_dhcp=False, use_dhcpv6=False,
addresses=None, routes=None, mtu=1500, members=None,
nic_mapping=None, persist_mapping=False, defroute=True,
- dhclient_args=None, dns_servers=None):
+ dhclient_args=None, dns_servers=None, nm_controlled=False):
addresses = addresses or []
routes = routes or []
members = members or []
@@ -610,7 +622,8 @@ class IvsBridge(_BaseOpts):
super(IvsBridge, self).__init__(name, use_dhcp, use_dhcpv6,
addresses, routes, mtu, False,
nic_mapping, persist_mapping,
- defroute, dhclient_args, dns_servers)
+ defroute, dhclient_args, dns_servers,
+ nm_controlled)
self.members = members
for member in self.members:
if isinstance(member, OvsBond) or isinstance(member, LinuxBond):
@@ -625,7 +638,7 @@ class IvsBridge(_BaseOpts):
name = 'ivs'
(use_dhcp, use_dhcpv6, addresses, routes, mtu, nic_mapping,
persist_mapping, defroute, dhclient_args,
- dns_servers) = _BaseOpts.base_opts_from_json(
+ dns_servers, nm_controlled) = _BaseOpts.base_opts_from_json(
json, include_primary=False)
members = []
@@ -644,7 +657,7 @@ class IvsBridge(_BaseOpts):
members=members, nic_mapping=nic_mapping,
persist_mapping=persist_mapping, defroute=defroute,
dhclient_args=dhclient_args,
- dns_servers=dns_servers)
+ dns_servers=dns_servers, nm_controlled=nm_controlled)
class NfvswitchBridge(_BaseOpts):
@@ -658,7 +671,8 @@ class NfvswitchBridge(_BaseOpts):
def __init__(self, name='nfvswitch', use_dhcp=False, use_dhcpv6=False,
addresses=None, routes=None, mtu=1500, members=None,
nic_mapping=None, persist_mapping=False, defroute=True,
- dhclient_args=None, dns_servers=None, options=""):
+ dhclient_args=None, dns_servers=None, nm_controlled=False,
+ options=""):
addresses = addresses or []
routes = routes or []
members = members or []
@@ -667,7 +681,7 @@ class NfvswitchBridge(_BaseOpts):
addresses, routes, mtu, False,
nic_mapping, persist_mapping,
defroute, dhclient_args,
- dns_servers)
+ dns_servers, nm_controlled)
self.options = options
self.members = members
for member in self.members:
@@ -683,7 +697,7 @@ class NfvswitchBridge(_BaseOpts):
name = 'nfvswitch'
(use_dhcp, use_dhcpv6, addresses, routes, mtu, nic_mapping,
persist_mapping, defroute, dhclient_args,
- dns_servers) = _BaseOpts.base_opts_from_json(
+ dns_servers, nm_controlled) = _BaseOpts.base_opts_from_json(
json, include_primary=False)
# members
@@ -707,7 +721,8 @@ class NfvswitchBridge(_BaseOpts):
members=members, nic_mapping=nic_mapping,
persist_mapping=persist_mapping,
defroute=defroute, dhclient_args=dhclient_args,
- dns_servers=dns_servers, options=options)
+ dns_servers=dns_servers,
+ nm_controlled=nm_controlled, options=options)
class LinuxTeam(_BaseOpts):
@@ -716,7 +731,8 @@ class LinuxTeam(_BaseOpts):
def __init__(self, name, use_dhcp=False, use_dhcpv6=False, addresses=None,
routes=None, mtu=None, primary=False, members=None,
bonding_options=None, nic_mapping=None, persist_mapping=False,
- defroute=True, dhclient_args=None, dns_servers=None):
+ defroute=True, dhclient_args=None, dns_servers=None,
+ nm_controlled=False):
addresses = addresses or []
routes = routes or []
members = members or []
@@ -724,7 +740,8 @@ class LinuxTeam(_BaseOpts):
super(LinuxTeam, self).__init__(name, use_dhcp, use_dhcpv6, addresses,
routes, mtu, primary, nic_mapping,
persist_mapping, defroute,
- dhclient_args, dns_servers)
+ dhclient_args, dns_servers,
+ nm_controlled)
self.members = members
self.bonding_options = bonding_options
for member in self.members:
@@ -743,7 +760,7 @@ class LinuxTeam(_BaseOpts):
name = _get_required_field(json, 'name', 'LinuxTeam')
(use_dhcp, use_dhcpv6, addresses, routes, mtu, nic_mapping,
persist_mapping, defroute, dhclient_args,
- dns_servers) = _BaseOpts.base_opts_from_json(
+ dns_servers, nm_controlled) = _BaseOpts.base_opts_from_json(
json, include_primary=False)
bonding_options = json.get('bonding_options')
members = []
@@ -763,7 +780,8 @@ class LinuxTeam(_BaseOpts):
members=members, bonding_options=bonding_options,
nic_mapping=nic_mapping,
persist_mapping=persist_mapping, defroute=defroute,
- dhclient_args=dhclient_args, dns_servers=dns_servers)
+ dhclient_args=dhclient_args, dns_servers=dns_servers,
+ nm_controlled=nm_controlled)
class LinuxBond(_BaseOpts):
@@ -772,7 +790,8 @@ class LinuxBond(_BaseOpts):
def __init__(self, name, use_dhcp=False, use_dhcpv6=False, addresses=None,
routes=None, mtu=None, primary=False, members=None,
bonding_options=None, nic_mapping=None, persist_mapping=False,
- defroute=True, dhclient_args=None, dns_servers=None):
+ defroute=True, dhclient_args=None, dns_servers=None,
+ nm_controlled=False):
addresses = addresses or []
routes = routes or []
members = members or []
@@ -780,7 +799,8 @@ class LinuxBond(_BaseOpts):
super(LinuxBond, self).__init__(name, use_dhcp, use_dhcpv6, addresses,
routes, mtu, primary, nic_mapping,
persist_mapping, defroute,
- dhclient_args, dns_servers)
+ dhclient_args, dns_servers,
+ nm_controlled)
self.members = members
self.bonding_options = bonding_options
for member in self.members:
@@ -799,7 +819,7 @@ class LinuxBond(_BaseOpts):
name = _get_required_field(json, 'name', 'LinuxBond')
(use_dhcp, use_dhcpv6, addresses, routes, mtu, nic_mapping,
persist_mapping, defroute, dhclient_args,
- dns_servers) = _BaseOpts.base_opts_from_json(
+ dns_servers, nm_controlled) = _BaseOpts.base_opts_from_json(
json, include_primary=False)
bonding_options = json.get('bonding_options')
members = []
@@ -819,7 +839,8 @@ class LinuxBond(_BaseOpts):
members=members, bonding_options=bonding_options,
nic_mapping=nic_mapping,
persist_mapping=persist_mapping, defroute=defroute,
- dhclient_args=dhclient_args, dns_servers=dns_servers)
+ dhclient_args=dhclient_args, dns_servers=dns_servers,
+ nm_controlled=nm_controlled)
class OvsBond(_BaseOpts):
@@ -829,7 +850,7 @@ class OvsBond(_BaseOpts):
routes=None, mtu=None, primary=False, members=None,
ovs_options=None, ovs_extra=None, nic_mapping=None,
persist_mapping=False, defroute=True, dhclient_args=None,
- dns_servers=None):
+ dns_servers=None, nm_controlled=False):
addresses = addresses or []
routes = routes or []
members = members or []
@@ -837,7 +858,7 @@ class OvsBond(_BaseOpts):
super(OvsBond, self).__init__(name, use_dhcp, use_dhcpv6, addresses,
routes, mtu, primary, nic_mapping,
persist_mapping, defroute, dhclient_args,
- dns_servers)
+ dns_servers, nm_controlled)
self.members = members
self.ovs_options = ovs_options
self.ovs_extra = format_ovs_extra(self, ovs_extra)
@@ -860,7 +881,7 @@ class OvsBond(_BaseOpts):
name = _get_required_field(json, 'name', 'OvsBond')
(use_dhcp, use_dhcpv6, addresses, routes, mtu, nic_mapping,
persist_mapping, defroute, dhclient_args,
- dns_servers) = _BaseOpts.base_opts_from_json(
+ dns_servers, nm_controlled) = _BaseOpts.base_opts_from_json(
json, include_primary=False)
ovs_options = json.get('ovs_options')
ovs_extra = json.get('ovs_extra', [])
@@ -883,7 +904,8 @@ class OvsBond(_BaseOpts):
members=members, ovs_options=ovs_options,
ovs_extra=ovs_extra, nic_mapping=nic_mapping,
persist_mapping=persist_mapping, defroute=defroute,
- dhclient_args=dhclient_args, dns_servers=dns_servers)
+ dhclient_args=dhclient_args, dns_servers=dns_servers,
+ nm_controlled=nm_controlled)
class OvsTunnel(_BaseOpts):
@@ -892,15 +914,16 @@ class OvsTunnel(_BaseOpts):
def __init__(self, name, use_dhcp=False, use_dhcpv6=False, addresses=None,
routes=None, mtu=None, primary=False, nic_mapping=None,
persist_mapping=False, defroute=True, dhclient_args=None,
- dns_servers=None, tunnel_type=None, ovs_options=None,
- ovs_extra=None):
+ dns_servers=None, nm_controlled=False, tunnel_type=None,
+ ovs_options=None, ovs_extra=None):
addresses = addresses or []
routes = routes or []
dns_servers = dns_servers or []
super(OvsTunnel, self).__init__(name, use_dhcp, use_dhcpv6, addresses,
routes, mtu, primary, nic_mapping,
persist_mapping, defroute,
- dhclient_args, dns_servers)
+ dhclient_args, dns_servers,
+ nm_controlled)
self.tunnel_type = tunnel_type
self.ovs_options = ovs_options or []
self.ovs_extra = format_ovs_extra(self, ovs_extra)
@@ -925,8 +948,8 @@ class OvsPatchPort(_BaseOpts):
def __init__(self, name, use_dhcp=False, use_dhcpv6=False, addresses=None,
routes=None, mtu=None, primary=False, nic_mapping=None,
persist_mapping=False, defroute=True, dhclient_args=None,
- dns_servers=None, bridge_name=None, peer=None,
- ovs_options=None, ovs_extra=None):
+ dns_servers=None, nm_controlled=False, bridge_name=None,
+ peer=None, ovs_options=None, ovs_extra=None):
addresses = addresses or []
routes = routes or []
dns_servers = dns_servers or []
@@ -934,7 +957,7 @@ class OvsPatchPort(_BaseOpts):
addresses, routes, mtu, primary,
nic_mapping, persist_mapping,
defroute, dhclient_args,
- dns_servers)
+ dns_servers, nm_controlled)
self.bridge_name = bridge_name
self.peer = peer
self.ovs_options = ovs_options or []
@@ -961,14 +984,15 @@ class IbInterface(_BaseOpts):
def __init__(self, name, use_dhcp=False, use_dhcpv6=False, addresses=None,
routes=None, mtu=None, primary=False, nic_mapping=None,
persist_mapping=False, defroute=True, dhclient_args=None,
- dns_servers=None, ethtool_opts=None):
+ dns_servers=None, nm_controlled=False, ethtool_opts=None):
addresses = addresses or []
routes = routes or []
dns_servers = dns_servers or []
super(IbInterface, self).__init__(name, use_dhcp, use_dhcpv6,
addresses, routes, mtu, primary,
nic_mapping, persist_mapping,
- defroute, dhclient_args, dns_servers)
+ defroute, dhclient_args, dns_servers,
+ nm_controlled)
self.ethtool_opts = ethtool_opts
@staticmethod
@@ -985,14 +1009,14 @@ class OvsDpdkPort(_BaseOpts):
def __init__(self, name, use_dhcp=False, use_dhcpv6=False, addresses=None,
routes=None, mtu=None, primary=False, nic_mapping=None,
persist_mapping=False, defroute=True, dhclient_args=None,
- dns_servers=None, members=None, driver='vfio-pci',
- ovs_options=None, ovs_extra=None):
+ dns_servers=None, nm_controlled=False, members=None,
+ driver='vfio-pci', ovs_options=None, ovs_extra=None):
super(OvsDpdkPort, self).__init__(name, use_dhcp, use_dhcpv6,
addresses, routes, mtu, primary,
nic_mapping, persist_mapping,
defroute, dhclient_args,
- dns_servers)
+ dns_servers, nm_controlled)
self.members = members or []
self.ovs_options = ovs_options or []
self.ovs_extra = format_ovs_extra(self, ovs_extra)
@@ -1047,11 +1071,12 @@ class OvsDpdkBond(_BaseOpts):
routes=None, mtu=None, primary=False, members=None,
ovs_options=None, ovs_extra=None, nic_mapping=None,
persist_mapping=False, defroute=True, dhclient_args=None,
- dns_servers=None):
+ dns_servers=None, nm_controlled=False):
super(OvsDpdkBond, self).__init__(name, use_dhcp, use_dhcpv6,
addresses, routes, mtu, primary,
nic_mapping, persist_mapping,
- defroute, dhclient_args, dns_servers)
+ defroute, dhclient_args, dns_servers,
+ nm_controlled)
self.members = members or []
self.ovs_options = ovs_options
self.ovs_extra = format_ovs_extra(self, ovs_extra)
@@ -1075,7 +1100,7 @@ class OvsDpdkBond(_BaseOpts):
name = _get_required_field(json, 'name', 'OvsDpdkBond')
(use_dhcp, use_dhcpv6, addresses, routes, mtu, nic_mapping,
persist_mapping, defroute, dhclient_args,
- dns_servers) = _BaseOpts.base_opts_from_json(
+ dns_servers, nm_controlled) = _BaseOpts.base_opts_from_json(
json, include_primary=False)
ovs_options = json.get('ovs_options')
ovs_extra = json.get('ovs_extra', [])
@@ -1104,4 +1129,5 @@ class OvsDpdkBond(_BaseOpts):
ovs_extra=ovs_extra, nic_mapping=nic_mapping,
persist_mapping=persist_mapping,
defroute=defroute, dhclient_args=dhclient_args,
- dns_servers=dns_servers)
+ dns_servers=dns_servers,
+ nm_controlled=nm_controlled)
diff --git a/os_net_config/tests/test_impl_ifcfg.py b/os_net_config/tests/test_impl_ifcfg.py
index 6576cef..82ca116 100644
--- a/os_net_config/tests/test_impl_ifcfg.py
+++ b/os_net_config/tests/test_impl_ifcfg.py
@@ -34,6 +34,14 @@ NM_CONTROLLED=no
PEERDNS=no
"""
+_BASE_IFCFG_NETWORKMANAGER = """# This file is autogenerated by os-net-config
+DEVICE=em1
+ONBOOT=yes
+HOTPLUG=no
+NM_CONTROLLED=yes
+PEERDNS=no
+"""
+
_HOTPLUG = """# This file is autogenerated by os-net-config
DEVICE=em1
ONBOOT=yes
@@ -153,6 +161,19 @@ OVSBOOTPROTO=dhcp
OVSDHCPINTERFACES="em1"
"""
+_NM_CONTROLLED_INTERFACE = _BASE_IFCFG_NETWORKMANAGER + """MASTER=bond1
+SLAVE=yes
+BOOTPROTO=none
+"""
+
+_NM_CONTROLLED_BOND = """# This file is autogenerated by os-net-config
+DEVICE=bond1
+ONBOOT=yes
+HOTPLUG=no
+NM_CONTROLLED=yes
+PEERDNS=no
+"""
+
_OVS_BRIDGE_DHCP_STANDALONE = _OVS_BRIDGE_DHCP + \
"OVS_EXTRA=\"set bridge br-ctlplane fail_mode=standalone\"\n"
@@ -845,6 +866,20 @@ DNS2=5.6.7.8
"""
self.assertEqual(em1_config, self.get_interface_config('em1'))
+ def test_nm_controlled(self):
+ interface1 = objects.Interface('em1', nm_controlled=True)
+ interface2 = objects.Interface('em2', nm_controlled=True)
+ bond = objects.LinuxBond('bond1', nm_controlled=True,
+ members=[interface1, interface2])
+ self.provider.add_linux_bond(bond)
+ self.provider.add_interface(interface1)
+ self.provider.add_interface(interface2)
+
+ ifcfg_data = self.get_interface_config('em1')
+ self.assertEqual(_NM_CONTROLLED_INTERFACE, ifcfg_data)
+ bond_data = self.get_linux_bond_config('bond1')
+ self.assertEqual(_NM_CONTROLLED_BOND, bond_data)
+
def test_network_ovs_dpdk_bridge_and_port(self):
nic_mapping = {'nic1': 'eth0', 'nic2': 'eth1', 'nic3': 'eth2'}
self.stubbed_mapped_nics = nic_mapping
@@ -924,6 +959,7 @@ class TestIfcfgNetConfigApply(base.TestCase):
def setUp(self):
super(TestIfcfgNetConfigApply, self).setUp()
self.temp_ifcfg_file = tempfile.NamedTemporaryFile()
+ self.temp_bond_file = tempfile.NamedTemporaryFile()
self.temp_route_file = tempfile.NamedTemporaryFile()
self.temp_route6_file = tempfile.NamedTemporaryFile()
self.temp_bridge_file = tempfile.NamedTemporaryFile()