aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--os_net_config/impl_ifcfg.py12
-rw-r--r--os_net_config/tests/test_impl_ifcfg.py23
2 files changed, 27 insertions, 8 deletions
diff --git a/os_net_config/impl_ifcfg.py b/os_net_config/impl_ifcfg.py
index df935fa..6459bcc 100644
--- a/os_net_config/impl_ifcfg.py
+++ b/os_net_config/impl_ifcfg.py
@@ -65,7 +65,6 @@ class IfcfgNetConfig(os_net_config.NetConfig):
self.linuxbridge_data = {}
self.linuxbond_data = {}
self.member_names = {}
- self.bond_slaves = {}
self.renamed_interfaces = {}
self.bond_primary_ifaces = {}
logger.info('Ifcfg net config provider created.')
@@ -89,6 +88,8 @@ class IfcfgNetConfig(os_net_config.NetConfig):
data += "ONBOOT=yes\n"
data += "HOTPLUG=no\n"
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):
if not base_opt.ovs_port:
# vlans on OVS bridges are internal ports (no device, etc)
@@ -102,6 +103,9 @@ class IfcfgNetConfig(os_net_config.NetConfig):
data += "TYPE=IVSIntPort\n"
elif re.match('\w+\.\d+$', base_opt.name):
data += "VLAN=yes\n"
+ if base_opt.linux_bond_name:
+ data += "MASTER=%s\n" % base_opt.linux_bond_name
+ data += "SLAVE=yes\n"
if base_opt.ivs_bridge_name:
data += "DEVICETYPE=ivs\n"
data += "IVS_BRIDGE=%s\n" % base_opt.ivs_bridge_name
@@ -171,15 +175,9 @@ class IfcfgNetConfig(os_net_config.NetConfig):
if base_opt.members:
members = [member.name for member in base_opt.members]
self.member_names[base_opt.name] = members
- for member in members:
- if isinstance(member, objects.Interface):
- self.bond_slaves[member] = base_opt.name
if base_opt.bonding_options:
data += "BONDING_OPTS=\"%s\"\n" % base_opt.bonding_options
else:
- if base_opt.name in self.bond_slaves:
- data += "MASTER=%s\n" % self.bond_slaves[base_opt.name]
- data += "SLAVE=yes\n"
if base_opt.use_dhcp:
data += "BOOTPROTO=dhcp\n"
elif not base_opt.addresses:
diff --git a/os_net_config/tests/test_impl_ifcfg.py b/os_net_config/tests/test_impl_ifcfg.py
index 3877e7b..d68a96e 100644
--- a/os_net_config/tests/test_impl_ifcfg.py
+++ b/os_net_config/tests/test_impl_ifcfg.py
@@ -30,6 +30,7 @@ DEVICE=em1
ONBOOT=yes
HOTPLUG=no
NM_CONTROLLED=no
+PEERDNS=no
"""
_NO_IP = _BASE_IFCFG + "BOOTPROTO=none\n"
@@ -52,6 +53,7 @@ DEVICE=em1.120
ONBOOT=yes
HOTPLUG=no
NM_CONTROLLED=no
+PEERDNS=no
VLAN=yes
BOOTPROTO=none
"""
@@ -120,6 +122,7 @@ DEVICE=br-ctlplane
ONBOOT=yes
HOTPLUG=no
NM_CONTROLLED=no
+PEERDNS=no
DEVICETYPE=ovs
TYPE=OVSBridge
BOOTPROTO=static
@@ -132,6 +135,7 @@ DEVICE=br-ctlplane
ONBOOT=yes
HOTPLUG=no
NM_CONTROLLED=no
+PEERDNS=no
TYPE=Bridge
DELAY=0
BOOTPROTO=static
@@ -153,6 +157,7 @@ DEVICE=vlan5
ONBOOT=yes
HOTPLUG=no
NM_CONTROLLED=no
+PEERDNS=no
VLAN=yes
PHYSDEV=em1
"""
@@ -163,6 +168,7 @@ DEVICE=vlan5
ONBOOT=yes
HOTPLUG=no
NM_CONTROLLED=no
+PEERDNS=no
"""
_VLAN_NO_IP = _BASE_VLAN + "BOOTPROTO=none\n"
@@ -195,7 +201,6 @@ OVSBOOTPROTO=dhcp
BOND_IFACES="em1 em2"
"""
-
_LINUX_BOND_DHCP = """# This file is autogenerated by os-net-config
DEVICE=bond0
ONBOOT=yes
@@ -205,11 +210,18 @@ BOOTPROTO=dhcp
"""
+_LINUX_BOND_INTERFACE = _BASE_IFCFG + """MASTER=bond0
+SLAVE=yes
+BOOTPROTO=none
+"""
+
+
_IVS_UPLINK = """# This file is autogenerated by os-net-config
DEVICE=em1
ONBOOT=yes
HOTPLUG=no
NM_CONTROLLED=no
+PEERDNS=no
DEVICETYPE=ivs
IVS_BRIDGE=ivs
BOOTPROTO=none
@@ -220,6 +232,7 @@ DEVICE=storage5
ONBOOT=yes
HOTPLUG=no
NM_CONTROLLED=no
+PEERDNS=no
TYPE=IVSIntPort
DEVICETYPE=ivs
IVS_BRIDGE=ivs
@@ -481,6 +494,7 @@ DEVICE=em2
ONBOOT=yes
HOTPLUG=no
NM_CONTROLLED=no
+PEERDNS=no
BOOTPROTO=none
"""
self.assertEqual(em2_config, self.get_interface_config('em2'))
@@ -493,8 +507,12 @@ BOOTPROTO=none
bond = objects.LinuxBond('bond0', use_dhcp=True,
members=[interface1, interface2])
self.provider.add_linux_bond(bond)
+ self.provider.add_interface(interface1)
+ self.provider.add_interface(interface2)
self.assertEqual(_LINUX_BOND_DHCP,
self.get_linux_bond_config('bond0'))
+ self.assertEqual(_LINUX_BOND_INTERFACE,
+ self.get_interface_config('em1'))
def test_interface_defroute(self):
interface1 = objects.Interface('em1')
@@ -506,6 +524,7 @@ DEVICE=em1
ONBOOT=yes
HOTPLUG=no
NM_CONTROLLED=no
+PEERDNS=no
BOOTPROTO=none
"""
em2_config = """# This file is autogenerated by os-net-config
@@ -513,6 +532,7 @@ DEVICE=em2
ONBOOT=yes
HOTPLUG=no
NM_CONTROLLED=no
+PEERDNS=no
BOOTPROTO=none
DEFROUTE=no
"""
@@ -527,6 +547,7 @@ DEVICE=em1
ONBOOT=yes
HOTPLUG=no
NM_CONTROLLED=no
+PEERDNS=no
BOOTPROTO=none
DHCLIENTARGS=--foobar
"""