Hanna Arhipova | e6ed8e4 | 2019-05-15 16:27:08 +0300 | [diff] [blame^] | 1 | import json |
| 2 | |
| 3 | |
| 4 | def test_etc_hosts(local_salt_client): |
| 5 | nodes_info = local_salt_client.cmd( |
| 6 | tgt='*', |
| 7 | param='cat /etc/hosts', |
| 8 | expr_form='compound') |
| 9 | result = {} |
| 10 | for node in nodes_info.keys(): |
| 11 | if isinstance(nodes_info[node], bool): |
| 12 | result[node] = 'Cannot access this node' |
| 13 | continue |
| 14 | for nd in nodes_info.keys(): |
| 15 | if nd not in nodes_info[node]: |
| 16 | if node in result: |
| 17 | result[node] += ',' + nd |
| 18 | else: |
| 19 | result[node] = nd |
| 20 | assert len(result) <= 1, \ |
| 21 | "Some hosts are not presented in /etc/hosts: {0}".format( |
| 22 | json.dumps(result, indent=4)) |