Oleksii Zhurba | a10927b | 2017-09-27 22:09:23 +0000 | [diff] [blame] | 1 | from collections import Counter |
| 2 | |
| 3 | |
Oleksii Zhurba | d0ae87f | 2018-03-26 13:36:25 -0500 | [diff] [blame] | 4 | def test_single_vip(local_salt_client, nodes_in_group): |
Oleksii Zhurba | 4bfd2ee | 2019-04-10 21:56:58 -0500 | [diff] [blame] | 5 | local_salt_client.cmd(tgt="L@"+','.join(nodes_in_group), |
| 6 | fun='saltutil.sync_all', |
| 7 | expr_form='compound') |
Oleksii Zhurba | a10927b | 2017-09-27 22:09:23 +0000 | [diff] [blame] | 8 | nodes_list = local_salt_client.cmd( |
Oleksii Zhurba | 4bfd2ee | 2019-04-10 21:56:58 -0500 | [diff] [blame] | 9 | tgt="L@"+','.join(nodes_in_group), |
| 10 | fun='grains.item', |
| 11 | param='ipv4', |
| 12 | expr_form='compound') |
Oleksii Zhurba | a10927b | 2017-09-27 22:09:23 +0000 | [diff] [blame] | 13 | |
| 14 | ipv4_list = [] |
| 15 | |
| 16 | for node in nodes_list: |
Oleksii Zhurba | 4bfd2ee | 2019-04-10 21:56:58 -0500 | [diff] [blame] | 17 | if not nodes_list.get(node): |
| 18 | # TODO: do not skip node |
| 19 | print "Node {} is skipped".format (node) |
| 20 | continue |
Oleksii Zhurba | a10927b | 2017-09-27 22:09:23 +0000 | [diff] [blame] | 21 | ipv4_list.extend(nodes_list.get(node).get('ipv4')) |
| 22 | |
| 23 | cnt = Counter(ipv4_list) |
| 24 | |
| 25 | for ip in cnt: |
| 26 | if ip == '127.0.0.1': |
| 27 | continue |
| 28 | elif cnt[ip] > 1: |
| 29 | assert "VIP IP duplicate found " \ |
Oleksii Zhurba | d0ae87f | 2018-03-26 13:36:25 -0500 | [diff] [blame] | 30 | "\n{}".format(ipv4_list) |