summaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/main
diff options
context:
space:
mode:
authorIttay Stern <ittay.stern@att.com>2020-02-05 18:51:21 +0200
committerIttay Stern <ittay.stern@att.com>2020-02-06 13:13:47 +0200
commitfe6392bf837d65bee87039545d21944c0e84bbf9 (patch)
tree31bb3a22779f263396ff36d052bc91d845fa3732 /vid-app-common/src/main
parentb4b88310c73f9faa15bbe8ad0ed6213660f6f52c (diff)
vfmodule tenant and region are dictated by parent VNF values
Issue-ID: VID-758 Change-Id: Ie48240442e5b2f858e530858d2e25827e799e4c2 Signed-off-by: Ittay Stern <ittay.stern@att.com>
Diffstat (limited to 'vid-app-common/src/main')
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/VnfCommand.kt28
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/VfModule.java24
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/utils/KotlinUtils.kt4
3 files changed, 50 insertions, 6 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/VnfCommand.kt b/vid-app-common/src/main/java/org/onap/vid/job/command/VnfCommand.kt
index 48ff7b7ac..b008c1306 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/command/VnfCommand.kt
+++ b/vid-app-common/src/main/java/org/onap/vid/job/command/VnfCommand.kt
@@ -12,6 +12,7 @@ import org.onap.vid.model.serviceInstantiation.Vnf
import org.onap.vid.mso.RestMsoImplementation
import org.onap.vid.properties.Features
import org.onap.vid.services.AsyncInstantiationBusinessLogic
+import org.onap.vid.utils.isNotActive
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.beans.factory.config.ConfigurableBeanFactory
import org.springframework.context.annotation.Scope
@@ -59,9 +60,9 @@ class VnfCommand @Autowired constructor(
val vfModules:List<VfModule> = request.vfModules.values.stream().flatMap { vfKey -> vfKey.values.stream() }.collect(Collectors.toList<VfModule>())
try {
- childJobs = pushChildrenJobsToBroker(vfModules.filter { filterModuleByNeedToCreateBase(it) }, dataForChild, JobType.VolumeGroupInstantiation)
+ childJobs = pushChildrenJobsToBroker(vfModulesForChildrenJobs(vfModules), dataForChild, JobType.VolumeGroupInstantiation)
} catch (e: AsdcCatalogException) {
- LOGGER.error(EELFLoggerDelegate.errorLogger, "Failed to retrieve service definitions from SDC, for VfModule is BaseModule.. Error: " + e.message , e)
+ LOGGER.error(EELFLoggerDelegate.errorLogger, "Failed to retrieve service definitions from SDC, for VfModule is BaseModule.. Error: " + e.message, e)
//return Job.JobStatus.FAILED
throw e;
}
@@ -70,11 +71,26 @@ class VnfCommand @Autowired constructor(
return Job.JobStatus.COMPLETED_WITH_NO_ACTION
}
- private fun filterModuleByNeedToCreateBase(it: VfModule):Boolean {
+ private fun vfModulesForChildrenJobs(vfModules: List<VfModule>): List<VfModule> =
+ vfModules
+ .filter { filterModuleByNeedToCreateBase(it) }
+ .map { childVfModuleWithVnfRegionAndTenant(it) }
+
+ internal fun childVfModuleWithVnfRegionAndTenant(vfModule: VfModule): VfModule {
+ if (featureManager.isNotActive(Features.FLAG_2006_VFMODULE_TAKES_TENANT_AND_REGION_FROM_VNF)) {
+ return vfModule
+ }
+
+ val vnfLcpCloudRegionId = getRequest().lcpCloudRegionId
+ val vnfTenantId = getRequest().tenantId
+ return vfModule.cloneWith(vnfLcpCloudRegionId, vnfTenantId)
+ }
+
+ private fun filterModuleByNeedToCreateBase(vfModule: VfModule): Boolean {
return needToCreateBaseModule ==
- commandUtils.isVfModuleBaseModule(
- serviceModelInfoFromRequest().modelVersionId,
- it.modelInfo.modelVersionId)
+ commandUtils.isVfModuleBaseModule(
+ serviceModelInfoFromRequest().modelVersionId,
+ vfModule.modelInfo.modelVersionId)
}
override fun planCreateMyselfRestCall(commandParentData: CommandParentData, request: JobAdapter.AsyncJobRequest, userId: String, testApi: String?): MsoRestCallPlan {
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 0b9a2a7b7..79ea7f147 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
@@ -140,4 +140,28 @@ public class VfModule extends BaseResource implements JobAdapter.AsyncJobRequest
this.getOriginalName()
);
}
+
+ public VfModule cloneWith(String lcpCloudRegionId, String tenantId) {
+ return new VfModule(
+ this.getModelInfo(),
+ this.getInstanceName(),
+ this.getVolumeGroupInstanceName(),
+ this.getAction().toString(),
+ lcpCloudRegionId,
+ lcpCloudRegionId,
+ tenantId,
+ this.getInstanceParams(),
+ this.getSupplementaryParams(),
+ this.isRollbackOnFailure(),
+ this.isUsePreload(),
+ this.getInstanceId(),
+ this.getTrackById(),
+ this.getIsFailed(),
+ this.getStatusMessage(),
+ this.isRetainAssignments(),
+ this.isRetainVolumeGroups(),
+ this.getPosition(),
+ this.getOriginalName()
+ );
+ }
} \ No newline at end of file
diff --git a/vid-app-common/src/main/java/org/onap/vid/utils/KotlinUtils.kt b/vid-app-common/src/main/java/org/onap/vid/utils/KotlinUtils.kt
index 81afe29e0..83077f28c 100644
--- a/vid-app-common/src/main/java/org/onap/vid/utils/KotlinUtils.kt
+++ b/vid-app-common/src/main/java/org/onap/vid/utils/KotlinUtils.kt
@@ -23,11 +23,15 @@ package org.onap.vid.utils
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import org.apache.commons.lang3.StringUtils.isEmpty
+import org.togglz.core.Feature
+import org.togglz.core.manager.FeatureManager
inline fun <reified E: Enum<E>> getEnumFromMapOfStrings(map: Map<String, Any>, key:String, defaultValue:E): E {
return java.lang.Enum.valueOf(E::class.java, (map.getOrDefault(key, defaultValue.name) as String))
}
+fun FeatureManager.isNotActive(feature: Feature) = this.isActive(feature).not()
+
@JvmField val JACKSON_OBJECT_MAPPER: ObjectMapper = jacksonObjectMapper()
class JoshworksJacksonObjectMapper: io.joshworks.restclient.http.mapper.ObjectMapper {