[Freeipa-devel] [patch 0020] ipatests: configure Network Manager not to manage resolv.conf

2015-10-01 Thread Milan Kubík

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?= 
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

Re: [Freeipa-devel] [patch 0020] ipatests: configure Network Manager not to manage resolv.conf

2015-10-01 Thread Milan Kubík

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
From 5d19b29474b577688910a60fbc5efdf38ff6c455 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Milan=20Kub=C3=ADk?= 
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 f579f286826f749a8c5f8433f2a8bf7348664ba9..d188adbd4d7b3af7dd82b964917770c5afda7a96 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 prepare_host(host):
 if isinstance(host, Host):
@@ -56,6 +57,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)
 
 
@@ -101,6 +103,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()
@@ -128,6 +144,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

Re: [Freeipa-devel] [patch 0020] ipatests: configure Network Manager not to manage resolv.conf

2015-10-01 Thread Alexander Bokovoy

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.

--
/ Alexander Bokovoy

--
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


Re: [Freeipa-devel] [patch 0020] ipatests: configure Network Manager not to manage resolv.conf

2015-10-01 Thread Milan Kubík

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 restart NetworkManager when it is 
already running. I don't check if the service is enabled.


--
Milan Kubik

From c41e5941c7d24575495b8064f6412afcecab55ff Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Milan=20Kub=C3=ADk?= 
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 f579f286826f749a8c5f8433f2a8bf7348664ba9..db10a52e8a68b0104cf6f4c8b29b25a655fa742a 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_host(host):
 if isinstance(host, Host):
@@ -56,6 +58,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)
 
 
@@ -101,6 +104,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()
@@ -128,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

From fb8ab435c71f08c6fcb9cc8f4a983a278824de44 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Milan=20Kub=C3=ADk?= 
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 +-
 

Re: [Freeipa-devel] [patch 0020] ipatests: configure Network Manager not to manage resolv.conf

2015-10-01 Thread Martin Basti



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 did investigation, this happened because my VM did not have 
NetworkManager installed (fedora 22 cloud)



-- 
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

Re: [Freeipa-devel] [patch 0020] ipatests: configure Network Manager not to manage resolv.conf

2015-10-01 Thread Martin Basti



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/
-- 
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