summaryrefslogtreecommitdiffstats
path: root/onap-dcae-dcaepolicy-lib/onap_dcae_dcaepolicy_lib/dcae_policy.py
diff options
context:
space:
mode:
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.py20
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)])