diff --git a/ceilometer/alarm/storage/impl_mongodb.py b/ceilometer/alarm/storage/impl_mongodb.py index c8a66e12..288b0d9e 100644 --- a/ceilometer/alarm/storage/impl_mongodb.py +++ b/ceilometer/alarm/storage/impl_mongodb.py @@ -64,11 +64,7 @@ class Connection(pymongo_base.Connection): self.upgrade() def upgrade(self): - # create collection if not present - if 'alarm' not in self.db.conn.collection_names(): - self.db.conn.create_collection('alarm') - if 'alarm_history' not in self.db.conn.collection_names(): - self.db.conn.create_collection('alarm_history') + super(Connection, self).upgrade() # Establish indexes ttl = cfg.CONF.database.alarm_history_time_to_live impl_mongodb.Connection.update_ttl( diff --git a/ceilometer/alarm/storage/pymongo_base.py b/ceilometer/alarm/storage/pymongo_base.py index c097ac1d..b72526f9 100644 --- a/ceilometer/alarm/storage/pymongo_base.py +++ b/ceilometer/alarm/storage/pymongo_base.py @@ -54,6 +54,13 @@ class Connection(base.Connection): AVAILABLE_STORAGE_CAPABILITIES, ) + def upgrade(self): + # create collection if not present + if 'alarm' not in self.db.conn.collection_names(): + self.db.conn.create_collection('alarm') + if 'alarm_history' not in self.db.conn.collection_names(): + self.db.conn.create_collection('alarm_history') + def update_alarm(self, alarm): """Update alarm.""" data = alarm.as_dict() diff --git a/ceilometer/event/storage/impl_db2.py b/ceilometer/event/storage/impl_db2.py index a2a83f71..2d88678b 100644 --- a/ceilometer/event/storage/impl_db2.py +++ b/ceilometer/event/storage/impl_db2.py @@ -55,6 +55,11 @@ class Connection(pymongo_base.Connection): self.upgrade() + def upgrade(self): + # create collection if not present + if 'event' not in self.db.conn.collection_names(): + self.db.conn.create_collection('event') + def clear(self): # drop_database command does nothing on db2 database since this has # not been implemented. However calling this method is important for diff --git a/ceilometer/storage/impl_db2.py b/ceilometer/storage/impl_db2.py index bf8843a0..ba19a1b2 100644 --- a/ceilometer/storage/impl_db2.py +++ b/ceilometer/storage/impl_db2.py @@ -156,6 +156,12 @@ class Connection(pymongo_base.Connection): return init_str def upgrade(self, version=None): + # create collection if not present + if 'resource' not in self.db.conn.collection_names(): + self.db.conn.create_collection('resource') + if 'meter' not in self.db.conn.collection_names(): + self.db.conn.create_collection('meter') + # Establish indexes # # We need variations for user_id vs. project_id because of the