Fix MongoDB backward compat wrt units
Fixes: bug#1193908 Change-Id: I9f4f2ec6cbec424279149b82704f88cad9c740b8 Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
f1752175a2
commit
9adf74094f
@ -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):
|
||||
|
Loading…
x
Reference in New Issue
Block a user