blob: b95d306478e108ca0ea85877a910d937b50a7204 [file] [log] [blame]
Yulia Portnova0e64ea22015-03-20 17:27:22 +02001import logging
2
Yulia Portnova0e64ea22015-03-20 17:27:22 +02003import ceph
4import fuel
koder aka kdanilove06762a2015-03-22 23:32:09 +02005import openstack
Yulia Portnova0e64ea22015-03-20 17:27:22 +02006
koder aka kdanilove06762a2015-03-22 23:32:09 +02007from disk_perf_test_tool.utils import parse_creds
Yulia Portnova0e64ea22015-03-20 17:27:22 +02008
9logger = logging.getLogger("io-perf-tool")
10
11
12def discover(cluster_conf):
13 if not cluster_conf:
14 logger.error("No nodes configured")
15
16 nodes_to_run = []
17 for cluster, cluster_info in cluster_conf.items():
18 if cluster == "openstack":
koder aka kdanilove06762a2015-03-22 23:32:09 +020019
20 conn = cluster_info['connection']
21 user, passwd, tenant = parse_creds(conn['creds'])
22
23 auth_data = dict(
24 auth_url=conn['auth_url'],
25 username=user,
26 api_key=passwd,
27 project_id=tenant)
28
Yulia Portnova0e64ea22015-03-20 17:27:22 +020029 if not conn:
30 logger.error("No connection provided for %s. Skipping"
31 % cluster)
32 continue
koder aka kdanilove06762a2015-03-22 23:32:09 +020033
Yulia Portnova0e64ea22015-03-20 17:27:22 +020034 logger.debug("Discovering openstack nodes "
35 "with connection details: %r" %
36 conn)
37
koder aka kdanilove06762a2015-03-22 23:32:09 +020038 os_nodes = openstack.discover_openstack_nodes(auth_data,
39 cluster_info)
40 nodes_to_run.extend(os_nodes)
41
Yulia Portnova0e64ea22015-03-20 17:27:22 +020042 if cluster == "fuel":
43 url = cluster_info['connection'].pop('url')
44 creads = cluster_info['connection']
45 roles = cluster_info['discover']
koder aka kdanilove06762a2015-03-22 23:32:09 +020046
Yulia Portnova0e64ea22015-03-20 17:27:22 +020047 if isinstance(roles, basestring):
48 roles = [roles]
koder aka kdanilove06762a2015-03-22 23:32:09 +020049
Yulia Portnova0e64ea22015-03-20 17:27:22 +020050 nodes_to_run.extend(fuel.discover_fuel_nodes(url, creads, roles))
51
52 if cluster == "ceph":
koder aka kdanilov2c473092015-03-29 17:12:13 +030053 nodes_to_run.extend(ceph.discover_ceph_nodes(cluster_info))
54
Yulia Portnova0e64ea22015-03-20 17:27:22 +020055 return nodes_to_run