summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Basti <mbasti@redhat.com>2015-12-06 18:44:43 +0100
committerMartin Basti <mbasti@redhat.com>2015-12-08 10:25:50 +0100
commite4259d5b49a6f501f0a6f1b020bf492cac06e1c7 (patch)
tree10b0a06c7d96b59e1e5c19b7a045cb955b9bc13f
parenta11cddd75b4e887998ad6fd52a05f87e0354ea30 (diff)
downloadfreeipa-e4259d5b49a6f501f0a6f1b020bf492cac06e1c7.tar.gz
freeipa-e4259d5b49a6f501f0a6f1b020bf492cac06e1c7.tar.xz
freeipa-e4259d5b49a6f501f0a6f1b020bf492cac06e1c7.zip
CI: fix function that prepare the hosts file before CI run
Without this fix function removed 2 lines from hosts file. Reviewed-By: Oleg Fayans <ofayans@redhat.com>
-rw-r--r--ipatests/test_integration/tasks.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/ipatests/test_integration/tasks.py b/ipatests/test_integration/tasks.py
index 217e78cbf..ddbb5af29 100644
--- a/ipatests/test_integration/tasks.py
+++ b/ipatests/test_integration/tasks.py
@@ -115,12 +115,14 @@ def fix_etc_hosts(host):
backup_file(host, paths.HOSTS)
contents = host.get_file_contents(paths.HOSTS)
# 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,
flags=re.MULTILINE)
- contents = re.sub('^%s.*' % re.escape(host.ip), '', contents,
- flags=re.MULTILINE)
# Add the host's info again
contents += '\n%s %s %s\n' % (host.ip, host.hostname, host.shortname)
log.debug('Writing the following to /etc/hosts:\n%s', contents)