diff --git a/Products/ZenCollector/services/ConfigCache.py b/Products/ZenCollector/services/ConfigCache.py index e61e8800c7..8dedded71d 100644 --- a/Products/ZenCollector/services/ConfigCache.py +++ b/Products/ZenCollector/services/ConfigCache.py @@ -128,10 +128,10 @@ def remote_getDeviceConfigs( return { "new": [ - self._stores.device.get(key).config for key in newest_keys + _get_configs(newest_keys, self._stores.device, self.log) ], "updated": [ - self._stores.device.get(key).config for key in updated_keys + _get_configs(updated_keys, self._stores.device, self.log) ], "removed": list(removed), } @@ -195,6 +195,25 @@ def _filter(self, keys, predicate): method("error filtering device ID %s", key.device) +def _get_configs(keys, store, log): + if log.isEnabledFor(logging.DEBUG): + mlog = log.exception + else: + mlog = log.error + for key in keys: + try: + yield store.get(key).config + except Exception as ex: + mlog( + "failed to retrieve config " + "error=%s service=%s collector=%s device=%s", + ex, + key.service, + key.monitor, + key.device, + ) + + class _DeviceProxy(object): # The predicate returned by getOptionsFilter expects an object # with an `id` attribute. So make a simple class with one attribute.