summaryrefslogtreecommitdiffstats
path: root/ipatests/test_integration/tasks.py
diff options
context:
space:
mode:
Diffstat (limited to 'ipatests/test_integration/tasks.py')
-rw-r--r--ipatests/test_integration/tasks.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/ipatests/test_integration/tasks.py b/ipatests/test_integration/tasks.py
index 63e101838..1911b17cb 100644
--- a/ipatests/test_integration/tasks.py
+++ b/ipatests/test_integration/tasks.py
@@ -41,6 +41,8 @@ from ipalib.util import get_reverse_zone_default
log = log_mgr.get_logger(__name__)
+IPATEST_NM_CONFIG = '20-ipatest-unmanaged-resolv.conf'
+
def check_arguments_are(slice, instanceof):
"""
@@ -80,6 +82,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)
@@ -125,6 +128,38 @@ def fix_hostname(host):
host.run_command('hostname > %s' % ipautil.shell_quote(backupname))
+def host_service_active(host, service):
+ res = host.run_command(['systemctl', 'is-active', '--quiet', service],
+ raiseonerr=False)
+
+ if res.returncode == 0:
+ return True
+ else:
+ return False
+
+
+def modify_nm_resolv_conf_settings(host):
+ if not host_service_active(host, 'NetworkManager'):
+ return
+
+ 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):
+ if not host_service_active(host, 'NetworkManager'):
+ return
+
+ 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()
@@ -153,6 +188,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])