blob: b33dc58272990ff639ce2e1c0032de3c6db5e2b9 [file] [log] [blame]
Ievgeniia Zadorozhna90fdfb52019-01-27 23:01:07 +03001import json
2import pytest
3
4from cvp_sanity import utils
5
6
7def test_nodes_deployed_in_maas(local_salt_client):
8 config = utils.get_configuration()
9 get_apis = local_salt_client.cmd(
10 'maas:cluster',
11 'cmd.run',
12 ['maas list'],
13 expr_form='pillar')
14 if not get_apis:
15 pytest.skip("Could not find MAAS on the environment")
16 profile = get_apis.values()[0].split(' ')[0]
17 get_nodes = local_salt_client.cmd('maas:cluster', 'cmd.run',
18 ['maas {} nodes read'.format(profile)],
19 expr_form='pillar')
20 result = ""
21 try:
22 result = json.loads(get_nodes.values()[0])
23 except Exception as e:
24 assert result, "Could not get nodes: {}\n{}".\
25 format(get_nodes.values()[0], e)
26
27 failed_nodes = []
28 for node in result:
29 if node["fqdn"] in config.get("skipped_nodes"):
30 continue
31 if "status_name" in node.keys():
32 if node["status_name"] != 'Deployed':
33 failed_nodes.append({node["fqdn"]: node["status_name"]})
34 assert not failed_nodes, "Some nodes have unexpected status in MAAS:" \
35 "\n{}".format(failed_nodes)