blob: 25476dca0253626872b44c9a10d9d92f3b0a041a [file] [log] [blame]
koder aka kdanilove06762a2015-03-22 23:32:09 +02001import logging
2
3
Yulia Portnova21289b22015-03-18 15:21:43 +02004import node
Yulia Portnova3556a062015-03-17 16:30:11 +02005import fuel_rest_api
koder aka kdanilove06762a2015-03-22 23:32:09 +02006from disk_perf_test_tool.utils import parse_creds
Yulia Portnova3556a062015-03-17 16:30:11 +02007
8
Yulia Portnova0e64ea22015-03-20 17:27:22 +02009logger = logging.getLogger("io-perf-tool")
10
11
12def discover_fuel_nodes(root_url, credentials, roles):
Yulia Portnova3556a062015-03-17 16:30:11 +020013 """Discover Fuel nodes"""
koder aka kdanilove06762a2015-03-22 23:32:09 +020014 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 Portnova3556a062015-03-17 16:30:11 +020023 fi = fuel_rest_api.FuelInfo(connection)
Yulia Portnova0e64ea22015-03-20 17:27:22 +020024 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 kdanilove06762a2015-03-22 23:32:09 +020028 return [node.Node(n.ip, n.get_roles()) for n in nodes]