Fixes https://fedorahosted.org/freeipa/ticket/5331

Patch attached.
From 4200b386058489f8ad73ee2d2f7eed582dea70b5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Milan=20Kub=C3=ADk?= <mku...@redhat.com>
Date: Fri, 25 Sep 2015 21:09:24 +0200
Subject: [PATCH] ipatests: configure Network Manager not to manage resolv.conf

For the duration of the test, makes resolv.conf unmanaged.

https://fedorahosted.org/freeipa/ticket/5331
---
 ipaplatform/base/paths.py          |  2 +-
 ipatests/test_integration/tasks.py | 17 +++++++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/ipaplatform/base/paths.py b/ipaplatform/base/paths.py
index 215caf90ea1ca4e5db8f43f8f09002ce5d5cd280..a272143d0053451c017c0df613951cc0e6d52c54 100644
--- a/ipaplatform/base/paths.py
+++ b/ipaplatform/base/paths.py
@@ -354,6 +354,6 @@ class BasePathNamespace(object):
     DB2BAK = '/usr/sbin/db2bak'
     KDCPROXY_CONFIG = '/etc/ipa/kdcproxy/kdcproxy.conf'
     CERTMONGER = '/usr/sbin/certmonger'
-
+    NETWORK_MANAGER_CONFIG_DIR = '/etc/NetworkManager/conf.d'
 
 path_namespace = BasePathNamespace
diff --git a/ipatests/test_integration/tasks.py b/ipatests/test_integration/tasks.py
index 06049d4ae01332e0af4d8775b745342406fc868d..d3d46682d90e749ebf33b5f673217940debf7f1c 100644
--- a/ipatests/test_integration/tasks.py
+++ b/ipatests/test_integration/tasks.py
@@ -40,6 +40,7 @@ from ipatests.test_integration.host import Host
 
 log = log_mgr.get_logger(__name__)
 
+IPATEST_NM_CONFIG = '20-ipatest-unmanaged-resolv.conf'
 
 def check_arguments_are(slice, instanceof):
     """
@@ -74,6 +75,7 @@ def prepare_host(host):
 def apply_common_fixes(host):
     fix_etc_hosts(host)
     fix_hostname(host)
+    modify_nm_resolv_conf_settings(host)
     fix_resolv_conf(host)
 
 
@@ -119,6 +121,20 @@ def fix_hostname(host):
     host.run_command('hostname > %s' % ipautil.shell_quote(backupname))
 
 
+def modify_nm_resolv_conf_settings(host):
+    config = "[main]\ndns=none\n"
+    path = os.path.join(paths.NETWORK_MANAGER_CONFIG_DIR, IPATEST_NM_CONFIG)
+
+    host.put_file_contents(path, config)
+    host.run_command(['systemctl', 'restart', 'NetworkManager'], raiseonerr=False)
+
+
+def undo_nm_resolv_conf_settings(host):
+    path = os.path.join(paths.NETWORK_MANAGER_CONFIG_DIR, IPATEST_NM_CONFIG)
+    host.run_command(['rm', '-f', path], raiseonerr=False)
+    host.run_command(['systemctl', 'restart', 'NetworkManager'], raiseonerr=False)
+
+
 def fix_resolv_conf(host):
     backup_file(host, paths.RESOLV_CONF)
     lines = host.get_file_contents(paths.RESOLV_CONF).splitlines()
@@ -147,6 +163,7 @@ def fix_apache_semaphores(master):
 def unapply_fixes(host):
     restore_files(host)
     restore_hostname(host)
+    undo_nm_resolv_conf_settings(host)
 
     # Clean up the test directory
     host.run_command(['rm', '-rvf', host.config.test_dir])
-- 
2.6.0

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to