Functest scripts, simulators, and payloads
[optf/osdf.git] / osdf / adapters / policy / utils.py
index f165079..2f873af 100644 (file)
@@ -23,37 +23,6 @@ import itertools
 from osdf.utils.programming_utils import dot_notation, list_flatten
 
 
-def group_policies(flat_policies):
-    """Filter policies using the following steps:
-    1. Apply prioritization among the policies that are sharing the same policy type and resource type
-    2. Remove redundant policies that may applicable across different types of resource
-    3. Filter policies based on type and return
-    :param flat_policies: list of flat policies
-    :return: Filtered policies
-    """
-    filtered_policies = defaultdict(list)
-    policy_name = []
-    policies = [x for x in flat_policies if x['content'].get('policyType')]  # drop ones without 'policy_type'
-    policy_types = set([x['content'].get('policyType') for x in policies])
-    aggregated_policies = dict((x, defaultdict(list)) for x in policy_types)
-
-    for policy in policies:
-        policy_type = policy['content'].get('policyType')
-        for resource in policy['content'].get('resources', []):
-            aggregated_policies[policy_type][resource].append(policy)
-
-    for policy_type in aggregated_policies:
-        for resource in aggregated_policies[policy_type]:
-            if aggregated_policies[policy_type][resource]:
-                aggregated_policies[policy_type][resource].sort(key=lambda x: x['priority'], reverse=True)
-                prioritized_policy = aggregated_policies[policy_type][resource][0]
-                if prioritized_policy['policyName'] not in policy_name:
-                    # TODO: Check logic here... should policy appear only once across all groups?
-                    filtered_policies[prioritized_policy['content']['policyType']].append(prioritized_policy)
-                    policy_name.append(prioritized_policy['policyName'])
-    return filtered_policies
-
-
 def group_policies_gen(flat_policies, config):
     """Filter policies using the following steps:
     1. Apply prioritization among the policies that are sharing the same policy type and resource type