Fixed tenant fetcher using Keystone objects

Change-Id: I3b84ff7850156bbfad86634719cb880a64ab6d29
This commit is contained in:
Stéphane Albert 2015-05-13 19:23:42 +02:00
parent a0cf5936a2
commit 797a63b345
3 changed files with 11 additions and 6 deletions

View File

@ -297,12 +297,12 @@ class Orchestrator(object):
self._load_tenant_list()
while len(self._tenants):
for tenant in self._tenants:
if not self._check_state(tenant.id):
if not self._check_state(tenant):
self._tenants.remove(tenant)
else:
worker = Worker(self.collector,
self.storage,
tenant.id)
tenant)
worker.run()
# FIXME(sheeprine): We may cause a drift here
eventlet.sleep(CONF.collect.period)

View File

@ -69,4 +69,4 @@ class KeystoneFetcher(tenant_fetcher.BaseFetcher):
tenant)
if 'rating' not in [role.name for role in roles]:
tenant_list.remove(tenant)
return tenant_list
return [tenant.id for tenant in tenant_list]

View File

@ -28,6 +28,11 @@ class FakeRole(object):
self.name = name
class FakeTenant(object):
def __init__(self, id):
self.id = id
class FakeKeystoneClient(object):
user_id = 'd89e3fee-2b92-4387-b564-63901d62e591'
@ -38,8 +43,8 @@ class FakeKeystoneClient(object):
class FakeTenants(object):
@classmethod
def list(cls):
return ['f266f30b11f246b589fd266f85eeec39',
'4dfb25b0947c4f5481daf7b948c14187']
return [FakeTenant('f266f30b11f246b589fd266f85eeec39'),
FakeTenant('4dfb25b0947c4f5481daf7b948c14187')]
class FakeRoles(object):
roles_mapping = {
@ -50,7 +55,7 @@ class FakeKeystoneClient(object):
@classmethod
def roles_for_user(cls, user_id, tenant, **kwargs):
return cls.roles_mapping[user_id][tenant]
return cls.roles_mapping[user_id][tenant.id]
roles = FakeRoles()
tenants = FakeTenants()