def select_configs_for_feature()

in cookbooks/aws-parallelcluster-environment/files/cloudwatch/write_cloudwatch_agent_json.py [0:0]


def select_configs_for_feature(configs):
    """Filter out from configs those entries whose 'feature_conditions' list contains an unsatisfied entry."""
    selected_configs = []
    node_info = get_node_info()
    for config in configs:
        conditions = config.get("feature_conditions", [])
        for condition in conditions:
            dna_keys = condition.get("dna_key")
            if isinstance(dna_keys, str):  # dna_key can be a string for single level dict or a list for nested dicts
                dna_keys = [dna_keys]
            value = node_info
            for key in dna_keys:
                value = value.get(key)
                if value is None:
                    break
            if value not in condition.get("satisfying_values"):
                break
        else:
            selected_configs.append(config)
    return selected_configs