* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
import java.util.HashMap;
import java.util.Optional;
-
+import org.camunda.bpm.engine.delegate.BpmnError;
import org.onap.appc.client.lcm.model.Action;
import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
import org.onap.so.client.exception.ExceptionBuilder;
import org.onap.so.db.catalog.client.CatalogDbClient;
import org.onap.so.db.catalog.beans.ControllerSelectionReference;
+import org.onap.so.logger.MessageEnum;
import org.onap.so.logger.MsoLogger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class GenericVnfHealthCheck {
- private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, GenericVnfHealthCheck.class);
+ private static final Logger logger = LoggerFactory.getLogger(GenericVnfHealthCheck.class);
@Autowired
private ExceptionBuilder exceptionUtil;
@Autowired
}
public void callAppcClient(BuildingBlockExecution execution) {
-
+ logger.trace("Start runAppcCommand ");
+ String appcCode = "1002";
+ String appcMessage = "";
try {
Action action = null;
action = Action.valueOf(execution.getVariable("action"));
payloadInfo.put("vfModuleId",execution.getVariable("vfModuleId"));
payloadInfo.put("oamIpAddress",execution.getVariable("oamIpAddress"));
payloadInfo.put("vnfHostIpAddress",execution.getVariable("vnfHostIpAddress"));
+
+ logger.debug("Running APP-C action: {}", action.toString());
+ logger.debug("VNFID: {}", vnfId);
//PayloadInfo contains extra information that adds on to payload before making request to appc
appCClient.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo, controllerType);
-
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ appcCode = appCClient.getErrorCode();
+ appcMessage = appCClient.getErrorMessage();
+ } catch (BpmnError ex) {
+ logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ "Caught exception in GenericVnfHealthCheck", "BPMN", MsoLogger.ErrorCode.UnknownError.getValue(), ex);
+ appcMessage = ex.getMessage();
+ exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(appcCode), appcMessage);
+ } catch (Exception e) {
+ if (e instanceof java.util.concurrent.TimeoutException )
+ {
+ appcMessage = "Request to APPC timed out. ";
+ logger.error("{} {} {} {} {}", MessageEnum.RA_CONNECTION_EXCEPTION.toString(),
+ "Caught timedOut exception in runAppcCommand in GenericVnfHealthCheck", "BPMN",
+ MsoLogger.ErrorCode.UnknownError.getValue(), "APPC Error", e);
+ throw e;
+ }
+ else {
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION.toString(),
+ "Caught exception in runAppcCommand in GenericVnfHealthCheck", "BPMN",
+ MsoLogger.ErrorCode.UnknownError.getValue(), "APPC Error", e);
+ appcMessage = e.getMessage();
+ exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(appcCode), appcMessage);
}
+ }
+ logger.error("Error Message: " + appcMessage);
+ logger.error("ERROR CODE: " + appcCode);
+ logger.trace("End of runAppCommand ");
+ if (appcCode != null && !appcCode.equals("0")) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(appcCode), appcMessage);
+ }
}
}