From 9adf74094f9dd37cbeca25c2ec48701e7ce396e3 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Mon, 8 Jul 2013 15:27:00 +0200 Subject: [PATCH] Fix MongoDB backward compat wrt units Fixes: bug#1193908 Change-Id: I9f4f2ec6cbec424279149b82704f88cad9c740b8 Signed-off-by: Julien Danjou --- ceilometer/storage/impl_mongodb.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ceilometer/storage/impl_mongodb.py b/ceilometer/storage/impl_mongodb.py index 4580833dd..b8dd11883 100644 --- a/ceilometer/storage/impl_mongodb.py +++ b/ceilometer/storage/impl_mongodb.py @@ -427,7 +427,7 @@ class Connection(base.Connection): models.ResourceMeter( counter_name=meter['counter_name'], counter_type=meter['counter_type'], - counter_unit=meter['counter_unit'], + counter_unit=meter.get('counter_unit', ''), ) for meter in resource['meter'] ], @@ -460,7 +460,7 @@ class Connection(base.Connection): name=r_meter['counter_name'], type=r_meter['counter_type'], # Return empty string if 'counter_unit' is not valid for - # backward compaitiblity. + # backward compatibility. unit=r_meter.get('counter_unit', ''), resource_id=r['_id'], project_id=r['project_id'], @@ -489,6 +489,8 @@ class Connection(base.Connection): # the sample was inserted. It is an implementation # detail that should not leak outside of the driver. del s['_id'] + # Backward compatibility for samples without units + s['counter_unit'] = s.get('counter_unit', '') yield models.Sample(**s) def get_meter_statistics(self, sample_filter, period=None):