koder aka kdanilov | e06762a | 2015-03-22 23:32:09 +0200 | [diff] [blame^] | 1 | import logging |
| 2 | |
| 3 | |
Yulia Portnova | 21289b2 | 2015-03-18 15:21:43 +0200 | [diff] [blame] | 4 | import node |
Yulia Portnova | 3556a06 | 2015-03-17 16:30:11 +0200 | [diff] [blame] | 5 | import fuel_rest_api |
koder aka kdanilov | e06762a | 2015-03-22 23:32:09 +0200 | [diff] [blame^] | 6 | from disk_perf_test_tool.utils import parse_creds |
Yulia Portnova | 3556a06 | 2015-03-17 16:30:11 +0200 | [diff] [blame] | 7 | |
| 8 | |
Yulia Portnova | 0e64ea2 | 2015-03-20 17:27:22 +0200 | [diff] [blame] | 9 | logger = logging.getLogger("io-perf-tool") |
| 10 | |
| 11 | |
| 12 | def discover_fuel_nodes(root_url, credentials, roles): |
Yulia Portnova | 3556a06 | 2015-03-17 16:30:11 +0200 | [diff] [blame] | 13 | """Discover Fuel nodes""" |
koder aka kdanilov | e06762a | 2015-03-22 23:32:09 +0200 | [diff] [blame^] | 14 | user, passwd, tenant = parse_creds(credentials['creds']) |
| 15 | |
| 16 | creds = dict( |
| 17 | username=user, |
| 18 | password=passwd, |
| 19 | tenant_name=tenant, |
| 20 | ) |
| 21 | |
| 22 | connection = fuel_rest_api.KeystoneAuth(root_url, creds) |
Yulia Portnova | 3556a06 | 2015-03-17 16:30:11 +0200 | [diff] [blame] | 23 | fi = fuel_rest_api.FuelInfo(connection) |
Yulia Portnova | 0e64ea2 | 2015-03-20 17:27:22 +0200 | [diff] [blame] | 24 | nodes = [] |
| 25 | for role in roles: |
| 26 | nodes.extend(getattr(fi.nodes, role)) |
| 27 | logger.debug("Found %s fuel nodes" % len(fi.nodes)) |
koder aka kdanilov | e06762a | 2015-03-22 23:32:09 +0200 | [diff] [blame^] | 28 | return [node.Node(n.ip, n.get_roles()) for n in nodes] |