diff options
author | Schmalzried, Terry (ts862m) <ts862m@att.com> | 2019-11-25 18:09:53 -0500 |
---|---|---|
committer | Schmalzried, Terry (ts862m) <ts862m@att.com> | 2019-11-26 10:37:13 -0500 |
commit | 0095ee39734b4f58ec8fc72fc09d7e3bc167d274 (patch) | |
tree | fea94c02ea25005951d7f58d59877bf053ef2896 /onap-dcae-dcaepolicy-lib/onap_dcae_dcaepolicy_lib/dcae_policy.py | |
parent | 8060697f3634bd21a66347114160ed416a9f617e (diff) |
policy lib 3.x support
Issue-ID: DCAEGEN2-1548
Change-Id: Id1c10f08f1375554aa744332bdfe37e1d6afc9d8
Signed-off-by: Schmalzried, Terry (ts862m) <ts862m@att.com>
Diffstat (limited to 'onap-dcae-dcaepolicy-lib/onap_dcae_dcaepolicy_lib/dcae_policy.py')
-rw-r--r-- | onap-dcae-dcaepolicy-lib/onap_dcae_dcaepolicy_lib/dcae_policy.py | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/onap-dcae-dcaepolicy-lib/onap_dcae_dcaepolicy_lib/dcae_policy.py b/onap-dcae-dcaepolicy-lib/onap_dcae_dcaepolicy_lib/dcae_policy.py index a8d8d70..68a9858 100644 --- a/onap-dcae-dcaepolicy-lib/onap_dcae_dcaepolicy_lib/dcae_policy.py +++ b/onap-dcae-dcaepolicy-lib/onap_dcae_dcaepolicy_lib/dcae_policy.py @@ -1,5 +1,5 @@ # ================================================================================ -# Copyright (c) 2017-2018 AT&T Intellectual Property. All rights reserved. +# Copyright (c) 2017-2019 AT&T Intellectual Property. All rights reserved. # ================================================================================ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -126,7 +126,7 @@ class Policies(object): property_policy_filter = target.node.properties.get(POLICY_FILTER) if property_policy_filter: policy_filter = deepcopy(dict( - (k, v) for (k, v) in dict(property_policy_filter).iteritems() + (k, v) for (k, v) in dict(property_policy_filter).items() if v or isinstance(v, (int, float)) )) Policies._fix_policy_filter(policy_filter) @@ -140,7 +140,7 @@ class Policies(object): filtered_policies = target.instance.runtime_properties.get(POLICIES_FILTERED) if not filtered_policies or not isinstance(filtered_policies, dict): return True - for (policy_id, policy) in filtered_policies.iteritems(): + for (policy_id, policy) in filtered_policies.items(): Policies._add_policy(policy_id, policy, False, policies) return True @@ -150,9 +150,8 @@ class Policies(object): if not policies: return {} - return dict((policy_id, policy.get(POLICY_BODY)) - for policy_id, policy in policies.iteritems() if policy.get(POLICY_BODY) - ) + return {policy_id: policy.get(POLICY_BODY) + for policy_id, policy in policies.items() if policy.get(POLICY_BODY)} @staticmethod def gather_policies_to_node(): @@ -238,11 +237,12 @@ class Policies(object): new_policies = dict((policy_id, policy) for policy_filter_id in policy_filters for (policy_id, policy) in added_policies.get(policy_filter_id, {}) - .get(POLICIES, {}).iteritems()) + .get(POLICIES, {}).items()) ctx.logger.info("new_policies: {0}".format(json.dumps(new_policies))) - for (policy_id, policy) in new_policies.iteritems(): + for policy_id in new_policies: + policy = new_policies.get(policy_id) deployed_policy = policies.get(policy_id) if not deployed_policy: policies[policy_id] = policy @@ -363,8 +363,8 @@ class Policies(object): """returns the list of policy_body objects if policy_body exists""" if isinstance(selected_policies, dict): return deepcopy([policy.get(POLICY_BODY) - for policy in selected_policies.values() if policy.get(POLICY_BODY)]) + for policy in selected_policies.itervalues() if policy.get(POLICY_BODY)]) policies = ctx.instance.runtime_properties.get(POLICIES, {}) return deepcopy([policy.get(POLICY_BODY) - for policy in policies.values() if policy.get(POLICY_BODY)]) + for policy in policies.itervalues() if policy.get(POLICY_BODY)]) |