Yulia Portnova | 0e64ea2 | 2015-03-20 17:27:22 +0200 | [diff] [blame] | 1 | import logging |
| 2 | |
Yulia Portnova | 0e64ea2 | 2015-03-20 17:27:22 +0200 | [diff] [blame] | 3 | import ceph |
| 4 | import fuel |
koder aka kdanilov | e06762a | 2015-03-22 23:32:09 +0200 | [diff] [blame] | 5 | import openstack |
Yulia Portnova | 0e64ea2 | 2015-03-20 17:27:22 +0200 | [diff] [blame] | 6 | |
koder aka kdanilov | e06762a | 2015-03-22 23:32:09 +0200 | [diff] [blame] | 7 | from disk_perf_test_tool.utils import parse_creds |
Yulia Portnova | 0e64ea2 | 2015-03-20 17:27:22 +0200 | [diff] [blame] | 8 | |
| 9 | logger = logging.getLogger("io-perf-tool") |
| 10 | |
| 11 | |
| 12 | def 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 kdanilov | e06762a | 2015-03-22 23:32:09 +0200 | [diff] [blame] | 19 | |
| 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 Portnova | 0e64ea2 | 2015-03-20 17:27:22 +0200 | [diff] [blame] | 29 | if not conn: |
| 30 | logger.error("No connection provided for %s. Skipping" |
| 31 | % cluster) |
| 32 | continue |
koder aka kdanilov | e06762a | 2015-03-22 23:32:09 +0200 | [diff] [blame] | 33 | |
Yulia Portnova | 0e64ea2 | 2015-03-20 17:27:22 +0200 | [diff] [blame] | 34 | logger.debug("Discovering openstack nodes " |
| 35 | "with connection details: %r" % |
| 36 | conn) |
| 37 | |
koder aka kdanilov | e06762a | 2015-03-22 23:32:09 +0200 | [diff] [blame] | 38 | os_nodes = openstack.discover_openstack_nodes(auth_data, |
| 39 | cluster_info) |
| 40 | nodes_to_run.extend(os_nodes) |
| 41 | |
Yulia Portnova | 0e64ea2 | 2015-03-20 17:27:22 +0200 | [diff] [blame] | 42 | if cluster == "fuel": |
| 43 | url = cluster_info['connection'].pop('url') |
| 44 | creads = cluster_info['connection'] |
| 45 | roles = cluster_info['discover'] |
koder aka kdanilov | e06762a | 2015-03-22 23:32:09 +0200 | [diff] [blame] | 46 | |
Yulia Portnova | 0e64ea2 | 2015-03-20 17:27:22 +0200 | [diff] [blame] | 47 | if isinstance(roles, basestring): |
| 48 | roles = [roles] |
koder aka kdanilov | e06762a | 2015-03-22 23:32:09 +0200 | [diff] [blame] | 49 | |
Yulia Portnova | 0e64ea2 | 2015-03-20 17:27:22 +0200 | [diff] [blame] | 50 | nodes_to_run.extend(fuel.discover_fuel_nodes(url, creads, roles)) |
| 51 | |
| 52 | if cluster == "ceph": |
koder aka kdanilov | 2c47309 | 2015-03-29 17:12:13 +0300 | [diff] [blame] | 53 | nodes_to_run.extend(ceph.discover_ceph_nodes(cluster_info)) |
| 54 | |
Yulia Portnova | 0e64ea2 | 2015-03-20 17:27:22 +0200 | [diff] [blame] | 55 | return nodes_to_run |