summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/MsoRequestBuilder.kt13
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/VfModule.java13
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/model/VfModuleInstantiationRequestDetails.java8
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/job/command/ResourceCommandTest.java2
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java10
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/MsoRequestBuilderTest.java22
6 files changed, 54 insertions, 14 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/MsoRequestBuilder.kt b/vid-app-common/src/main/java/org/onap/vid/job/command/MsoRequestBuilder.kt
index b35deb892..a03d62d68 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/command/MsoRequestBuilder.kt
+++ b/vid-app-common/src/main/java/org/onap/vid/job/command/MsoRequestBuilder.kt
@@ -99,7 +99,11 @@ class MsoRequestBuilder
return RequestDetailsWrapper(VnfInstantiationRequestDetails(vnfDetails.modelInfo, cloudConfiguration, requestInfo, null, null, null, null))
}
- fun generateVfModuleInstantiationRequest(vfModuleDetails: VfModule, serviceModelInfo: ModelInfo, serviceInstanceId: String, vnfModelInfo: ModelInfo, vnfInstanceId: String, vgInstanceId: String?, userId: String, testApi: String?): RequestDetailsWrapper<VfModuleInstantiationRequestDetails> {
+ fun generateVfModuleInstantiationRequest(
+ vfModuleDetails: VfModule, serviceModelInfo: ModelInfo,
+ serviceInstanceId: String, vnfModelInfo: ModelInfo, vnfInstanceId: String,
+ vgInstanceId: String?, userId: String, testApi: String?
+ ): RequestDetailsWrapper<VfModuleInstantiationRequestDetails> {
val requestInfo = generateRequestInfo(vfModuleDetails.instanceName, ResourceType.VF_MODULE, vfModuleDetails.isRollbackOnFailure, null, userId)
//cloud configuration
@@ -107,7 +111,8 @@ class MsoRequestBuilder
//request parameters
val userParams = aggregateAllInstanceParams(extractActualInstanceParams(vfModuleDetails.instanceParams), vfModuleDetails.supplementaryParams)
- val requestParameters = VfModuleInstantiationRequestDetails.RequestParametersVfModule(userParams, vfModuleDetails.isUsePreload, testApi)
+ val requestParameters = VfModuleInstantiationRequestDetails.RequestParametersVfModule(
+ userParams, vfModuleDetails.isUsePreload, testApi, nullSafeNegate(vfModuleDetails.isRetainVolumeGroups))
//related instance list
val relatedInstanceList = generateRelatedInstances(mapOf(serviceInstanceId to serviceModelInfo, vnfInstanceId to vnfModelInfo))
@@ -119,11 +124,13 @@ class MsoRequestBuilder
return RequestDetailsWrapper(VfModuleInstantiationRequestDetails(vfModuleDetails.modelInfo, cloudConfiguration, requestInfo, relatedInstanceList, requestParameters))
}
+ private fun nullSafeNegate(booleanValue: Boolean?): Boolean? = booleanValue?.not()
+
fun generateVolumeGroupInstantiationRequest(vfModuleDetails: VfModule, serviceModelInfo: ModelInfo, serviceInstanceId: String, vnfModelInfo: ModelInfo, vnfInstanceId: String, userId: String, testApi: String?): RequestDetailsWrapper<VolumeGroupRequestDetails> {
val requestInfo = generateRequestInfo(vfModuleDetails.volumeGroupInstanceName, ResourceType.VOLUME_GROUP, vfModuleDetails.isRollbackOnFailure, null, userId)
val cloudConfiguration = generateCloudConfiguration(vfModuleDetails.lcpCloudRegionId, vfModuleDetails.tenantId)
val userParams = aggregateAllInstanceParams(extractActualInstanceParams(vfModuleDetails.instanceParams), vfModuleDetails.supplementaryParams)
- val requestParameters = VfModuleInstantiationRequestDetails.RequestParametersVfModule(userParams, vfModuleDetails.isUsePreload, testApi)
+ val requestParameters = VfModuleInstantiationRequestDetails.RequestParametersVfModule(userParams, vfModuleDetails.isUsePreload, testApi, null)
val relatedInstances = generateRelatedInstances(mapOf(serviceInstanceId to serviceModelInfo, vnfInstanceId to vnfModelInfo))
vfModuleDetails.modelInfo.modelType = "volumeGroup"
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/VfModule.java b/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/VfModule.java
index 41da85e35..5c847b87c 100644
--- a/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/VfModule.java
+++ b/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/VfModule.java
@@ -28,6 +28,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
+import javax.annotation.Nullable;
import org.onap.vid.job.JobAdapter;
import org.onap.vid.job.JobType;
import org.onap.vid.mso.model.ModelInfo;
@@ -42,6 +43,10 @@ public class VfModule extends BaseResource implements JobAdapter.AsyncJobRequest
@JsonInclude(NON_NULL) private Boolean usePreload;
private Map<String, String> supplementaryParams;
+ @JsonInclude(NON_NULL)
+ @Nullable
+ private final Boolean retainVolumeGroups;
+
public VfModule(@JsonProperty("modelInfo") ModelInfo modelInfo,
@JsonProperty("instanceName") String instanceName,
@JsonProperty("volumeGroupName") String volumeGroupInstanceName,
@@ -57,12 +62,14 @@ public class VfModule extends BaseResource implements JobAdapter.AsyncJobRequest
@JsonProperty("trackById") String trackById,
@JsonProperty("isFailed") Boolean isFailed,
@JsonProperty("statusMessage") String statusMessage,
+ @JsonProperty("retainVolumeGroups") Boolean retainVolumeGroups,
@JsonProperty("position") Integer position) {
super(modelInfo, instanceName, action, lcpCloudRegionId, legacyRegion, tenantId, instanceParams, rollbackOnFailure, instanceId, trackById, isFailed, statusMessage,
position);
this.volumeGroupInstanceName = volumeGroupInstanceName;
this.usePreload = usePreload;
this.supplementaryParams = supplementaryParams;
+ this.retainVolumeGroups = retainVolumeGroups;
}
public String getVolumeGroupInstanceName() {
@@ -93,6 +100,11 @@ public class VfModule extends BaseResource implements JobAdapter.AsyncJobRequest
return JobType.VfmoduleInstantiation;
}
+ @Nullable
+ public Boolean isRetainVolumeGroups() {
+ return retainVolumeGroups;
+ }
+
public VfModule cloneWith(ModelInfo modelInfo) {
return new VfModule(
modelInfo,
@@ -110,6 +122,7 @@ public class VfModule extends BaseResource implements JobAdapter.AsyncJobRequest
this.getTrackById(),
this.getIsFailed(),
this.getStatusMessage(),
+ this.isRetainVolumeGroups(),
this.getPosition());
}
} \ No newline at end of file
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/model/VfModuleInstantiationRequestDetails.java b/vid-app-common/src/main/java/org/onap/vid/mso/model/VfModuleInstantiationRequestDetails.java
index 3b6cd1d3d..d54fe7c53 100644
--- a/vid-app-common/src/main/java/org/onap/vid/mso/model/VfModuleInstantiationRequestDetails.java
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/model/VfModuleInstantiationRequestDetails.java
@@ -112,15 +112,21 @@ public class VfModuleInstantiationRequestDetails extends BaseResourceInstantiati
public static class RequestParametersVfModule extends BaseResourceInstantiationRequestDetails.RequestParameters {
@JsonInclude(NON_NULL) private final Boolean usePreload;
+ @JsonInclude(NON_NULL) private final Boolean rebuildVolumeGroups;
- public RequestParametersVfModule(List<? extends UserParamTypes> userParams, Boolean usePreload, String testApi) {
+ public RequestParametersVfModule(List<? extends UserParamTypes> userParams, Boolean usePreload, String testApi, Boolean rebuildVolumeGroups) {
super(userParams, testApi);
this.usePreload = usePreload;
+ this.rebuildVolumeGroups = rebuildVolumeGroups;
}
public Boolean isUsePreload() {
return usePreload;
}
+
+ public Boolean getRebuildVolumeGroups() {
+ return rebuildVolumeGroups;
+ }
}
public static class UserParamMap<K,V> extends HashMap<K,V> implements UserParamTypes, Map<K,V> {
diff --git a/vid-app-common/src/test/java/org/onap/vid/job/command/ResourceCommandTest.java b/vid-app-common/src/test/java/org/onap/vid/job/command/ResourceCommandTest.java
index 986f5d0f5..525acf944 100644
--- a/vid-app-common/src/test/java/org/onap/vid/job/command/ResourceCommandTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/job/command/ResourceCommandTest.java
@@ -320,7 +320,7 @@ public class ResourceCommandTest {
static VfModule createVfModule(Action action) {
return new VfModule(mock(ModelInfo.class), null, null, action.toString(), null, null, null, null, null, false, false, null, null, null, null,
- null);
+ null, null);
}
static Network createNetwork(Action action) {
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java b/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java
index 9c0260e85..d6af2ad25 100644
--- a/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java
@@ -172,20 +172,22 @@ public class AsyncInstantiationBaseTest extends AbstractTestNGSpringContextTests
vfModuleInfo.setModelVersion("10.0");
return new VfModule(vfModuleInfo, instanceName, volumeGroupInstanceName, Action.Create.name(), "mdt1", null,
"88a6ca3ee0394ade9403f075db23167e", instanceParams, supplementaryParams, false, true, null, UUID.randomUUID().toString(), null, null,
- null);
+ null, null);
}
return new VfModule(vfModuleInfo, instanceName, volumeGroupInstanceName, Action.Create.name(), null, null, null,
- instanceParams, supplementaryParams, false, false, null, UUID.randomUUID().toString(), null, null, null);
+ instanceParams, supplementaryParams, false, false, null, UUID.randomUUID().toString(), null,
+ null, null, null);
}
protected ModelInfo createVfModuleModelInfo(String modelName, String modelVersion, String modelVersionId, String modelInvariantId, String modelCustomizationId, String modelCustomizationName) {
return createModelInfo("vfModule", modelName, modelVersion, modelVersionId, modelInvariantId, modelCustomizationId, modelCustomizationName);
}
- protected VfModule createVfModuleForReplace(ModelInfo vfModuleModelInfo, String instanceName, String lcpCloudRegionId, String tenantId) {
+ protected VfModule createVfModuleForReplace(ModelInfo vfModuleModelInfo, String instanceName,
+ String lcpCloudRegionId, String tenantId, Boolean retainVolumeGroups) {
return new VfModule( vfModuleModelInfo, instanceName, null, Action.Upgrade.name(), lcpCloudRegionId, null, tenantId,
- null, null, true, null, null, UUID.randomUUID().toString(), null, null, null);
+ null, null, true, null, null, UUID.randomUUID().toString(), null, null, retainVolumeGroups, null);
}
protected ModelInfo createVnfModelInfo(boolean isAlacarte) {
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/MsoRequestBuilderTest.java b/vid-app-common/src/test/java/org/onap/vid/services/MsoRequestBuilderTest.java
index a7e2d553d..036c0fb47 100644
--- a/vid-app-common/src/test/java/org/onap/vid/services/MsoRequestBuilderTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/services/MsoRequestBuilderTest.java
@@ -22,6 +22,7 @@ package org.onap.vid.services;
import static com.google.common.collect.Maps.newHashMap;
import static net.javacrumbs.jsonunit.JsonMatchers.jsonEquals;
+import static net.javacrumbs.jsonunit.JsonMatchers.jsonPartEquals;
import static net.javacrumbs.jsonunit.core.Option.IGNORING_ARRAY_ORDER;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.IsEqual.equalTo;
@@ -610,23 +611,34 @@ public class MsoRequestBuilderTest extends AsyncInstantiationBaseTest {
}
@Test
+ public void generateReplaceVfModuleRequest_whenRetainVolumeGroupIsTrue_rebuildVolumeGroupIsFalse() {
+ assertThat(generatedVfModuleInstantiationRequest(true),
+ jsonPartEquals("requestDetails.requestParameters.rebuildVolumeGroups", false));
+ }
+
+ @Test
public void generateReplaceVfModuleRequest_verifyResultAsExpected() {
String expected = TestUtils.readFileAsString("/payload_jsons/vfmodule/replace_vfmodule__payload_to_mso.json");
+ assertThat(generatedVfModuleInstantiationRequest(null), jsonEquals(expected).when(IGNORING_ARRAY_ORDER));
+ }
+
+ private RequestDetailsWrapper<VfModuleInstantiationRequestDetails> generatedVfModuleInstantiationRequest(
+ Boolean retainVolumeGroups) {
when(featureManager.isActive(Features.FLAG_1810_CR_ADD_CLOUD_OWNER_TO_MSO_REQUEST)).thenReturn(true);
when(aaiClient.getCloudOwnerByCloudRegionId("regionOne")).thenReturn("irma-aic");
ModelInfo vfModuleModelInfo = createVfModuleModelInfo("newest-model-name-vfm", "newest-model-version-vfm", "newest-model-uuid-vfm",
"f7a867f2-596b-4f4a-a128-421e825a6190", "newest-model-customization-uuid-vfm","newest-model-customization-name-vfm" );
- VfModule vfModuleDetails = createVfModuleForReplace(vfModuleModelInfo, "replace_module", "regionOne", "0422ffb57ba042c0800a29dc85ca70f8");
+ VfModule vfModuleDetails = createVfModuleForReplace(vfModuleModelInfo, "replace_module", "regionOne", "0422ffb57ba042c0800a29dc85ca70f8",
+ retainVolumeGroups);
ModelInfo serviceModelInfo = createServiceModelInfo("newest-model-name-service", "newest-model-version-service", "newest-model-uuid-service", "b16a9398-ffa3-4041-b78c-2956b8ad9c7b", null, null );
ModelInfo vnfModelInfo = createVnfModelInfo("newest-model-name-vnf", "newest-model-version-vnf", "newest-model-uuid-vnf", "23122c9b-dd7f-483f-bf0a-e069303db2f7", "newest-model-customization-uuid-vnf", "newest-model-customization-name-vnf" );
- RequestDetailsWrapper<VfModuleInstantiationRequestDetails> result =
- msoRequestBuilder.generateVfModuleInstantiationRequest(vfModuleDetails, serviceModelInfo, "e9993045-cc96-4f3f-bf9a-71b2a400a956", vnfModelInfo, "5c9c2896-1fe6-4055-b7ec-d0a01e5f9bf5", null,"az2016", "GR_API");
-
- assertThat(result, jsonEquals(expected).when(IGNORING_ARRAY_ORDER));
+ return msoRequestBuilder.generateVfModuleInstantiationRequest(vfModuleDetails, serviceModelInfo, "e9993045-cc96-4f3f-bf9a-71b2a400a956", vnfModelInfo, "5c9c2896-1fe6-4055-b7ec-d0a01e5f9bf5", null,
+ "az2016", "GR_API"
+ );
}
} \ No newline at end of file