Merge pull request #51 from Martin819/master
Added Kitchen tests and Travis
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)
diff --git a/collectd/files/plugin/openstack_glance.py b/collectd/files/plugin/openstack_glance.py
index 90bc9f8..efb94be 100644
--- a/collectd/files/plugin/openstack_glance.py
+++ b/collectd/files/plugin/openstack_glance.py
@@ -40,6 +40,19 @@
def itermetrics(self):
+ def default_metrics(suffix=''):
+ ret = {}
+ for name in ('snapshots', 'images'):
+ for visibility in ('public', 'private',
+ 'community', 'shared'):
+ for status in ('active', 'queued', 'saving',
+ 'killed', 'deleted', 'deactivated',
+ 'pending_delete'):
+ key = '%s%s.%s.%s' % (name, suffix,
+ visibility, status)
+ ret[key] = 0
+ return ret
+
def is_snap(d):
return d.get('image_type') == 'snapshot'
@@ -56,6 +69,8 @@
detail=False)
status = self.count_objects_group_by(images_details,
group_by_func=groupby)
+ if len(status) == 0:
+ status = default_metrics()
for s, nb in status.iteritems():
(name, visibility, state) = s.split('.')
yield {
@@ -79,6 +94,8 @@
sizes = self.count_objects_group_by(images_details,
group_by_func=groupby_size,
count_func=count_size_bytes)
+ if len(sizes) == 0:
+ sizes = default_metrics('_size')
for s, nb in sizes.iteritems():
(name, visibility, state) = s.split('.')
yield {