summaryrefslogtreecommitdiffstats
path: root/mso-api-handlers
diff options
context:
space:
mode:
authorBenjamin, Max (mb388a) <mb388a@us.att.com>2018-11-10 12:43:10 -0500
committerRob Daugherty <rd472p@att.com>2018-11-14 20:55:38 +0000
commit6b405cd8bfab89ccc6d93eaa0e2a13cda9ecc9a3 (patch)
treea8b5732629aa9f8eee04e4f7d489e4e49ec0a17a /mso-api-handlers
parent7feaa94e569653066c7ebff3dda3218869797f39 (diff)
accept a la carte create instance group request
Updated postBPELRequest to accept RequestClientParameter Switched to using .toString rather than .name for enum Added source to fix failing test Added action to fix failing apih tests Removed unused headers from test Removed unused import from RequestClientParameter Updated to use instanceGroupId constant Removed defaulting source in requestInfo Added validation for mandatory headers Added test case for modelVersionId in service related instance Added relatedInstance validation for create instanceGroup Added unit test cases for MembersValidation Added test cases for relatedInstances validation Added tests for add/remove member validation Added updates for deleteInstanceGroups Removed serviceProxy from test resource file Removed ServiceProxy as it is no longer needed Changed action to be removeMembers in endpoint Added removeMembers endpoint and validation Updated validation for create instanceGroups ... Change-Id: I12b14d6d81dd0690eea33dfcbf1be17c509f9832 Issue-ID: SO-1207 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'mso-api-handlers')
-rw-r--r--mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/CamundaVIDRequest.java13
-rw-r--r--mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CamundaClient.java9
-rw-r--r--mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CommonConstants.java1
-rw-r--r--mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/RequestClientParameter.java13
-rw-r--r--mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/Action.java4
-rw-r--r--mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/common/CamundaClientTest.java3
-rw-r--r--mso-api-handlers/mso-api-handler-common/src/test/resources/CamundaClientTest/WrappedVIDRequest.json2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Action.java4
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java185
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java259
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CloudConfigurationValidation.java39
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/InstanceIdMapValidation.java8
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/MembersValidation.java69
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ModelInfoValidation.java173
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidation.java22
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java27
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java151
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/MembersValidation/AddMembersInstanceId.json17
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/MembersValidation/AddMembersSource.json17
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/MembersValidation/DeleteMembersModelType.json17
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/MembersValidation/MembersRequestInfo.json14
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/MembersValidation/MembersRequestorId.json17
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/MembersValidation/RelatedInstances.json15
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/MembersValidation/RelatedInstancesVnf.json25
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/CreateInstanceGroupNoModelVersionId.json25
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RelatedInstances/CreateInstanceGroupNoModelCustomizationId.json33
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RelatedInstances/CreateInstanceGroupNoRelatedInstances.json16
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RelatedInstances/CreateInstanceGroupRelatedInstanceModelVersionId.json25
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RelatedInstances/CreateInstanceGroupService.json25
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/AddMembers.json18
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/CreateInstanceGroup.json26
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/MembersRequestInfo.json17
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/RemoveMembers.json18
33 files changed, 1054 insertions, 253 deletions
diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/CamundaVIDRequest.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/CamundaVIDRequest.java
index 9099b48f11..829f8ce30c 100644
--- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/CamundaVIDRequest.java
+++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/CamundaVIDRequest.java
@@ -109,6 +109,9 @@ public class CamundaVIDRequest {
@JsonProperty(CommonConstants.REQUEST_URI)
private CamundaInput requestUri;
+
+ @JsonProperty(CommonConstants.INSTANCE_GROUP_ID)
+ private CamundaInput instanceGroupId;
@JsonProperty(CommonConstants.CAMUNDA_SERVICE_INPUT)
public CamundaInput getServiceInput() {
@@ -326,6 +329,14 @@ public class CamundaVIDRequest {
public void setRecipeParams(CamundaInput recipeParams) {
this.recipeParams = recipeParams;
}
+ @JsonProperty(CommonConstants.INSTANCE_GROUP_ID)
+ public void setInstanceGroupId(CamundaInput instanceGroupIdInput) {
+ this.instanceGroupId = instanceGroupIdInput;
+ }
+ @JsonProperty(CommonConstants.INSTANCE_GROUP_ID)
+ public CamundaInput getInstanceGroupId() {
+ return instanceGroupId;
+ }
@Override
public String toString() {
@@ -335,4 +346,6 @@ public class CamundaVIDRequest {
return "CamundaRequest";
}
+
+
}
diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CamundaClient.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CamundaClient.java
index 3936cca08d..34cfe18508 100644
--- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CamundaClient.java
+++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CamundaClient.java
@@ -129,7 +129,8 @@ public class CamundaClient extends RequestClient{
msoLogger.debug(CAMUNDA_URL_MESAGE+ url);
String jsonReq = wrapVIDRequest(parameterObject.getRequestId(), parameterObject.isBaseVfModule(), parameterObject.getRecipeTimeout(), parameterObject.getRequestAction(),
parameterObject.getServiceInstanceId(), parameterObject.getCorrelationId(), parameterObject.getVnfId(), parameterObject.getVfModuleId(), parameterObject.getVolumeGroupId(), parameterObject.getNetworkId(), parameterObject.getConfigurationId(),
- parameterObject.getServiceType(), parameterObject.getVnfType(), parameterObject.getVfModuleType(), parameterObject.getNetworkType(), parameterObject.getRequestDetails(), parameterObject.getApiVersion(), parameterObject.isaLaCarte(), parameterObject.getRequestUri(), parameterObject.getRecipeParamXsd());
+ parameterObject.getServiceType(), parameterObject.getVnfType(), parameterObject.getVfModuleType(), parameterObject.getNetworkType(), parameterObject.getRequestDetails(), parameterObject.getApiVersion(), parameterObject.isaLaCarte(), parameterObject.getRequestUri(), parameterObject.getRecipeParamXsd(),
+ parameterObject.getInstanceGroupId());
StringEntity input = new StringEntity(jsonReq);
input.setContentType(CommonConstants.CONTENT_TYPE_JSON);
@@ -200,7 +201,8 @@ public class CamundaClient extends RequestClient{
int recipeTimeout, String requestAction, String serviceInstanceId, String correlationId,
String vnfId, String vfModuleId, String volumeGroupId, String networkId, String configurationId,
String serviceType, String vnfType, String vfModuleType, String networkType,
- String requestDetails, String apiVersion, boolean aLaCarte, String requestUri, String paramXsd){
+ String requestDetails, String apiVersion, boolean aLaCarte, String requestUri, String paramXsd,
+ String instanceGroupId){
String jsonReq = null;
try{
@@ -226,6 +228,7 @@ public class CamundaClient extends RequestClient{
CamundaInput apiVersionInput = new CamundaInput();
CamundaInput requestUriInput = new CamundaInput();
CamundaInput recipeParamsInput = new CamundaInput();
+ CamundaInput instanceGroupIdInput = new CamundaInput();
//host.setValue(parseURL());
requestIdInput.setValue(StringUtils.defaultString(requestId));
@@ -247,6 +250,7 @@ public class CamundaClient extends RequestClient{
apiVersionInput.setValue(StringUtils.defaultString(apiVersion));
requestUriInput.setValue(StringUtils.defaultString(requestUri));
recipeParamsInput.setValue(paramXsd);
+ instanceGroupIdInput.setValue(StringUtils.defaultString(instanceGroupId));
serviceInput.setValue(requestDetails);
camundaRequest.setServiceInput(serviceInput);
@@ -271,6 +275,7 @@ public class CamundaClient extends RequestClient{
camundaRequest.setApiVersion(apiVersionInput);
camundaRequest.setRequestUri(requestUriInput);
camundaRequest.setRecipeParams(recipeParamsInput);
+ camundaRequest.setInstanceGroupId(instanceGroupIdInput);
ObjectMapper mapper = new ObjectMapper();
mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true);
diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CommonConstants.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CommonConstants.java
index d1b629f60c..b75ad9e415 100644
--- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CommonConstants.java
+++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CommonConstants.java
@@ -79,6 +79,7 @@ public final class CommonConstants {
public static final String X_MINOR_VERSION = "X-MinorVersion";
public static final String X_PATCH_VERSION = "X-PatchVersion";
public static final String X_LATEST_VERSION = "X-LatestVersion";
+ public static final String INSTANCE_GROUP_ID = "instanceGroupId";
private CommonConstants () {
// prevent creating an instance of this class
diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/RequestClientParameter.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/RequestClientParameter.java
index 89db934985..1d18e2b02c 100644
--- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/RequestClientParameter.java
+++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/RequestClientParameter.java
@@ -43,6 +43,7 @@ public class RequestClientParameter {
private boolean aLaCarte;
private String recipeParamXsd;
private String requestUri;
+ private String instanceGroupId;
private RequestClientParameter(Builder builder) {
requestId = builder.requestId;
@@ -65,6 +66,7 @@ public class RequestClientParameter {
apiVersion = builder.apiVersion;
aLaCarte = builder.aLaCarte;
requestUri = builder.requestUri;
+ instanceGroupId = builder.instanceGroupId;
}
@@ -147,6 +149,10 @@ public class RequestClientParameter {
public String getRequestUri() {
return requestUri;
}
+
+ public String getInstanceGroupId() {
+ return instanceGroupId;
+ }
public static class Builder {
private String requestId;
@@ -169,6 +175,7 @@ public class RequestClientParameter {
private boolean aLaCarte = false;
private String recipeParamXsd;
private String requestUri;
+ private String instanceGroupId;
public Builder setRequestId(String requestId) {
this.requestId = requestId;
@@ -269,10 +276,16 @@ public class RequestClientParameter {
this.requestUri = requestUri;
return this;
}
+
+ public Builder setInstanceGroupId(String instanceGroupId) {
+ this.instanceGroupId = instanceGroupId;
+ return this;
+ }
public RequestClientParameter build(){
return new RequestClientParameter(this);
}
+
}
diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/Action.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/Action.java
index 3a35c23a86..03d68f88e8 100644
--- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/Action.java
+++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/Action.java
@@ -44,5 +44,7 @@ public enum Action {
scaleInstance,
deactivateAndCloudDelete,
scaleOut,
- recreateInstance
+ recreateInstance,
+ addMembers,
+ removeMembers
}
diff --git a/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/common/CamundaClientTest.java b/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/common/CamundaClientTest.java
index 247a62ec81..7a03ce0542 100644
--- a/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/common/CamundaClientTest.java
+++ b/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/common/CamundaClientTest.java
@@ -162,10 +162,11 @@ public class CamundaClientTest{
String apiVersion = "6";
boolean aLaCarte = true;
String requestUri = "v7/serviceInstances/assign";
+ String instanceGroupId = "ff305d54-75b4-431b-adb2-eb6b9e5ff000";
String testResult = testClient.wrapVIDRequest(requestId, isBaseVfModule, recipeTimeout, requestAction, serviceInstanceId, correlationId,
vnfId, vfModuleId, volumeGroupId, networkId, configurationId, serviceType,
- vnfType, vfModuleType, networkType, requestDetails, apiVersion, aLaCarte, requestUri, "");
+ vnfType, vfModuleType, networkType, requestDetails, apiVersion, aLaCarte, requestUri, "", instanceGroupId);
String expected = inputStream("/WrappedVIDRequest.json");
assertEquals(expected, testResult);
diff --git a/mso-api-handlers/mso-api-handler-common/src/test/resources/CamundaClientTest/WrappedVIDRequest.json b/mso-api-handlers/mso-api-handler-common/src/test/resources/CamundaClientTest/WrappedVIDRequest.json
index c4c7b030f9..4c716c2ae3 100644
--- a/mso-api-handlers/mso-api-handler-common/src/test/resources/CamundaClientTest/WrappedVIDRequest.json
+++ b/mso-api-handlers/mso-api-handler-common/src/test/resources/CamundaClientTest/WrappedVIDRequest.json
@@ -1 +1 @@
-{"variables":{"bpmnRequest":{"value":"{requestDetails: }","type":"String"},"requestId":{"value":"f7ce78bb-423b-11e7-93f8-0050569a796","type":"String"},"mso-request-id":{"value":"f7ce78bb-423b-11e7-93f8-0050569a796","type":"String"},"isBaseVfModule":{"value":true,"type":"Boolean"},"recipeTimeout":{"value":10000,"type":"Integer"},"requestAction":{"value":"createInstance","type":"String"},"serviceInstanceId":{"value":"12345679","type":"String"},"correlationId":{"value":"12345679","type":"String"},"vnfId":{"value":"234567891","type":"String"},"vfModuleId":{"value":"345678912","type":"String"},"volumeGroupId":{"value":"456789123","type":"String"},"networkId":{"value":"567891234","type":"String"},"configurationId":{"value":"678912345","type":"String"},"serviceType":{"value":"testService","type":"String"},"vnfType":{"value":"testVnf","type":"String"},"vfModuleType":{"value":"vfModuleType","type":"String"},"networkType":{"value":"networkType","type":"String"},"recipeParams":{"value":"","type":"String"},"host":{"value":null,"type":"String"},"apiVersion":{"value":"6","type":"String"},"aLaCarte":{"value":true,"type":"Boolean"},"requestUri":{"value":"v7/serviceInstances/assign","type":"String"}}} \ No newline at end of file
+{"variables":{"bpmnRequest":{"value":"{requestDetails: }","type":"String"},"requestId":{"value":"f7ce78bb-423b-11e7-93f8-0050569a796","type":"String"},"mso-request-id":{"value":"f7ce78bb-423b-11e7-93f8-0050569a796","type":"String"},"isBaseVfModule":{"value":true,"type":"Boolean"},"recipeTimeout":{"value":10000,"type":"Integer"},"requestAction":{"value":"createInstance","type":"String"},"serviceInstanceId":{"value":"12345679","type":"String"},"correlationId":{"value":"12345679","type":"String"},"vnfId":{"value":"234567891","type":"String"},"vfModuleId":{"value":"345678912","type":"String"},"volumeGroupId":{"value":"456789123","type":"String"},"networkId":{"value":"567891234","type":"String"},"configurationId":{"value":"678912345","type":"String"},"serviceType":{"value":"testService","type":"String"},"vnfType":{"value":"testVnf","type":"String"},"vfModuleType":{"value":"vfModuleType","type":"String"},"networkType":{"value":"networkType","type":"String"},"recipeParams":{"value":"","type":"String"},"host":{"value":null,"type":"String"},"apiVersion":{"value":"6","type":"String"},"aLaCarte":{"value":true,"type":"Boolean"},"requestUri":{"value":"v7/serviceInstances/assign","type":"String"},"instanceGroupId":{"value":"ff305d54-75b4-431b-adb2-eb6b9e5ff000","type":"String"}}} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Action.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Action.java
index 6013677684..897e2a5fc8 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Action.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Action.java
@@ -44,5 +44,7 @@ public enum Action implements Actions{
scaleInstance,
deactivateAndCloudDelete,
scaleOut,
- recreateInstance
+ recreateInstance,
+ addMembers,
+ removeMembers
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java
index c9f32d9705..440a9ea3ee 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java
@@ -44,6 +44,7 @@ import javax.xml.transform.stream.StreamResult;
import org.onap.so.apihandler.common.ResponseBuilder;
import org.onap.so.apihandlerinfra.tasksbeans.TasksRequest;
+import org.onap.so.apihandlerinfra.validation.MembersValidation;
import org.onap.so.apihandlerinfra.validation.ApplyUpdatedConfigValidation;
import org.onap.so.apihandlerinfra.validation.CloudConfigurationValidation;
import org.onap.so.apihandlerinfra.validation.ConfigurationParametersValidation;
@@ -174,6 +175,8 @@ public class MsoRequest {
rules.add(new InPlaceSoftwareUpdateValidation());
}else if(reqVersion >= 6 && action == Action.applyUpdatedConfig){
rules.add(new ApplyUpdatedConfigValidation());
+ }else if(action == Action.addMembers || action == Action.removeMembers){
+ rules.add(new MembersValidation());
}else{
rules.add(new RequestScopeValidation());
rules.add(new RequestParametersValidation());
@@ -264,7 +267,6 @@ public class MsoRequest {
if (null == servInsReq) {
servInsReq = new ServiceInstancesRequest ();
}
-
String networkType = "";
String vnfType = "";
aq.setRequestId (requestId);
@@ -275,97 +277,104 @@ public class MsoRequest {
Timestamp startTimeStamp = new Timestamp (System.currentTimeMillis());
aq.setStartTime (startTimeStamp);
- RequestInfo requestInfo =servInsReq.getRequestDetails().getRequestInfo();
- if (requestInfo != null) {
-
- if(requestInfo.getSource() != null){
- aq.setSource(requestInfo.getSource());
- }
- if(requestInfo.getCallbackUrl() != null){
- aq.setCallBackUrl(requestInfo.getCallbackUrl());
- }
- if(requestInfo.getCorrelator() != null){
- aq.setCorrelator(requestInfo.getCorrelator());
- }
-
- if(requestInfo.getRequestorId() != null) {
- aq.setRequestorId(requestInfo.getRequestorId());
- }
- }
-
- if (servInsReq.getRequestDetails().getModelInfo() != null || (action == Action.inPlaceSoftwareUpdate || action == Action.applyUpdatedConfig)) {
+ if(requestScope.equals(ModelType.instanceGroup.name()) && action == Action.deleteInstance){
aq.setRequestScope(requestScope);
- }
-
- if (servInsReq.getRequestDetails().getCloudConfiguration() != null) {
- CloudConfiguration cloudConfiguration = servInsReq.getRequestDetails().getCloudConfiguration();
- if(cloudConfiguration.getLcpCloudRegionId() != null) {
- aq.setAicCloudRegion(cloudConfiguration.getLcpCloudRegionId());
- }
-
- if(cloudConfiguration.getTenantId() != null) {
- aq.setTenantId(cloudConfiguration.getTenantId());
- }
-
- }
-
- if(servInsReq.getServiceInstanceId() != null){
- aq.setServiceInstanceId(servInsReq.getServiceInstanceId());
- }
-
- if(servInsReq.getVnfInstanceId() != null){
- aq.setVnfId(servInsReq.getVnfInstanceId());
- }
-
- if(ModelType.service.name().equalsIgnoreCase(requestScope)){
- if(servInsReq.getRequestDetails().getRequestInfo().getInstanceName() != null){
- aq.setServiceInstanceName(requestInfo.getInstanceName());
- }
- }
-
- if(ModelType.network.name().equalsIgnoreCase(requestScope)){
- aq.setNetworkName(servInsReq.getRequestDetails().getRequestInfo().getInstanceName());
- aq.setNetworkType(networkType);
- aq.setNetworkId(servInsReq.getNetworkInstanceId());
- }
-
- if(ModelType.volumeGroup.name().equalsIgnoreCase(requestScope)){
- aq.setVolumeGroupId(servInsReq.getVolumeGroupInstanceId());
- aq.setVolumeGroupName(servInsReq.getRequestDetails().getRequestInfo().getInstanceName());
- aq.setVnfType(vnfType);
-
- }
-
- if(ModelType.vfModule.name().equalsIgnoreCase(requestScope)){
- aq.setVfModuleName(requestInfo.getInstanceName());
- aq.setVfModuleModelName(servInsReq.getRequestDetails().getModelInfo().getModelName());
- aq.setVfModuleId(servInsReq.getVfModuleInstanceId());
- aq.setVolumeGroupId(servInsReq.getVolumeGroupInstanceId());
- aq.setVnfType(vnfType);
-
- }
-
- if(ModelType.configuration.name().equalsIgnoreCase(requestScope)) {
- aq.setConfigurationId(servInsReq.getConfigurationId());
- aq.setConfigurationName(requestInfo.getInstanceName());
- }
-
- if(ModelType.vnf.name().equalsIgnoreCase(requestScope)){
- aq.setVnfName(requestInfo.getInstanceName());
- if (null != servInsReq.getRequestDetails()) {
- RelatedInstanceList[] instanceList = servInsReq.getRequestDetails().getRelatedInstanceList();
-
- if (instanceList != null) {
-
- for(RelatedInstanceList relatedInstanceList : instanceList){
-
- RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance();
- if(relatedInstance.getModelInfo().getModelType().equals(ModelType.service)){
- aq.setVnfType(vnfType);
+ }else{
+ RequestInfo requestInfo =servInsReq.getRequestDetails().getRequestInfo();
+ if (requestInfo != null) {
+
+ if(requestInfo.getSource() != null){
+ aq.setSource(requestInfo.getSource());
+ }
+ if(requestInfo.getCallbackUrl() != null){
+ aq.setCallBackUrl(requestInfo.getCallbackUrl());
+ }
+ if(requestInfo.getCorrelator() != null){
+ aq.setCorrelator(requestInfo.getCorrelator());
+ }
+
+ if(requestInfo.getRequestorId() != null) {
+ aq.setRequestorId(requestInfo.getRequestorId());
+ }
+ }
+
+ if (servInsReq.getRequestDetails().getModelInfo() != null || (action == Action.inPlaceSoftwareUpdate || action == Action.applyUpdatedConfig)) {
+ aq.setRequestScope(requestScope);
+ }
+
+ if (servInsReq.getRequestDetails().getCloudConfiguration() != null) {
+ CloudConfiguration cloudConfiguration = servInsReq.getRequestDetails().getCloudConfiguration();
+ if(cloudConfiguration.getLcpCloudRegionId() != null) {
+ aq.setAicCloudRegion(cloudConfiguration.getLcpCloudRegionId());
+ }
+
+ if(cloudConfiguration.getTenantId() != null) {
+ aq.setTenantId(cloudConfiguration.getTenantId());
+ }
+
+ }
+
+ if(servInsReq.getServiceInstanceId() != null){
+ aq.setServiceInstanceId(servInsReq.getServiceInstanceId());
+ }
+
+ if(servInsReq.getVnfInstanceId() != null){
+ aq.setVnfId(servInsReq.getVnfInstanceId());
+ }
+
+ if(ModelType.service.name().equalsIgnoreCase(requestScope)){
+ if(servInsReq.getRequestDetails().getRequestInfo().getInstanceName() != null){
+ aq.setServiceInstanceName(requestInfo.getInstanceName());
+ }
+ }
+
+ if(ModelType.network.name().equalsIgnoreCase(requestScope)){
+ aq.setNetworkName(servInsReq.getRequestDetails().getRequestInfo().getInstanceName());
+ aq.setNetworkType(networkType);
+ aq.setNetworkId(servInsReq.getNetworkInstanceId());
+ }
+
+ if(ModelType.volumeGroup.name().equalsIgnoreCase(requestScope)){
+ aq.setVolumeGroupId(servInsReq.getVolumeGroupInstanceId());
+ aq.setVolumeGroupName(servInsReq.getRequestDetails().getRequestInfo().getInstanceName());
+ aq.setVnfType(vnfType);
+
+ }
+
+ if(ModelType.vfModule.name().equalsIgnoreCase(requestScope)){
+ aq.setVfModuleName(requestInfo.getInstanceName());
+ aq.setVfModuleModelName(servInsReq.getRequestDetails().getModelInfo().getModelName());
+ aq.setVfModuleId(servInsReq.getVfModuleInstanceId());
+ aq.setVolumeGroupId(servInsReq.getVolumeGroupInstanceId());
+ aq.setVnfType(vnfType);
+
+ }
+
+ if(ModelType.configuration.name().equalsIgnoreCase(requestScope)) {
+ aq.setConfigurationId(servInsReq.getConfigurationId());
+ aq.setConfigurationName(requestInfo.getInstanceName());
+ }
+ if(requestScope.equalsIgnoreCase(ModelType.instanceGroup.name())){
+ aq.setInstanceGroupId(servInsReq.getInstanceGroupId());
+ aq.setInstanceGroupName(requestInfo.getInstanceName());
+ }
+ if(ModelType.vnf.name().equalsIgnoreCase(requestScope)){
+ aq.setVnfName(requestInfo.getInstanceName());
+ if (null != servInsReq.getRequestDetails()) {
+ RelatedInstanceList[] instanceList = servInsReq.getRequestDetails().getRelatedInstanceList();
+
+ if (instanceList != null) {
+
+ for(RelatedInstanceList relatedInstanceList : instanceList){
+
+ RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance();
+ if(relatedInstance.getModelInfo().getModelType().equals(ModelType.service)){
+ aq.setVnfType(vnfType);
+ }
}
}
}
- }
+ }
}
aq.setRequestBody (originalRequestJSON);
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
index cb66209fc9..0cd5d8dcb7 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
@@ -32,6 +32,7 @@ import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang.StringUtils;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.onap.so.apihandler.camundabeans.CamundaResponse;
import org.onap.so.apihandler.common.CommonConstants;
import org.onap.so.apihandler.common.ErrorNumbers;
@@ -93,6 +94,7 @@ import javax.ws.rs.Produces;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import java.io.IOException;
import java.net.URL;
@@ -611,12 +613,75 @@ public class ServiceInstances {
instanceIdMap.put("networkInstanceId", networkInstanceId);
return serviceInstances(request, Action.deleteInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
}
+
+ @POST
+ @Path("/{version:[vV][7]}/instanceGroups")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Create instanceGroups",response=Response.class)
+ @Transactional
+ public Response createInstanceGroups(String request, @PathParam("version") String version, @Context ContainerRequestContext requestContext) throws ApiException {
+ String requestId = getRequestId(requestContext);
+ return serviceInstances(request, Action.createInstance, null, version, requestId, getRequestUri(requestContext));
+ }
+
+ @DELETE
+ @Path("/{version:[vV][7]}/instanceGroups/{instanceGroupId}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Delete instanceGroup",response=Response.class)
+ @Transactional
+ public Response deleteInstanceGroups(@PathParam("version") String version, @PathParam("instanceGroupId") String instanceGroupId, @Context ContainerRequestContext requestContext) throws ApiException {
+ String requestId = getRequestId(requestContext);
+ HashMap<String, String> instanceIdMap = new HashMap<>();
+ instanceIdMap.put(CommonConstants.INSTANCE_GROUP_ID, instanceGroupId);
+ return deleteInstanceGroups(Action.deleteInstance, instanceIdMap, version, requestId, getRequestUri(requestContext), requestContext);
+ }
+
+ @POST
+ @Path("/{version:[vV][7]}/instanceGroups/{instanceGroupId}/addMembers")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Add instanceGroup members",response=Response.class)
+ @Transactional
+ public Response addInstanceGroupMembers(String request, @PathParam("version") String version, @PathParam("instanceGroupId") String instanceGroupId, @Context ContainerRequestContext requestContext) throws ApiException {
+ String requestId = getRequestId(requestContext);
+ HashMap<String, String> instanceIdMap = new HashMap<>();
+ instanceIdMap.put(CommonConstants.INSTANCE_GROUP_ID, instanceGroupId);
+ return serviceInstances(request, Action.addMembers, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ }
+
+ @POST
+ @Path("/{version:[vV][7]}/instanceGroups/{instanceGroupId}/removeMembers")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Remove instanceGroup members",response=Response.class)
+ @Transactional
+ public Response removeInstanceGroupMembers(String request, @PathParam("version") String version, @PathParam("instanceGroupId") String instanceGroupId, @Context ContainerRequestContext requestContext) throws ApiException {
+ String requestId = getRequestId(requestContext);
+ HashMap<String, String> instanceIdMap = new HashMap<>();
+ instanceIdMap.put(CommonConstants.INSTANCE_GROUP_ID, instanceGroupId);
+ return serviceInstances(request, Action.removeMembers, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ }
public String getRequestUri(ContainerRequestContext context){
String requestUri = context.getUriInfo().getPath();
requestUri = requestUri.substring(requestUri.indexOf("/serviceInstantiation/") + 22);
return requestUri;
}
+
+ public void validateHeaders(ContainerRequestContext context) throws ValidationException{
+ MultivaluedMap<String, String> headers = context.getHeaders();
+ if(!headers.containsKey(ONAPLogConstants.Headers.REQUEST_ID)){
+ throw new ValidationException(ONAPLogConstants.Headers.REQUEST_ID + " header", true);
+ }
+ if(!headers.containsKey(ONAPLogConstants.Headers.PARTNER_NAME)){
+ throw new ValidationException(ONAPLogConstants.Headers.PARTNER_NAME + " header", true);
+ }
+ if(!headers.containsKey(MsoLogger.REQUESTOR_ID)){
+ throw new ValidationException(MsoLogger.REQUESTOR_ID + " header", true);
+ }
+ }
public Response serviceInstances(String requestJSON, Actions action, HashMap<String, String> instanceIdMap, String version, String requestId, String requestUri) throws ApiException {
String serviceInstanceId = (instanceIdMap ==null)? null:instanceIdMap.get("serviceInstanceId");
@@ -624,7 +689,7 @@ public class ServiceInstances {
long startTime = System.currentTimeMillis ();
ServiceInstancesRequest sir = null;
String apiVersion = version.substring(1);
-
+
sir = convertJsonToServiceInstanceRequest(requestJSON, action, startTime, sir, msoRequest, requestId, requestUri);
String requestScope = deriveRequestScope(action, sir, requestUri);
InfraActiveRequests currentActiveReq = msoRequest.createRequestObject (sir, action, requestId, Status.PENDING, requestJSON, requestScope);
@@ -672,6 +737,8 @@ public class ServiceInstances {
ModelInfo modelInfo = sir.getRequestDetails().getModelInfo();
if (action == Action.applyUpdatedConfig || action == Action.inPlaceSoftwareUpdate) {
modelType = ModelType.vnf;
+ }else if(action == Action.addMembers || action == Action.removeMembers){
+ modelType = ModelType.instanceGroup;
}else {
modelType =modelInfo.getModelType();
}
@@ -719,7 +786,7 @@ public class ServiceInstances {
String volumeGroupId = "";
String networkId = "";
String correlationId = "";
-
+ String instanceGroupId = null;
if(sir.getServiceInstanceId () != null){
serviceInstanceId = sir.getServiceInstanceId ();
}
@@ -739,6 +806,9 @@ public class ServiceInstances {
if(sir.getNetworkInstanceId () != null){
networkId = sir.getNetworkInstanceId ();
}
+ if(sir.getInstanceGroupId() != null){
+ instanceGroupId = sir.getInstanceGroupId();
+ }
correlationId = getCorrelationId(sir);
@@ -756,9 +826,93 @@ public class ServiceInstances {
aLaCarte = false;
}
- return postBPELRequest(currentActiveReq,action, requestId, startTime, requestJSON, recipeLookupResult.getOrchestrationURI(), recipeLookupResult.getRecipeTimeout(),
- isBaseVfModule, serviceInstanceId, correlationId, vnfId, vfModuleId, volumeGroupId, networkId, null,
- serviceInstanceType,vnfType, vfModuleType,networkType, apiVersion, aLaCarte, requestUri, null, requestScope, sir);
+ RequestClientParameter requestClientParameter = null;
+ try {
+ requestClientParameter = new RequestClientParameter.Builder()
+ .setRequestId(requestId)
+ .setBaseVfModule(isBaseVfModule)
+ .setRecipeTimeout(recipeLookupResult.getRecipeTimeout())
+ .setRequestAction(action.toString())
+ .setServiceInstanceId(serviceInstanceId)
+ .setCorrelationId(correlationId)
+ .setVnfId(vnfId)
+ .setVfModuleId(vfModuleId)
+ .setVolumeGroupId(volumeGroupId)
+ .setNetworkId(networkId)
+ .setServiceType(serviceInstanceType)
+ .setVnfType(vnfType)
+ .setVfModuleType(vfModuleType)
+ .setNetworkType(networkType)
+ .setRequestDetails(mapJSONtoMSOStyle(requestJSON, sir, aLaCarte, action))
+ .setApiVersion(apiVersion)
+ .setALaCarte(aLaCarte)
+ .setRequestUri(requestUri)
+ .setInstanceGroupId(instanceGroupId).build();
+ } catch (IOException e) {
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, MsoLogger.ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+ throw new ValidateException.Builder("Unable to generate RequestClientParamter object" + e.getMessage(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_BAD_PARAMETER)
+ .errorInfo(errorLoggerInfo).build();
+ }
+ return postBPELRequest(currentActiveReq, requestClientParameter, recipeLookupResult.getOrchestrationURI(), requestScope);
+ }
+ public Response deleteInstanceGroups(Actions action, HashMap<String, String> instanceIdMap, String version, String requestId, String requestUri, ContainerRequestContext requestContext) throws ApiException {
+ String instanceGroupId = instanceIdMap.get(CommonConstants.INSTANCE_GROUP_ID);
+ Boolean aLaCarte = true;
+ long startTime = System.currentTimeMillis ();
+ String apiVersion = version.substring(1);
+ ServiceInstancesRequest sir = new ServiceInstancesRequest();
+ sir.setInstanceGroupId(instanceGroupId);
+
+ String requestScope = ModelType.instanceGroup.toString();
+ InfraActiveRequests currentActiveReq = msoRequest.createRequestObject (sir, action, requestId, Status.PENDING, null, requestScope);
+ setInstanceId(currentActiveReq, requestScope, null, instanceIdMap);
+ try {
+ validateHeaders(requestContext);
+ } catch (ValidationException e) {
+ msoLogger.error(e);
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_VALIDATION_ERROR, MsoLogger.ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+ ValidateException validateException = new ValidateException.Builder(e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e)
+ .errorInfo(errorLoggerInfo).build();
+ updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
+ throw validateException;
+ }
+
+ InfraActiveRequests dup = duplicateCheck(action, instanceIdMap, startTime, msoRequest, null, requestScope, currentActiveReq);
+
+ if (dup != null) {
+ buildErrorOnDuplicateRecord(currentActiveReq, action, instanceIdMap, startTime, msoRequest, null, requestScope, dup);
+ }
+
+ ServiceInstancesResponse serviceResponse = new ServiceInstancesResponse();
+
+ RequestReferences referencesResponse = new RequestReferences();
+
+ referencesResponse.setRequestId(requestId);
+
+ serviceResponse.setRequestReferences(referencesResponse);
+ Boolean isBaseVfModule = false;
+
+ RecipeLookupResult recipeLookupResult = new RecipeLookupResult("/mso/async/services/WorkflowActionBB", 180);
+
+ try{
+ infraActiveRequestsClient.save(currentActiveReq);
+ }catch(Exception e){
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, MsoLogger.ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+ throw new RequestDbFailureException.Builder(SAVE_TO_DB, e.toString(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e)
+ .errorInfo(errorLoggerInfo).build();
+ }
+
+ RequestClientParameter requestClientParameter = new RequestClientParameter.Builder()
+ .setRequestId(requestId)
+ .setBaseVfModule(isBaseVfModule)
+ .setRecipeTimeout(recipeLookupResult.getRecipeTimeout())
+ .setRequestAction(action.toString())
+ .setApiVersion(apiVersion)
+ .setALaCarte(aLaCarte)
+ .setRequestUri(requestUri)
+ .setInstanceGroupId(instanceGroupId).build();
+
+ return postBPELRequest(currentActiveReq, requestClientParameter, recipeLookupResult.getOrchestrationURI(), requestScope);
}
private String getCorrelationId(ServiceInstancesRequest sir) {
@@ -772,6 +926,8 @@ public class ServiceInstances {
private String deriveRequestScope(Actions action, ServiceInstancesRequest sir, String requestUri) {
if(action == Action.inPlaceSoftwareUpdate || action == Action.applyUpdatedConfig){
return (ModelType.vnf.name());
+ }else if(action == Action.addMembers || action == Action.removeMembers){
+ return(ModelType.instanceGroup.toString());
}else{
String requestScope;
if(sir.getRequestDetails().getModelInfo().getModelType() == null){
@@ -799,38 +955,12 @@ public class ServiceInstances {
}
return requestScope;
}
- private Response postBPELRequest(InfraActiveRequests currentActiveReq, Actions action, String requestId, long startTime, String msoRawRequest,
- String orchestrationUri, int timeOut, Boolean isBaseVfModule,
- String serviceInstanceId, String correlationId, String vnfId, String vfModuleId, String volumeGroupId, String networkId,
- String configurationId, String serviceInstanceType, String vnfType, String vfModuleType, String networkType,
- String apiVersion, boolean aLaCarte, String requestUri, String paramXsd, String requestScope, ServiceInstancesRequest sir) throws ApiException {
+ private Response postBPELRequest(InfraActiveRequests currentActiveReq, RequestClientParameter requestClientParameter, String orchestrationUri, String requestScope)throws ApiException {
RequestClient requestClient = null;
HttpResponse response = null;
try {
requestClient = reqClientFactory.getRequestClient (orchestrationUri);
- response = requestClient.post(new RequestClientParameter.Builder()
- .setRequestId(requestId)
- .setBaseVfModule(isBaseVfModule)
- .setRecipeTimeout(timeOut)
- .setRequestAction(action.toString())
- .setServiceInstanceId(serviceInstanceId)
- .setCorrelationId(correlationId)
- .setVnfId(vnfId)
- .setVfModuleId(vfModuleId)
- .setVolumeGroupId(volumeGroupId)
- .setNetworkId(networkId)
- .setConfigurationId(configurationId)
- .setServiceType(serviceInstanceType)
- .setVnfType(vnfType)
- .setVfModuleType(vfModuleType)
- .setNetworkType(networkType)
- .setRequestDetails(mapJSONtoMSOStyle(msoRawRequest, sir, aLaCarte, action))
- .setApiVersion(apiVersion)
- .setALaCarte(aLaCarte)
- .setRecipeParamXsd(paramXsd)
- .setRequestUri(requestUri).build());
-
-
+ response = requestClient.post(requestClientParameter);
} catch (Exception e) {
ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MsoLogger.ErrorCode.AvailabilityError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
@@ -874,8 +1004,8 @@ public class ServiceInstances {
try {
ObjectMapper mapper = new ObjectMapper();
jsonResponse = mapper.readValue(camundaResp.getResponse(), ServiceInstancesResponse.class);
- jsonResponse.getRequestReferences().setRequestId(requestId);
- Optional<URL> selfLinkUrl = msoRequest.buildSelfLinkUrl(currentActiveReq.getRequestUrl(), requestId);
+ jsonResponse.getRequestReferences().setRequestId(requestClientParameter.getRequestId());
+ Optional<URL> selfLinkUrl = msoRequest.buildSelfLinkUrl(currentActiveReq.getRequestUrl(), requestClientParameter.getRequestId());
if(selfLinkUrl.isPresent()){
jsonResponse.getRequestReferences().setRequestSelfLink(selfLinkUrl.get());
} else {
@@ -900,7 +1030,8 @@ public class ServiceInstances {
throw new RequestDbFailureException.Builder(SAVE_TO_DB, e.toString(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e)
.errorInfo(errorLoggerInfo).build();
}
- return builder.buildResponse(HttpStatus.SC_ACCEPTED, requestId, jsonResponse, apiVersion);
+
+ return builder.buildResponse(HttpStatus.SC_ACCEPTED, requestClientParameter.getRequestId(), jsonResponse, requestClientParameter.getApiVersion());
}
}
@@ -943,6 +1074,8 @@ public class ServiceInstances {
currentActiveReq.setNetworkId(instanceId);
} else if(ModelType.configuration.name().equalsIgnoreCase(requestScope)) {
currentActiveReq.setConfigurationId(instanceId);
+ }else if(ModelType.instanceGroup.toString().equalsIgnoreCase(requestScope)){
+ currentActiveReq.setInstanceGroupId(instanceId);
}
} else if(instanceIdMap != null && !instanceIdMap.isEmpty()) {
if(instanceIdMap.get("serviceInstanceId") != null){
@@ -963,21 +1096,27 @@ public class ServiceInstances {
if(instanceIdMap.get("configurationInstanceId") != null){
currentActiveReq.setConfigurationId(instanceIdMap.get("configurationInstanceId"));
}
+ if(instanceIdMap.get("InstanceGroupInstanceId") != null){
+ currentActiveReq.setInstanceGroupId(instanceIdMap.get("InstanceGroupInstanceId"));
+ }
}
}
protected String mapJSONtoMSOStyle(String msoRawRequest, ServiceInstancesRequest serviceInstRequest, boolean isAlaCarte, Actions action) throws IOException {
ObjectMapper mapper = new ObjectMapper();
mapper.setSerializationInclusion(Include.NON_NULL);
- ServiceInstancesRequest sir = mapper.readValue(msoRawRequest, ServiceInstancesRequest.class);
- if( !isAlaCarte && Action.createInstance.equals(action) && serviceInstRequest != null &&
- serviceInstRequest.getRequestDetails() != null &&
- serviceInstRequest.getRequestDetails().getRequestParameters() != null) {
- sir.getRequestDetails().setCloudConfiguration(serviceInstRequest.getRequestDetails().getCloudConfiguration());
- sir.getRequestDetails().getRequestParameters().setUserParams(serviceInstRequest.getRequestDetails().getRequestParameters().getUserParams());
+ if(msoRawRequest != null){
+ ServiceInstancesRequest sir = mapper.readValue(msoRawRequest, ServiceInstancesRequest.class);
+ if( !isAlaCarte && Action.createInstance.equals(action) && serviceInstRequest != null &&
+ serviceInstRequest.getRequestDetails() != null &&
+ serviceInstRequest.getRequestDetails().getRequestParameters() != null) {
+ sir.getRequestDetails().setCloudConfiguration(serviceInstRequest.getRequestDetails().getCloudConfiguration());
+ sir.getRequestDetails().getRequestParameters().setUserParams(serviceInstRequest.getRequestDetails().getRequestParameters().getUserParams());
+ }
+ msoLogger.debug("Value as string: " + mapper.writeValueAsString(sir));
+ return mapper.writeValueAsString(sir);
}
- msoLogger.debug("Value as string: " + mapper.writeValueAsString(sir));
- return mapper.writeValueAsString(sir);
+ return null;
}
private void buildErrorOnDuplicateRecord(InfraActiveRequests currentActiveReq, Actions action, HashMap<String, String> instanceIdMap, long startTime, MsoRequest msoRequest,
@@ -1065,7 +1204,9 @@ public class ServiceInstances {
if (action == Action.applyUpdatedConfig || action == Action.inPlaceSoftwareUpdate) {
recipeLookupResult = getDefaultVnfUri(sir, action);
- } else if (modelInfo.getModelType().equals(ModelType.service)) {
+ }else if(action == Action.addMembers || action == Action.removeMembers){
+ recipeLookupResult = new RecipeLookupResult("/mso/async/services/WorkflowActionBB", 180);
+ }else if (modelInfo.getModelType().equals(ModelType.service)) {
try {
recipeLookupResult = getServiceURI(sir, action,alaCarteFlag);
} catch (IOException e) {
@@ -1107,7 +1248,9 @@ public class ServiceInstances {
updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
throw validateException;
- }
+ }
+ }else if(modelInfo.getModelType().equals(ModelType.instanceGroup)){
+ recipeLookupResult = new RecipeLookupResult("/mso/async/services/WorkflowActionBB", 180);
}
if (recipeLookupResult == null) {
@@ -1672,9 +1815,27 @@ public class ServiceInstances {
}else if(aLaCarte == null){
aLaCarte = false;
}
-
- return postBPELRequest(currentActiveReq,action, requestId, startTime, requestJSON, orchestrationUri, Integer.parseInt(timeOut), false,
- serviceInstanceId, correlationId, null, null, null, null, configurationId, null, null, null, null, apiVersion, aLaCarte, requestUri, null, requestScope, null);
+ RequestClientParameter requestClientParameter = null;
+ try {
+ requestClientParameter = new RequestClientParameter.Builder()
+ .setRequestId(requestId)
+ .setBaseVfModule(false)
+ .setRecipeTimeout(Integer.parseInt(timeOut))
+ .setRequestAction(action.toString())
+ .setServiceInstanceId(serviceInstanceId)
+ .setCorrelationId(correlationId)
+ .setConfigurationId(configurationId)
+ .setRequestDetails(mapJSONtoMSOStyle(requestJSON, sir, aLaCarte, action))
+ .setApiVersion(apiVersion)
+ .setALaCarte(aLaCarte)
+ .setRequestUri(requestUri).build();
+ } catch (IOException e) {
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, MsoLogger.ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+ throw new ValidateException.Builder("Unable to generate RequestClientParamter object" + e.getMessage(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_BAD_PARAMETER)
+ .errorInfo(errorLoggerInfo).build();
+ }
+
+ return postBPELRequest(currentActiveReq, requestClientParameter, orchestrationUri, requestScope);
}
public String getRequestId(ContainerRequestContext requestContext) throws ValidateException {
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CloudConfigurationValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CloudConfigurationValidation.java
index b0ea85779c..937ce19741 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CloudConfigurationValidation.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CloudConfigurationValidation.java
@@ -39,25 +39,26 @@ public class CloudConfigurationValidation implements ValidationRule{
Actions action = info.getAction();
Boolean aLaCarteFlag = info.getALaCarteFlag();
-
- if(cloudConfiguration == null && reqVersion >= 5 && (aLaCarteFlag != null && aLaCarteFlag)){
- if((!requestScope.equalsIgnoreCase(ModelType.service.name()) && !requestScope.equalsIgnoreCase(ModelType.configuration.name())) &&
- (action == Action.createInstance || action == Action.deleteInstance || action == Action.updateInstance)){
- throw new ValidationException ("cloudConfiguration");
- }
- if((requestScope.equalsIgnoreCase(ModelType.vnf.name()) || requestScope.equalsIgnoreCase(ModelType.vfModule.name())) &&
- action == Action.replaceInstance){
- throw new ValidationException ("cloudConfiguration");
- }
- if(requestScope.equalsIgnoreCase(ModelType.configuration.name()) &&
- (action == Action.enablePort || action == Action.disablePort || action == Action.activateInstance || action == Action.deactivateInstance)){
- throw new ValidationException ("cloudConfiguration");
- }
- if(requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && (action == Action.deactivateAndCloudDelete || action == Action.scaleOut)){
- throw new ValidationException("cloudConfiguration");
- }
- if(requestScope.equals(ModelType.vnf.name()) && action == Action.recreateInstance){
- throw new ValidationException("cloudConfiguration", true);
+ if(!requestScope.equals(ModelType.instanceGroup.toString())){
+ if(cloudConfiguration == null && reqVersion >= 5 && (aLaCarteFlag != null && aLaCarteFlag)){
+ if((!requestScope.equalsIgnoreCase(ModelType.service.name()) && !requestScope.equalsIgnoreCase(ModelType.configuration.name())) &&
+ (action == Action.createInstance || action == Action.deleteInstance || action == Action.updateInstance)){
+ throw new ValidationException ("cloudConfiguration");
+ }
+ if((requestScope.equalsIgnoreCase(ModelType.vnf.name()) || requestScope.equalsIgnoreCase(ModelType.vfModule.name())) &&
+ action == Action.replaceInstance){
+ throw new ValidationException ("cloudConfiguration");
+ }
+ if(requestScope.equalsIgnoreCase(ModelType.configuration.name()) &&
+ (action == Action.enablePort || action == Action.disablePort || action == Action.activateInstance || action == Action.deactivateInstance)){
+ throw new ValidationException ("cloudConfiguration");
+ }
+ if(requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && (action == Action.deactivateAndCloudDelete || action == Action.scaleOut)){
+ throw new ValidationException("cloudConfiguration");
+ }
+ if(requestScope.equals(ModelType.vnf.name()) && action == Action.recreateInstance){
+ throw new ValidationException("cloudConfiguration", true);
+ }
}
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/InstanceIdMapValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/InstanceIdMapValidation.java
index a42a13c676..f1985e9fcf 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/InstanceIdMapValidation.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/InstanceIdMapValidation.java
@@ -23,6 +23,7 @@ package org.onap.so.apihandlerinfra.validation;
import java.util.HashMap;
+import org.onap.so.apihandler.common.CommonConstants;
import org.onap.so.exceptions.ValidationException;
import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
import org.onap.so.utils.UUIDChecker;
@@ -75,6 +76,13 @@ public class InstanceIdMapValidation implements ValidationRule{
}
sir.setConfigurationId(instanceIdMap.get("configurationInstanceId"));
}
+
+ if(instanceIdMap.get(CommonConstants.INSTANCE_GROUP_ID) != null){
+ if (!UUIDChecker.isValidUUID (instanceIdMap.get (CommonConstants.INSTANCE_GROUP_ID))) {
+ throw new ValidationException (CommonConstants.INSTANCE_GROUP_ID, true);
+ }
+ sir.setInstanceGroupId(instanceIdMap.get(CommonConstants.INSTANCE_GROUP_ID));
+ }
}
return info;
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/MembersValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/MembersValidation.java
new file mode 100644
index 0000000000..89bb15dcb1
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/MembersValidation.java
@@ -0,0 +1,69 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 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.apihandlerinfra.validation;
+
+import org.onap.so.exceptions.ValidationException;
+import org.onap.so.serviceinstancebeans.ModelType;
+import org.onap.so.serviceinstancebeans.RelatedInstance;
+import org.onap.so.serviceinstancebeans.RelatedInstanceList;
+import org.onap.so.serviceinstancebeans.RequestInfo;
+
+public class MembersValidation implements ValidationRule{
+ private static boolean empty(String s) {
+ return (s == null || s.trim().isEmpty());
+ }
+ @Override
+ public ValidationInformation validate(ValidationInformation info) throws ValidationException{
+ RequestInfo requestInfo = info.getSir().getRequestDetails().getRequestInfo();
+ RelatedInstanceList[] relatedInstanceList = info.getSir().getRequestDetails().getRelatedInstanceList();
+ boolean vnfRelatedInstance = false;
+
+ if(requestInfo == null){
+ throw new ValidationException("requestInfo", true);
+ }else if(empty(requestInfo.getRequestorId())) {
+ throw new ValidationException ("requestorId", true);
+ }else if (empty (requestInfo.getSource ())) {
+ throw new ValidationException ("source", true);
+ }
+ if(relatedInstanceList == null){
+ throw new ValidationException("related instances", true);
+ }else{
+ for(RelatedInstanceList instanceList : relatedInstanceList){
+ RelatedInstance relatedInstance = instanceList.getRelatedInstance();
+ ModelType modelType = relatedInstance.getModelInfo().getModelType();
+ if(empty(relatedInstance.getInstanceId())){
+ throw new ValidationException("instanceId in relatedInstances", true);
+ }
+ if (modelType == null) {
+ throw new ValidationException("modelType in relatedInstance", true);
+ }
+ if(modelType == ModelType.vnf){
+ vnfRelatedInstance = true;
+ }
+ }
+ if(!vnfRelatedInstance){
+ throw new ValidationException("vnf relatedInstance", true);
+ }
+ }
+ return info;
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ModelInfoValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ModelInfoValidation.java
index c6fae6e872..e2a1bdc46a 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ModelInfoValidation.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ModelInfoValidation.java
@@ -30,9 +30,9 @@ import org.onap.so.serviceinstancebeans.ModelType;
import org.onap.so.serviceinstancebeans.RequestParameters;
import org.onap.so.utils.UUIDChecker;
public class ModelInfoValidation implements ValidationRule{
- private static boolean empty(String s) {
- return (s == null || s.trim().isEmpty());
- }
+ private static boolean empty(String s) {
+ return (s == null || s.trim().isEmpty());
+ }
@Override
public ValidationInformation validate(ValidationInformation info) throws ValidationException{
ModelInfo modelInfo = info.getSir().getRequestDetails().getModelInfo();
@@ -42,89 +42,96 @@ public class ModelInfoValidation implements ValidationRule{
int reqVersion = info.getReqVersion();
Boolean aLaCarteFlag = info.getALaCarteFlag();
- if(!empty(modelInfo.getModelNameVersionId())){
- modelInfo.setModelVersionId(modelInfo.getModelNameVersionId());
- }
- // modelCustomizationId is required when usePreLoad is false for v4 and higher for VF Module Create
- if(requestParameters != null && reqVersion >= 4 && requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.createInstance && !requestParameters.isUsePreload()) {
- if(!UUIDChecker.isValidUUID(modelInfo.getModelCustomizationId())) {
- throw new ValidationException("modelCustomizationId");
- }
- }
-
- // modelCustomizationId is required for v5 and higher for VF Module Replace
- if(requestParameters != null && reqVersion > 4 && requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.replaceInstance) {
- if(!UUIDChecker.isValidUUID(modelInfo.getModelCustomizationId())) {
- throw new ValidationException("modelCustomizationId");
- }
- }
-
- // modelCustomizationId or modelCustomizationName are required for VNF Replace
- if(requestParameters != null && reqVersion > 4 && requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action == Action.replaceInstance || action == Action.recreateInstance) {
- if(!UUIDChecker.isValidUUID(modelInfo.getModelCustomizationId()) && modelInfo.getModelCustomizationName() == null) {
- throw new ValidationException("modelCustomizationId or modelCustomizationName");
- }
- }
+ if(!requestScope.equals(ModelType.instanceGroup.toString())){
+
+ if(!empty(modelInfo.getModelNameVersionId())){
+ modelInfo.setModelVersionId(modelInfo.getModelNameVersionId());
+ }
+ // modelCustomizationId is required when usePreLoad is false for v4 and higher for VF Module Create
+ if(requestParameters != null && reqVersion >= 4 && requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.createInstance && !requestParameters.isUsePreload()) {
+ if(!UUIDChecker.isValidUUID(modelInfo.getModelCustomizationId())) {
+ throw new ValidationException("modelCustomizationId");
+ }
+ }
+
+ // modelCustomizationId is required for v5 and higher for VF Module Replace
+ if(requestParameters != null && reqVersion > 4 && requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.replaceInstance) {
+ if(!UUIDChecker.isValidUUID(modelInfo.getModelCustomizationId())) {
+ throw new ValidationException("modelCustomizationId");
+ }
+ }
+
+ // modelCustomizationId or modelCustomizationName are required for VNF Replace
+ if(requestParameters != null && reqVersion > 4 && requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action == Action.replaceInstance || action == Action.recreateInstance) {
+ if(!UUIDChecker.isValidUUID(modelInfo.getModelCustomizationId()) && modelInfo.getModelCustomizationName() == null) {
+ throw new ValidationException("modelCustomizationId or modelCustomizationName");
+ }
+ }
+
+ //is required for serviceInstance delete macro when aLaCarte=false (v3)
+ //create and updates except for network (except v4)
+ if (empty (modelInfo.getModelInvariantId ()) && ((reqVersion >2 && (aLaCarteFlag != null && !aLaCarteFlag) && requestScope.equalsIgnoreCase(ModelType.service.name()) && action == Action.deleteInstance) ||
+ !(reqVersion < 4 && requestScope.equalsIgnoreCase (ModelType.network.name ())) &&
+ (action == Action.createInstance || action == Action.updateInstance || action == Action.enablePort || action == Action.disablePort || action == Action.addRelationships || action == Action.removeRelationships ||
+ (requestScope.equalsIgnoreCase(ModelType.configuration.name()) && (action == Action.activateInstance || action == Action.deactivateInstance))))) {
+ throw new ValidationException ("modelInvariantId");
+ }
+ if(empty(modelInfo.getModelInvariantId()) && (requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.scaleOut)){
+ throw new ValidationException("modelInvariantId");
+ }
+ if(empty(modelInfo.getModelInvariantId()) && (requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action == Action.recreateInstance)){
+ throw new ValidationException("modelInvariantId", true);
+ }
+ if (!empty (modelInfo.getModelInvariantId ()) && !UUIDChecker.isValidUUID (modelInfo.getModelInvariantId ())) {
+ throw new ValidationException ("modelInvariantId format");
+ }
+
+ if(reqVersion >= 4 && !(requestScope.equalsIgnoreCase(ModelType.configuration.name())) && empty (modelInfo.getModelName ()) && (action == Action.createInstance || action == Action.updateInstance ||
+ action == Action.addRelationships || action == Action.removeRelationships || action == Action.recreateInstance || ((action == Action.deleteInstance || action == Action.scaleOut) && (requestScope.equalsIgnoreCase (ModelType.vfModule.name ()))))){
+ throw new ValidationException ("modelName", true);
+ }
- //is required for serviceInstance delete macro when aLaCarte=false (v3)
- //create and updates except for network (except v4)
- if (empty (modelInfo.getModelInvariantId ()) && ((reqVersion >2 && (aLaCarteFlag != null && !aLaCarteFlag) && requestScope.equalsIgnoreCase(ModelType.service.name()) && action == Action.deleteInstance) ||
- !(reqVersion < 4 && requestScope.equalsIgnoreCase (ModelType.network.name ())) &&
- (action == Action.createInstance || action == Action.updateInstance || action == Action.enablePort || action == Action.disablePort || action == Action.addRelationships || action == Action.removeRelationships ||
- (requestScope.equalsIgnoreCase(ModelType.configuration.name()) && (action == Action.activateInstance || action == Action.deactivateInstance))))) {
- throw new ValidationException ("modelInvariantId");
- }
- if(empty(modelInfo.getModelInvariantId()) && (requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.scaleOut)){
- throw new ValidationException("modelInvariantId");
- }
- if(empty(modelInfo.getModelInvariantId()) && (requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action == Action.recreateInstance)){
- throw new ValidationException("modelInvariantId", true);
- }
- if (!empty (modelInfo.getModelInvariantId ()) && !UUIDChecker.isValidUUID (modelInfo.getModelInvariantId ())) {
- throw new ValidationException ("modelInvariantId format");
- }
+ if (empty (modelInfo.getModelVersion ()) && !(requestScope.equalsIgnoreCase(ModelType.configuration.name())) &&
+ (!(reqVersion < 4 && requestScope.equalsIgnoreCase (ModelType.network.name ()))
+ && (action == Action.createInstance || action == Action.updateInstance || action == Action.addRelationships || action == Action.removeRelationships || action == Action.scaleOut))) {
+ throw new ValidationException ("modelVersion");
+ }
- if(reqVersion >= 4 && !(requestScope.equalsIgnoreCase(ModelType.configuration.name())) && empty (modelInfo.getModelName ()) && (action == Action.createInstance || action == Action.updateInstance ||
- action == Action.addRelationships || action == Action.removeRelationships || action == Action.recreateInstance || ((action == Action.deleteInstance || action == Action.scaleOut) && (requestScope.equalsIgnoreCase (ModelType.vfModule.name ()))))){
- throw new ValidationException ("modelName", true);
- }
+ if(empty(modelInfo.getModelVersion()) && (requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action == Action.recreateInstance)){
+ throw new ValidationException("modelVersion", true);
+ }
- if (empty (modelInfo.getModelVersion ()) && !(requestScope.equalsIgnoreCase(ModelType.configuration.name())) &&
- (!(reqVersion < 4 && requestScope.equalsIgnoreCase (ModelType.network.name ()))
- && (action == Action.createInstance || action == Action.updateInstance || action == Action.addRelationships || action == Action.removeRelationships || action == Action.scaleOut))) {
- throw new ValidationException ("modelVersion");
- }
-
- if(empty(modelInfo.getModelVersion()) && (requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action == Action.recreateInstance)){
- throw new ValidationException("modelVersion", true);
- }
+ // is required for serviceInstance delete macro when aLaCarte=false in v4
+ if (reqVersion >= 4 && empty (modelInfo.getModelVersionId()) && (((aLaCarteFlag != null && !aLaCarteFlag) && requestScope.equalsIgnoreCase(ModelType.service.name()) && action == Action.deleteInstance) ||
+ (action == Action.createInstance || action == Action.updateInstance || action == Action.enablePort || action == Action.disablePort || action == Action.addRelationships || action == Action.removeRelationships ||
+ (requestScope.equalsIgnoreCase(ModelType.configuration.name()) && (action == Action.activateInstance || action == Action.deactivateInstance))))) {
+ throw new ValidationException ("modelVersionId");
+ }
+ if(empty(modelInfo.getModelVersionId()) && (requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action == Action.recreateInstance)){
+ throw new ValidationException("modelVersionId", true);
+ }
+ if(empty(modelInfo.getModelVersionId()) && (requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.scaleOut)){
+ throw new ValidationException("modelVersionId");
+ }
- // is required for serviceInstance delete macro when aLaCarte=false in v4
- if (reqVersion >= 4 && empty (modelInfo.getModelVersionId()) && (((aLaCarteFlag != null && !aLaCarteFlag) && requestScope.equalsIgnoreCase(ModelType.service.name()) && action == Action.deleteInstance) ||
- (action == Action.createInstance || action == Action.updateInstance || action == Action.enablePort || action == Action.disablePort || action == Action.addRelationships || action == Action.removeRelationships ||
- (requestScope.equalsIgnoreCase(ModelType.configuration.name()) && (action == Action.activateInstance || action == Action.deactivateInstance))))) {
- throw new ValidationException ("modelVersionId");
- }
- if(empty(modelInfo.getModelVersionId()) && (requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action == Action.recreateInstance)){
- throw new ValidationException("modelVersionId", true);
- }
- if(empty(modelInfo.getModelVersionId()) && (requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.scaleOut)){
- throw new ValidationException("modelVersionId");
- }
-
- if(requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action != Action.deleteInstance && empty (modelInfo.getModelCustomizationName ())) {
- if (!UUIDChecker.isValidUUID (modelInfo.getModelCustomizationId())) {
- throw new ValidationException ("modelCustomizationId or modelCustomizationName");
- }
- }
+ if(requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action != Action.deleteInstance && empty (modelInfo.getModelCustomizationName ())) {
+ if (!UUIDChecker.isValidUUID (modelInfo.getModelCustomizationId())) {
+ throw new ValidationException ("modelCustomizationId or modelCustomizationName");
+ }
+ }
- if(reqVersion >= 4 && (!UUIDChecker.isValidUUID (modelInfo.getModelCustomizationId())) && (requestScope.equalsIgnoreCase (ModelType.network.name ()) || requestScope.equalsIgnoreCase(ModelType.configuration.name()))
- && (action == Action.updateInstance || action == Action.createInstance)){
- throw new ValidationException ("modelCustomizationId");
- }
- if(empty(modelInfo.getModelCustomizationId()) && action == Action.scaleOut && !(requestParameters.getTestApi() == TestApi.VNF_API.name() && requestParameters.isUsePreload() == true)){
- throw new ValidationException ("modelCustomizationId");
- }
- return info;
+ if(reqVersion >= 4 && (!UUIDChecker.isValidUUID (modelInfo.getModelCustomizationId())) && (requestScope.equalsIgnoreCase (ModelType.network.name ()) || requestScope.equalsIgnoreCase(ModelType.configuration.name()))
+ && (action == Action.updateInstance || action == Action.createInstance)){
+ throw new ValidationException ("modelCustomizationId");
+ }
+ if(empty(modelInfo.getModelCustomizationId()) && requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.scaleOut && !(requestParameters.getTestApi() == TestApi.VNF_API.name() && requestParameters.isUsePreload() == true)){
+ throw new ValidationException ("modelCustomizationId");
+ }
+ }else{
+ if(empty(modelInfo.getModelVersionId()) && action == Action.createInstance){
+ throw new ValidationException("modelVersionId", true);
+ }
+ }
+ return info;
}
-} \ No newline at end of file
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidation.java
index f22294b33f..c4671aed3c 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidation.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidation.java
@@ -100,9 +100,14 @@ public class RelatedInstancesValidation implements ValidationRule{
if (!empty(relatedInstance.getInstanceId ()) && !UUIDChecker.isValidUUID (relatedInstance.getInstanceId ())) {
throw new ValidationException ("instanceId format in relatedInstance");
}
-
-
- if (action != Action.deleteInstance) {
+ if(empty(relatedInstanceModelInfo.getModelVersionId()) && requestScope.equals(ModelType.instanceGroup.toString()) && relatedInstanceModelInfo.getModelType().equals(ModelType.service)){
+ throw new ValidationException("modelVersionId in relatedInstance", true);
+ }
+ if(requestScope.equalsIgnoreCase(ModelType.instanceGroup.toString()) && relatedInstanceModelInfo.getModelType().equals(ModelType.service)){
+ isRelatedServiceInstancePresent = true;
+ }
+
+ if (action != Action.deleteInstance && !requestScope.equalsIgnoreCase(ModelType.instanceGroup.toString())) {
if(!( relatedInstanceModelInfo.getModelType().equals(ModelType.volumeGroup) ||
relatedInstanceModelInfo.getModelType().equals(ModelType.connectionPoint) ||
relatedInstanceModelInfo.getModelType().equals(ModelType.pnf) ||
@@ -144,7 +149,7 @@ public class RelatedInstancesValidation implements ValidationRule{
}
}
- if(relatedInstanceModelInfo.getModelType().equals(ModelType.service)) {
+ if(relatedInstanceModelInfo.getModelType().equals(ModelType.service) && !(requestScope.equalsIgnoreCase(ModelType.instanceGroup.toString()) && action == Action.createInstance)) {
isRelatedServiceInstancePresent = true;
if (!relatedInstance.getInstanceId ().equals (sir.getServiceInstanceId ())) {
throw new ValidationException ("serviceInstanceId matching the serviceInstanceId in request URI");
@@ -177,7 +182,11 @@ public class RelatedInstancesValidation implements ValidationRule{
throw new ValidationException ("connectionPoint relatedInstance for Port Configuration");
}
}
-
+ if(requestScope.equals(ModelType.instanceGroup.toString())){
+ if(!isRelatedServiceInstancePresent){
+ throw new ValidationException("related service instance for instanceGroup request", true);
+ }
+ }
if(requestScope.equalsIgnoreCase (ModelType.volumeGroup.name ())) {
if (!isRelatedServiceInstancePresent) {
throw new ValidationException ("related service instance for volumeGroup request");
@@ -223,6 +232,9 @@ public class RelatedInstancesValidation implements ValidationRule{
msoLogger.debug ("related instance exception");
throw new ValidationException ("related instances");
}
+ if(instanceList == null && requestScope.equalsIgnoreCase(ModelType.instanceGroup.toString()) && action == Action.createInstance){
+ throw new ValidationException("relatedInstanceList", true);
+ }
info.setVfModuleModelName(vfModuleModelName);
info.setServiceInstanceType(serviceInstanceType);
info.setVnfType(vnfType);
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java
index a9d848f765..aa51704724 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java
@@ -179,6 +179,7 @@ public class MsoRequestTest extends BaseTest {
this.version = "v" + reqVersion;
this.instanceIdMapTest.put("serviceInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
this.instanceIdMapTest.put("vnfInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
+ this.instanceIdMapTest.put("instanceGroupId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
thrown.expect(ValidationException.class);
thrown.expectMessage(expectedException);
this.msoRequest = new MsoRequest();
@@ -243,6 +244,7 @@ public class MsoRequestTest extends BaseTest {
{"No valid modelVersionId is specified", mapper.readValue(inputStream("/ModelInfo/v5ActivateModelVersionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, 5},
{"No valid modelVersionId is specified", mapper.readValue(inputStream("/ModelInfo/ScaleOutNoModelVersionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.scaleOut, 7},
{"No valid modelVersionId is specified", mapper.readValue(inputStream("/ModelInfo/VnfRecreateModelVersionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.recreateInstance, 7},
+ {"No valid modelVersionId is specified", mapper.readValue(inputStream("/ModelInfo/CreateInstanceGroupNoModelVersionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 7},
//ValidationException for Platform and LineOfBusiness
{"No valid lineOfBusinessName is specified", mapper.readValue(inputStream("/PlatformAndLineOfBusiness/EmptyLineOfBusiness.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5},
{"No valid platform is specified", mapper.readValue(inputStream("/PlatformAndLineOfBusiness/Platform.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 6},
@@ -286,6 +288,9 @@ public class MsoRequestTest extends BaseTest {
{"No valid source vnf relatedInstance for Port Configuration is specified", mapper.readValue(inputStream("/RelatedInstances/v5CreateNoSourceRelatedInstance.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5},
{"No valid vnfInstanceId matching the vnfInstanceId in request URI is specified", mapper.readValue(inputStream("/RelatedInstances/RelatedInstancesVnfInstanceId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, 5},
{"No valid instanceName format is specified", mapper.readValue(inputStream("/RelatedInstances/InvalidInstanceName.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 2},
+ {"No valid relatedInstanceList is specified", mapper.readValue(inputStream("/RelatedInstances/CreateInstanceGroupNoRelatedInstances.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 7},
+ {"No valid related service instance for instanceGroup request is specified", mapper.readValue(inputStream("/RelatedInstances/CreateInstanceGroupService.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 7},
+ {"No valid modelVersionId in relatedInstance is specified", mapper.readValue(inputStream("/RelatedInstances/CreateInstanceGroupRelatedInstanceModelVersionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 7},
//ValidationException for RequestInfo
{"No valid requestInfo is specified", mapper.readValue(inputStream("/RequestInfo/RequestInfoNull.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5},
{"No valid requestInfo is specified", mapper.readValue(inputStream("/RequestInfo/RequestInfo.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.applyUpdatedConfig, 6},
@@ -328,7 +333,15 @@ public class MsoRequestTest extends BaseTest {
{"No valid modelCustomizationId in userParams vnf resources is specified", mapper.readValue(inputStream("/RequestParameters/VnfModelCustomizationId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.assignInstance, 7},
{"No valid modelCustomizationId in userParams network resources is specified", mapper.readValue(inputStream("/RequestParameters/NetworkModelCustomizationId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.assignInstance, 7},
//Validation for ConfigurationParameters
- {"No valid configuration parameters is specified", mapper.readValue(inputStream("/ConfigurationParameters/NoConfigurationParameters.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.scaleOut, 7}
+ {"No valid configuration parameters is specified", mapper.readValue(inputStream("/ConfigurationParameters/NoConfigurationParameters.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.scaleOut, 7},
+ //Validation for Add and Remove Members
+ {"No valid vnf relatedInstance is specified", mapper.readValue(inputStream("/MembersValidation/RelatedInstancesVnf.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.addMembers, 7},
+ {"No valid related instances is specified", mapper.readValue(inputStream("/MembersValidation/RelatedInstances.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.addMembers, 7},
+ {"No valid requestInfo is specified", mapper.readValue(inputStream("/MembersValidation/MembersRequestInfo.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.addMembers, 7},
+ {"No valid requestorId is specified", mapper.readValue(inputStream("/MembersValidation/MembersRequestorId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.addMembers, 7},
+ {"No valid source is specified", mapper.readValue(inputStream("/MembersValidation/AddMembersSource.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.addMembers, 7},
+ {"No valid instanceId in relatedInstances is specified", mapper.readValue(inputStream("/MembersValidation/AddMembersInstanceId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.addMembers, 7},
+ {"No valid modelType in relatedInstance is specified", mapper.readValue(inputStream("/MembersValidation/DeleteMembersModelType.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.removeMembers, 7}
});
}
@Test
@@ -415,6 +428,18 @@ public class MsoRequestTest extends BaseTest {
this.msoRequest.parse(sir, instanceIdMapTest, action, version, originalRequestJSON, reqVersion, false);
}
@Test
+ public void instanceGroupIdHashMapFailureTest() throws JsonParseException, JsonMappingException, IOException, ValidationException{
+ this.sir = mapper.readValue(inputStream("/SuccessfulValidation/InstanceIdHashMap.json"), ServiceInstancesRequest.class);
+ this.instanceIdMapTest.put("instanceGroupId", "test");
+ this.action = Action.createInstance;
+ thrown.expect(ValidationException.class);
+ this.reqVersion = 7;
+ this.version = "v" + reqVersion;
+ thrown.expectMessage("No valid instanceGroupId is specified");
+ this.msoRequest = new MsoRequest();
+ this.msoRequest.parse(sir, instanceIdMapTest, action, version, originalRequestJSON, reqVersion, false);
+ }
+ @Test
public void testVfModuleV4UsePreLoad() throws JsonParseException, JsonMappingException, IOException, ValidationException {
this.requestJSON = inputStream("/SuccessfulValidation/v4CreateVfModule.json");
this.instanceIdMapTest.put("serviceInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc");
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java
index 9371c7ee04..8d3649a65d 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java
@@ -52,7 +52,6 @@ import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.onap.so.db.catalog.beans.Service;
import org.onap.so.db.catalog.beans.ServiceRecipe;
import org.onap.so.db.request.beans.InfraActiveRequests;
-import org.onap.so.logger.LogConstants;
import org.onap.so.logger.MsoLogger;
import org.onap.so.serviceinstancebeans.CloudConfiguration;
import org.onap.so.serviceinstancebeans.ModelInfo;
@@ -61,7 +60,6 @@ import org.onap.so.serviceinstancebeans.RequestParameters;
import org.onap.so.serviceinstancebeans.RequestReferences;
import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
-import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity;
@@ -2435,4 +2433,153 @@ public class ServiceInstancesTest extends BaseTest{
ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
}
+ @Test
+ public void createInstanceGroup() throws IOException{
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ HttpHeaders headers = new HttpHeaders();
+ //expect
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "/v7/instanceGroups";
+ ResponseEntity<String> response = sendRequest(inputStream("/CreateInstanceGroup.json"), uri, HttpMethod.POST, headers);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ //then
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void deleteInstanceGroup() throws IOException{
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ HttpHeaders headers = new HttpHeaders();
+ headers.set(ONAPLogConstants.Headers.REQUEST_ID, "eca3a1b1-43ab-457e-ab1c-367263d148b4");
+ headers.set(ONAPLogConstants.Headers.PARTNER_NAME, "test_name");
+ headers.set(MsoLogger.REQUESTOR_ID, "xxxxxx");
+ //expect
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
+ ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, headers);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ //then
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void deleteInstanceGroupNoRequestIdHeader() throws IOException{
+ HttpHeaders headers = new HttpHeaders();
+ headers.set(ONAPLogConstants.Headers.PARTNER_NAME, "test_name");
+ headers.set(MsoLogger.REQUESTOR_ID, "xxxxxx");
+ uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
+ ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, headers);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
+
+ //then
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
+ RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
+ assertEquals(realResponse.getServiceException().getText(), "No valid X-ONAP-RequestID header is specified");
+ }
+ @Test
+ public void deleteInstanceGroupNoPartnerNameHeader() throws IOException{
+ HttpHeaders headers = new HttpHeaders();
+ headers.set(ONAPLogConstants.Headers.REQUEST_ID, "eca3a1b1-43ab-457e-ab1c-367263d148b4");
+ headers.set(MsoLogger.REQUESTOR_ID, "xxxxxx");
+ uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
+ ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, headers);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
+
+ //then
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
+ RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
+ assertEquals(realResponse.getServiceException().getText(), "No valid X-ONAP-PartnerName header is specified");
+ }
+ @Test
+ public void deleteInstanceGroupNoRquestorIdHeader() throws IOException{
+ HttpHeaders headers = new HttpHeaders();
+ headers.set(ONAPLogConstants.Headers.REQUEST_ID, "eca3a1b1-43ab-457e-ab1c-367263d148b4");
+ headers.set(ONAPLogConstants.Headers.PARTNER_NAME, "eca3a1b1-43ab-457e-ab1c-367263d148b4");
+ //expect
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
+ ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, headers);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
+
+ //then
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
+ RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
+ assertEquals(realResponse.getServiceException().getText(), "No valid X-RequestorID header is specified");
+ }
+ @Test
+ public void addMembers() throws IOException{
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+ HttpHeaders headers = new HttpHeaders();
+ //expect
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c/addMembers";
+ ResponseEntity<String> response = sendRequest(inputStream("/AddMembers.json"), uri, HttpMethod.POST, headers);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ //then
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void removeMembers() throws IOException{
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+ HttpHeaders headers = new HttpHeaders();
+ //expect
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c/removeMembers";
+ ResponseEntity<String> response = sendRequest(inputStream("/RemoveMembers.json"), uri, HttpMethod.POST, headers);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ //then
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/MembersValidation/AddMembersInstanceId.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/MembersValidation/AddMembersInstanceId.json
new file mode 100644
index 0000000000..10805134da
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/MembersValidation/AddMembersInstanceId.json
@@ -0,0 +1,17 @@
+{
+ "requestDetails": {
+ "requestInfo": {
+ "source": "VID",
+ "requestorId": "xxxxxx"
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "modelInfo": {
+ "modelType": "vnf"
+ }
+ }
+ }
+ ]
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/MembersValidation/AddMembersSource.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/MembersValidation/AddMembersSource.json
new file mode 100644
index 0000000000..ca4798e79f
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/MembersValidation/AddMembersSource.json
@@ -0,0 +1,17 @@
+{
+ "requestDetails": {
+ "requestInfo": {
+ "requestorId": "xxxxxx"
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "{the to be related vnf-id}",
+ "modelInfo": {
+ "modelType": "vnf"
+ }
+ }
+ }
+ ]
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/MembersValidation/DeleteMembersModelType.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/MembersValidation/DeleteMembersModelType.json
new file mode 100644
index 0000000000..d3afee1189
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/MembersValidation/DeleteMembersModelType.json
@@ -0,0 +1,17 @@
+{
+ "requestDetails": {
+ "requestInfo": {
+ "source": "VID",
+ "requestorId": "xxxxxx"
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "{the to be related vnf-id}",
+ "modelInfo": {
+ }
+ }
+ }
+ ]
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/MembersValidation/MembersRequestInfo.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/MembersValidation/MembersRequestInfo.json
new file mode 100644
index 0000000000..c4240a86b8
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/MembersValidation/MembersRequestInfo.json
@@ -0,0 +1,14 @@
+{
+ "requestDetails": {
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "{the to be related vnf-id}",
+ "modelInfo": {
+ "modelType": "vnf"
+ }
+ }
+ }
+ ]
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/MembersValidation/MembersRequestorId.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/MembersValidation/MembersRequestorId.json
new file mode 100644
index 0000000000..8564b605d2
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/MembersValidation/MembersRequestorId.json
@@ -0,0 +1,17 @@
+{
+ "requestDetails": {
+ "requestInfo": {
+ "source": "VID"
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "{the to be removed as member vnf-id}",
+ "modelInfo": {
+ "modelType": "vnf"
+ }
+ }
+ }
+ ]
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/MembersValidation/RelatedInstances.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/MembersValidation/RelatedInstances.json
new file mode 100644
index 0000000000..616f79b651
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/MembersValidation/RelatedInstances.json
@@ -0,0 +1,15 @@
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "instanceGroup",
+ "modelVersionId": "ddcbbf3d-f2c1-4ca0-8852-76a807285efc"
+ },
+ "requestInfo": {
+ "source": "VID",
+ "requestorId": "xxxxxx"
+ },
+ "requestParameters": {
+ "userParams": []
+ }
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/MembersValidation/RelatedInstancesVnf.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/MembersValidation/RelatedInstancesVnf.json
new file mode 100644
index 0000000000..0d3396481e
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/MembersValidation/RelatedInstancesVnf.json
@@ -0,0 +1,25 @@
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "instanceGroup",
+ "modelVersionId": "ddcbbf3d-f2c1-4ca0-8852-76a807285efc"
+ },
+ "requestInfo": {
+ "source": "VID",
+ "requestorId": "xxxxxx"
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "96f40d14-705d-40d9-b829-3dab90811321",
+ "modelInfo": {
+ "modelType": "vfModule"
+ }
+ }
+ }
+ ],
+ "requestParameters": {
+ "userParams": []
+ }
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/CreateInstanceGroupNoModelVersionId.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/CreateInstanceGroupNoModelVersionId.json
new file mode 100644
index 0000000000..0bac9ce4b2
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/CreateInstanceGroupNoModelVersionId.json
@@ -0,0 +1,25 @@
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "instanceGroup"
+ },
+ "requestInfo": {
+ "source": "VID",
+ "requestorId": "xxxxxx"
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "96f40d14-705d-40d9-b829-3dab90811321",
+ "modelInfo": {
+ "modelType": "service"
+ }
+ }
+ }
+ ],
+ "requestParameters": {
+ "userParams": []
+ }
+ }
+}
+
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RelatedInstances/CreateInstanceGroupNoModelCustomizationId.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RelatedInstances/CreateInstanceGroupNoModelCustomizationId.json
new file mode 100644
index 0000000000..058daf2aa9
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RelatedInstances/CreateInstanceGroupNoModelCustomizationId.json
@@ -0,0 +1,33 @@
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "instanceGroup",
+ "modelVersionId": "ddcbbf3d-f2c1-4ca0-8852-76a807285efc"
+ },
+ "requestInfo": {
+ "source": "VID",
+ "requestorId": "xxxxxx"
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "96f40d14-705d-40d9-b829-3dab90811321",
+ "modelInfo": {
+ "modelType": "service"
+ }
+ }
+ },
+ {
+ "relatedInstance": {
+ "modelInfo": {
+ "modelType": "service"
+ }
+ }
+ }
+ ],
+ "requestParameters": {
+ "userParams": []
+ }
+ }
+}
+
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RelatedInstances/CreateInstanceGroupNoRelatedInstances.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RelatedInstances/CreateInstanceGroupNoRelatedInstances.json
new file mode 100644
index 0000000000..5827c52f3b
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RelatedInstances/CreateInstanceGroupNoRelatedInstances.json
@@ -0,0 +1,16 @@
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "instanceGroup",
+ "modelVersionId": "ddcbbf3d-f2c1-4ca0-8852-76a807285efc"
+ },
+ "requestInfo": {
+ "source": "VID",
+ "requestorId": "xxxxxx"
+ },
+ "requestParameters": {
+ "userParams": []
+ }
+ }
+}
+
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RelatedInstances/CreateInstanceGroupRelatedInstanceModelVersionId.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RelatedInstances/CreateInstanceGroupRelatedInstanceModelVersionId.json
new file mode 100644
index 0000000000..d855078fef
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RelatedInstances/CreateInstanceGroupRelatedInstanceModelVersionId.json
@@ -0,0 +1,25 @@
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "instanceGroup",
+ "modelVersionId": "ddcbbf3d-f2c1-4ca0-8852-76a807285efc"
+ },
+ "requestInfo": {
+ "source": "VID",
+ "requestorId": "xxxxxx"
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "ddcbbf3d-f2c1-4ca0-8852-76a807285efc",
+ "modelInfo": {
+ "modelType": "service"
+ }
+ }
+ }
+ ],
+ "requestParameters": {
+ "userParams": []
+ }
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RelatedInstances/CreateInstanceGroupService.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RelatedInstances/CreateInstanceGroupService.json
new file mode 100644
index 0000000000..0d3396481e
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RelatedInstances/CreateInstanceGroupService.json
@@ -0,0 +1,25 @@
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "instanceGroup",
+ "modelVersionId": "ddcbbf3d-f2c1-4ca0-8852-76a807285efc"
+ },
+ "requestInfo": {
+ "source": "VID",
+ "requestorId": "xxxxxx"
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "96f40d14-705d-40d9-b829-3dab90811321",
+ "modelInfo": {
+ "modelType": "vfModule"
+ }
+ }
+ }
+ ],
+ "requestParameters": {
+ "userParams": []
+ }
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/AddMembers.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/AddMembers.json
new file mode 100644
index 0000000000..e9d056c3dc
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/AddMembers.json
@@ -0,0 +1,18 @@
+{
+ "requestDetails": {
+ "requestInfo": {
+ "source": "VID",
+ "requestorId": "xxxxxx"
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "{the to be related vnf-id}",
+ "modelInfo": {
+ "modelType": "vnf"
+ }
+ }
+ }
+ ]
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/CreateInstanceGroup.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/CreateInstanceGroup.json
new file mode 100644
index 0000000000..474c8015a7
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/CreateInstanceGroup.json
@@ -0,0 +1,26 @@
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "instanceGroup",
+ "modelVersionId": "ddcbbf3d-f2c1-4ca0-8852-76a807285efc"
+ },
+ "requestInfo": {
+ "source": "VID",
+ "requestorId": "xxxxxx"
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "ddcbbf3d-f2c1-4ca0-8852-76a807285efc",
+ "modelInfo": {
+ "modelType": "service",
+ "modelVersionId": "ddcbbf3d-f2c1-4ca0-8852-76a807285efc"
+ }
+ }
+ }
+ ],
+ "requestParameters": {
+ "userParams": []
+ }
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/MembersRequestInfo.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/MembersRequestInfo.json
new file mode 100644
index 0000000000..58f83ef917
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/MembersRequestInfo.json
@@ -0,0 +1,17 @@
+{
+ "requestDetails": {
+ "requestInfo": {
+ "source": "VID"
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "{the to be related vnf-id}",
+ "modelInfo": {
+ "modelType": "vnf"
+ }
+ }
+ }
+ ]
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/RemoveMembers.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/RemoveMembers.json
new file mode 100644
index 0000000000..437f19dc8d
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/RemoveMembers.json
@@ -0,0 +1,18 @@
+{
+ "requestDetails": {
+ "requestInfo": {
+ "source": "VID",
+ "requestorId": "xxxxxx"
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "{the to be removed as member vnf-id}",
+ "modelInfo": {
+ "modelType": "vnf"
+ }
+ }
+ }
+ ]
+ }
+}