From ab7a87456538e561d60d209fe534c175ddd0269c Mon Sep 17 00:00:00 2001 From: Sastry Isukapalli Date: Wed, 28 Mar 2018 22:21:30 -0400 Subject: Functest scripts, simulators, and payloads osdf/adapters/policy/utils.py: Removed duplicated code (group_policies and group_policies_gen are very similar, and group_policies seems to be not used osdf/optimizers/placementopt/conductor/api_builder.py: changed param name from "grouped_policies" to "flat_policies" tox.ini added starup and shutdown of simulators (flask app with mock payloads) in tox tests rest all files/changes in "test/" folder quite a few payload files Patch set 2: removed a "print()" statement from simulator code Issue-ID: OPTFRA-22 Change-Id: I0006c577fc459c7c884b55e8316c689afd151780 Signed-off-by: Sastry Isukapalli --- osdf/adapters/policy/utils.py | 31 ------------------------------- 1 file changed, 31 deletions(-) (limited to 'osdf/adapters/policy') diff --git a/osdf/adapters/policy/utils.py b/osdf/adapters/policy/utils.py index f165079..2f873af 100644 --- a/osdf/adapters/policy/utils.py +++ b/osdf/adapters/policy/utils.py @@ -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 -- cgit 1.2.3-korg