def test_alert_source_get_all(self, mock_session): fake_alert_source = [] mock_session.return_value.__enter__.return_value.query.return_value \ = fake_alert_source result = db_api.alert_source_get_all(ctxt) assert len(result) == 0 result = db_api.alert_source_get_all(ctxt, filters={'status': 'Normal'}) assert len(result) == 0
def _load_snmp_config(self): """Load snmp config from database when service start.""" ctxt = context.get_admin_context() marker = None finished = False limit = constants.DEFAULT_LIMIT while not finished: alert_sources = db_api.alert_source_get_all(ctxt, marker=marker, limit=limit) for alert_source in alert_sources: snmp_config = dict() snmp_config.update(alert_source) self._add_snmp_config(ctxt, snmp_config) marker = alert_source['storage_id'] if len(alert_sources) < limit: finished = True