Beispiel #1
0
 def _create_node(cls, node_config: Dict[str,
                                         Any]) -> AbstractBICompiledNode:
     if node_config["type"] == BICompiledRule.type():
         return cls.create_tree_from_schema(node_config)
     if node_config["type"] == BICompiledLeaf.type():
         return BICompiledLeaf(**node_config)
     raise NotImplementedError("Unknown node type")
Beispiel #2
0
 def execute(
     self, argument: ActionArgument, bi_searcher: ABCBISearcher
 ) -> List[ABCBICompiledNode]:
     host_matches, _match_groups = bi_searcher.get_host_name_matches(
         list(bi_searcher.hosts.values()), argument[0]
     )
     return [BICompiledLeaf(host_name=x.name, site_id=x.site_id) for x in host_matches]
Beispiel #3
0
    def execute(self, search_result: SearchResult,
                bi_searcher: ABCBISearcher) -> List[ABCBICompiledNode]:
        host_re = replace_macros(self.host_regex, search_result)
        host_matches, _match_groups = bi_searcher.get_host_name_matches(
            list(bi_searcher.hosts.values()), host_re)

        action_results: List[ABCBICompiledNode] = []
        for host_match in host_matches:
            action_results.append(
                BICompiledLeaf(host_name=host_match.name, site_id=host_match.site_id))
        return action_results
Beispiel #4
0
    def execute(self, argument: ActionArgument,
                bi_searcher: ABCBISearcher) -> List[ABCBICompiledNode]:
        matched_hosts, match_groups = bi_searcher.get_host_name_matches(
            list(bi_searcher.hosts.values()), argument[0])

        host_search_matches = [
            BIHostSearchMatch(x, match_groups[x.name]) for x in matched_hosts
        ]
        service_matches = bi_searcher.get_service_description_matches(
            host_search_matches, argument[1])
        return [
            BICompiledLeaf(
                site_id=x.host_match.host.site_id,
                host_name=x.host_match.host.name,
                service_description=x.service_description,
            ) for x in service_matches
        ]
Beispiel #5
0
    def execute(self, search_result: SearchResult,
                bi_searcher: ABCBISearcher) -> List[ABCBICompiledNode]:
        host_re = replace_macros(self.host_regex, search_result)
        service_re = replace_macros(self.service_regex, search_result)
        host_matches, _match_groups = bi_searcher.get_host_name_matches(
            list(bi_searcher.hosts.values()), host_re)

        action_results: List[ABCBICompiledNode] = []
        service_matches = bi_searcher.get_service_description_matches(host_matches, service_re)
        for service_match in service_matches:
            action_results.append(
                BICompiledLeaf(
                    site_id=service_match.host.site_id,
                    host_name=service_match.host.name,
                    service_description=service_match.service_description,
                ))

        return action_results