Fix collectd plugins when 'internalURL' isn't set

It is possible to register a service in the Keystone catalog without
internalURL. This change fixes the collectd plugins to support that
configuration.

Change-Id: Id5ef3c4fcd473b92855cb656a80435d670062cfb
Closes-Bug: #1676755
This commit is contained in:
Simon Pasquier 2017-03-28 09:35:44 +02:00
parent 9040d3e359
commit b5a12ffbfa
1 changed files with 6 additions and 1 deletions

View File

@ -104,11 +104,16 @@ class OSClient(object):
self.service_catalog = []
for item in data['access']['serviceCatalog']:
endpoint = item['endpoints'][0]
if 'internalURL' not in endpoint and 'publicURL' not in endpoint:
self.logger.warning(
"Service '{}' skipped because no URL can be found".format(
item['name']))
continue
self.service_catalog.append({
'name': item['name'],
'region': endpoint['region'],
'service_type': item['type'],
'url': endpoint['internalURL'],
'url': endpoint.get('internalURL', endpoint.get('publicURL')),
'admin_url': endpoint['adminURL'],
})