On 10/02/2015 02:05 PM, Martin Basti wrote:


On 10/01/2015 01:58 PM, Milan Kubík wrote:
On 10/01/2015 12:39 PM, Alexander Bokovoy wrote:
On Thu, 01 Oct 2015, Milan Kubík wrote:
On 10/01/2015 11:23 AM, Martin Basti wrote:


On 10/01/2015 10:18 AM, Milan Kubík wrote:
On 10/01/2015 10:06 AM, Milan Kubík wrote:
Fixes https://fedorahosted.org/freeipa/ticket/5331

Patch attached.


Patch for ipa-4-2 branch.

Milan


NACK

http://fpaste.org/273499/43691381/
I disagree. From [1]:

Fedora now by default relies on NetworkManager for network configuration. This is the case also for minimal installations and server installations.

The cloud image, which you are probably using does not have NetworkManager installed. I think we can rely on the default here and assume
NetworkManager is present.

If you and the list disagree, I will make the fix depend on NetworkManager's presence. Nitpick: there can be other services that manage (and rewrite) resolv.conf.
While other tools may do it, please make it so that your fix only
activated if NetworkManager is active.

We'll get to other services once we'll encounter them.

Ok. Now I only apply the config and resta

rt NetworkManager when it is already running. I don't check if the service is enabled.

ACK

Pushed to master: c22c60b87c101178e5e653cada53dfdb861d1ad0

I cannot apply patch for ipa42 please send rebased version
There you go.

--
Milan Kubik

From 74b428ab356e32903712f7f01cc24b6a61bb638a 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.
If NetworkManager is not running, nothing is changed.

https://fedorahosted.org/freeipa/ticket/5331
---
 ipaplatform/base/paths.py          |  2 +-
 ipatests/test_integration/tasks.py | 36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 37 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 0fcc860a20865063ffb76b0553eb2c2831321bd1..5fc9329d62622eb6157c1e780687b3a2c5ecc4fd 100644
--- a/ipatests/test_integration/tasks.py
+++ b/ipatests/test_integration/tasks.py
@@ -40,6 +40,8 @@ from ipatests.test_integration.host import Host
 
 log = log_mgr.get_logger(__name__)
 
+IPATEST_NM_CONFIG = '20-ipatest-unmanaged-resolv.conf'
+
 
 def prepare_reverse_zone(host, ip):
     zone = get_reverse_zone_default(ip)
@@ -61,6 +63,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)
 
 
@@ -106,6 +109,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()
@@ -133,6 +168,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