From 17d4e43f11ac66fa1d5cba27894f440fae877818 Mon Sep 17 00:00:00 2001 From: subhash kumar singh Date: Wed, 18 Apr 2018 11:08:23 +0000 Subject: Add resource sequence if config file not defined Add resource sequence if config file not defined Change-Id: I2016c3a58a182be3851bb99e40193f013c24b934 Issue-ID: SO-422 Signed-off-by: subhash kumar singh --- .../scripts/DoCreateResources.groovy | 41 ++++++++++++++++------ .../scripts/DoDeleteResourcesV1.groovy | 35 ++++++++++++++---- 2 files changed, 59 insertions(+), 17 deletions(-) (limited to 'bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp') diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateResources.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateResources.groovy index 8eea0f5b9c..d9080b8942 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateResources.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateResources.groovy @@ -100,25 +100,44 @@ public class DoCreateResources extends AbstractServiceTaskProcessor String serviceModelUUID = execution.getVariable("modelUuid") - List addResourceList = execution.getVariable("addResourceList") - + List addResourceList = execution.getVariable("addResourceList") List networkResourceList = new ArrayList() - //define sequenced resource list, we deploy vf first and then network and then ar - //this is defaule sequence List sequencedResourceList = new ArrayList() def resourceSequence = BPMNProperties.getResourceSequenceProp() - for (resourceType in resourceSequence) { - for (resource in addResourceList) { - if (StringUtils.containsIgnoreCase(resource.getModelInfo().getModelName(), resourceType)) { - sequencedResourceList.add(resource) + if(resourceSequence != null) { + // sequence is defined in config file + for (resourceType in resourceSequence) { + for (resource in addResourceList) { + if (StringUtils.containsIgnoreCase(resource.getModelInfo().getModelName(), resourceType)) { + sequencedResourceList.add(resource) - if (resource instanceof NetworkResource) { - networkResourceList.add(resource) + if (resource instanceof NetworkResource) { + networkResourceList.add(resource) + } } } } + } else { + + //define sequenced resource list, we deploy vf first and then network and then ar + //this is defaule sequence + List vnfResourceList = new ArrayList() + List arResourceList = new ArrayList() + + for (Resource rc : addResourceList){ + if (rc instanceof VnfResource) { + vnfResourceList.add(rc) + } else if (rc instanceof NetworkResource) { + networkResourceList.add(rc) + } else if (rc instanceof AllottedResource) { + arResourceList.add(rc) + } + } + sequencedResourceList.addAll(vnfResourceList) + sequencedResourceList.addAll(networkResourceList) + sequencedResourceList.addAll(arResourceList) } String isContainsWanResource = networkResourceList.isEmpty() ? "false" : "true" @@ -156,7 +175,7 @@ public class DoCreateResources extends AbstractServiceTaskProcessor } public void prepareResourceRecipeRequest(DelegateExecution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") utils.log("INFO", "======== Start prepareResourceRecipeRequest Process ======== ", isDebugEnabled) ResourceInput resourceInput = new ResourceInput() String serviceInstanceName = execution.getVariable("serviceInstanceName") diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteResourcesV1.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteResourcesV1.groovy index 690738b312..6e19a3469a 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteResourcesV1.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteResourcesV1.groovy @@ -32,11 +32,13 @@ import org.openecomp.mso.bpmn.common.resource.ResourceRequestBuilder import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor import org.openecomp.mso.bpmn.common.scripts.CatalogDbUtils import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil +import org.openecomp.mso.bpmn.core.domain.AllottedResource import org.openecomp.mso.bpmn.core.domain.ModelInfo import org.openecomp.mso.bpmn.core.domain.NetworkResource import org.openecomp.mso.bpmn.core.domain.Resource import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition import org.openecomp.mso.bpmn.core.domain.ServiceInstance +import org.openecomp.mso.bpmn.core.domain.VnfResource import org.openecomp.mso.bpmn.core.json.JsonUtils import org.openecomp.mso.bpmn.infrastructure.properties.BPMNProperties @@ -156,16 +158,37 @@ public class DoDeleteResourcesV1 extends AbstractServiceTaskProcessor { def resourceSequence = BPMNProperties.getResourceSequenceProp() - for (resourceType in resourceSequence.reverse()) { - for (resource in delResourceList) { - if (StringUtils.containsIgnoreCase(resource.getModelInfo().getModelName(), resourceType)) { - sequencedResourceList.add(resource) + if(resourceSequence != null) { + for (resourceType in resourceSequence.reverse()) { + for (resource in delResourceList) { + if (StringUtils.containsIgnoreCase(resource.getModelInfo().getModelName(), resourceType)) { + sequencedResourceList.add(resource) - if (resource instanceof NetworkResource) { - wanResources.add(resource) + if (resource instanceof NetworkResource) { + wanResources.add(resource) + } } } } + }else { + //define sequenced resource list, we deploy vf first and then network and then ar + //this is defaule sequence + List vnfResourceList = new ArrayList() + List arResourceList = new ArrayList() + + for (Resource rc : delResourceList) { + if (rc instanceof VnfResource) { + vnfResourceList.add(rc) + } else if (rc instanceof NetworkResource) { + networkResourceList.add(rc) + } else if (rc instanceof AllottedResource) { + arResourceList.add(rc) + } + } + + sequencedResourceList.addAll(arResourceList) + sequencedResourceList.addAll(networkResourceList) + sequencedResourceList.addAll(vnfResourceList) } String isContainsWanResource = wanResources.isEmpty() ? "false" : "true" -- cgit 1.2.3-korg