summaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks/src/main/java
diff options
context:
space:
mode:
authorEnbo Wang <wangenbo@huawei.com>2020-03-05 02:11:13 +0800
committerEnbo Wang <wangenbo@huawei.com>2020-03-05 20:52:53 +0800
commit2aacf632e9d21e140b6a35a8096cca8d2b2329dd (patch)
tree575e9f41cf4ac982dab374c6f3044d9c126f8260 /bpmn/so-bpmn-tasks/src/main/java
parente0f2aae2a783beac292e51fb9ef13272ae050b67 (diff)
Support PNF software upgrade workflow using SDNC LCM API
Issue-ID: SO-2589 Signed-off-by: Enbo Wang <wangenbo@huawei.com> Change-Id: I4b6940c21b70eeeaf96e8781762cb7029572e7ae
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/main/java')
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/LcmControllerDE.java4
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/common/SoPropertyConstants.java35
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SDNCLcmPayloadBuilder.java153
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDE.java225
4 files changed, 401 insertions, 16 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/LcmControllerDE.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/LcmControllerDE.java
index 95e270a071..40034aa26c 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/LcmControllerDE.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/LcmControllerDE.java
@@ -24,7 +24,6 @@ import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext;
import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerRunnable;
import org.onap.so.bpmn.infrastructure.decisionpoint.api.controller.ControllerPreparable;
-import org.onap.so.client.appc.ApplicationControllerAction;
import org.onap.so.client.exception.ExceptionBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -44,9 +43,6 @@ public abstract class LcmControllerDE implements ControllerRunnable<DelegateExec
@Autowired
protected List<ControllerPreparable<DelegateExecution>> prepareList;
- @Autowired
- protected ApplicationControllerAction client;
-
@Override
public void prepare(ControllerContext<DelegateExecution> context) {
prepareList.stream().filter(prepare -> prepare.understand(context))
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/common/SoPropertyConstants.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/common/SoPropertyConstants.java
new file mode 100644
index 0000000000..badce18a51
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/common/SoPropertyConstants.java
@@ -0,0 +1,35 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda.controller.common;
+
+public interface SoPropertyConstants {
+ String TARGET_SOFTWARE_VERSION = "targetSoftwareVersion";
+
+ String SO_ACTION = "action";
+ String SO_ACTION_MODE = "mode";
+
+ String ACTION_ACTIVATE_N_E_SW = "activateNESw";
+ String ACTION_DOWNLOAD_N_E_SW = "downloadNESw";
+ String ACTION_POST_CHECK = "postCheck";
+ String ACTION_PRE_CHECK = "preCheck";
+
+ String CONTROLLER_STATUS = "ControllerStatus";
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SDNCLcmPayloadBuilder.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SDNCLcmPayloadBuilder.java
new file mode 100644
index 0000000000..b29009ff1d
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SDNCLcmPayloadBuilder.java
@@ -0,0 +1,153 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda.controller.sdnc;
+
+import java.util.Arrays;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.onap.so.bpmn.core.json.JsonUtils;
+import org.onap.so.client.sdnc.lcm.beans.payload.*;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.REQUEST_PAYLOAD;
+import org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda.controller.common.SoPropertyConstants;
+
+public class SDNCLcmPayloadBuilder {
+
+ private static Logger logger = LoggerFactory.getLogger(SDNCLcmPayloadBuilder.class);
+
+ public static ActivateNESwPayload buildActivateNESwPayload(DelegateExecution execution) {
+ String requestPayload = String.valueOf(execution.getVariable(REQUEST_PAYLOAD));
+
+ ActivateNESwPayload activateNESwPayload = new ActivateNESwPayload();
+
+ String ipaddressV4Oam = JsonUtils.getJsonValue(requestPayload, "ipaddressV4Oam");
+ activateNESwPayload.setIpaddressV4Oam(ipaddressV4Oam);
+
+ String targetSwVersion = String.valueOf(execution.getVariable(SoPropertyConstants.TARGET_SOFTWARE_VERSION));
+ if (targetSwVersion == null) {
+ targetSwVersion = JsonUtils.getJsonValue(requestPayload, "targetSwVersion");
+ }
+ activateNESwPayload.setSwVersionToBeActivated(targetSwVersion);
+
+ String playbookName = JsonUtils.getJsonValue(requestPayload, "activateNESwPlaybook");
+ if (playbookName != null) {
+ activateNESwPayload.setPlaybookName(playbookName);
+ }
+
+ return activateNESwPayload;
+ }
+
+ public static DownloadNESwPayload buildDownloadNESwPayload(DelegateExecution execution) {
+ String requestPayload = String.valueOf(execution.getVariable(REQUEST_PAYLOAD));
+
+ DownloadNESwPayload downloadNESwPayload = new DownloadNESwPayload();
+
+ String ipaddressV4Oam = JsonUtils.getJsonValue(requestPayload, "ipaddressV4Oam");
+ downloadNESwPayload.setIpaddressV4Oam(ipaddressV4Oam);
+
+ String swToBeDownloadedString = JsonUtils.getJsonValue(requestPayload, "swToBeDownloaded");
+ SwToBeDownloadedElement[] swToBeDownloadedArray;
+
+ ObjectMapper mapper = new ObjectMapper();
+ try {
+ swToBeDownloadedArray = mapper.readValue(swToBeDownloadedString, SwToBeDownloadedElement[].class);
+ downloadNESwPayload.setSwToBeDownloaded(Arrays.asList(swToBeDownloadedArray));
+ } catch (Exception e) {
+ logger.error("Parse SwToBeDownloaded error: ", e);
+ }
+
+ String playbookName = JsonUtils.getJsonValue(requestPayload, "downloadNESwPlaybook");
+ if (playbookName != null) {
+ downloadNESwPayload.setPlaybookName(playbookName);
+ }
+
+ return downloadNESwPayload;
+ }
+
+ public static UpgradePostCheckPayload buildUpgradePostCheckPayload(DelegateExecution execution) {
+ String requestPayload = String.valueOf(execution.getVariable(REQUEST_PAYLOAD));
+
+ UpgradePostCheckPayload upgradePostCheckPayload = new UpgradePostCheckPayload();
+
+ String ipaddressV4Oam = JsonUtils.getJsonValue(requestPayload, "ipaddressV4Oam");
+ upgradePostCheckPayload.setIpaddressV4Oam(ipaddressV4Oam);
+
+ String oldSwVersion = JsonUtils.getJsonValue(requestPayload, "oldSwVersion");
+ upgradePostCheckPayload.setOldSwVersion(oldSwVersion);
+
+ String targetSwVersion = String.valueOf(execution.getVariable(SoPropertyConstants.TARGET_SOFTWARE_VERSION));
+ if (targetSwVersion == null) {
+ targetSwVersion = JsonUtils.getJsonValue(requestPayload, "targetSwVersion");
+ }
+ upgradePostCheckPayload.setTargetSwVersion(targetSwVersion);
+
+ String ruleName = JsonUtils.getJsonValue(requestPayload, "postCheckRuleName");
+ upgradePostCheckPayload.setRuleName(ruleName);
+
+ String additionalData = JsonUtils.getJsonValue(requestPayload, "postCheckAdditionalData");
+ upgradePostCheckPayload.setAdditionalData(additionalData);
+
+ String playbookName = JsonUtils.getJsonValue(requestPayload, "postCheckPlaybook");
+ if (playbookName != null) {
+ upgradePostCheckPayload.setPlaybookName(playbookName);
+ }
+
+ return upgradePostCheckPayload;
+ }
+
+ public static UpgradePreCheckPayload buildUpgradePreCheckPayload(DelegateExecution execution) {
+ String requestPayload = String.valueOf(execution.getVariable(REQUEST_PAYLOAD));
+
+ UpgradePreCheckPayload upgradePreCheckPayload = new UpgradePreCheckPayload();
+
+ String ipaddressV4Oam = JsonUtils.getJsonValue(requestPayload, "ipaddressV4Oam");
+ upgradePreCheckPayload.setIpaddressV4Oam(ipaddressV4Oam);
+
+ String oldSwVersion = JsonUtils.getJsonValue(requestPayload, "oldSwVersion");
+ upgradePreCheckPayload.setOldSwVersion(oldSwVersion);
+
+ String targetSwVersion = String.valueOf(execution.getVariable(SoPropertyConstants.TARGET_SOFTWARE_VERSION));
+ if (targetSwVersion == null) {
+ targetSwVersion = JsonUtils.getJsonValue(requestPayload, "targetSwVersion");
+ }
+ upgradePreCheckPayload.setTargetSwVersion(targetSwVersion);
+
+ String ruleName = JsonUtils.getJsonValue(requestPayload, "preCheckRuleName");
+ upgradePreCheckPayload.setRuleName(ruleName);
+
+ String additionalData = JsonUtils.getJsonValue(requestPayload, "preCheckAdditionalData");
+ upgradePreCheckPayload.setAdditionalData(additionalData);
+
+ String playbookName = JsonUtils.getJsonValue(requestPayload, "preCheckPlaybook");
+ if (playbookName != null) {
+ upgradePreCheckPayload.setPlaybookName(playbookName);
+ }
+
+ return upgradePreCheckPayload;
+ }
+
+ public static String convertToSting(Object msgObject) throws JsonProcessingException {
+ ObjectMapper mapper = new ObjectMapper();
+ return mapper.writeValueAsString(msgObject);
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDE.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDE.java
index db0d402f6e..ed865e058f 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDE.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDE.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix
+ * Modifications Copyright (C) 2020 Huawei
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,16 +20,24 @@
package org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda.controller.sdnc;
+import java.util.List;
+import java.util.UUID;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.springframework.stereotype.Component;
import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.onap.so.bpmn.core.json.JsonUtils;
import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext;
+import org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda.controller.common.SoPropertyConstants;
import org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda.controller.LcmControllerDE;
-import org.springframework.stereotype.Component;
+import org.onap.so.client.sdnc.common.SDNCConstants;
+import org.onap.so.client.sdnc.lcm.*;
+import org.onap.so.client.sdnc.lcm.beans.*;
+import org.onap.so.client.sdnc.lcm.beans.payload.*;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.REQUEST_ID;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_CORRELATION_ID;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.REQUEST_PAYLOAD;
-/**
- * This class is created to demonstrate how to support {@link DelegateExecution} API based SDNC controller.
- *
- * Function wise, it's similar to the Appc Controller, like in the AppcClient groovy code.
- */
@Component
public class SdncControllerDE extends LcmControllerDE {
@@ -44,14 +53,33 @@ public class SdncControllerDE extends LcmControllerDE {
return true;
}
- /**
- * This method is left empty intentionally. If you are planning to use the SDNC Controller, please implement here.
- *
- * You can use the {@ref ApplicationControllerAction}, {@ref ApplicationControllerOrchestrator},
- * {@ref ApplicationControllerClient} or create your own SDNC Client proxy.
- */
@Override
protected int callLcmClient(ControllerContext<DelegateExecution> context) {
+ DelegateExecution execution = context.getExecution();
+
+ logger.debug("Running activity for id: {}, name: {}", execution.getCurrentActivityId(),
+ execution.getCurrentActivityName());
+
+ boolean result;
+ try {
+ LcmInput lcmInput = buildLcmInput(execution);
+ if (lcmInput != null) {
+ result = sendLcmRequest(execution, lcmInput);
+ } else {
+ logger.error("Build LCM Input error");
+ result = false;
+ }
+ } catch (Exception e) {
+ logger.error("Call SDNC LCM Client failure: ", e);
+ result = false;
+ }
+
+ if (result) {
+ execution.setVariable(SoPropertyConstants.CONTROLLER_STATUS, "Success");
+ } else {
+ execution.setVariable(SoPropertyConstants.CONTROLLER_STATUS, "Failure");
+ }
+
return 0;
}
@@ -59,4 +87,177 @@ public class SdncControllerDE extends LcmControllerDE {
protected int getErrorCode() {
return SDNC_DELEGATE_EXECUTION_ERROR_CODE;
}
+
+ private LcmOutput sendSyncRequest(String operation, LcmInput lcmInput) {
+ SDNCLcmClientBuilder sdncLcmClientBuilder = new SDNCLcmClientBuilder();
+ SDNCLcmRestClient sdncLcmRestClient;
+ try {
+ sdncLcmRestClient = sdncLcmClientBuilder.newSDNCLcmRestClient(operation);
+ } catch (SDNCLcmClientBuilderException e) {
+ logger.error("Create SDNCLcmRestClient error: ", e);
+ return null;
+ }
+
+ return sdncLcmRestClient.sendRequest(lcmInput);
+ }
+
+ private LcmOutput selectLcmOutputFromDmaapResponses(List<LcmDmaapResponse> lcmDmaapResponses, LcmInput lcmInput) {
+ String expectedCorrelationId =
+ lcmInput.getCommonHeader().getRequestId() + "-" + lcmInput.getCommonHeader().getSubRequestId();
+
+ for (LcmDmaapResponse lcmDmaapResponse : lcmDmaapResponses) {
+ String correlationId = lcmDmaapResponse.getCorrelationId();
+ if (expectedCorrelationId.equals(correlationId)) {
+ return lcmDmaapResponse.getBody().getOutput();
+ }
+ }
+
+ return null;
+ }
+
+ private LcmOutput sendAsyncRequest(String operation, LcmInput lcmInput) {
+ SDNCLcmClientBuilder sdncLcmClientBuilder = new SDNCLcmClientBuilder();
+ SDNCLcmDmaapClient sdncLcmDmaapClient;
+ try {
+ sdncLcmDmaapClient = sdncLcmClientBuilder.newSDNCLcmDmaapClient();
+ } catch (SDNCLcmClientBuilderException e) {
+ logger.error("Create SDNCLcmDmaapClient error: ", e);
+ return null;
+ }
+
+ LcmDmaapRequest lcmDmaapRequest = SDNCLcmMessageBuilder.buildLcmDmaapRequest(operation, lcmInput);
+ try {
+ sdncLcmDmaapClient.sendRequest(lcmDmaapRequest);
+ } catch (Exception e) {
+ logger.error("SDNCLcmDmaapClient sends request error: ", e);
+ return null;
+ }
+
+ long timeout = sdncLcmClientBuilder.getSDNCLcmProperties().getActionTimeout();
+ long startTime = System.currentTimeMillis();
+ while (true) {
+ List<LcmDmaapResponse> lcmDmaapResponses = sdncLcmDmaapClient.getResponse();
+ if (lcmDmaapResponses.size() > 0) {
+ LcmOutput lcmOutput = selectLcmOutputFromDmaapResponses(lcmDmaapResponses, lcmInput);
+ if (lcmOutput != null) {
+ return lcmOutput;
+ }
+ }
+
+ long stopTime = System.currentTimeMillis();
+ if ((stopTime - startTime) > timeout) {
+ logger.error("Timeout for SDNC LCM action {}", lcmInput.getAction());
+ return null;
+ }
+ }
+ }
+
+ public static String toLowerHyphen(String lcmAction) {
+ String regex = "([a-z0-9A-Z])(?=[A-Z])";
+ String replacement = "$1-";
+ return lcmAction.replaceAll(regex, replacement).toLowerCase();
+ }
+
+ private LcmInput buildLcmInput(DelegateExecution execution) throws JsonProcessingException {
+ String requestId = String.valueOf(execution.getVariable(REQUEST_ID));
+ String requestAction = String.valueOf(execution.getVariable(SoPropertyConstants.SO_ACTION));
+ String pnfName = String.valueOf(execution.getVariable(PNF_CORRELATION_ID));
+ logger.debug(String.format("requestId: %s, action: %s, pnfName: %s", requestId, requestAction, pnfName));
+
+ String requestPayload = String.valueOf(execution.getVariable(REQUEST_PAYLOAD));
+ logger.debug("SO request payload: " + requestPayload);
+
+ String lcmAction;
+ String lcmPayload;
+
+ switch (requestAction) {
+ case SoPropertyConstants.ACTION_PRE_CHECK:
+ lcmAction = SDNCLcmActionConstants.UPGRADE_PRE_CHECK;
+
+ UpgradePreCheckPayload upgradePreCheckPayload;
+ upgradePreCheckPayload = SDNCLcmPayloadBuilder.buildUpgradePreCheckPayload(execution);
+ lcmPayload = SDNCLcmPayloadBuilder.convertToSting(upgradePreCheckPayload);
+ break;
+ case SoPropertyConstants.ACTION_DOWNLOAD_N_E_SW:
+ lcmAction = SDNCLcmActionConstants.DOWNLOAD_N_E_SW;
+
+ DownloadNESwPayload downloadNESwPayload;
+ downloadNESwPayload = SDNCLcmPayloadBuilder.buildDownloadNESwPayload(execution);
+ lcmPayload = SDNCLcmPayloadBuilder.convertToSting(downloadNESwPayload);
+ break;
+ case SoPropertyConstants.ACTION_ACTIVATE_N_E_SW:
+ lcmAction = SDNCLcmActionConstants.ACTIVATE_N_E_SW;
+
+ ActivateNESwPayload activateNESwPayload;
+ activateNESwPayload = SDNCLcmPayloadBuilder.buildActivateNESwPayload(execution);
+ lcmPayload = SDNCLcmPayloadBuilder.convertToSting(activateNESwPayload);
+ break;
+ case SoPropertyConstants.ACTION_POST_CHECK:
+ lcmAction = SDNCLcmActionConstants.UPGRADE_POST_CHECK;
+
+ UpgradePostCheckPayload upgradePostCheckPayload;
+ upgradePostCheckPayload = SDNCLcmPayloadBuilder.buildUpgradePostCheckPayload(execution);
+ lcmPayload = SDNCLcmPayloadBuilder.convertToSting(upgradePostCheckPayload);
+ break;
+ default:
+ logger.error("Unsupported SO Action: " + requestAction);
+ return null;
+ }
+
+ logger.debug("SDNC LCM payload for {}: {}", lcmAction, lcmPayload);
+
+ String subRequestId = UUID.randomUUID().toString();
+ LcmInput lcmInput =
+ SDNCLcmMessageBuilder.buildLcmInputForPnf(requestId, subRequestId, pnfName, lcmAction, lcmPayload);
+
+ ObjectMapper mapper = new ObjectMapper();
+ String lcmInputMsg = mapper.writeValueAsString(lcmInput);
+ logger.debug("SDNC input message:\n" + lcmInputMsg);
+
+ return lcmInput;
+ }
+
+ private boolean parseLcmOutput(LcmOutput lcmOutput, String lcmAction) {
+ if (lcmOutput == null) {
+ logger.error("Call SDNC LCM API failure");
+ return false;
+ }
+
+ LcmStatus lcmStatus = lcmOutput.getStatus();
+
+ if (lcmStatus.getCode() == SDNCConstants.LCM_OUTPUT_SUCCESS_CODE) {
+ logger.debug("Call SDNC LCM API success: " + lcmStatus.getMessage());
+ } else {
+ logger.error("Call SDNC LCM API failure: " + lcmStatus.getMessage());
+ }
+
+ String outputPayload = lcmOutput.getPayload();
+ logger.debug("SDNC LCM action: {}, result: {}", lcmAction, outputPayload);
+ if (outputPayload != null) {
+ String result = JsonUtils.getJsonValue(outputPayload, "result");
+ if ("Success".equals(result)) {
+ logger.debug("Run SDNC LCM action {} success", lcmAction);
+ return true;
+ } else {
+ String reason = JsonUtils.getJsonValue(outputPayload, "reason");
+ logger.error("Run SDNC LCM action {} failure, reason: {}", lcmAction, reason);
+ }
+ }
+
+ return false;
+ }
+
+ private boolean sendLcmRequest(DelegateExecution execution, LcmInput lcmInput) {
+ String actionMode = String.valueOf(execution.getVariable(SoPropertyConstants.SO_ACTION_MODE));
+ String lcmOperation = toLowerHyphen(lcmInput.getAction());
+
+ LcmOutput lcmOutput;
+ if ("async".equals(actionMode)) {
+ lcmOutput = sendAsyncRequest(lcmOperation, lcmInput);
+ } else {
+ lcmOutput = sendSyncRequest(lcmOperation, lcmInput);
+ }
+
+ return parseLcmOutput(lcmOutput, lcmInput.getAction());
+ }
}