Rework the logs
[clamp.git] / src / main / java / org / onap / clamp / loop / components / external / DcaeComponent.java
index ca26b13..8b85471 100644 (file)
@@ -23,6 +23,8 @@
 
 package org.onap.clamp.loop.components.external;
 
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
 import com.google.gson.JsonObject;
 
 import java.util.Iterator;
@@ -30,6 +32,7 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.UUID;
 
+import javax.persistence.Transient;
 import org.apache.camel.Exchange;
 import org.json.simple.JSONArray;
 import org.json.simple.JSONObject;
@@ -43,10 +46,14 @@ import org.onap.clamp.policy.microservice.MicroServicePolicy;
 
 public class DcaeComponent extends ExternalComponent {
 
+    @Transient
+    private static final EELFLogger logger = EELFManager.getInstance().getLogger(DcaeComponent.class);
+
     private static final String DCAE_DEPLOYMENT_PREFIX = "CLAMP_";
     private static final String DEPLOYMENT_PARAMETER = "dcaeDeployParameters";
     private static final String DCAE_SERVICETYPE_ID = "serviceTypeId";
     private static final String DCAE_INPUTS = "inputs";
+    public static final String UNIQUE_BLUEPRINT_PARAMETERS = "uniqueBlueprintParameters";
 
     private String name;
 
@@ -54,7 +61,7 @@ public class DcaeComponent extends ExternalComponent {
             "The DCAE blueprint has been found in the DCAE inventory but not yet instancianted for this loop");
     public static final ExternalComponentState PROCESSING_MICROSERVICE_INSTALLATION = new ExternalComponentState(
             "PROCESSING_MICROSERVICE_INSTALLATION", "Clamp has requested DCAE to install the microservices "
-                    + "defined in the DCAE blueprint and it's currently processing the request");
+            + "defined in the DCAE blueprint and it's currently processing the request");
     public static final ExternalComponentState MICROSERVICE_INSTALLATION_FAILED = new ExternalComponentState(
             "MICROSERVICE_INSTALLATION_FAILED",
             "Clamp has requested DCAE to install the microservices defined in the DCAE blueprint and it failed");
@@ -63,7 +70,7 @@ public class DcaeComponent extends ExternalComponent {
             "Clamp has requested DCAE to install the DCAE blueprint and it has been installed successfully");
     public static final ExternalComponentState PROCESSING_MICROSERVICE_UNINSTALLATION = new ExternalComponentState(
             "PROCESSING_MICROSERVICE_UNINSTALLATION", "Clamp has requested DCAE to uninstall the microservices "
-                    + "defined in the DCAE blueprint and it's currently processing the request");
+            + "defined in the DCAE blueprint and it's currently processing the request");
     public static final ExternalComponentState MICROSERVICE_UNINSTALLATION_FAILED = new ExternalComponentState(
             "MICROSERVICE_UNINSTALLATION_FAILED",
             "Clamp has requested DCAE to uninstall the microservices defined in the DCAE blueprint and it failed");
@@ -91,7 +98,7 @@ public class DcaeComponent extends ExternalComponent {
 
     /**
      * Convert the json response to a DcaeOperationStatusResponse.
-     * 
+     *
      * @param responseBody The DCAE response Json paylaod
      * @return The dcae object provisioned
      */
@@ -131,7 +138,8 @@ public class DcaeComponent extends ExternalComponent {
      */
     public static String getDeployPayload(Loop loop) {
         JsonObject globalProp = loop.getGlobalPropertiesJson();
-        JsonObject deploymentProp = globalProp.getAsJsonObject(DEPLOYMENT_PARAMETER);
+        JsonObject deploymentProp = globalProp.getAsJsonObject(DEPLOYMENT_PARAMETER).getAsJsonObject(
+                UNIQUE_BLUEPRINT_PARAMETERS);
 
         String serviceTypeId = loop.getLoopTemplate().getDcaeBlueprintId();
 
@@ -140,19 +148,21 @@ public class DcaeComponent extends ExternalComponent {
         if (deploymentProp != null) {
             rootObject.add(DCAE_INPUTS, deploymentProp);
         }
+        logger.info("DCAE Deploy payload for unique blueprint: " + rootObject.toString());
         return rootObject.toString();
     }
 
     /**
      * Return the deploy payload for DCAE.
      *
-     * @param loop             The loop object
+     * @param loop               The loop object
      * @param microServicePolicy The micro service policy
      * @return The payload used to send deploy closed loop request
      */
     public static String getDeployPayload(Loop loop, MicroServicePolicy microServicePolicy) {
         JsonObject globalProp = loop.getGlobalPropertiesJson();
-        JsonObject deploymentProp = globalProp.getAsJsonObject(DEPLOYMENT_PARAMETER).getAsJsonObject(microServicePolicy.getName());
+        JsonObject deploymentProp =
+                globalProp.getAsJsonObject(DEPLOYMENT_PARAMETER).getAsJsonObject(microServicePolicy.getName());
 
         String serviceTypeId = microServicePolicy.getDcaeBlueprintId();
 
@@ -161,6 +171,7 @@ public class DcaeComponent extends ExternalComponent {
         if (deploymentProp != null) {
             rootObject.add(DCAE_INPUTS, deploymentProp);
         }
+        logger.info("DCAE Deploy payload for multiple blueprints: " + rootObject.toString());
         return rootObject.toString();
     }
 
@@ -173,6 +184,7 @@ public class DcaeComponent extends ExternalComponent {
     public static String getUndeployPayload(Loop loop) {
         JsonObject rootObject = new JsonObject();
         rootObject.addProperty(DCAE_SERVICETYPE_ID, loop.getLoopTemplate().getDcaeBlueprintId());
+        logger.info("DCAE Undeploy payload for unique blueprint: " + rootObject.toString());
         return rootObject.toString();
     }
 
@@ -185,6 +197,7 @@ public class DcaeComponent extends ExternalComponent {
     public static String getUndeployPayload(MicroServicePolicy policy) {
         JsonObject rootObject = new JsonObject();
         rootObject.addProperty(DCAE_SERVICETYPE_ID, policy.getDcaeBlueprintId());
+        logger.info("DCAE Undeploy payload for multiple blueprints: " + rootObject.toString());
         return rootObject.toString();
     }