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: Ib43a42ca555ee31361fa454588bbb8f53737a5c0
diff --git a/collectd/files/plugin/collectd_openstack.py b/collectd/files/plugin/collectd_openstack.py
index ade9b60..e118332 100644
--- a/collectd/files/plugin/collectd_openstack.py
+++ b/collectd/files/plugin/collectd_openstack.py
@@ -111,13 +111,18 @@
endpoint = item['endpoints'][0]
if self.region and self.region != endpoint['region']:
continue
+ if 'internalURL' not in endpoint and 'publicURL' not in endpoint:
+ self.logger.warning(
+ "Skipping service '{}' with no valid URL".format(
+ endpoint["name"]
+ )
+ )
+ continue
self.service_catalog.append({
'name': item['name'],
'region': endpoint['region'],
- 'service_type': item['type'],
- 'url': endpoint['internalURL'],
- 'admin_url': endpoint['adminURL'],
+ 'url': endpoint.get('internalURL', endpoint.get('publicURL')),
})
self.logger.debug("Got token '%s'" % self.token)