Oleksii Zhurba | edb0a21 | 2018-01-16 17:02:55 +0000 | [diff] [blame] | 1 | import json |
| 2 | |
| 3 | |
| 4 | def test_etc_hosts(local_salt_client): |
| 5 | nodes_info = local_salt_client.cmd( |
Oleksii Zhurba | 4bfd2ee | 2019-04-10 21:56:58 -0500 | [diff] [blame] | 6 | tgt='*', |
| 7 | param='cat /etc/hosts', |
Oleksii Zhurba | 26a3a1c | 2018-01-16 19:10:20 +0000 | [diff] [blame] | 8 | expr_form='compound') |
Oleksii Zhurba | edb0a21 | 2018-01-16 17:02:55 +0000 | [diff] [blame] | 9 | result = {} |
| 10 | for node in nodes_info.keys(): |
Oleksii Zhurba | 4bfd2ee | 2019-04-10 21:56:58 -0500 | [diff] [blame] | 11 | if isinstance(nodes_info[node], bool): |
| 12 | result[node] = 'Cannot access this node' |
| 13 | continue |
Oleksii Zhurba | edb0a21 | 2018-01-16 17:02:55 +0000 | [diff] [blame] | 14 | for nd in nodes_info.keys(): |
Oleksii Zhurba | 4bfd2ee | 2019-04-10 21:56:58 -0500 | [diff] [blame] | 15 | if nd not in nodes_info[node]: |
| 16 | if node in result: |
| 17 | result[node] += ',' + nd |
| 18 | else: |
| 19 | result[node] = nd |
Oleksii Zhurba | edb0a21 | 2018-01-16 17:02:55 +0000 | [diff] [blame] | 20 | assert len(result) <= 1, \ |
| 21 | "Some hosts are not presented in /etc/hosts: {0}".format( |
Oleksii Zhurba | 4bfd2ee | 2019-04-10 21:56:58 -0500 | [diff] [blame] | 22 | json.dumps(result, indent=4)) |