summaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/main/java/org/onap
diff options
context:
space:
mode:
authorIttay Stern <ittay.stern@att.com>2019-10-30 17:44:28 +0200
committerIttay Stern <ittay.stern@att.com>2019-10-31 12:13:49 +0200
commit9a5f618f84142930a9955fc555033c765d308186 (patch)
tree5b727f85e4288b13a304f0d93bb21bfd139cd40a /vid-app-common/src/main/java/org/onap
parent2faaef3c1c05fcef0cbcda7f77f6c173826e57b6 (diff)
Backend's vfModule upgrade: test refinement + code fix
Now using modelCustomizationName to map each module from existing service-model to target's service-model. Issue-ID: VID-603 Change-Id: Ie6a2584b6f9d0aa835e8f2ddff4a3ab9d80ef434 Signed-off-by: Ittay Stern <ittay.stern@att.com>
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/VfmoduleCommand.kt61
1 files changed, 8 insertions, 53 deletions
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 276b00e6f..25373d4ac 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
@@ -78,23 +78,6 @@ class VfmoduleCommand @Autowired constructor(
return false
}
- private fun planReplaceMyselfRestCall3(commandParentData: CommandParentData, request: JobAdapter.AsyncJobRequest, userId: String, testApi: String?): MsoRestCallPlan {
- val serviceInstanceId = commandParentData.getInstanceId(CommandParentData.CommandDataKey.SERVICE_INSTANCE_ID)
- val serviceModelInfo = commandParentData.getModelInfo(CommandParentData.CommandDataKey.SERVICE_MODEL_INFO)
- val vnfModelInfo = commandParentData.getModelInfo(CommandParentData.CommandDataKey.VNF_MODEL_INFO)
- val vnfInstanceId = commandParentData.getInstanceId(CommandParentData.CommandDataKey.VNF_INSTANCE_ID)
- val replacePath = asyncInstantiationBL.getVfModuleReplacePath(serviceInstanceId, vnfInstanceId, getRequest().instanceId)
-
- amendModelInfoWithNewestModel(serviceModelInfo, vnfModelInfo, (request as VfModule).modelInfo)
-
- val requestDetailsWrapper = msoRequestBuilder.generateVfModuleInstantiationRequest(
- request as VfModule, serviceModelInfo, serviceInstanceId,vnfModelInfo, vnfInstanceId,null,userId, testApi)
-
- val actionDescription = "replace vfmodule ${request.instanceId}"
-
- return MsoRestCallPlan(HttpMethod.POST, replacePath, Optional.of(requestDetailsWrapper), Optional.of(userId), actionDescription)
- }
-
private fun planReplaceMyselfRestCall(commandParentData: CommandParentData): MsoRestCallPlan {
val newestModel = fetchNewestServiceModel()
@@ -139,19 +122,21 @@ class VfmoduleCommand @Autowired constructor(
private fun newestVfmModelInfo(newestModel: ServiceModel): ModelInfo? {
val vfmModelInfo = getRequest().modelInfo
- val newestVfm = selectVfm(newestModel, vfmModelInfo)
- return toModelInfo(newestVfm)
+ val matchingVfms = selectVfms(newestModel, vfmModelInfo)
+ return toModelInfo(matchingVfms.getOrNull(0))
}
private fun newestVnfModelInfo(newestModel: ServiceModel, commandParentData: CommandParentData): ModelInfo? {
val vnfModelInfo = commandParentData.getModelInfo(CommandParentData.CommandDataKey.VNF_MODEL_INFO)
- val newestVnf = selectVnf(newestModel, vnfModelInfo)
- return toModelInfo(newestVnf)
+ val matchingVnfs = selectVnfs(newestModel, vnfModelInfo)
+ return toModelInfo(matchingVnfs.getOrNull(0))
}
- private fun selectVfm(newestModel: ServiceModel, modelInfo: ModelInfo) = newestModel.vfModules[modelInfo.modelCustomizationId]
+ private fun selectVfms(newestModel: ServiceModel, modelInfo: ModelInfo) =
+ newestModel.vfModules.values.filter { it.modelCustomizationName == modelInfo.modelCustomizationName }
- private fun selectVnf(newestModel: ServiceModel, modelInfo: ModelInfo) = newestModel.vnfs[modelInfo.modelCustomizationId]
+ private fun selectVnfs(newestModel: ServiceModel, modelInfo: ModelInfo) =
+ newestModel.vnfs.values.filter { it.modelCustomizationName == modelInfo.modelCustomizationName }
private fun toModelInfo(toBeConverted: VNF?): ModelInfo? = toBeConverted?.let { toModelInfo(it, "vnf") }
@@ -192,42 +177,12 @@ class VfmoduleCommand @Autowired constructor(
targetModelInfo.modelVersionId = toBeConverted.uuid
targetModelInfo.modelInvariantId = toBeConverted.invariantUuid
targetModelInfo.modelVersion = toBeConverted.version
- //targetModelInfo.modelCustomizationId = toBeConverted.customizationUuid
- //targetModelInfo.modelCustomizationName = toBeConverted.modelCustomizationName
targetModelInfo.modelType = "service"
targetModelInfo.modelName = toBeConverted.name
return targetModelInfo
}
- private fun amendModelInfoWithNewestModel(serviceModelInfo: ModelInfo, vnfModelInfo: ModelInfo, vfmModelInfo: ModelInfo) {
- val newestModel = fetchNewestServiceModel()
- val newestService = newestModel.service
-
- val newestVfm = newestModel.vfModules[vfmModelInfo.modelCustomizationId]
- val newestVnf = newestModel.vnfs[vnfModelInfo.modelCustomizationId]
-
- if (!(newestService == null || newestVnf == null || newestVfm == null)) {
-
- serviceModelInfo.modelName = newestService.name
- serviceModelInfo.modelVersionId = newestService.uuid
- serviceModelInfo.modelVersion = newestService.version
-
- vnfModelInfo.modelName = newestVnf.name
- vnfModelInfo.modelVersionId = newestVnf.uuid
- vnfModelInfo.modelVersion = newestVnf.version
- vnfModelInfo.modelCustomizationId = newestVnf.customizationUuid
- vnfModelInfo.modelCustomizationName = newestVnf.modelCustomizationName
-
- vfmModelInfo.modelName = newestVfm.name
- vfmModelInfo.modelVersionId = newestVfm.uuid
- vfmModelInfo.modelVersion = newestVfm.version
- vfmModelInfo.modelCustomizationId = newestVfm.customizationUuid
- vfmModelInfo.modelCustomizationName = newestVfm.modelCustomizationName
- }
- }
-
-
override fun replaceMyself(): Job.JobStatus {
try {
val replaceMyselfCommand = planReplaceMyselfRestCall(commandParentData)