Yulia Portnova | 0e64ea2 | 2015-03-20 17:27:22 +0200 | [diff] [blame] | 1 | import logging |
koder aka kdanilov | da45e88 | 2015-04-06 02:24:42 +0300 | [diff] [blame^] | 2 | import urlparse |
Yulia Portnova | 0e64ea2 | 2015-03-20 17:27:22 +0200 | [diff] [blame] | 3 | |
Yulia Portnova | 0e64ea2 | 2015-03-20 17:27:22 +0200 | [diff] [blame] | 4 | import ceph |
| 5 | import fuel |
koder aka kdanilov | e06762a | 2015-03-22 23:32:09 +0200 | [diff] [blame] | 6 | import openstack |
Yulia Portnova | 0e64ea2 | 2015-03-20 17:27:22 +0200 | [diff] [blame] | 7 | |
koder aka kdanilov | e06762a | 2015-03-22 23:32:09 +0200 | [diff] [blame] | 8 | from disk_perf_test_tool.utils import parse_creds |
Yulia Portnova | 0e64ea2 | 2015-03-20 17:27:22 +0200 | [diff] [blame] | 9 | |
| 10 | logger = logging.getLogger("io-perf-tool") |
| 11 | |
| 12 | |
koder aka kdanilov | da45e88 | 2015-04-06 02:24:42 +0300 | [diff] [blame^] | 13 | def discover(discover, clusters_info): |
Yulia Portnova | 0e64ea2 | 2015-03-20 17:27:22 +0200 | [diff] [blame] | 14 | nodes_to_run = [] |
koder aka kdanilov | da45e88 | 2015-04-06 02:24:42 +0300 | [diff] [blame^] | 15 | for cluster in discover: |
Yulia Portnova | 0e64ea2 | 2015-03-20 17:27:22 +0200 | [diff] [blame] | 16 | if cluster == "openstack": |
koder aka kdanilov | da45e88 | 2015-04-06 02:24:42 +0300 | [diff] [blame^] | 17 | cluster_info = clusters_info["openstack"] |
koder aka kdanilov | e06762a | 2015-03-22 23:32:09 +0200 | [diff] [blame] | 18 | 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 Portnova | 0e64ea2 | 2015-03-20 17:27:22 +0200 | [diff] [blame] | 27 | if not conn: |
| 28 | logger.error("No connection provided for %s. Skipping" |
| 29 | % cluster) |
| 30 | continue |
koder aka kdanilov | e06762a | 2015-03-22 23:32:09 +0200 | [diff] [blame] | 31 | |
Yulia Portnova | 0e64ea2 | 2015-03-20 17:27:22 +0200 | [diff] [blame] | 32 | logger.debug("Discovering openstack nodes " |
| 33 | "with connection details: %r" % |
| 34 | conn) |
| 35 | |
koder aka kdanilov | e06762a | 2015-03-22 23:32:09 +0200 | [diff] [blame] | 36 | os_nodes = openstack.discover_openstack_nodes(auth_data, |
| 37 | cluster_info) |
| 38 | nodes_to_run.extend(os_nodes) |
| 39 | |
koder aka kdanilov | da45e88 | 2015-04-06 02:24:42 +0300 | [diff] [blame^] | 40 | 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 kdanilov | e06762a | 2015-03-22 23:32:09 +0200 | [diff] [blame] | 48 | |
koder aka kdanilov | da45e88 | 2015-04-06 02:24:42 +0300 | [diff] [blame^] | 49 | if ':' in ip_port: |
| 50 | ip = ip_port.split(":")[0] |
| 51 | else: |
| 52 | ip = ip_port |
koder aka kdanilov | e06762a | 2015-03-22 23:32:09 +0200 | [diff] [blame] | 53 | |
koder aka kdanilov | da45e88 | 2015-04-06 02:24:42 +0300 | [diff] [blame^] | 54 | ssh_creds = "ssh://{0}@{1}".format(ssh_creds, ip) |
Yulia Portnova | 0e64ea2 | 2015-03-20 17:27:22 +0200 | [diff] [blame] | 55 | |
koder aka kdanilov | da45e88 | 2015-04-06 02:24:42 +0300 | [diff] [blame^] | 56 | 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 kdanilov | 2c47309 | 2015-03-29 17:12:13 +0300 | [diff] [blame] | 62 | nodes_to_run.extend(ceph.discover_ceph_nodes(cluster_info)) |
koder aka kdanilov | da45e88 | 2015-04-06 02:24:42 +0300 | [diff] [blame^] | 63 | else: |
| 64 | msg_templ = "Unknown cluster type in 'discover' parameter: {0!r}" |
| 65 | raise ValueError(msg_templ.format(cluster)) |
koder aka kdanilov | 2c47309 | 2015-03-29 17:12:13 +0300 | [diff] [blame] | 66 | |
Yulia Portnova | 0e64ea2 | 2015-03-20 17:27:22 +0200 | [diff] [blame] | 67 | return nodes_to_run |