From a6c79acde23a0dead6cab4e32cd6934050df07aa Mon Sep 17 00:00:00 2001 From: xg353y Date: Tue, 10 Oct 2017 15:45:46 +0200 Subject: [PATCH] Update the TCA blueprint format Change-Id: Ib5b6fe1b46a509bea6c40ebc8ec9058990e5f64d Signed-off-by: xg353y Issue-ID: CLAMP-59 --- .../org/onap/clamp/clds/client/req/OperationalPolicyReq.java | 4 ++-- .../org/onap/clamp/clds/client/req/TcaRequestFormatter.java | 10 ++++++++++ src/main/resources/clds/clds-reference.properties | 1 + .../resources/example/tca-policy-req/blueprint-expected.yaml | 3 +++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/onap/clamp/clds/client/req/OperationalPolicyReq.java b/src/main/java/org/onap/clamp/clds/client/req/OperationalPolicyReq.java index 1d345e9c..a5506da9 100644 --- a/src/main/java/org/onap/clamp/clds/client/req/OperationalPolicyReq.java +++ b/src/main/java/org/onap/clamp/clds/client/req/OperationalPolicyReq.java @@ -178,7 +178,7 @@ public class OperationalPolicyReq { * @throws BuilderException * @throws UnsupportedEncodingException */ - private static String formatYaml(RefProp refProp, ModelProperties prop, String modelElementId, + public static String formatYaml(RefProp refProp, ModelProperties prop, String modelElementId, PolicyChain policyChain) throws BuilderException, UnsupportedEncodingException { // get property objects @@ -253,7 +253,7 @@ public class OperationalPolicyReq { * @throws BuilderException * @throws UnsupportedEncodingException */ - private static String formateNodeBYaml(RefProp refProp, ModelProperties prop, String modelElementId, + public static String formateNodeBYaml(RefProp refProp, ModelProperties prop, String modelElementId, PolicyChain policyChain) throws BuilderException, UnsupportedEncodingException { // get property objects diff --git a/src/main/java/org/onap/clamp/clds/client/req/TcaRequestFormatter.java b/src/main/java/org/onap/clamp/clds/client/req/TcaRequestFormatter.java index 3fbf8739..c2590d76 100644 --- a/src/main/java/org/onap/clamp/clds/client/req/TcaRequestFormatter.java +++ b/src/main/java/org/onap/clamp/clds/client/req/TcaRequestFormatter.java @@ -29,6 +29,7 @@ import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.dataformat.yaml.snakeyaml.Yaml; +import java.util.HashMap; import java.util.Map; import org.onap.clamp.clds.exception.TcaRequestFormatterException; @@ -150,6 +151,15 @@ public class TcaRequestFormatter { Map loadedYaml = (Map) yaml.load(yamlValue); Map nodeTemplates = (Map) loadedYaml.get("node_templates"); + //add policy_0 section in blueprint + Map policyObject = new HashMap (); + Map policyIdObject = new HashMap (); + String policyPrefix = refProp.getStringValue("tca.policyid.prefix"); + policyIdObject.put("policy_id", policyPrefix + modelProperties.getCurrentPolicyScopeAndPolicyName()); + policyObject.put("type", "dcae.nodes.policy"); + policyObject.put("properties", policyIdObject); + nodeTemplates.put("policy_0", policyObject); + Map tcaObject = (Map) nodeTemplates.get("tca_tca"); Map propsObject = (Map) tcaObject.get("properties"); Map appPreferences = (Map) propsObject.get("app_preferences"); diff --git a/src/main/resources/clds/clds-reference.properties b/src/main/resources/clds/clds-reference.properties index eadfb32a..fd7af5ef 100644 --- a/src/main/resources/clds/clds-reference.properties +++ b/src/main/resources/clds/clds-reference.properties @@ -47,6 +47,7 @@ policy.op.policyNamePrefix=Config_BRMS_Param_ # TCA MicroService Policy request build properties # +tca.policyid.prefix=DCAE.Config_ tca.template={"cdap-tca-hi-lo_policy": {"domain": "measurementsForVfScaling","metricsPerEventName": [{"eventName": "???","policyScope": "DCAE","policyName": "???","policyVersion": "v0.0.1","thresholds": []}]}} tca.thresholds.template={"closedLoopControlName": "???", "controlLoopSchema": "VM","version": "1.0.2","fieldPath": "?????", "thresholdValue": 0,"direction": "???","severity": "MAJOR", "closedLoopEventStatus": "???"} diff --git a/src/test/resources/example/tca-policy-req/blueprint-expected.yaml b/src/test/resources/example/tca-policy-req/blueprint-expected.yaml index cd8ebd8f..747d342c 100644 --- a/src/test/resources/example/tca-policy-req/blueprint-expected.yaml +++ b/src/test/resources/example/tca-policy-req/blueprint-expected.yaml @@ -48,3 +48,6 @@ node_templates: streamname: TCASubscriberOutputStream relationships: - {target: cdap_host_host, type: dcae.relationships.component_contained_in} + policy_0: + type: dcae.nodes.policy + properties: {policy_id: nullexample_model01.ClosedLoop_FRWL_SIG_fad4dcae_e498_11e6_852e_0050568c4ccf_TCA_1jy9to4} -- 2.16.6