def _create_in_db(context, updates): session = db_api.get_api_session() db_mapping = api_models.CellMapping() db_mapping.update(updates) db_mapping.save(session) return db_mapping
def _destroy_in_db(context, uuid): session = db_api.get_api_session() with session.begin(): result = session.query(api_models.CellMapping).filter_by( uuid=uuid).delete() if not result: raise exception.CellMappingNotFound(uuid=uuid)
def _get_by_project_id_from_db(context, project_id): session = db_api.get_api_session() with session.begin(): db_mappings = session.query(api_models.InstanceMapping).filter_by( project_id=project_id).all() return db_mappings
def _get_by_uuid_from_db(context, uuid): session = db_api.get_api_session() with session.begin(): db_mapping = session.query(api_models.CellMapping).filter_by( uuid=uuid).first() if not db_mapping: raise exception.CellMappingNotFound(uuid=uuid) return db_mapping
def _save_in_db(context, uuid, updates): session = db_api.get_api_session() with session.begin(): db_mapping = session.query( api_models.CellMapping).filter_by(uuid=uuid).first() if not db_mapping: raise exception.CellMappingNotFound(uuid=uuid) db_mapping.update(updates) session.add(db_mapping) return db_mapping