Update the TCA blueprint format 67/18267/2
authorxg353y <xg353y@intl.att.com>
Tue, 10 Oct 2017 13:45:46 +0000 (15:45 +0200)
committerxg353y <xg353y@intl.att.com>
Wed, 11 Oct 2017 12:23:29 +0000 (14:23 +0200)
Change-Id: Ib5b6fe1b46a509bea6c40ebc8ec9058990e5f64d
Signed-off-by: xg353y <xg353y@intl.att.com>
Issue-ID: CLAMP-59

src/main/java/org/onap/clamp/clds/client/req/OperationalPolicyReq.java
src/main/java/org/onap/clamp/clds/client/req/TcaRequestFormatter.java
src/main/resources/clds/clds-reference.properties
src/test/resources/example/tca-policy-req/blueprint-expected.yaml

index 1d345e9..a5506da 100644 (file)
@@ -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
index 3fbf873..c2590d7 100644 (file)
@@ -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<String, Object> loadedYaml = (Map<String, Object>) yaml.load(yamlValue);
 
             Map<String, Object> nodeTemplates = (Map<String, Object>) loadedYaml.get("node_templates");
+            //add policy_0 section in blueprint
+            Map<String, Object> policyObject = new HashMap<String, Object> ();
+            Map<String, Object> policyIdObject = new HashMap<String, Object> ();
+            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<String, Object> tcaObject = (Map<String, Object>) nodeTemplates.get("tca_tca");
             Map<String, Object> propsObject = (Map<String, Object>) tcaObject.get("properties");
             Map<String, Object> appPreferences = (Map<String, Object>) propsObject.get("app_preferences");
index eadfb32..fd7af5e 100644 (file)
@@ -47,6 +47,7 @@ policy.op.policyNamePrefix=Config_BRMS_Param_
 \r
 # TCA MicroService Policy request build properties\r
 #\r
+tca.policyid.prefix=DCAE.Config_\r
 tca.template={"cdap-tca-hi-lo_policy": {"domain": "measurementsForVfScaling","metricsPerEventName": [{"eventName": "???","policyScope": "DCAE","policyName": "???","policyVersion": "v0.0.1","thresholds": []}]}}\r
 tca.thresholds.template={"closedLoopControlName": "???", "controlLoopSchema": "VM","version": "1.0.2","fieldPath": "?????", "thresholdValue": 0,"direction": "???","severity": "MAJOR", "closedLoopEventStatus": "???"}\r
 \r
index cd8ebd8..747d342 100644 (file)
@@ -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}