blob: 8850ab79a9b4309a8ac6f9afce79a720d6efb13d [file] [log] [blame]
Oleksii Zhurbaedb0a212018-01-16 17:02:55 +00001import json
2
3
4def test_etc_hosts(local_salt_client):
5 nodes_info = local_salt_client.cmd(
Oleksii Zhurba4bfd2ee2019-04-10 21:56:58 -05006 tgt='*',
7 param='cat /etc/hosts',
Oleksii Zhurba26a3a1c2018-01-16 19:10:20 +00008 expr_form='compound')
Oleksii Zhurbaedb0a212018-01-16 17:02:55 +00009 result = {}
10 for node in nodes_info.keys():
Oleksii Zhurba4bfd2ee2019-04-10 21:56:58 -050011 if isinstance(nodes_info[node], bool):
12 result[node] = 'Cannot access this node'
13 continue
Oleksii Zhurbaedb0a212018-01-16 17:02:55 +000014 for nd in nodes_info.keys():
Oleksii Zhurba4bfd2ee2019-04-10 21:56:58 -050015 if nd not in nodes_info[node]:
16 if node in result:
17 result[node] += ',' + nd
18 else:
19 result[node] = nd
Oleksii Zhurbaedb0a212018-01-16 17:02:55 +000020 assert len(result) <= 1, \
21 "Some hosts are not presented in /etc/hosts: {0}".format(
Oleksii Zhurba4bfd2ee2019-04-10 21:56:58 -050022 json.dumps(result, indent=4))