From 33d6af13c857b299f6e67f99dd92f2bca0afe227 Mon Sep 17 00:00:00 2001 From: Andrew Lazarev Date: Wed, 11 Jun 2014 15:09:18 -0700 Subject: [PATCH] Fixed /etc/hosts update for external hdfs Before the change /etc/hosts were growing infinitely Change-Id: I303c013fc0fa85f1826aa60106846a3b7b214be3 Closes-Bug: #1326114 --- sahara/service/edp/hdfs_helper.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/sahara/service/edp/hdfs_helper.py b/sahara/service/edp/hdfs_helper.py index ca0c4ccb..9e8b38d1 100644 --- a/sahara/service/edp/hdfs_helper.py +++ b/sahara/service/edp/hdfs_helper.py @@ -90,12 +90,13 @@ def configure_cluster_for_hdfs(cluster, data_source): # Ip address hasn't been resolved, the last chance is for VM itself return - create_etc_host = 'sudo "cat /tmp/etc-hosts-update ' - create_etc_host += '/etc/hosts > /tmp/etc-hosts"' - copy_etc_host = 'sudo "cat /tmp/etc-hosts > /etc/hosts"' + update_etc_hosts_cmd = ( + 'cat /tmp/etc-hosts-update /etc/hosts | ' + 'sort | uniq > /tmp/etc-hosts && ' + 'cat /tmp/etc-hosts > /etc/hosts && ' + 'rm -f /tmp/etc-hosts /tmp/etc-hosts-update') for inst in u.get_instances(cluster): with inst.remote() as r: r.write_file_to('/tmp/etc-hosts-update', etc_hosts_information) - r.execute_command(create_etc_host) - r.execute_command(copy_etc_host) + r.execute_command(update_etc_hosts_cmd, run_as_root=True)