aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--os_net_config/impl_ifcfg.py2
-rw-r--r--os_net_config/tests/test_impl_ifcfg.py12
2 files changed, 14 insertions, 0 deletions
diff --git a/os_net_config/impl_ifcfg.py b/os_net_config/impl_ifcfg.py
index 2172a08..f2a5dc0 100644
--- a/os_net_config/impl_ifcfg.py
+++ b/os_net_config/impl_ifcfg.py
@@ -88,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)
diff --git a/os_net_config/tests/test_impl_ifcfg.py b/os_net_config/tests/test_impl_ifcfg.py
index 262d0a1..e81e049 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"
@@ -215,6 +221,7 @@ DEVICE=em1
ONBOOT=yes
HOTPLUG=no
NM_CONTROLLED=no
+PEERDNS=no
DEVICETYPE=ivs
IVS_BRIDGE=ivs
BOOTPROTO=none
@@ -225,6 +232,7 @@ DEVICE=storage5
ONBOOT=yes
HOTPLUG=no
NM_CONTROLLED=no
+PEERDNS=no
TYPE=IVSIntPort
DEVICETYPE=ivs
IVS_BRIDGE=ivs
@@ -486,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'))
@@ -515,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
@@ -522,6 +532,7 @@ DEVICE=em2
ONBOOT=yes
HOTPLUG=no
NM_CONTROLLED=no
+PEERDNS=no
BOOTPROTO=none
DEFROUTE=no
"""
@@ -536,6 +547,7 @@ DEVICE=em1
ONBOOT=yes
HOTPLUG=no
NM_CONTROLLED=no
+PEERDNS=no
BOOTPROTO=none
DHCLIENTARGS=--foobar
"""