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 ]
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