From d84c152a0e5cba0bdaf7c16ca82b1c9f56bdb7c6 Mon Sep 17 00:00:00 2001 From: Ittay Stern Date: Sun, 24 Nov 2019 10:51:11 +0200 Subject: VfModule and VolumeGroup RequestParameters: introduce objects hierarchy -- RequestParametersVfModuleOrVolumeGroup +-- RequestParametersVfModuleOrVolumeGroupInstantiation +-- RequestParametersVfModuleUpgrade Change-Id: I97ef46c7cf66936685e030a73b42d4deac7403b5 Issue-ID: VID-603 Signed-off-by: Ittay Stern --- .../org/onap/vid/job/command/MsoRequestBuilder.kt | 50 +++++-- .../org/onap/vid/job/command/VfmoduleCommand.kt | 2 +- .../model/VfModuleInstantiationRequestDetails.java | 139 ------------------- .../model/VfModuleOrVolumeGroupRequestDetails.java | 152 +++++++++++++++++++++ .../vid/mso/model/VolumeGroupRequestDetails.java | 4 +- 5 files changed, 192 insertions(+), 155 deletions(-) delete mode 100644 vid-app-common/src/main/java/org/onap/vid/mso/model/VfModuleInstantiationRequestDetails.java create mode 100644 vid-app-common/src/main/java/org/onap/vid/mso/model/VfModuleOrVolumeGroupRequestDetails.java (limited to 'vid-app-common/src/main/java/org/onap') 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 { + serviceInstanceId: String, vnfModelInfo: ModelInfo, vnfInstanceId: String, vgInstanceId: String?, userId: String, + requestParameters: (userParams: List) -> RequestParametersVfModuleOrVolumeGroup + ): RequestDetailsWrapper { 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 { + val requestParameters = { userParams: List -> + 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 { + val requestParameters = { userParams: List -> + 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 { + fun generateDeleteVfModuleRequest(vfModuleDetails: VfModule, userId: String): RequestDetailsWrapper { 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()) } - fun aggregateAllInstanceParams(instanceParams: Map?, supplementaryParams: Map?): List> { + fun aggregateAllInstanceParams(instanceParams: Map?, supplementaryParams: Map?): List> { var instanceParamsFinal: Map = instanceParams ?: emptyMap() val supplementaryParamsFinal: Map = 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/VfModuleInstantiationRequestDetails.java deleted file mode 100644 index d54fe7c53..000000000 --- a/vid-app-common/src/main/java/org/onap/vid/mso/model/VfModuleInstantiationRequestDetails.java +++ /dev/null @@ -1,139 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * VID - * ================================================================================ - * Copyright (C) 2017 - 2019 AT&T Intellectual Property. 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.vid.mso.model; - -import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/* Based on this model: - -{ - "requestDetails": { - "modelInfo": { - “modelType”: “vfModule”, - “modelInvariantId”: “ff5256d2-5a33-55df-13ab-12abad84e7ff”, - “modelVersionId”: “fe6478e5-ea33-3346-ac12-ab121484a3fe”, - “modelCustomizationId”: “856f9806-b01a-11e6-80f5-76304dec7eb7”, - “modelName”: “vSAMP12..base..module-0”, - "modelVersion": "1" - }, - “cloudConfiguration”: { - “lcpCloudRegionId”: “mdt1”, - “tenantId”: “88a6ca3ee0394ade9403f075db23167e” - }, - "requestInfo": { - “instanceName”: “MSOTEST103a-vSAMP12_base_module-0”, - “source”: “VID”, - “suppressRollback”: true, - “requestorId”: “az2016” - }, - "relatedInstanceList": [ - { - // This related instance captures the volumeGroup to attach - “relatedInstance”: { - “instanceId”: “17ef4658-bd1f-4ef0-9ca0-ea76e2bf122c”, - “instanceName”: “MSOTESTVOL103a-vSAMP12_base_module-0_vol”, - “modelInfo”: { - “modelType”: “volumeGroup” - } - } - }, - { - “relatedInstance”: { - “instanceId”: “{serviceInstanceId}”, - “modelInfo”: { - “modelType”: “service”, - “modelInvariantId”: “ff3514e3-5a33-55df-13ab-12abad84e7ff”, - “modelVersionId”: “fe6985cd-ea33-3346-ac12-ab121484a3fe”, - “modelName”: “{parent service model name}”, - "modelVersion": "1.0" - } - } - }, - { - “relatedInstance”: { - “instanceId”: “{vnfInstanceId}”, - "modelInfo": { - “modelType”: “vnf”, - “modelInvariantId”: “ff5256d1-5a33-55df-13ab-12abad84e7ff”, - “modelVersionId”: “fe6478e4-ea33-3346-ac12-ab121484a3fe”, - “modelName”: “vSAMP12”, - "modelVersion": "1.0", - “modelCustomizationName”: “vSAMP12 1”, - “modelCustomizationId”: “a7f1d08e-b02d-11e6-80f5-76304dec7eb7” - } - } - } - ], - “requestParameters”: { - “usePreload”: true, - “userParams”: [] - } - } -} - - - */ - -public class VfModuleInstantiationRequestDetails extends BaseResourceInstantiationRequestDetails { - - public VfModuleInstantiationRequestDetails( - @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 relatedInstanceList, - @JsonProperty(value = "requestParameters", required = true) RequestParametersVfModule requestParameters) - { - super(modelInfo, cloudConfiguration, requestInfo, relatedInstanceList, requestParameters); - } - - public static class RequestParametersVfModule extends BaseResourceInstantiationRequestDetails.RequestParameters { - @JsonInclude(NON_NULL) private final Boolean usePreload; - @JsonInclude(NON_NULL) private final Boolean rebuildVolumeGroups; - - public RequestParametersVfModule(List 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 extends HashMap implements UserParamTypes, Map { - - public UserParamMap() { - super(); - } - } -} - diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/model/VfModuleOrVolumeGroupRequestDetails.java b/vid-app-common/src/main/java/org/onap/vid/mso/model/VfModuleOrVolumeGroupRequestDetails.java new file mode 100644 index 000000000..794714edf --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/mso/model/VfModuleOrVolumeGroupRequestDetails.java @@ -0,0 +1,152 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. 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.vid.mso.model; + +import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/* Based on this model: + +{ + "requestDetails": { + "modelInfo": { + “modelType”: “vfModule”, + “modelInvariantId”: “ff5256d2-5a33-55df-13ab-12abad84e7ff”, + “modelVersionId”: “fe6478e5-ea33-3346-ac12-ab121484a3fe”, + “modelCustomizationId”: “856f9806-b01a-11e6-80f5-76304dec7eb7”, + “modelName”: “vSAMP12..base..module-0”, + "modelVersion": "1" + }, + “cloudConfiguration”: { + “lcpCloudRegionId”: “mdt1”, + “tenantId”: “88a6ca3ee0394ade9403f075db23167e” + }, + "requestInfo": { + “instanceName”: “MSOTEST103a-vSAMP12_base_module-0”, + “source”: “VID”, + “suppressRollback”: true, + “requestorId”: “az2016” + }, + "relatedInstanceList": [ + { + // This related instance captures the volumeGroup to attach + “relatedInstance”: { + “instanceId”: “17ef4658-bd1f-4ef0-9ca0-ea76e2bf122c”, + “instanceName”: “MSOTESTVOL103a-vSAMP12_base_module-0_vol”, + “modelInfo”: { + “modelType”: “volumeGroup” + } + } + }, + { + “relatedInstance”: { + “instanceId”: “{serviceInstanceId}”, + “modelInfo”: { + “modelType”: “service”, + “modelInvariantId”: “ff3514e3-5a33-55df-13ab-12abad84e7ff”, + “modelVersionId”: “fe6985cd-ea33-3346-ac12-ab121484a3fe”, + “modelName”: “{parent service model name}”, + "modelVersion": "1.0" + } + } + }, + { + “relatedInstance”: { + “instanceId”: “{vnfInstanceId}”, + "modelInfo": { + “modelType”: “vnf”, + “modelInvariantId”: “ff5256d1-5a33-55df-13ab-12abad84e7ff”, + “modelVersionId”: “fe6478e4-ea33-3346-ac12-ab121484a3fe”, + “modelName”: “vSAMP12”, + "modelVersion": "1.0", + “modelCustomizationName”: “vSAMP12 1”, + “modelCustomizationId”: “a7f1d08e-b02d-11e6-80f5-76304dec7eb7” + } + } + } + ], + “requestParameters”: { + “usePreload”: true, + “userParams”: [] + } + } +} + + + */ + +public class VfModuleOrVolumeGroupRequestDetails extends BaseResourceInstantiationRequestDetails { + + 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 relatedInstanceList, + @JsonProperty(value = "requestParameters", required = true) RequestParametersVfModuleOrVolumeGroup requestParameters) + { + super(modelInfo, cloudConfiguration, requestInfo, relatedInstanceList, requestParameters); + } + + public static class RequestParametersVfModuleOrVolumeGroup extends BaseResourceInstantiationRequestDetails.RequestParameters { + @JsonInclude(NON_NULL) private final Boolean usePreload; + + private RequestParametersVfModuleOrVolumeGroup(List userParams, Boolean usePreload, String testApi) { + super(userParams, testApi); + this.usePreload = usePreload; + } + + public Boolean isUsePreload() { + return usePreload; + } + } + + public static class RequestParametersVfModuleOrVolumeGroupInstantiation extends RequestParametersVfModuleOrVolumeGroup { + public RequestParametersVfModuleOrVolumeGroupInstantiation( + List 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 userParams, Boolean usePreload, String testApi, Boolean rebuildVolumeGroups) { + super(userParams, usePreload, testApi); + this.rebuildVolumeGroups = rebuildVolumeGroups; + } + + public Boolean getRebuildVolumeGroups() { + return rebuildVolumeGroups; + } + } + + public static class UserParamMap extends HashMap implements UserParamTypes, Map { + 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 relatedInstanceList, - @JsonProperty(value = "requestParameters", required = true) VfModuleInstantiationRequestDetails.RequestParametersVfModule requestParameters) + @JsonProperty(value = "requestParameters", required = true) RequestParametersVfModuleOrVolumeGroup requestParameters) { super(modelInfo, cloudConfiguration, requestInfo, relatedInstanceList, requestParameters); } -- cgit 1.2.3-korg