summaryrefslogtreecommitdiffstats
path: root/onap-dcae-dcaepolicy-lib/onap_dcae_dcaepolicy_lib/dcae_policy.py
diff options
context:
space:
mode:
authorAlex Shatov <alexs@att.com>2018-02-01 14:04:48 -0500
committerAlex Shatov <alexs@att.com>2018-02-01 14:04:48 -0500
commit6ea7282470ceb19dd537636721cd96bc6e4bbf4a (patch)
tree296ad99acab9dfa684b3e82599fac1bc911a6fe7 /onap-dcae-dcaepolicy-lib/onap_dcae_dcaepolicy_lib/dcae_policy.py
parent90f21051fc4347a84a2c079c994e03abbfec5c62 (diff)
get policy config data from config.content
* get policy config data from config.content instead of config when policyType is MicroService * identify the microservice by policyType provided by policy-engine or by parsing policy_id -it should contain Config_MS after scope = defense in case the policyType is not provided Change-Id: I25b1ce9e30ee717b14aca3e59e92d4d64d825414 Issue-ID: DCAEGEN2-196 Signed-off-by: Alex Shatov <alexs@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.py24
1 files changed, 22 insertions, 2 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 740f736..ff0af32 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,6 +1,6 @@
# org.onap.dcae
# ================================================================================
-# Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
+# Copyright (c) 2018 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.
@@ -41,9 +41,13 @@ POLICY_ID = 'policy_id'
POLICY_BODY = 'policy_body'
POLICY_VERSION = "policyVersion"
POLICY_CONFIG = 'config'
+POLICY_CONFIG_CONTENT = 'content'
APPLICATION_CONFIG = 'application_config'
POLICY_FILTER = 'policy_filter'
POLICY_FILTER_ID = 'policy_filter_id'
+POLICY_TYPE = 'policyType'
+POLICY_TYPE_MICROSERVICE = 'MicroService'
+POLICY_CONFIG_MS = "Config_MS"
POLICY_PERSISTENT = 'policy_persistent'
DCAE_POLICY_TYPE = 'dcae.nodes.policy'
@@ -64,7 +68,23 @@ class Policies(object):
@staticmethod
def _get_config_from_policy(policy):
"""returns the config field from policy object"""
- return (policy or {}).get(POLICY_BODY, {}).get(POLICY_CONFIG)
+ policy_body = (policy or {}).get(POLICY_BODY)
+ if not policy_body:
+ return
+
+ policy_config = policy_body.get(POLICY_CONFIG)
+ policy_type = policy_body.get(POLICY_TYPE)
+ if not policy_type:
+ policy_id = policy.get(POLICY_ID)
+ if policy_id:
+ policy_type_pos = policy_id.rfind(".") + 1
+ if policy_type_pos and policy_id.startswith(POLICY_CONFIG_MS, policy_type_pos):
+ policy_type = POLICY_TYPE_MICROSERVICE
+
+ if policy_type == POLICY_TYPE_MICROSERVICE and isinstance(policy_config, dict):
+ return policy_config.get(POLICY_CONFIG_CONTENT)
+
+ return policy_config
@staticmethod
def _store_policy_apply_order_clause(policy_apply_order_path):