def build_tag_query_dict_tuple(tags):
    query_tag_tuple = ()
    for string_tag in tags:
        query_tag_dict = {}
        tag_dict = Tag.from_string(string_tag).data()
        for key in tag_dict.keys():
            query_tag_dict[key] = {"eq": tag_dict[key]}
        query_tag_tuple += ({"tag": query_tag_dict}, )
    logger.debug("query_tag_tuple: %s", query_tag_tuple)
    return query_tag_tuple
Ejemplo n.º 2
0
def _find_hosts_by_tag(string_tags, query):
    logger.debug("_find_hosts_by_tag(%s)", string_tags)

    tags = []

    for string_tag in string_tags:
        tags.append(Tag.from_string(string_tag))

    tags_to_find = Tag.create_nested_from_tags(tags)

    return query.filter(Host.tags.contains(tags_to_find))