summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--api/resources/write_hosts.py14
-rw-r--r--requirements.txt1
2 files changed, 11 insertions, 4 deletions
diff --git a/api/resources/write_hosts.py b/api/resources/write_hosts.py
index e4b69846b..a3025d3b0 100644
--- a/api/resources/write_hosts.py
+++ b/api/resources/write_hosts.py
@@ -13,11 +13,19 @@ import json
def write_hosts(hosts_ip):
- hosts_list = ('\n{} {}'.format(ip, host_name)
+
+ yardstick_flag = "# SUT hosts info for Yardstick"
+ hosts_list = ('\n{} {} {}'.format(ip, host_name, yardstick_flag)
for host_name, ip in hosts_ip.items())
- with open("/etc/hosts", 'a') as f:
+
+ with open("/etc/hosts", 'r') as f:
+ origin_lines = [line for line in f if yardstick_flag not in line]
+
+ with open("/etc/hosts", 'w') as f:
+ f.writelines(origin_lines)
+ f.write(yardstick_flag)
f.writelines(hosts_list)
- f.write("\n")
+
if __name__ == "__main__":
write_hosts(json.load(sys.stdin))
diff --git a/requirements.txt b/requirements.txt
index d03c4377f..d90a9e5e4 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -60,7 +60,6 @@ oslo.utils==3.22.0
paramiko==2.1.1
pbr==1.10.0
pep8==1.7.0
-ping==0.2; python_version <= '2.7'
pika==0.10.0
positional==1.1.1
prettytable==0.7.2