Add CellMappingList object

The ability to get a list of all CellMapping objects is needed for some
tooling around adding new hosts to a cell. This adds the necessary
class/method.

Change-Id: Ia402a49d68a5c69891d39c95ac92ea1ceeb99739
This commit is contained in:
Andrew Laski
2016-06-13 18:12:32 -04:00
parent fab0cba7cd
commit 34834d82c0
4 changed files with 85 additions and 18 deletions

View File

@@ -103,3 +103,23 @@ class CellMapping(base.NovaTimestampObject, base.NovaObject):
@base.remotable
def destroy(self):
self._destroy_in_db(self._context, self.uuid)
@base.NovaObjectRegistry.register
class CellMappingList(base.ObjectListBase, base.NovaObject):
# Version 1.0: Initial version
VERSION = '1.0'
fields = {
'objects': fields.ListOfObjectsField('CellMapping'),
}
@staticmethod
@db_api.api_context_manager.reader
def _get_all_from_db(context):
return context.session.query(api_models.CellMapping).all()
@base.remotable_classmethod
def get_all(cls, context):
db_mappings = cls._get_all_from_db(context)
return base.obj_make_list(context, cls(), CellMapping, db_mappings)