From 77a0603bebcb25fba94ddfb40e50baed46eb9384 Mon Sep 17 00:00:00 2001 From: Tong Li Date: Wed, 2 Oct 2013 09:18:14 -0400 Subject: [PATCH] db2 does not allow None as a key for user_id in user collection mongodb allows None value as a key for _id field, but db2 does not. this patch will fix the problem when meters coming with user_id being set to None. Change-Id: If48e5117198f3e9ad834e4f7fa58ec27c57a8bc8 fixes: bug #1234165 --- ceilometer/storage/impl_db2.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ceilometer/storage/impl_db2.py b/ceilometer/storage/impl_db2.py index f74e774d7..b44f424b1 100644 --- a/ceilometer/storage/impl_db2.py +++ b/ceilometer/storage/impl_db2.py @@ -307,7 +307,7 @@ class Connection(base.Connection): """ # Make sure we know about the user and project self.db.user.update( - {'_id': data['user_id']}, + {'_id': data['user_id'] or 'null'}, {'$addToSet': {'source': data['source'], }, }, @@ -325,7 +325,7 @@ class Connection(base.Connection): self.db.resource.update( {'_id': data['resource_id']}, {'$set': {'project_id': data['project_id'], - 'user_id': data['user_id'], + 'user_id': data['user_id'] or 'null', 'metadata': data['resource_metadata'], 'source': data['source'], },