Hi all,

a function 'fix_etc_hosts' in ipatests/test_integration/tasks.py produces incorrect /etc/hosts file (solitary IPv6 address), and currently parser is not able to resolve the issue, causing ipa-server-install to fail with 'list index out of range' error.


Hence I'm attaching patch to fix this issue before parser is fixed (related ticket to it #6014). The fix is just change of regexs responsible for creating incorrect file so that all the lines containing defined hostname are removed, not just specific IP/hostname/shortname strings.


Lenka

From a2be2991041725d03d53d1cff04fc45290acd092 Mon Sep 17 00:00:00 2001
From: Lenka Doudova <ldoud...@redhat.com>
Date: Wed, 29 Jun 2016 18:13:23 +0200
Subject: [PATCH] Tests: Fix integration tests not to produce incorrect
 /etc/hosts file

Function 'fix_etc_hosts' in ipatests/test_integration/tasks.py produces incorrectly formatted /etc/hosts file (solitary IPv6 address), which causes ipa-server-install failure.
This provides fix of the function so that the regex changing /etc/hosts file remove entire lines with hostname entry in them.
---
 ipatests/test_integration/tasks.py | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/ipatests/test_integration/tasks.py b/ipatests/test_integration/tasks.py
index 38218fa709c2c220d5fea98a092b55e995d48d77..61f772638b319a74e935d4962b5921e451e9bb27 100644
--- a/ipatests/test_integration/tasks.py
+++ b/ipatests/test_integration/tasks.py
@@ -124,11 +124,7 @@ def fix_etc_hosts(host):
     # Remove existing mentions of the host's FQDN, short name, and IP
     # Removing of IP must be done as first, otherwise hosts file may be
     # corrupted
-    contents = re.sub('^%s.*' % re.escape(host.ip), '', contents,
-                      flags=re.MULTILINE)
-    contents = re.sub('\s%s(\s|$)' % re.escape(host.hostname), ' ', contents,
-                      flags=re.MULTILINE)
-    contents = re.sub('\s%s(\s|$)' % re.escape(host.shortname), ' ', contents,
+    contents = re.sub('^.*%s.*$' % re.escape(host.hostname), '', contents,
                       flags=re.MULTILINE)
     # Add the host's info again
     contents += '\n%s %s %s\n' % (host.ip, host.hostname, host.shortname)
-- 
2.7.4

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