super().__init__()
self._client = client
self._bus = bus
+ self._tags = None
# self._uow = bus.uow
def targetname(self) -> str:
return self._targetname()
- def probe(self, parent: commands.Command = None):
+ def probe(self, parent: commands.Command = None, tags: object = None):
try:
- cmds = self._probe(parent.data if parent else None)
+ cmds = self._probe(
+ parent.data if parent else None, tags)
for cmd in cmds:
self._bus.handle(cmd)
# return self._probe(parent)
return cmds
except Exception as ex:
- logger.warning("Failed to probe resource due to: " + str(ex))
+ logger.warning("Failed to probe %s watcher due to: %s - %s" %
+ (self._targetname(), type(ex), str(ex)))
return []
- def _probe(self, parent: object = None) -> commands.Command:
+ def _probe(self, parent: object = None, tags: object = None) \
+ -> commands.Command:
raise NotImplementedError
def _targetname(self):
super().__init__()
self.watcher = watcher
self.children = {}
+ self.tags = None
def addchild(self, watcher: BaseWatcher) -> object:
child = WatcherTree(watcher)
return self.children.pop(targetname)
# probe all resources by parent, depth = 0 for indefinite recursive
- def probe(self, parentresource=None, depth: int = 0):
+ def probe(self, parentresource=None, depth: int = 0, tags: object = None):
logger.debug("probe resources with watcher: "
+ self.watcher.targetname())
childdepth = depth - 1 if depth > 0 else 0
- resources = self.watcher.probe(parentresource)
+ resources = self.watcher.probe(parentresource, tags)
logger.debug("probe returns " + str(len(resources)) + " resources")
+ if self.watcher._tags is not None:
+ tags = self.watcher._tags
if depth == 1:
# stop recursive
for res in resources:
for targetname in self.children.keys():
- self.children[targetname].probe(res, childdepth)
+ self.children[targetname].probe(res, childdepth, tags)