blob: 62da457026fb91d9d2492bcb4c9c1558902d1587 [file] [log] [blame]
Yulia Portnova0e64ea22015-03-20 17:27:22 +02001import logging
koder aka kdanilovda45e882015-04-06 02:24:42 +03002import urlparse
Yulia Portnova0e64ea22015-03-20 17:27:22 +02003
Yulia Portnova0e64ea22015-03-20 17:27:22 +02004import ceph
5import fuel
koder aka kdanilove06762a2015-03-22 23:32:09 +02006import openstack
Yulia Portnova0e64ea22015-03-20 17:27:22 +02007
koder aka kdanilove06762a2015-03-22 23:32:09 +02008from disk_perf_test_tool.utils import parse_creds
Yulia Portnova0e64ea22015-03-20 17:27:22 +02009
10logger = logging.getLogger("io-perf-tool")
11
12
koder aka kdanilovda45e882015-04-06 02:24:42 +030013def discover(discover, clusters_info):
Yulia Portnova0e64ea22015-03-20 17:27:22 +020014 nodes_to_run = []
koder aka kdanilovda45e882015-04-06 02:24:42 +030015 for cluster in discover:
Yulia Portnova0e64ea22015-03-20 17:27:22 +020016 if cluster == "openstack":
koder aka kdanilovda45e882015-04-06 02:24:42 +030017 cluster_info = clusters_info["openstack"]
koder aka kdanilove06762a2015-03-22 23:32:09 +020018 conn = cluster_info['connection']
19 user, passwd, tenant = parse_creds(conn['creds'])
20
21 auth_data = dict(
22 auth_url=conn['auth_url'],
23 username=user,
24 api_key=passwd,
25 project_id=tenant)
26
Yulia Portnova0e64ea22015-03-20 17:27:22 +020027 if not conn:
28 logger.error("No connection provided for %s. Skipping"
29 % cluster)
30 continue
koder aka kdanilove06762a2015-03-22 23:32:09 +020031
Yulia Portnova0e64ea22015-03-20 17:27:22 +020032 logger.debug("Discovering openstack nodes "
33 "with connection details: %r" %
34 conn)
35
koder aka kdanilove06762a2015-03-22 23:32:09 +020036 os_nodes = openstack.discover_openstack_nodes(auth_data,
37 cluster_info)
38 nodes_to_run.extend(os_nodes)
39
koder aka kdanilovda45e882015-04-06 02:24:42 +030040 elif cluster == "fuel" or cluster == "fuel+openstack":
41 cluster_info = clusters_info['fuel']
42 url = cluster_info['url']
43 creds = cluster_info['creds']
44 ssh_creds = cluster_info['ssh_creds']
45 # if user:password format us used
46 if not ssh_creds.startswith("ssh://"):
47 ip_port = urlparse.urlparse(url).netloc
koder aka kdanilove06762a2015-03-22 23:32:09 +020048
koder aka kdanilovda45e882015-04-06 02:24:42 +030049 if ':' in ip_port:
50 ip = ip_port.split(":")[0]
51 else:
52 ip = ip_port
koder aka kdanilove06762a2015-03-22 23:32:09 +020053
koder aka kdanilovda45e882015-04-06 02:24:42 +030054 ssh_creds = "ssh://{0}@{1}".format(ssh_creds, ip)
Yulia Portnova0e64ea22015-03-20 17:27:22 +020055
koder aka kdanilovda45e882015-04-06 02:24:42 +030056 env = cluster_info['openstack_env']
57
58 nodes_to_run.extend(fuel.discover_fuel_nodes(url, creds, env))
59
60 elif cluster == "ceph":
61 cluster_info = clusters_info["ceph"]
koder aka kdanilov2c473092015-03-29 17:12:13 +030062 nodes_to_run.extend(ceph.discover_ceph_nodes(cluster_info))
koder aka kdanilovda45e882015-04-06 02:24:42 +030063 else:
64 msg_templ = "Unknown cluster type in 'discover' parameter: {0!r}"
65 raise ValueError(msg_templ.format(cluster))
koder aka kdanilov2c473092015-03-29 17:12:13 +030066
Yulia Portnova0e64ea22015-03-20 17:27:22 +020067 return nodes_to_run