* ============LICENSE_START=======================================================\r
* ONAP CLAMP\r
* ================================================================================\r
- * Copyright (C) 2017 AT&T Intellectual Property. All rights\r
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights\r
* reserved.\r
* ================================================================================\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* limitations under the License.\r
* ============LICENSE_END============================================\r
* ===================================================================\r
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
+ * \r
*/\r
\r
package org.onap.clamp.clds.client;\r
\r
import com.att.eelf.configuration.EELFLogger;\r
import com.att.eelf.configuration.EELFManager;\r
+import com.fasterxml.jackson.databind.JsonNode;\r
import com.fasterxml.jackson.databind.node.ObjectNode;\r
\r
import java.util.Date;\r
\r
import org.json.simple.JSONObject;\r
import org.json.simple.parser.JSONParser;\r
-import org.onap.clamp.clds.exception.DcaeDeploymentException;\r
-import org.onap.clamp.clds.model.refprop.RefProp;\r
+import org.onap.clamp.clds.config.ClampProperties;\r
+import org.onap.clamp.clds.exception.dcae.DcaeDeploymentException;\r
import org.onap.clamp.clds.util.LoggingUtils;\r
import org.springframework.beans.factory.annotation.Autowired;\r
+import org.springframework.stereotype.Component;\r
\r
/**\r
* This class implements the communication with DCAE for the service\r
* deployments.\r
- *\r
*/\r
+@Component\r
public class DcaeDispatcherServices {\r
- protected static final EELFLogger logger = EELFManager.getInstance()\r
- .getLogger(DcaeDispatcherServices.class);\r
- protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();\r
+\r
+ protected static final EELFLogger logger = EELFManager.getInstance().getLogger(DcaeDispatcherServices.class);\r
+ protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();\r
@Autowired\r
- private RefProp refProp;\r
- private static final String STATUS_URL_LOG = "Status URL extracted: ";\r
- private static final String DCAE_URL_PREFIX = "/dcae-deployments/";\r
- private static final String DCAE_URL_PROPERTY_NAME = "DCAE_DISPATCHER_URL";\r
- private static final String DCAE_LINK_FIELD = "links";\r
- private static final String DCAE_STATUS_FIELD = "status";\r
+ private ClampProperties refProp;\r
+ private static final String STATUS_URL_LOG = "Status URL extracted: ";\r
+ private static final String DCAE_URL_PREFIX = "/dcae-deployments/";\r
+ private static final String DCAE_URL_PROPERTY_NAME = "dcae.dispatcher.url";\r
+ private static final String DCAE_REQUEST_FAILED_LOG = "RequestFailed - responseStr=";\r
+ public static final String DCAE_REQUESTID_PROPERTY_NAME = "dcae.header.requestId";\r
+ private static final String DCAE_LINK_FIELD = "links";\r
+ private static final String DCAE_STATUS_FIELD = "status";\r
\r
/**\r
* Delete the deployment on DCAE.\r
JSONObject linksObj = (JSONObject) jsonObj.get(DCAE_LINK_FIELD);\r
String statusUrl = (String) linksObj.get(DCAE_STATUS_FIELD);\r
logger.info(STATUS_URL_LOG + statusUrl);\r
+ LoggingUtils.setResponseContext("0", "Delete deployments success", this.getClass().getName());\r
return statusUrl;\r
} catch (Exception e) {\r
+ // Log StatusCode during exception in metrics log\r
+ LoggingUtils.setResponseContext("900", "Delete deployments failed", this.getClass().getName());\r
+ LoggingUtils.setErrorContext("900", "Delete deployments error");\r
logger.error("Exception occurred during Delete Deployment Operation with DCAE", e);\r
throw new DcaeDeploymentException("Exception occurred during Delete Deployment Operation with DCAE", e);\r
} finally {\r
* @param statusUrl\r
* The URL provided by a previous DCAE Query\r
* @return The status\r
- * \r
*/\r
public String getOperationStatus(String statusUrl) {\r
// Assigning processing status to monitor operation status further\r
String operationType = (String) jsonObj.get("operationType");\r
String status = (String) jsonObj.get("status");\r
logger.info("Operation Type - " + operationType + ", Status " + status);\r
+ LoggingUtils.setResponseContext("0", "Get operation status success", this.getClass().getName());\r
opStatus = status;\r
} catch (Exception e) {\r
+ // Log StatusCode during exception in metrics log\r
+ LoggingUtils.setResponseContext("900", "Get operation status failed", this.getClass().getName());\r
+ LoggingUtils.setErrorContext("900", "Get operation status error");\r
logger.error("Exception occurred during getOperationStatus Operation with DCAE", e);\r
} finally {\r
LoggingUtils.setTimeContext(startTime, new Date());\r
\r
/**\r
* This method send a getDeployments operation to DCAE.\r
- * \r
*/\r
public void getDeployments() {\r
Date startTime = new Date();\r
try {\r
String url = refProp.getStringValue(DCAE_URL_PROPERTY_NAME) + DCAE_URL_PREFIX;\r
DcaeHttpConnectionManager.doDcaeHttpQuery(url, "GET", null, null);\r
+ LoggingUtils.setResponseContext("0", "Get deployments success", this.getClass().getName());\r
} catch (Exception e) {\r
+ // Log StatusCode during exception in metrics log\r
+ LoggingUtils.setResponseContext("900", "Get deployments failed", this.getClass().getName());\r
+ LoggingUtils.setErrorContext("900", "Get deployments error");\r
logger.error("Exception occurred during getDeployments Operation with DCAE", e);\r
throw new DcaeDeploymentException("Exception occurred during getDeployments Operation with DCAE", e);\r
} finally {\r
* The deployment ID\r
* @param serviceTypeId\r
* Service type ID\r
+ * @param blueprintInputJson\r
+ * The value for each blueprint parameters in a flat JSON\r
* @return The status URL\r
*/\r
- public String createNewDeployment(String deploymentId, String serviceTypeId) {\r
+ public String createNewDeployment(String deploymentId, String serviceTypeId, JsonNode blueprintInputJson) {\r
Date startTime = new Date();\r
LoggingUtils.setTargetContext("DCAE", "createNewDeployment");\r
try {\r
ObjectNode rootNode = (ObjectNode) refProp.getJsonTemplate("dcae.deployment.template");\r
rootNode.put("serviceTypeId", serviceTypeId);\r
+ if (blueprintInputJson != null) {\r
+ rootNode.put("inputs", blueprintInputJson);\r
+ }\r
String apiBodyString = rootNode.toString();\r
logger.info("Dcae api Body String - " + apiBodyString);\r
String url = refProp.getStringValue(DCAE_URL_PROPERTY_NAME) + DCAE_URL_PREFIX + deploymentId;\r
JSONObject linksObj = (JSONObject) jsonObj.get(DCAE_LINK_FIELD);\r
String statusUrl = (String) linksObj.get(DCAE_STATUS_FIELD);\r
logger.info(STATUS_URL_LOG + statusUrl);\r
+ LoggingUtils.setResponseContext("0", "Create new deployment failed", this.getClass().getName());\r
return statusUrl;\r
} catch (Exception e) {\r
+ // Log StatusCode during exception in metrics log\r
+ LoggingUtils.setResponseContext("900", "Create new deployment failed", this.getClass().getName());\r
+ LoggingUtils.setErrorContext("900", "Create new deployment error");\r
logger.error("Exception occurred during createNewDeployment Operation with DCAE", e);\r
throw new DcaeDeploymentException("Exception occurred during createNewDeployment Operation with DCAE", e);\r
} finally {\r
JSONObject linksObj = (JSONObject) jsonObj.get(DCAE_LINK_FIELD);\r
String statusUrl = (String) linksObj.get(DCAE_STATUS_FIELD);\r
logger.info(STATUS_URL_LOG + statusUrl);\r
+ LoggingUtils.setResponseContext("0", "Delete existing deployment success", this.getClass().getName());\r
return statusUrl;\r
} catch (Exception e) {\r
+ // Log StatusCode during exception in metrics log\r
+ LoggingUtils.setResponseContext("900", "Delete existing deployment failed", this.getClass().getName());\r
+ LoggingUtils.setErrorContext("900", "Delete existing deployment error");\r
logger.error("Exception occurred during deleteExistingDeployment Operation with DCAE", e);\r
throw new DcaeDeploymentException("Exception occurred during deleteExistingDeployment Operation with DCAE",\r
e);\r