diff options
author | Amichai Hemli <amichai.hemli@intl.att.com> | 2019-11-25 08:44:19 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-11-25 08:44:19 +0000 |
commit | f670a8236f9bd398f0b1a6be30c2b08122383925 (patch) | |
tree | a77f83306a13663c0dd1762e3c77ec85e326b048 /vid-app-common/src/main/java/org/onap | |
parent | b6f8fb70024e863152ed9a234e3535363b7d23f9 (diff) | |
parent | d84c152a0e5cba0bdaf7c16ca82b1c9f56bdb7c6 (diff) |
Merge "VfModule and VolumeGroup RequestParameters: introduce objects hierarchy"
Diffstat (limited to 'vid-app-common/src/main/java/org/onap')
-rw-r--r-- | vid-app-common/src/main/java/org/onap/vid/job/command/MsoRequestBuilder.kt | 50 | ||||
-rw-r--r-- | vid-app-common/src/main/java/org/onap/vid/job/command/VfmoduleCommand.kt | 2 | ||||
-rw-r--r-- | vid-app-common/src/main/java/org/onap/vid/mso/model/VfModuleOrVolumeGroupRequestDetails.java (renamed from vid-app-common/src/main/java/org/onap/vid/mso/model/VfModuleInstantiationRequestDetails.java) | 29 | ||||
-rw-r--r-- | vid-app-common/src/main/java/org/onap/vid/mso/model/VolumeGroupRequestDetails.java | 4 |
4 files changed, 61 insertions, 24 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 a03d62d68..e71315d67 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 @@ -11,7 +11,7 @@ import org.onap.vid.changeManagement.RequestDetailsWrapper import org.onap.vid.model.serviceInstantiation.* import org.onap.vid.mso.model.* import org.onap.vid.mso.model.BaseResourceInstantiationRequestDetails.* -import org.onap.vid.mso.model.VfModuleInstantiationRequestDetails.UserParamMap +import org.onap.vid.mso.model.VfModuleOrVolumeGroupRequestDetails.* import org.onap.vid.mso.rest.SubscriberInfo import org.onap.vid.properties.Features import org.onap.vid.services.AsyncInstantiationBusinessLogic @@ -99,20 +99,17 @@ class MsoRequestBuilder return RequestDetailsWrapper(VnfInstantiationRequestDetails(vnfDetails.modelInfo, cloudConfiguration, requestInfo, null, null, null, null)) } - fun generateVfModuleInstantiationRequest( + protected fun generateVfModuleRequestWithRequestParams( vfModuleDetails: VfModule, serviceModelInfo: ModelInfo, - serviceInstanceId: String, vnfModelInfo: ModelInfo, vnfInstanceId: String, - vgInstanceId: String?, userId: String, testApi: String? - ): RequestDetailsWrapper<VfModuleInstantiationRequestDetails> { + serviceInstanceId: String, vnfModelInfo: ModelInfo, vnfInstanceId: String, vgInstanceId: String?, userId: String, + requestParameters: (userParams: List<UserParamTypes>) -> RequestParametersVfModuleOrVolumeGroup + ): RequestDetailsWrapper<VfModuleOrVolumeGroupRequestDetails> { val requestInfo = generateRequestInfo(vfModuleDetails.instanceName, ResourceType.VF_MODULE, vfModuleDetails.isRollbackOnFailure, null, userId) //cloud configuration val cloudConfiguration = generateCloudConfiguration(vfModuleDetails.lcpCloudRegionId, vfModuleDetails.tenantId) - //request parameters val userParams = aggregateAllInstanceParams(extractActualInstanceParams(vfModuleDetails.instanceParams), vfModuleDetails.supplementaryParams) - val requestParameters = VfModuleInstantiationRequestDetails.RequestParametersVfModule( - userParams, vfModuleDetails.isUsePreload, testApi, nullSafeNegate(vfModuleDetails.isRetainVolumeGroups)) //related instance list val relatedInstanceList = generateRelatedInstances(mapOf(serviceInstanceId to serviceModelInfo, vnfInstanceId to vnfModelInfo)) @@ -121,7 +118,34 @@ class MsoRequestBuilder volumeGroupModel.modelType = "volumeGroup" relatedInstanceList.add(RelatedInstance(volumeGroupModel, vgInstanceId, vfModuleDetails.volumeGroupInstanceName)) } - return RequestDetailsWrapper(VfModuleInstantiationRequestDetails(vfModuleDetails.modelInfo, cloudConfiguration, requestInfo, relatedInstanceList, requestParameters)) + + return RequestDetailsWrapper(VfModuleOrVolumeGroupRequestDetails(vfModuleDetails.modelInfo, cloudConfiguration, requestInfo, relatedInstanceList, requestParameters(userParams))) + } + + fun generateVfModuleInstantiationRequest( + vfModuleDetails: VfModule, serviceModelInfo: ModelInfo, + serviceInstanceId: String, vnfModelInfo: ModelInfo, vnfInstanceId: String, + vgInstanceId: String?, userId: String, testApi: String? + ): RequestDetailsWrapper<VfModuleOrVolumeGroupRequestDetails> { + val requestParameters = { userParams: List<UserParamTypes> -> + RequestParametersVfModuleOrVolumeGroupInstantiation(userParams, vfModuleDetails.isUsePreload, testApi) + } + + return generateVfModuleRequestWithRequestParams(vfModuleDetails, serviceModelInfo, serviceInstanceId, + vnfModelInfo, vnfInstanceId, vgInstanceId, userId, requestParameters) + } + + fun generateVfModuleReplaceRequest( + vfModuleDetails: VfModule, serviceModelInfo: ModelInfo, + serviceInstanceId: String, vnfModelInfo: ModelInfo, vnfInstanceId: String, + vgInstanceId: String?, userId: String, testApi: String? + ): RequestDetailsWrapper<VfModuleOrVolumeGroupRequestDetails> { + val requestParameters = { userParams: List<UserParamTypes> -> + RequestParametersVfModuleUpgrade(userParams, vfModuleDetails.isUsePreload, testApi, nullSafeNegate(vfModuleDetails.isRetainVolumeGroups)) + } + + return generateVfModuleRequestWithRequestParams(vfModuleDetails, serviceModelInfo, serviceInstanceId, + vnfModelInfo, vnfInstanceId, vgInstanceId, userId, requestParameters) } private fun nullSafeNegate(booleanValue: Boolean?): Boolean? = booleanValue?.not() @@ -130,7 +154,7 @@ class MsoRequestBuilder 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, null) + val requestParameters = RequestParametersVfModuleOrVolumeGroupInstantiation(userParams, vfModuleDetails.isUsePreload, testApi) val relatedInstances = generateRelatedInstances(mapOf(serviceInstanceId to serviceModelInfo, vnfInstanceId to vnfModelInfo)) vfModuleDetails.modelInfo.modelType = "volumeGroup" @@ -158,10 +182,10 @@ class MsoRequestBuilder return RequestDetailsWrapper(NetworkInstantiationRequestDetails(networkDetails.modelInfo, cloudConfiguration, requestInfo, null, null, null, null)) } - fun generateDeleteVfModuleRequest(vfModuleDetails: VfModule, userId: String): RequestDetailsWrapper<VfModuleInstantiationRequestDetails> { + fun generateDeleteVfModuleRequest(vfModuleDetails: VfModule, userId: String): RequestDetailsWrapper<VfModuleOrVolumeGroupRequestDetails> { val requestInfo = generateRequestInfo(null, null, null, null, userId) val cloudConfiguration = generateCloudConfiguration(vfModuleDetails.lcpCloudRegionId, vfModuleDetails.tenantId) - return RequestDetailsWrapper(VfModuleInstantiationRequestDetails(vfModuleDetails.modelInfo, cloudConfiguration, requestInfo, null, null)) + return RequestDetailsWrapper(VfModuleOrVolumeGroupRequestDetails(vfModuleDetails.modelInfo, cloudConfiguration, requestInfo, null, null)) } private fun generateServiceName(jobId: UUID?, payload: ServiceInstantiation, optimisticUniqueServiceInstanceName: String): String? { @@ -271,7 +295,7 @@ class MsoRequestBuilder }.collect(Collectors.toList<VfModuleMacro>()) } - fun aggregateAllInstanceParams(instanceParams: Map<String, String>?, supplementaryParams: Map<String, String>?): List<VfModuleInstantiationRequestDetails.UserParamMap<String, String>> { + fun aggregateAllInstanceParams(instanceParams: Map<String, String>?, supplementaryParams: Map<String, String>?): List<VfModuleOrVolumeGroupRequestDetails.UserParamMap<String, String>> { var instanceParamsFinal: Map<String, String> = instanceParams ?: emptyMap() val supplementaryParamsFinal: Map<String, String> = supplementaryParams ?: emptyMap() diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/VfmoduleCommand.kt b/vid-app-common/src/main/java/org/onap/vid/job/command/VfmoduleCommand.kt index bee42fbd4..6c499079f 100644 --- a/vid-app-common/src/main/java/org/onap/vid/job/command/VfmoduleCommand.kt +++ b/vid-app-common/src/main/java/org/onap/vid/job/command/VfmoduleCommand.kt @@ -90,7 +90,7 @@ class VfmoduleCommand @Autowired constructor( val originalRequestWithNewestVfmModelInfo = getRequest().cloneWith(vfmModelInfo) - val requestDetailsWrapper = msoRequestBuilder.generateVfModuleInstantiationRequest( + val requestDetailsWrapper = msoRequestBuilder.generateVfModuleReplaceRequest( originalRequestWithNewestVfmModelInfo, serviceModelInfo, serviceInstanceId, vnfModelInfo, vnfInstanceId, null, sharedData.userId, sharedData.testApi) 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/VfModuleOrVolumeGroupRequestDetails.java index d54fe7c53..794714edf 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/VfModuleOrVolumeGroupRequestDetails.java @@ -98,31 +98,45 @@ import java.util.Map; */ -public class VfModuleInstantiationRequestDetails extends BaseResourceInstantiationRequestDetails { +public class VfModuleOrVolumeGroupRequestDetails extends BaseResourceInstantiationRequestDetails { - public VfModuleInstantiationRequestDetails( + public VfModuleOrVolumeGroupRequestDetails( @JsonProperty(value = "modelInfo", required = true) ModelInfo modelInfo, @JsonProperty(value = "cloudConfiguration", required = true) CloudConfiguration cloudConfiguration, @JsonProperty(value = "requestInfo", required = true) RequestInfo requestInfo, @JsonProperty(value = "relatedInstanceList", required = true) List<RelatedInstance> relatedInstanceList, - @JsonProperty(value = "requestParameters", required = true) RequestParametersVfModule requestParameters) + @JsonProperty(value = "requestParameters", required = true) RequestParametersVfModuleOrVolumeGroup requestParameters) { super(modelInfo, cloudConfiguration, requestInfo, relatedInstanceList, requestParameters); } - public static class RequestParametersVfModule extends BaseResourceInstantiationRequestDetails.RequestParameters { + public static class RequestParametersVfModuleOrVolumeGroup 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, Boolean rebuildVolumeGroups) { + private RequestParametersVfModuleOrVolumeGroup(List<? extends UserParamTypes> userParams, Boolean usePreload, String testApi) { super(userParams, testApi); this.usePreload = usePreload; - this.rebuildVolumeGroups = rebuildVolumeGroups; } public Boolean isUsePreload() { return usePreload; } + } + + public static class RequestParametersVfModuleOrVolumeGroupInstantiation extends RequestParametersVfModuleOrVolumeGroup { + public RequestParametersVfModuleOrVolumeGroupInstantiation( + List<? extends UserParamTypes> userParams, Boolean usePreload, String testApi) { + super(userParams, usePreload, testApi); + } + } + + public static class RequestParametersVfModuleUpgrade extends RequestParametersVfModuleOrVolumeGroup { + @JsonInclude(NON_NULL) private final Boolean rebuildVolumeGroups; + + public RequestParametersVfModuleUpgrade(List<? extends UserParamTypes> userParams, Boolean usePreload, String testApi, Boolean rebuildVolumeGroups) { + super(userParams, usePreload, testApi); + this.rebuildVolumeGroups = rebuildVolumeGroups; + } public Boolean getRebuildVolumeGroups() { return rebuildVolumeGroups; @@ -130,7 +144,6 @@ public class VfModuleInstantiationRequestDetails extends BaseResourceInstantiati } public static class UserParamMap<K,V> extends HashMap<K,V> implements UserParamTypes, Map<K,V> { - public UserParamMap() { super(); } diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/model/VolumeGroupRequestDetails.java b/vid-app-common/src/main/java/org/onap/vid/mso/model/VolumeGroupRequestDetails.java index e1a5e56dd..6b7d6b9e3 100644 --- a/vid-app-common/src/main/java/org/onap/vid/mso/model/VolumeGroupRequestDetails.java +++ b/vid-app-common/src/main/java/org/onap/vid/mso/model/VolumeGroupRequestDetails.java @@ -21,8 +21,8 @@ package org.onap.vid.mso.model; import com.fasterxml.jackson.annotation.JsonProperty; - import java.util.List; +import org.onap.vid.mso.model.VfModuleOrVolumeGroupRequestDetails.RequestParametersVfModuleOrVolumeGroup; public class VolumeGroupRequestDetails extends BaseResourceInstantiationRequestDetails { @@ -31,7 +31,7 @@ public class VolumeGroupRequestDetails extends BaseResourceInstantiationRequestD @JsonProperty(value = "cloudConfiguration", required = true) CloudConfiguration cloudConfiguration, @JsonProperty(value = "requestInfo", required = true) RequestInfo requestInfo, @JsonProperty(value = "relatedInstanceList", required = true) List<RelatedInstance> relatedInstanceList, - @JsonProperty(value = "requestParameters", required = true) VfModuleInstantiationRequestDetails.RequestParametersVfModule requestParameters) + @JsonProperty(value = "requestParameters", required = true) RequestParametersVfModuleOrVolumeGroup requestParameters) { super(modelInfo, cloudConfiguration, requestInfo, relatedInstanceList, requestParameters); } |