Enable Keystone v3 API when obtaining users and tenants
Always use Keystone v3 API obtaining users and projects in order to list all
users and tenants in multi-domain environments.
Change-Id: If94ad4a0d61d0467031b384d132eb433682b3a20
Closes-Bug: #1662142
(cherry picked from commit bc797dfb4b
)
This commit is contained in:
parent
f2653d5a82
commit
f61071aca6
|
@ -169,12 +169,11 @@ class CollectdPlugin(base.Base):
|
||||||
|
|
||||||
def _build_url(self, service, resource):
|
def _build_url(self, service, resource):
|
||||||
s = (self.get_service(service) or {})
|
s = (self.get_service(service) or {})
|
||||||
# the adminURL must be used to access resources with Keystone API v2
|
url = s.get('url')
|
||||||
if service == 'keystone' and \
|
# v3 API must be used in order to obtain tenants in multi-domain envs
|
||||||
(resource in ['tenants', 'users'] or 'OS-KS' in resource):
|
if service == 'keystone' and (resource in ['projects',
|
||||||
url = s.get('admin_url')
|
'users', 'roles']):
|
||||||
else:
|
url = url.replace('v2.0', 'v3')
|
||||||
url = s.get('url')
|
|
||||||
|
|
||||||
if url:
|
if url:
|
||||||
if url[-1] != '/':
|
if url[-1] != '/':
|
||||||
|
|
|
@ -40,11 +40,11 @@ class KeystoneStatsPlugin(openstack.CollectdPlugin):
|
||||||
return 'enabled' if d.get('enabled') else 'disabled'
|
return 'enabled' if d.get('enabled') else 'disabled'
|
||||||
|
|
||||||
# tenants
|
# tenants
|
||||||
r = self.get('keystone', 'tenants')
|
r = self.get('keystone', 'projects')
|
||||||
if not r:
|
if not r:
|
||||||
self.logger.warning('Could not find Keystone tenants')
|
self.logger.warning('Could not find Keystone tenants')
|
||||||
return
|
return
|
||||||
tenants_details = r.json().get('tenants', [])
|
tenants_details = r.json().get('projects', [])
|
||||||
status = self.count_objects_group_by(tenants_details,
|
status = self.count_objects_group_by(tenants_details,
|
||||||
group_by_func=groupby)
|
group_by_func=groupby)
|
||||||
for s, nb in status.iteritems():
|
for s, nb in status.iteritems():
|
||||||
|
@ -70,7 +70,7 @@ class KeystoneStatsPlugin(openstack.CollectdPlugin):
|
||||||
}
|
}
|
||||||
|
|
||||||
# roles
|
# roles
|
||||||
r = self.get('keystone', 'OS-KSADM/roles')
|
r = self.get('keystone', 'roles')
|
||||||
if not r:
|
if not r:
|
||||||
self.logger.warning('Could not find Keystone roles')
|
self.logger.warning('Could not find Keystone roles')
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue