summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChuanyu Chen <chenchuanyu@huawei.com>2020-03-06 13:40:42 +0000
committerGerrit Code Review <gerrit@onap.org>2020-03-06 13:40:42 +0000
commit4d1e251ebcde26583cc85abef7b6909e9808771c (patch)
tree8d8d489a5f76a95d0af51308fd71c41663880712
parent6f09b0a3f076848eba7a315d049a3167dc4f687b (diff)
parent2aacf632e9d21e140b6a35a8096cca8d2b2329dd (diff)
Merge "Support PNF software upgrade workflow using SDNC LCM API"
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/SDNCLcmPropertiesImpl.java12
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/common/SDNCConstants.java3
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmActionConstants.java28
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmClientBuilder.java4
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmProperties.java2
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/ActivateNESwPayload.java64
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/DownloadNESwPayload.java66
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/SwToBeDownloadedElement.java75
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePostCheckPayload.java96
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePreCheckPayload.java96
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/SDNCLcmDmaapClientTest.java2
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/ActivateNESwPayloadTest.java52
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/DownloadNESwPayloadTest.java82
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/LcmBasePayloadTest.java42
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePostCheckPayloadTest.java56
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePreCheckPayloadTest.java56
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/NfSoftwareUpgradeDispatcher.java9
-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
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SDNCLcmPayloadBuilderTest.java135
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDETest.java4
24 files changed, 1276 insertions, 27 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/SDNCLcmPropertiesImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/SDNCLcmPropertiesImpl.java
index eb2567d47c..9b46611468 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/SDNCLcmPropertiesImpl.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/SDNCLcmPropertiesImpl.java
@@ -31,12 +31,14 @@ public class SDNCLcmPropertiesImpl implements SDNCLcmProperties {
public static final String SDNC_HOST = "sdnc.host";
public static final String SDNC_AUTH = "sdnc.auth";
public static final String LCM_PATH = "sdnc.lcm.path";
+ public static final String LCM_ACTION_TIMEOUT = "sdnc.lcm.actionTimeout";
public static final String DMAAP_HOST = "sdnc.dmaap.host";
public static final String DMAAP_AUTH = "sdnc.dmaap.auth";
- public static final String DMAAP_PARTITION = "sdnc.dmaap.partition";
public static final String DMAAP_TIMEOUT = "sdnc.dmaap.timeout";
public static final String DMAAP_ENVIRONMENT = "sdnc.dmaap.environment";
+
+ public static final String LCM_DMAAP_PARTITION = "sdnc.lcm.dmaap.partition";
public static final String LCM_DMAAP_READ_TOPIC = "sdnc.lcm.dmapp.readTopic";
public static final String LCM_DMAAP_WRITE_TOPIC = "sdnc.lcm.dmaap.writeTopic";
@@ -56,6 +58,12 @@ public class SDNCLcmPropertiesImpl implements SDNCLcmProperties {
}
@Override
+ public long getActionTimeout() {
+ String actionTimeout = UrnPropertiesReader.getVariable(LCM_ACTION_TIMEOUT);
+ return (actionTimeout != null) ? Long.parseLong(actionTimeout) : SDNCConstants.LCM_ACTION_TIMEOUT;
+ }
+
+ @Override
public String getBasicAuth() {
return UrnPropertiesReader.getVariable(SDNC_AUTH);
}
@@ -72,7 +80,7 @@ public class SDNCLcmPropertiesImpl implements SDNCLcmProperties {
@Override
public String getDmaapPartition() {
- String partition = UrnPropertiesReader.getVariable(DMAAP_PARTITION);
+ String partition = UrnPropertiesReader.getVariable(LCM_DMAAP_PARTITION);
return (partition != null) ? partition : SDNCConstants.LCM_DMAAP_PARTITION;
}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/common/SDNCConstants.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/common/SDNCConstants.java
index fd9412e70e..dcbb120c69 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/common/SDNCConstants.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/common/SDNCConstants.java
@@ -45,5 +45,6 @@ public interface SDNCConstants {
String LCM_DMAAP_READ_TOPIC = "SDNC-LCM-WRITE";
String LCM_DMAAP_WRITE_TOPIC = "SDNC-LCM-READ";
- int LCM_TIMEOUT = 300;
+ long LCM_ACTION_TIMEOUT = 300000; // Millisecond
+ int LCM_OUTPUT_SUCCESS_CODE = 400;
}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmActionConstants.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmActionConstants.java
new file mode 100644
index 0000000000..8ab40cb08d
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmActionConstants.java
@@ -0,0 +1,28 @@
+/*-
+ * ============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.client.sdnc.lcm;
+
+public interface SDNCLcmActionConstants {
+ String ACTIVATE_N_E_SW = "ActivateNESw";
+ String DOWNLOAD_N_E_SW = "DownloadNESw";
+ String UPGRADE_POST_CHECK = "UpgradePostCheck";
+ String UPGRADE_PRE_CHECK = "UpgradePreCheck";
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmClientBuilder.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmClientBuilder.java
index 5616db3577..0f17c547b5 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmClientBuilder.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmClientBuilder.java
@@ -39,6 +39,10 @@ public class SDNCLcmClientBuilder {
sdncLcmProperties = pros;
}
+ public SDNCLcmProperties getSDNCLcmProperties() {
+ return sdncLcmProperties;
+ }
+
public SDNCLcmRestClient newSDNCLcmRestClient(String operation) throws SDNCLcmClientBuilderException {
URI pathUri;
try {
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmProperties.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmProperties.java
index df5fb3be0b..a21196e08f 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmProperties.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmProperties.java
@@ -27,6 +27,8 @@ public interface SDNCLcmProperties extends RestProperties {
String getPath();
+ long getActionTimeout();
+
String getBasicAuth();
String getDmaapHost();
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/ActivateNESwPayload.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/ActivateNESwPayload.java
new file mode 100644
index 0000000000..d86d114a9f
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/ActivateNESwPayload.java
@@ -0,0 +1,64 @@
+/*-
+ * ============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.client.sdnc.lcm.beans.payload;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({"ipaddressV4Oam", "playbookName", "swVersionToBeActivated"})
+public class ActivateNESwPayload {
+
+ @JsonProperty(value = "ipaddress-v4-oam", required = true)
+ private String ipaddressV4Oam;
+
+ @JsonProperty(value = "playbook-name")
+ private String playbookName;
+
+ @JsonProperty(value = "swVersionToBeActivated", required = true)
+ private String swVersionToBeActivated;
+
+ public String getIpaddressV4Oam() {
+ return ipaddressV4Oam;
+ }
+
+ public void setIpaddressV4Oam(String value) {
+ this.ipaddressV4Oam = value;
+ }
+
+ public String getPlaybookName() {
+ return playbookName;
+ }
+
+ public void setPlaybookName(String value) {
+ this.playbookName = value;
+ }
+
+ public String getSwVersionToBeActivated() {
+ return swVersionToBeActivated;
+ }
+
+ public void setSwVersionToBeActivated(String value) {
+ this.swVersionToBeActivated = value;
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/DownloadNESwPayload.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/DownloadNESwPayload.java
new file mode 100644
index 0000000000..5dc5cf503d
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/DownloadNESwPayload.java
@@ -0,0 +1,66 @@
+/*-
+ * ============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.client.sdnc.lcm.beans.payload;
+
+import java.util.ArrayList;
+import java.util.List;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({"ipaddressV4Oam", "playbookName", "swToBeDownloaded"})
+public class DownloadNESwPayload {
+
+ @JsonProperty(value = "ipaddress-v4-oam", required = true)
+ private String ipaddressV4Oam;
+
+ @JsonProperty(value = "playbook-name")
+ private String playbookName;
+
+ @JsonProperty(value = "swToBeDownloaded", required = true)
+ private List<SwToBeDownloadedElement> swToBeDownloaded = new ArrayList<>();
+
+ public String getIpaddressV4Oam() {
+ return ipaddressV4Oam;
+ }
+
+ public void setIpaddressV4Oam(String value) {
+ this.ipaddressV4Oam = value;
+ }
+
+ public String getPlaybookName() {
+ return playbookName;
+ }
+
+ public void setPlaybookName(String value) {
+ this.playbookName = value;
+ }
+
+ public List<SwToBeDownloadedElement> getSwToBeDownloaded() {
+ return swToBeDownloaded;
+ }
+
+ public void setSwToBeDownloaded(List<SwToBeDownloadedElement> value) {
+ this.swToBeDownloaded = value;
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/SwToBeDownloadedElement.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/SwToBeDownloadedElement.java
new file mode 100644
index 0000000000..1a3529d7c4
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/SwToBeDownloadedElement.java
@@ -0,0 +1,75 @@
+/*-
+ * ============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.client.sdnc.lcm.beans.payload;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({"swLocation", "swFileSize", "swFileCompression", "swFileFormat"})
+public class SwToBeDownloadedElement {
+
+ @JsonProperty(value = "swLocation", required = true)
+ private String swLocation;
+
+ @JsonProperty(value = "swFileSize")
+ private long swFileSize;
+
+ @JsonProperty(value = "swFileCompression")
+ private String swFileCompression;
+
+ @JsonProperty(value = "swFileFormat")
+ private String swFileFormat;
+
+ public String getSwLocation() {
+ return swLocation;
+ }
+
+ public void setSwLocation(String value) {
+ this.swLocation = value;
+ }
+
+ public long getSwFileSize() {
+ return swFileSize;
+ }
+
+ public void setSwFileSize(long value) {
+ this.swFileSize = value;
+ }
+
+ public String getSwFileCompression() {
+ return swFileCompression;
+ }
+
+ public void setSwFileCompression(String value) {
+ this.swFileCompression = value;
+ }
+
+ public String getSwFileFormat() {
+ return swFileFormat;
+ }
+
+ public void setSwFileFormat(String value) {
+ this.swFileFormat = value;
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePostCheckPayload.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePostCheckPayload.java
new file mode 100644
index 0000000000..76937d262c
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePostCheckPayload.java
@@ -0,0 +1,96 @@
+/*-
+ * ============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.client.sdnc.lcm.beans.payload;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({"ipaddressV4Oam", "playbookName", "oldSwVersion", "targetSwVersion", "ruleName", "additionalData"})
+public class UpgradePostCheckPayload {
+
+ @JsonProperty(value = "ipaddress-v4-oam", required = true)
+ private String ipaddressV4Oam;
+
+ @JsonProperty(value = "playbook-name")
+ private String playbookName;
+
+ @JsonProperty(value = "oldSwVersion", required = true)
+ private String oldSwVersion;
+
+ @JsonProperty(value = "targetSwVersion", required = true)
+ private String targetSwVersion;
+
+ @JsonProperty(value = "ruleName", required = true)
+ private String ruleName;
+
+ @JsonProperty(value = "additionalData")
+ private String additionalData;
+
+ public String getIpaddressV4Oam() {
+ return ipaddressV4Oam;
+ }
+
+ public void setIpaddressV4Oam(String value) {
+ this.ipaddressV4Oam = value;
+ }
+
+ public String getPlaybookName() {
+ return playbookName;
+ }
+
+ public void setPlaybookName(String value) {
+ this.playbookName = value;
+ }
+
+ public String getOldSwVersion() {
+ return oldSwVersion;
+ }
+
+ public void setOldSwVersion(String value) {
+ this.oldSwVersion = value;
+ }
+
+ public String getTargetSwVersion() {
+ return targetSwVersion;
+ }
+
+ public void setTargetSwVersion(String value) {
+ this.targetSwVersion = value;
+ }
+
+ public String getRuleName() {
+ return ruleName;
+ }
+
+ public void setRuleName(String value) {
+ this.ruleName = value;
+ }
+
+ public String getAdditionalData() {
+ return additionalData;
+ }
+
+ public void setAdditionalData(String value) {
+ this.additionalData = value;
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePreCheckPayload.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePreCheckPayload.java
new file mode 100644
index 0000000000..d1a95b8418
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePreCheckPayload.java
@@ -0,0 +1,96 @@
+/*-
+ * ============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.client.sdnc.lcm.beans.payload;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({"ipaddressV4Oam", "playbookName", "oldSwVersion", "targetSwVersion", "ruleName", "additionalData"})
+public class UpgradePreCheckPayload {
+
+ @JsonProperty(value = "ipaddress-v4-oam", required = true)
+ private String ipaddressV4Oam;
+
+ @JsonProperty(value = "playbook-name")
+ private String playbookName;
+
+ @JsonProperty(value = "oldSwVersion", required = true)
+ private String oldSwVersion;
+
+ @JsonProperty(value = "targetSwVersion", required = true)
+ private String targetSwVersion;
+
+ @JsonProperty(value = "ruleName", required = true)
+ private String ruleName;
+
+ @JsonProperty(value = "additionalData")
+ private String additionalData;
+
+ public String getIpaddressV4Oam() {
+ return ipaddressV4Oam;
+ }
+
+ public void setIpaddressV4Oam(String value) {
+ this.ipaddressV4Oam = value;
+ }
+
+ public String getPlaybookName() {
+ return playbookName;
+ }
+
+ public void setPlaybookName(String value) {
+ this.playbookName = value;
+ }
+
+ public String getOldSwVersion() {
+ return oldSwVersion;
+ }
+
+ public void setOldSwVersion(String value) {
+ this.oldSwVersion = value;
+ }
+
+ public String getTargetSwVersion() {
+ return targetSwVersion;
+ }
+
+ public void setTargetSwVersion(String value) {
+ this.targetSwVersion = value;
+ }
+
+ public String getRuleName() {
+ return ruleName;
+ }
+
+ public void setRuleName(String value) {
+ this.ruleName = value;
+ }
+
+ public String getAdditionalData() {
+ return additionalData;
+ }
+
+ public void setAdditionalData(String value) {
+ this.additionalData = value;
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/SDNCLcmDmaapClientTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/SDNCLcmDmaapClientTest.java
index 5483792a84..3757769769 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/SDNCLcmDmaapClientTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/SDNCLcmDmaapClientTest.java
@@ -42,7 +42,7 @@ public class SDNCLcmDmaapClientTest extends BaseTest {
protected static final String DMAAP_HOST_PROP = SDNCLcmPropertiesImpl.DMAAP_HOST;
protected static final String DMAAP_WRITE_TOPIC_PROP = SDNCLcmPropertiesImpl.LCM_DMAAP_WRITE_TOPIC;
protected static final String DMAAP_READ_TOPIC_PROP = SDNCLcmPropertiesImpl.LCM_DMAAP_READ_TOPIC;
- protected static final String DMAAP_PARTITION_PROP = SDNCLcmPropertiesImpl.DMAAP_PARTITION;
+ protected static final String DMAAP_PARTITION_PROP = SDNCLcmPropertiesImpl.LCM_DMAAP_PARTITION;
protected String testWriteTopic = "TEST-WRITE-TOPIC";
protected String testReadTopic = "TEST-READ-TOPIC";
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/ActivateNESwPayloadTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/ActivateNESwPayloadTest.java
new file mode 100644
index 0000000000..bee07f2022
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/ActivateNESwPayloadTest.java
@@ -0,0 +1,52 @@
+/*-
+ * ============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.client.sdnc.lcm.beans.payload;
+
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+public class ActivateNESwPayloadTest extends LcmBasePayloadTest {
+ private static String expectedActivateNESwPayload = "{" + "\"ipaddress-v4-oam\":\"192.168.1.10\","
+ + "\"playbook-name\":\"test_playbook\"," + "\"swVersionToBeActivated\":\"v2\"" + "}";
+
+ public ActivateNESwPayload buildActivateNESwPayload() {
+ ActivateNESwPayload activateNESwPayload = new ActivateNESwPayload();
+
+ activateNESwPayload.setIpaddressV4Oam(ipaddressV4Oam);
+ activateNESwPayload.setPlaybookName(playbookName);
+ activateNESwPayload.setSwVersionToBeActivated("v2");
+
+ return activateNESwPayload;
+ }
+
+ @Test
+ public final void testActivateNESwPayload() {
+ ActivateNESwPayload activateNESwPayload = buildActivateNESwPayload();
+
+ try {
+ String activateNESwPayloadString = convertToSting(activateNESwPayload);
+ assertEquals(expectedActivateNESwPayload, activateNESwPayloadString);
+ } catch (Exception e) {
+ fail("Convert ActivateNESwPayload to String error: " + e.toString());
+ }
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/DownloadNESwPayloadTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/DownloadNESwPayloadTest.java
new file mode 100644
index 0000000000..f9fa679790
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/DownloadNESwPayloadTest.java
@@ -0,0 +1,82 @@
+/*-
+ * ============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.client.sdnc.lcm.beans.payload;
+
+import java.util.Collections;
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+public class DownloadNESwPayloadTest extends LcmBasePayloadTest {
+ private static String expectedSwToBeDownloadedElement = "{" + "\"swLocation\":\"http://192.168.1.20/test.zip\","
+ + "\"swFileSize\":123456," + "\"swFileCompression\":\"ZIP\"," + "\"swFileFormat\":\"binary\"" + "}";
+
+ private static String expectedDownloadNESwPayload =
+ "{" + "\"ipaddress-v4-oam\":\"192.168.1.10\"," + "\"playbook-name\":\"test_playbook\","
+ + "\"swToBeDownloaded\":[" + expectedSwToBeDownloadedElement + "]" + "}";
+
+ public SwToBeDownloadedElement buildSwToBeDownloadedElement() {
+ SwToBeDownloadedElement swToBeDownloadedElement = new SwToBeDownloadedElement();
+
+ swToBeDownloadedElement.setSwLocation("http://192.168.1.20/test.zip");
+ swToBeDownloadedElement.setSwFileSize(123456);
+ swToBeDownloadedElement.setSwFileCompression("ZIP");
+ swToBeDownloadedElement.setSwFileFormat("binary");
+
+ return swToBeDownloadedElement;
+ }
+
+ public DownloadNESwPayload buildDownloadNESwPayload() {
+ DownloadNESwPayload downloadNESwPayload = new DownloadNESwPayload();
+
+ downloadNESwPayload.setIpaddressV4Oam(ipaddressV4Oam);
+ downloadNESwPayload.setPlaybookName(playbookName);
+
+ SwToBeDownloadedElement swToBeDownloadedElement = buildSwToBeDownloadedElement();
+ downloadNESwPayload.setSwToBeDownloaded(Collections.singletonList(swToBeDownloadedElement));
+
+ return downloadNESwPayload;
+ }
+
+ @Test
+ public final void testSwToBeDownloadedElement() {
+ SwToBeDownloadedElement swToBeDownloadedElement = buildSwToBeDownloadedElement();
+
+ try {
+ String swToBeDownloadedElementString = convertToSting(swToBeDownloadedElement);
+ assertEquals(expectedSwToBeDownloadedElement, swToBeDownloadedElementString);
+ } catch (Exception e) {
+ fail("Convert SwToBeDownloadedElement to String error: " + e.toString());
+ }
+ }
+
+ @Test
+ public final void testDownloadNESwPayload() {
+ DownloadNESwPayload downloadNESwPayload = buildDownloadNESwPayload();
+
+ try {
+ String downloadNESwPayloadString = convertToSting(downloadNESwPayload);
+ assertEquals(expectedDownloadNESwPayload, downloadNESwPayloadString);
+ } catch (Exception e) {
+ fail("Convert DownloadNESwPayload to String error: " + e.toString());
+ }
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/LcmBasePayloadTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/LcmBasePayloadTest.java
new file mode 100644
index 0000000000..5452166d03
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/LcmBasePayloadTest.java
@@ -0,0 +1,42 @@
+/*-
+ * ============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.client.sdnc.lcm.beans.payload;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class LcmBasePayloadTest {
+ private static Logger logger = LoggerFactory.getLogger(LcmBasePayloadTest.class);
+
+ protected String ipaddressV4Oam = "192.168.1.10";
+ protected String playbookName = "test_playbook";
+
+ public String convertToSting(Object msgObject) throws JsonProcessingException {
+ ObjectMapper mapper = new ObjectMapper();
+
+ String msgString = mapper.writeValueAsString(msgObject);
+ logger.debug(msgObject.getClass().getSimpleName() + "\n" + msgString);
+
+ return msgString;
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePostCheckPayloadTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePostCheckPayloadTest.java
new file mode 100644
index 0000000000..acd447e890
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePostCheckPayloadTest.java
@@ -0,0 +1,56 @@
+/*-
+ * ============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.client.sdnc.lcm.beans.payload;
+
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+public class UpgradePostCheckPayloadTest extends LcmBasePayloadTest {
+ private static String expectedUpgradePostCheckPayload = "{" + "\"ipaddress-v4-oam\":\"192.168.1.10\","
+ + "\"playbook-name\":\"test_playbook\"," + "\"oldSwVersion\":\"v1\"," + "\"targetSwVersion\":\"v2\","
+ + "\"ruleName\":\"r102\"," + "\"additionalData\":\"{}\"" + "}";
+
+ public UpgradePostCheckPayload buildUpgradePostCheckPayload() {
+ UpgradePostCheckPayload upgradePostCheckPayload = new UpgradePostCheckPayload();
+
+ upgradePostCheckPayload.setIpaddressV4Oam(ipaddressV4Oam);
+ upgradePostCheckPayload.setPlaybookName(playbookName);
+ upgradePostCheckPayload.setOldSwVersion("v1");
+ upgradePostCheckPayload.setTargetSwVersion("v2");
+ upgradePostCheckPayload.setRuleName("r102");
+ upgradePostCheckPayload.setAdditionalData("{}");
+
+ return upgradePostCheckPayload;
+ }
+
+ @Test
+ public final void testUpgradePostCheckPayload() {
+ UpgradePostCheckPayload upgradePostCheckPayload = buildUpgradePostCheckPayload();
+
+ try {
+ String upgradePostCheckPayloadString = convertToSting(upgradePostCheckPayload);
+ assertEquals(expectedUpgradePostCheckPayload, upgradePostCheckPayloadString);
+ } catch (Exception e) {
+ fail("Convert UpgradePostCheckPayload to String error: " + e.toString());
+ }
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePreCheckPayloadTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePreCheckPayloadTest.java
new file mode 100644
index 0000000000..8bc0714fff
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePreCheckPayloadTest.java
@@ -0,0 +1,56 @@
+/*-
+ * ============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.client.sdnc.lcm.beans.payload;
+
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+public class UpgradePreCheckPayloadTest extends LcmBasePayloadTest {
+ private static String expectedUpgradePreCheckPayload = "{" + "\"ipaddress-v4-oam\":\"192.168.1.10\","
+ + "\"playbook-name\":\"test_playbook\"," + "\"oldSwVersion\":\"v1\"," + "\"targetSwVersion\":\"v2\","
+ + "\"ruleName\":\"r101\"," + "\"additionalData\":\"{}\"" + "}";
+
+ public UpgradePreCheckPayload buildUpgradePreCheckPayload() {
+ UpgradePreCheckPayload upgradePreCheckPayload = new UpgradePreCheckPayload();
+
+ upgradePreCheckPayload.setIpaddressV4Oam(ipaddressV4Oam);
+ upgradePreCheckPayload.setPlaybookName(playbookName);
+ upgradePreCheckPayload.setOldSwVersion("v1");
+ upgradePreCheckPayload.setTargetSwVersion("v2");
+ upgradePreCheckPayload.setRuleName("r101");
+ upgradePreCheckPayload.setAdditionalData("{}");
+
+ return upgradePreCheckPayload;
+ }
+
+ @Test
+ public final void testUpgradePreCheckPayload() {
+ UpgradePreCheckPayload upgradePreCheckPayload = buildUpgradePreCheckPayload();
+
+ try {
+ String upgradePreCheckPayloadString = convertToSting(upgradePreCheckPayload);
+ assertEquals(expectedUpgradePreCheckPayload, upgradePreCheckPayloadString);
+ } catch (Exception e) {
+ fail("Convert UpgradePreCheckPayload to String error: " + e.toString());
+ }
+ }
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java
index fab3496559..3ea8b190ad 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java
@@ -35,8 +35,10 @@ public class ExecutionVariableNames {
public final static String TIMEOUT_FOR_NOTIFICATION = "timeoutForPnfEntryNotification";
public final static String PNF_UUID = "pnfUuid";
public final static String SERVICE_INSTANCE_ID = "serviceInstanceId";
+ public final static String REQUEST_ID = "requestId";
public final static String MSO_REQUEST_ID = "msoRequestId";
public final static String MODEL_UUID = "modelUuid";
+ public final static String REQUEST_PAYLOAD = "requestPayload";
public final static String SERVICE_MODEL_INFO = "serviceModelInfo";
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/NfSoftwareUpgradeDispatcher.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/NfSoftwareUpgradeDispatcher.java
index 4482d2a327..6c140061c0 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/NfSoftwareUpgradeDispatcher.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/NfSoftwareUpgradeDispatcher.java
@@ -69,7 +69,7 @@ public class NfSoftwareUpgradeDispatcher implements JavaDelegate {
@Override
public void execute(DelegateExecution delegateExecution) throws Exception {
- logger.debug("Running execute block for activity id:{}, name:{}", delegateExecution.getCurrentActivityId(),
+ logger.debug("Running execute block for activity id: {}, name: {}", delegateExecution.getCurrentActivityId(),
delegateExecution.getCurrentActivityName());
RequestDetails bpmnRequestDetails = requestVerification(delegateExecution);
@@ -82,9 +82,10 @@ public class NfSoftwareUpgradeDispatcher implements JavaDelegate {
final List<PnfResourceCustomization> pnfCustomizations =
getPnfResourceCustomizations(delegateExecution, serviceModelUuid);
final PnfResourceCustomization pnfResourceCustomization = pnfCustomizations.get(0);
+ final String payload = bpmnRequestDetails.getRequestParameters().getPayload();
populateExecution(delegateExecution, bpmnRequestDetails, pnfResourceCustomization, pnf, serviceInstanceName,
- pnfName, serviceModelUuid, userParams);
+ pnfName, serviceModelUuid, userParams, payload);
logger.trace("Completed preProcessRequest PnfSoftwareUpgradeServiceRequest Request ");
}
@@ -104,7 +105,7 @@ public class NfSoftwareUpgradeDispatcher implements JavaDelegate {
private void populateExecution(DelegateExecution delegateExecution, RequestDetails bpmnRequestDetails,
PnfResourceCustomization pnfResourceCustomization, Pnf pnf, String serviceInstanceName, String pnfName,
- String serviceModelUuid, List<Map<String, Object>> userParams) {
+ String serviceModelUuid, List<Map<String, Object>> userParams, String payload) {
delegateExecution.setVariable(SERVICE_MODEL_INFO, bpmnRequestDetails.getModelInfo());
delegateExecution.setVariable(SERVICE_INSTANCE_NAME, serviceInstanceName);
@@ -124,6 +125,8 @@ public class NfSoftwareUpgradeDispatcher implements JavaDelegate {
delegateExecution.setVariable(param.get("name").toString(), param.get("value").toString());
}
}
+
+ delegateExecution.setVariable(REQUEST_PAYLOAD, payload);
}
private Pnf getPnfByPnfName(DelegateExecution delegateExecution, String pnfName) {
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());
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SDNCLcmPayloadBuilderTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SDNCLcmPayloadBuilderTest.java
new file mode 100644
index 0000000000..61f2ee3432
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SDNCLcmPayloadBuilderTest.java
@@ -0,0 +1,135 @@
+/*-
+ * ============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 com.fasterxml.jackson.core.JsonProcessingException;
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.junit.Before;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.junit.runner.RunWith;
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.when;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.REQUEST_PAYLOAD;
+import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda.controller.common.SoPropertyConstants;
+import org.onap.so.client.sdnc.lcm.beans.payload.*;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+public class SDNCLcmPayloadBuilderTest {
+ private static Logger logger = LoggerFactory.getLogger(SDNCLcmPayloadBuilderTest.class);
+
+ protected static String payload = "{" + "\"ipaddressV4Oam\": \"192.168.1.10\"," + "\"oldSwVersion\": \"v1\","
+ + "\"preCheckRuleName\": \"r101\"," + "\"preCheckAdditionalData\": \"{}\","
+ + "\"preCheckPlaybook\": \"precheck_playbook\"," + "\"swToBeDownloaded\": \"[{"
+ + "\\\"swLocation\\\": \\\"http://192.168.1.20/test.zip\\\"," + "\\\"swFileSize\\\": 123456,"
+ + "\\\"swFileCompression\\\": \\\"ZIP\\\"," + "\\\"swFileFormat\\\": \\\"binary\\\"}]\","
+ + "\"downloadNESwPlaybook\": \"downloadnesw_playbook\","
+ + "\"activateNESwPlaybook\": \"activatenesw_playbook\"," + "\"postCheckRuleName\": \"r102\","
+ + "\"postCheckAdditionalData\": \"{}\"," + "\"postCheckPlaybook\": \"postcheck_playbook\"" + "}";
+ protected String targetSoftwareVersion = "v2";
+
+ @MockBean
+ private DelegateExecution execution;
+
+ public static String getRequestPayload() {
+ return payload;
+ }
+
+ @Before
+ public void setUp() {
+ when(execution.getVariable(REQUEST_PAYLOAD)).thenReturn(payload);
+ when(execution.getVariable(SoPropertyConstants.TARGET_SOFTWARE_VERSION)).thenReturn(targetSoftwareVersion);
+ }
+
+
+ @Test
+ public final void testBuildActivateNESwPayload() {
+ String expectedPayload = "{" + "\"ipaddress-v4-oam\":\"192.168.1.10\","
+ + "\"playbook-name\":\"activatenesw_playbook\"," + "\"swVersionToBeActivated\":\"v2\"" + "}";
+
+ ActivateNESwPayload activateNESwPayload = SDNCLcmPayloadBuilder.buildActivateNESwPayload(execution);
+ try {
+ String payload = SDNCLcmPayloadBuilder.convertToSting(activateNESwPayload);
+ logger.debug("ActivateNESwPayload:\n" + payload);
+
+ assertEquals(expectedPayload, payload);
+ } catch (JsonProcessingException e) {
+ fail("Convert ActivateNESwPayload to String error: " + e.toString());
+ }
+ }
+
+ @Test
+ public final void testBuildDownloadNESwPayload() {
+ String expectedSwToBeDownloadedElement = "{" + "\"swLocation\":\"http://192.168.1.20/test.zip\","
+ + "\"swFileSize\":123456," + "\"swFileCompression\":\"ZIP\"," + "\"swFileFormat\":\"binary\"" + "}";
+ String expectedPayload =
+ "{" + "\"ipaddress-v4-oam\":\"192.168.1.10\"," + "\"playbook-name\":\"downloadnesw_playbook\","
+ + "\"swToBeDownloaded\":[" + expectedSwToBeDownloadedElement + "]" + "}";
+
+ DownloadNESwPayload downloadNESwPayload = SDNCLcmPayloadBuilder.buildDownloadNESwPayload(execution);
+ try {
+ String payload = SDNCLcmPayloadBuilder.convertToSting(downloadNESwPayload);
+ logger.debug("DownloadNESwPayload:\n" + payload);
+
+ assertEquals(expectedPayload, payload);
+ } catch (JsonProcessingException e) {
+ fail("Convert DownloadNESwPayload to String error: " + e.toString());
+ }
+ }
+
+ @Test
+ public final void testBuildUpgradePostCheckPayload() {
+ String expectedPayload = "{" + "\"ipaddress-v4-oam\":\"192.168.1.10\","
+ + "\"playbook-name\":\"postcheck_playbook\"," + "\"oldSwVersion\":\"v1\","
+ + "\"targetSwVersion\":\"v2\"," + "\"ruleName\":\"r102\"," + "\"additionalData\":\"{}\"" + "}";
+
+ UpgradePostCheckPayload upgradePostCheckPayload = SDNCLcmPayloadBuilder.buildUpgradePostCheckPayload(execution);
+ try {
+ String payload = SDNCLcmPayloadBuilder.convertToSting(upgradePostCheckPayload);
+ logger.debug("UpgradePostCheckPayload:\n" + payload);
+
+ assertEquals(expectedPayload, payload);
+ } catch (JsonProcessingException e) {
+ fail("Convert UpgradePostCheckPayload to String error: " + e.toString());
+ }
+ }
+
+ @Test
+ public final void testBuildUpgradePreCheckPayload() {
+ String expectedPayload = "{" + "\"ipaddress-v4-oam\":\"192.168.1.10\","
+ + "\"playbook-name\":\"precheck_playbook\"," + "\"oldSwVersion\":\"v1\","
+ + "\"targetSwVersion\":\"v2\"," + "\"ruleName\":\"r101\"," + "\"additionalData\":\"{}\"" + "}";
+
+ UpgradePreCheckPayload upgradePreCheckPayload = SDNCLcmPayloadBuilder.buildUpgradePreCheckPayload(execution);
+ try {
+ String payload = SDNCLcmPayloadBuilder.convertToSting(upgradePreCheckPayload);
+ logger.debug("UpgradePreCheckPayload:\n" + payload);
+
+ assertEquals(expectedPayload, payload);
+ } catch (JsonProcessingException e) {
+ fail("Convert UpgradePreCheckPayload to String error: " + e.toString());
+ }
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDETest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDETest.java
index 674167624e..02c7dca9ae 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDETest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDETest.java
@@ -28,7 +28,6 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext;
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.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.MockBean;
@@ -48,9 +47,6 @@ public class SdncControllerDETest {
@MockBean
private ControllerPreparable<DelegateExecution> preparable;
- @MockBean
- protected ApplicationControllerAction client;
-
@Before
public void setUp() {
when(controllerContext.getControllerActor()).thenReturn("sdnc");