blob: 769f263070788238468709152d34e3c0b4cca7bc [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
koder aka kdanilove06762a2015-03-22 23:32:09 +02005import openstack
Yulia Portnova0e64ea22015-03-20 17:27:22 +02006
gstepanovf1ff52d2015-04-07 15:54:33 +03007from utils import parse_creds
8from scripts import connector
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']
gstepanovf1ff52d2015-04-07 15:54:33 +030042 cluster_id = cluster_info['id']
koder aka kdanilovda45e882015-04-06 02:24:42 +030043 url = cluster_info['url']
44 creds = cluster_info['creds']
45 ssh_creds = cluster_info['ssh_creds']
46 # if user:password format us used
47 if not ssh_creds.startswith("ssh://"):
48 ip_port = urlparse.urlparse(url).netloc
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']
gstepanovf1ff52d2015-04-07 15:54:33 +030057 nodes_to_run.extend(connector.discover_fuel_nodes(url, creds, cluster_id)[0])
koder aka kdanilovda45e882015-04-06 02:24:42 +030058
59 elif cluster == "ceph":
60 cluster_info = clusters_info["ceph"]
koder aka kdanilov2c473092015-03-29 17:12:13 +030061 nodes_to_run.extend(ceph.discover_ceph_nodes(cluster_info))
koder aka kdanilovda45e882015-04-06 02:24:42 +030062 else:
63 msg_templ = "Unknown cluster type in 'discover' parameter: {0!r}"
64 raise ValueError(msg_templ.format(cluster))
koder aka kdanilov2c473092015-03-29 17:12:13 +030065
Yulia Portnova0e64ea22015-03-20 17:27:22 +020066 return nodes_to_run