Example #1
0
    def execute(self, macros: MacroMappings,
                bi_searcher: ABCBISearcher) -> List[Dict]:
        new_conditions = replace_macros(self.conditions, macros)
        search_matches: List[BIHostSearchMatch] = bi_searcher.search_hosts(
            new_conditions)

        if self.refer_to == "host":
            return self._refer_to_host_results(search_matches)
        if self.refer_to == "child":
            return self._refer_to_children_results(search_matches, bi_searcher)
        if self.refer_to == "parent":
            return self._refer_to_parent_results(search_matches)
        # TODO: child with, will be done in later commit

        raise NotImplementedError("Invalid refer to type %r" % self.refer_to)
Example #2
0
    def execute(self, macros: MacroMapping, bi_searcher: ABCBISearcher) -> List[Dict]:
        new_conditions = replace_macros(self.conditions, macros)
        search_matches: List[BIHostSearchMatch] = bi_searcher.search_hosts(new_conditions)

        if self.refer_to == "host":
            return self._refer_to_host_results(search_matches)
        if self.refer_to == "child":
            return self._refer_to_children_results(search_matches, bi_searcher)
        if self.refer_to == "parent":
            return self._refer_to_parent_results(search_matches)
        if isinstance(self.refer_to, tuple):
            refer_type, refer_config = self.refer_to
            if refer_type == "child_with":
                return self._refer_to_children_with_results(search_matches, bi_searcher,
                                                            refer_config)

        raise NotImplementedError("Invalid refer to type %r" % (self.refer_to,))