aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'vid-app-common/src/main')
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/VnfCommand.kt7
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/VfModule.java14
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/properties/Features.java2
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/utils/KotlinUtils.kt12
4 files changed, 34 insertions, 1 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 9023682f6..016c66cca 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
@@ -8,10 +8,12 @@ import org.onap.vid.job.impl.JobSharedData
import org.onap.vid.model.Action
import org.onap.vid.model.serviceInstantiation.BaseResource
import org.onap.vid.model.serviceInstantiation.VfModule
+import org.onap.vid.model.serviceInstantiation.VfModule.PauseInstantiation
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.takeUntilIncluding
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.beans.factory.config.ConfigurableBeanFactory
import org.springframework.context.annotation.Scope
@@ -71,9 +73,14 @@ class VnfCommand @Autowired constructor(
private fun vfModulesForChildrenJobs(vfModules: List<VfModule>): List<VfModule> =
vfModules
+ .takeUntilIncluding { shoudlPauseAfterInstantiation(it) }
.filter { filterModuleByNeedToCreateBase(it) }
.map { childVfModuleWithVnfRegionAndTenant(it) }
+ fun shoudlPauseAfterInstantiation(vfModule: VfModule) =
+ (vfModule.action == Action.Create && vfModule.pauseInstantiation == PauseInstantiation.afterCompletion
+ && featureManager.isActive(Features.FLAG_2006_PAUSE_VFMODULE_INSTANTIATION_CREATION))
+
internal fun childVfModuleWithVnfRegionAndTenant(vfModule: VfModule): VfModule {
if (!shouldEntailRegionAndTenantToVfModule(vfModule)) {
return vfModule
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 79ea7f147..46d4de800 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
@@ -49,6 +49,9 @@ public class VfModule extends BaseResource implements JobAdapter.AsyncJobRequest
private final Boolean retainVolumeGroups;
@JsonInclude(NON_NULL)
+ private final PauseInstantiation pauseInstantiation;
+
+ @JsonInclude(NON_NULL)
private Boolean retainAssignments;
public VfModule(@JsonProperty("modelInfo") ModelInfo modelInfo,
@@ -69,6 +72,7 @@ public class VfModule extends BaseResource implements JobAdapter.AsyncJobRequest
@Nullable @JsonProperty("retainAssignments") Boolean retainAssignments,
@Nullable @JsonProperty("retainVolumeGroups") Boolean retainVolumeGroups,
@JsonProperty("position") Integer position,
+ @JsonProperty("pauseInstantiation") PauseInstantiation pauseInstantiation,
@JsonProperty("originalName") String originalName) {
super(modelInfo, instanceName, action, lcpCloudRegionId, legacyRegion, tenantId, instanceParams, rollbackOnFailure, instanceId, trackById, isFailed, statusMessage,
position, originalName);
@@ -77,6 +81,7 @@ public class VfModule extends BaseResource implements JobAdapter.AsyncJobRequest
this.supplementaryParams = supplementaryParams;
this.retainAssignments = retainAssignments;
this.retainVolumeGroups = retainVolumeGroups;
+ this.pauseInstantiation = pauseInstantiation;
}
public String getVolumeGroupInstanceName() {
@@ -88,6 +93,10 @@ public class VfModule extends BaseResource implements JobAdapter.AsyncJobRequest
return usePreload;
}
+ public enum PauseInstantiation {
+ afterCompletion
+ }
+
public List<UserParamNameAndValue> getSupplementaryParams() {
return supplementaryParams;
}
@@ -117,6 +126,9 @@ public class VfModule extends BaseResource implements JobAdapter.AsyncJobRequest
return retainVolumeGroups;
}
+ @Nullable
+ public PauseInstantiation getPauseInstantiation() {return pauseInstantiation;}
+
public VfModule cloneWith(ModelInfo modelInfo) {
return new VfModule(
modelInfo,
@@ -137,6 +149,7 @@ public class VfModule extends BaseResource implements JobAdapter.AsyncJobRequest
this.isRetainAssignments(),
this.isRetainVolumeGroups(),
this.getPosition(),
+ this.getPauseInstantiation(),
this.getOriginalName()
);
}
@@ -161,6 +174,7 @@ public class VfModule extends BaseResource implements JobAdapter.AsyncJobRequest
this.isRetainAssignments(),
this.isRetainVolumeGroups(),
this.getPosition(),
+ this.getPauseInstantiation(),
this.getOriginalName()
);
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/properties/Features.java b/vid-app-common/src/main/java/org/onap/vid/properties/Features.java
index a83ca47b2..c8c4c73e3 100644
--- a/vid-app-common/src/main/java/org/onap/vid/properties/Features.java
+++ b/vid-app-common/src/main/java/org/onap/vid/properties/Features.java
@@ -95,7 +95,7 @@ public enum Features implements Feature {
FLAG_2006_VNF_LOB_MULTI_SELECT,
FLAG_2006_NEW_VIEW_EDIT_BUTTON_IN_INSTANTIATION_STATUS,
FLAG_2006_PORT_MIRRORING_LET_SELECTING_SOURCE_SUBSCRIBER,
-
+ FLAG_2006_PAUSE_VFMODULE_INSTANTIATION_CREATION,
FLAG_GUILIN_CONFIG_PORTAL_APP_PASSWORD,
;
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 83077f28c..35871856e 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
@@ -25,6 +25,7 @@ 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
+import java.util.*
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))
@@ -46,3 +47,14 @@ class JoshworksJacksonObjectMapper: io.joshworks.restclient.http.mapper.ObjectMa
@JvmField val JOSHWORKS_JACKSON_OBJECT_MAPPER:
io.joshworks.restclient.http.mapper.ObjectMapper = JoshworksJacksonObjectMapper()
+
+fun <T> Iterable<T>.takeUntilIncluding(predicate: (T) -> Boolean): List<T> {
+ val list = ArrayList<T>()
+ for (item in this) {
+ list.add(item)
+ if (predicate(item)) {
+ break
+ }
+ }
+ return list
+} \ No newline at end of file