summaryrefslogtreecommitdiffstats
path: root/bpmn/MSOInfrastructureBPMN
diff options
context:
space:
mode:
authorZhuoyao Huang <10112215@zte.com.cn>2017-10-14 19:51:20 +0800
committerZhuoyao Huang <10112215@zte.com.cn>2017-10-14 20:14:17 +0800
commit09c8a0f61868c69315115156447b34acaf907bad (patch)
tree03013b14423a0c93d5b273267d98f08d337b32de /bpmn/MSOInfrastructureBPMN
parente137c11a9e1f6f62b2f4a4354f097419d4e8ce3f (diff)
overlay-vpn
change input parameters' names and action-type for overlay-vpn Change-Id: I232410e4e6056bd4253d7e66ad4b895d2052583a Issue-ID:SO-181 Signed-off-by: Zhuoyao Huang <10112215@zte.com.cn>
Diffstat (limited to 'bpmn/MSOInfrastructureBPMN')
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java27
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncServiceTopologyOperationTask.java3
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/builder/AbstractBuilder.java57
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/builder/NetworkRpcInputEntityBuilder.java2
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/builder/ServiceRpcInputEntityBuilder.java2
5 files changed, 69 insertions, 22 deletions
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java
index 0f384096cb..4495e87789 100644
--- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java
+++ b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java
@@ -22,16 +22,19 @@ package org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask;
import org.apache.commons.lang3.StringUtils;
import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.json.JSONObject;
import org.onap.msb.sdk.httpclient.RestServiceCreater;
import org.onap.msb.sdk.httpclient.msb.MSBServiceClient;
-import org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.client.GenericResourceApi;
import org.openecomp.mso.bpmn.core.BaseTask;
+import org.openecomp.mso.bpmn.core.PropertyConfiguration;
+import org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.client.GenericResourceApi;
import org.openecomp.mso.logger.MessageEnum;
import org.openecomp.mso.logger.MsoLogger;
import org.openecomp.mso.requestsdb.RequestsDatabase;
import org.openecomp.mso.requestsdb.RequestsDbConstant;
import org.openecomp.mso.requestsdb.ResourceOperationStatus;
+import java.util.HashMap;
import java.util.Map;
/**
@@ -41,7 +44,7 @@ public abstract class AbstractSdncOperationTask extends BaseTask {
private static final String DEFAULT_MSB_IP = "127.0.0.1";
private static final int DEFAULT_MSB_Port = 10081;
- private static final String SDCADAPTOR_INPUTS = "SDCADAPTOR_INPUTS";
+ private static final String SDCADAPTOR_INPUTS = "resourceParameters";
private RequestsDatabase requestsDB = RequestsDatabase.getInstance();
@@ -51,7 +54,7 @@ public abstract class AbstractSdncOperationTask extends BaseTask {
public void execute(DelegateExecution execution) {
GenericResourceApi genericResourceApiClient = getGenericResourceApiClient(execution);
updateProgress(execution, RequestsDbConstant.Status.PROCESSING, null, "10", "execute begin!");
- Map<String, String> inputs = (Map<String, String>) execution.getVariable(SDCADAPTOR_INPUTS);
+ Map<String, String> inputs = getInputs(execution);
updateProgress(execution, null, null, "30", "getGenericResourceApiClient finished!");
try {
sendRestrequestAndHandleResponse(execution, inputs, genericResourceApiClient);
@@ -63,6 +66,15 @@ public abstract class AbstractSdncOperationTask extends BaseTask {
}
}
+ protected Map<String, String> getInputs(DelegateExecution execution) {
+ Map<String, String> inputs = new HashMap<>();
+ String json = (String) execution.getVariable(SDCADAPTOR_INPUTS);
+ JSONObject jsonObject = new JSONObject(json);
+ JSONObject paras = jsonObject.getJSONObject("additionalParamForNs");
+ paras.keySet().stream().forEach(key -> inputs.put(key, paras.getString((String) key)));
+ return inputs;
+ }
+
public abstract void sendRestrequestAndHandleResponse(DelegateExecution execution,
Map<String, String> inputs,
GenericResourceApi genericResourceApiClient) throws Exception;
@@ -93,15 +105,16 @@ public abstract class AbstractSdncOperationTask extends BaseTask {
private GenericResourceApi getGenericResourceApiClient(DelegateExecution execution) {
updateProgress(execution, null, null, "20", "getGenericResourceApiClient begin!");
- String msbIp = getString(execution, "MSB_IP", DEFAULT_MSB_IP);
- int msbPort = getInteger(execution, "MSB_Port", DEFAULT_MSB_Port);
+ Map<String, String> properties = PropertyConfiguration.getInstance().getProperties("mso.bpmn.urn.properties");
+ String msbIp = getString(properties, "msb.address", DEFAULT_MSB_IP);
+ int msbPort = Integer.valueOf(getString(properties, "msb.port", String.valueOf(DEFAULT_MSB_Port)));
MSBServiceClient msbClient = new MSBServiceClient(msbIp, msbPort);
RestServiceCreater restServiceCreater = new RestServiceCreater(msbClient);
return restServiceCreater.createService(GenericResourceApi.class);
}
- private String getString(DelegateExecution execution, String name, String defaultValue) {
- String vlaue = (String) execution.getVariable(name);
+ private String getString(Map<String, String> properties, String name, String defaultValue) {
+ String vlaue = properties.get(name);
try {
if (!StringUtils.isBlank(vlaue)) {
return vlaue;
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncServiceTopologyOperationTask.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncServiceTopologyOperationTask.java
index b5f312d71f..d6ccc8b03b 100644
--- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncServiceTopologyOperationTask.java
+++ b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncServiceTopologyOperationTask.java
@@ -40,9 +40,12 @@ public class SdncServiceTopologyOperationTask extends AbstractSdncOperationTask
public void sendRestrequestAndHandleResponse(DelegateExecution execution,
Map<String, String> inputs,
GenericResourceApi genericResourceApiClient) throws Exception {
+ updateProgress(execution, null, null, "40", "sendRestrequestAndHandleResponse begin!");
ServiceRpcInputEntityBuilder builder = new ServiceRpcInputEntityBuilder();
RpcServiceTopologyOperationInputEntity inputEntity = builder.build(execution, inputs);
+ updateProgress(execution, null, null, "50", "RequestBody build finished!");
RpcServiceTopologyOperationOutputEntity outputEntity = genericResourceApiClient.postServiceTopologyOperation(inputEntity).execute().body();
+ updateProgress(execution, null, null, "90", "sendRestrequestAndHandleResponse finished!");
saveOutput(execution, outputEntity);
}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/builder/AbstractBuilder.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/builder/AbstractBuilder.java
index 41fa8f250a..0634da7264 100644
--- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/builder/AbstractBuilder.java
+++ b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/builder/AbstractBuilder.java
@@ -22,7 +22,6 @@ package org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.client.builde
import org.apache.commons.lang3.StringUtils;
import org.camunda.bpm.engine.delegate.DelegateExecution;
-import org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.SdncUnderlayVpnPreprocessTask;
import org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.client.entity.OnapModelInformationEntity;
import org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.client.entity.ParamEntity;
import org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.client.entity.RequestInformationEntity;
@@ -41,6 +40,10 @@ import java.util.UUID;
* Created by 10112215 on 2017/9/20.
*/
public abstract class AbstractBuilder<IN, OUT> {
+
+ public static final String OPERATION_TYPE = "operationType";
+ public static final String RESOURCE_TYPE = "resourceType";
+
public static enum RequestAction {
CreateNetworkInstance(0, "CreateNetworkInstance"),
ActivateNetworkInstance(1, "ActivateNetworkInstance"),
@@ -56,7 +59,9 @@ public abstract class AbstractBuilder<IN, OUT> {
CreateContrailRouteInstance(11, "CreateContrailRouteInstance"),
DeleteContrailRouteInstance(12, "DeleteContrailRouteInstance"),
CreateSecurityZoneInstance(13, "CreateSecurityZoneInstance"),
- DeleteSecurityZoneInstance(14, "DeleteSecurityZoneInstance");
+ DeleteSecurityZoneInstance(14, "DeleteSecurityZoneInstance"),
+ ActivateDCINetworkInstance(15, "ActivateDCINetworkInstance"),
+ DeActivateDCINetworkInstance(16, "DeActivateDCINetworkInstance");
String name;
int value;
@@ -110,25 +115,55 @@ public abstract class AbstractBuilder<IN, OUT> {
protected String getRequestActoin(DelegateExecution execution) {
String action = /*RequestInformation.*/RequestAction.CreateNetworkInstance.name();
- String operType = getOperType(execution);
+ String operType = (String) execution.getVariable(OPERATION_TYPE);
+ String resourceType = ((String) execution.getVariable(RESOURCE_TYPE)).toLowerCase();
if (!StringUtils.isBlank(operType)) {
if (RequestsDbConstant.OperationType.DELETE.equals(operType)) {
- action = /*RequestInformation.*/RequestAction.DeleteNetworkInstance.name();
+ if (isOverlay(resourceType)) {
+ action = /*RequestInformation.*/RequestAction.DeActivateDCINetworkInstance.name();
+ } else if (isUnderlay(resourceType)) {
+ action = /*RequestInformation.*/RequestAction.DeleteNetworkInstance.name();
+ } else {
+ action = /*RequestInformation.*/RequestAction.DeleteServiceInstance.name();
+ }
} else if (RequestsDbConstant.OperationType.CREATE.equals(operType)) {
- action = /*RequestInformation.*/RequestAction.CreateNetworkInstance.name();
+ if (isOverlay(resourceType)) {
+ action = /*RequestInformation.*/RequestAction.ActivateDCINetworkInstance.name();
+ } else if (isUnderlay(resourceType)) {
+ action = /*RequestInformation.*/RequestAction.CreateNetworkInstance.name();
+ } else {
+ action = /*RequestInformation.*/RequestAction.CreateServiceInstance.name();
+ }
}
}
return action;
}
- protected String getOperationType(DelegateExecution execution) {
+ private boolean isOverlay(String resourceType) {
+ return !StringUtils.isBlank(resourceType) && resourceType.contains("overlay");
+ }
+
+ private boolean isUnderlay(String resourceType) {
+ return !StringUtils.isBlank(resourceType) && resourceType.contains("underlay");
+ }
+
+ protected String getSvcAction(DelegateExecution execution) {
String action = /*SdncRequestHeader.*/SvcAction.Create.name();
- String operType = getOperType(execution);
+ String operType = (String) execution.getVariable(OPERATION_TYPE);
+ String resourceType = ((String) execution.getVariable(RESOURCE_TYPE)).toLowerCase();
if (!StringUtils.isBlank(operType)) {
if (RequestsDbConstant.OperationType.DELETE.equals(operType)) {
- action = /*SdncRequestHeader.*/SvcAction.Delete.name();
+ if (isOverlay(resourceType)) {
+ action = /*SdncRequestHeader.*/SvcAction.Deactivate.name();
+ } else {
+ action = /*SdncRequestHeader.*/SvcAction.Delete.name();
+ }
} else if (RequestsDbConstant.OperationType.CREATE.equals(operType)) {
- action = /*SdncRequestHeader.*/SvcAction.Create.name();
+ if (isOverlay(resourceType)) {
+ action = /*SdncRequestHeader.*/SvcAction.Activate.name();
+ } else {
+ action = /*SdncRequestHeader.*/SvcAction.Create.name();
+ }
}
}
return action;
@@ -144,10 +179,6 @@ public abstract class AbstractBuilder<IN, OUT> {
return requestId;
}
- protected String getOperType(DelegateExecution execution) {
- return (String) execution.getVariable(SdncUnderlayVpnPreprocessTask.RESOURCE_OPER_TYPE);
- }
-
protected OnapModelInformationEntity getOnapModelInformationEntity(DelegateExecution execution) {
OnapModelInformationEntity onapModelInformationEntity = new OnapModelInformationEntity();
{
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/builder/NetworkRpcInputEntityBuilder.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/builder/NetworkRpcInputEntityBuilder.java
index a1e47df501..94838ed1ff 100644
--- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/builder/NetworkRpcInputEntityBuilder.java
+++ b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/builder/NetworkRpcInputEntityBuilder.java
@@ -60,7 +60,7 @@ public class NetworkRpcInputEntityBuilder extends AbstractBuilder<Map<String, St
SdncRequestHeaderEntity sdncRequestHeaderEntity = new SdncRequestHeaderEntity();
{
sdncRequestHeaderEntity.setSvcRequestId(getRequestId(execution));
- sdncRequestHeaderEntity.setSvcAction(getOperationType(execution));
+ sdncRequestHeaderEntity.setSvcAction(getSvcAction(execution));
}
networkTopologyOperationInputEntity.setSdncRequestHeader(sdncRequestHeaderEntity);
}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/builder/ServiceRpcInputEntityBuilder.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/builder/ServiceRpcInputEntityBuilder.java
index 5cb9272564..7867358bb6 100644
--- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/builder/ServiceRpcInputEntityBuilder.java
+++ b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/builder/ServiceRpcInputEntityBuilder.java
@@ -76,7 +76,7 @@ public class ServiceRpcInputEntityBuilder extends AbstractBuilder<Map<String, St
SdncRequestHeaderEntity sdncRequestHeaderEntity = new SdncRequestHeaderEntity();
{
sdncRequestHeaderEntity.setSvcRequestId(getRequestId(execution));
- sdncRequestHeaderEntity.setSvcAction(getOperationType(execution));
+ sdncRequestHeaderEntity.setSvcAction(getSvcAction(execution));
}
serviceTopologyOperationInputEntity.setSdncRequestHeader(sdncRequestHeaderEntity);
}