From f891e734e3bc0d4b367f893e57b7efb5079d133c Mon Sep 17 00:00:00 2001 From: Rob Daugherty Date: Thu, 15 Nov 2018 15:09:30 -0500 Subject: Accept vCPE vfModuleNames in NB API This affects the vCPE custom flow. You can specify zero or more VF Module names (correlated with the model invariant UUID) in the user parameters, like this: "userParams": [ . . . { "name": "VfModuleNames", "value": [ { "VfModuleModelInvariantUuId": "5366deab-be06-44c7-b4f7-77e657b78b25", "VfModuleName": "VGW:e2:25:25:25:%" } ] } ] Change-Id: I673c04775bf5796079dc0ed19890e73e76820ac0 Issue-ID: SO-1213 Signed-off-by: Rob Daugherty --- .../scripts/DoCreateVnfAndModules.groovy | 39 +++++++++++++++++++--- .../vcpe/scripts/CreateVcpeResCustService.groovy | 36 ++++++++++++++++---- 2 files changed, 63 insertions(+), 12 deletions(-) (limited to 'bpmn/so-bpmn-infrastructure-common/src/main') diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModules.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModules.groovy index d3dbd9107e..31f2977210 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModules.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModules.groovy @@ -121,7 +121,10 @@ class DoCreateVnfAndModules extends AbstractServiceTaskProcessor { } } execution.setVariable("vnfId", vnfId) - + + Map vfModuleNames = execution.getVariable("vfModuleNames") + msoLogger.debug("Incoming vfModuleNames: " + vfModuleNames) + // Set aLaCarte to false execution.setVariable("aLaCarte", false) @@ -140,9 +143,17 @@ class DoCreateVnfAndModules extends AbstractServiceTaskProcessor { rollbackData.put("VNFANDMODULES", "numOfCreatedAddOnModules", "0") execution.setVariable("rollbackData", rollbackData) - sleep (20000) + String delayMS = execution.getVariable("delayMS") + long longDelayMS = 20000; + if (delayMS != null && !delayMS.isEmpty()) { + longDelayMS = Long.parseLong(delayMS); + } + if (longDelayMS > 0) { + msoLogger.debug("Delaying workflow " + longDelayMS + "ms"); + sleep(longDelayMS) + } }catch(BpmnError b){ msoLogger.debug("Rethrowing MSOWorkflowException") throw b @@ -154,7 +165,6 @@ class DoCreateVnfAndModules extends AbstractServiceTaskProcessor { msoLogger.trace("COMPLETED DoCreateVnfAndModules PreProcessRequest Process") } - public void queryCatalogDB (DelegateExecution execution) { execution.setVariable("prefix",Prefix) @@ -162,8 +172,8 @@ class DoCreateVnfAndModules extends AbstractServiceTaskProcessor { msoLogger.trace("STARTED DoCreateVnfAndModules QueryCatalogDB Process") try { VnfResource vnf = null - ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") // if serviceDecomposition is specified, get info from serviceDecomposition + ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") if (serviceDecomposition != null) { msoLogger.debug("Getting Catalog DB data from ServiceDecomposition object: " + serviceDecomposition.toJsonString()) List vnfs = serviceDecomposition.getVnfResources() @@ -211,6 +221,7 @@ class DoCreateVnfAndModules extends AbstractServiceTaskProcessor { } ModuleResource baseVfModule = null + Map vfModuleNames = execution.getVariable("vfModuleNames") for (int i = 0; i < vfModules.size; i++) { msoLogger.debug("handling VF Module ") @@ -225,6 +236,8 @@ class DoCreateVnfAndModules extends AbstractServiceTaskProcessor { execution.setVariable("baseVfModuleLabel", baseVfModuleLabel) String basePersonaModelId = baseVfModuleModelInfoObject.getModelInvariantUuid() execution.setVariable("basePersonaModelId", basePersonaModelId) + String baseVfModuleName = getPredefinedVfModuleName(execution, basePersonaModelId) + execution.setVariable("baseVfModuleName", baseVfModuleName) baseVfModule = vfModule break } @@ -287,6 +300,8 @@ class DoCreateVnfAndModules extends AbstractServiceTaskProcessor { execution.setVariable("addOnVfModuleLabel", addOnVfModuleLabel) String addOnPersonaModelId = addOnVfModuleModelInfoObject.getModelInvariantUuid() execution.setVariable("addOnPersonaModelId", addOnPersonaModelId) + String addOnVfModuleName = getPredefinedVfModuleName(execution, addOnPersonaModelId) + execution.setVariable("addOnVfModuleName", addOnVfModuleName) int addOnInitialCount = addOnModule.getInitialCount() execution.setVariable("initialCount", addOnInitialCount) @@ -463,5 +478,19 @@ class DoCreateVnfAndModules extends AbstractServiceTaskProcessor { msoLogger.trace("Exit createLineOfBusiness") } + public String getPredefinedVfModuleName(DelegateExecution execution, String vfModuleModelInvariantUuid) { + Map vfModuleNames = execution.getVariable("vfModuleNames") + + if (vfModuleNames == null) { + return null + } + + String vfModuleName = vfModuleNames.get(vfModuleModelInvariantUuid) -} \ No newline at end of file + if (vfModuleName != null) { + msoLogger.debug("Using vfModuleName='" + vfModuleName + "' for vfModuleModelInvariantUuid=" + vfModuleModelInvariantUuid) + } + + return vfModuleName + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy index 187189c694..eea784f591 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy @@ -99,7 +99,7 @@ public class CreateVcpeResCustService extends AbstractServiceTaskProcessor { InitializeProcessVariables(execution) //Config Inputs - String aaiDistDelay = UrnPropertiesReader.getVariable("aai.workflowAaiDistributionDelay") + String aaiDistDelay = UrnPropertiesReader.getVariable("aai.workflowAaiDistributionDelay", execution) if (isBlank(aaiDistDelay)) { String msg = "workflowAaiDistributionDelay is null" msoLogger.debug(msg) @@ -211,14 +211,13 @@ public class CreateVcpeResCustService extends AbstractServiceTaskProcessor { def userParams = reqMap.requestDetails?.requestParameters?.userParams Map inputMap = [:] - if (userParams) { + if (userParams) { userParams.each { - userParam -> + userParam -> if ("Customer_Location".equals(userParam?.name)) { Map customerMap = [:] userParam.value.each { param -> - inputMap.put(param.key, param.value) customerMap.put(param.key, param.value) } @@ -240,7 +239,7 @@ public class CreateVcpeResCustService extends AbstractServiceTaskProcessor { param.getClass() , isDebugEnabled) } execution.setVariable("homingModelIds", modelIdLst) - } + } if ("BRG_WAN_MAC_Address".equals(userParam?.name)) { execution.setVariable("brgWanMacAddress", userParam.value) inputMap.put("BRG_WAN_MAC_Address", userParam.value) @@ -249,11 +248,34 @@ public class CreateVcpeResCustService extends AbstractServiceTaskProcessor { execution.setVariable("homingService", userParam.value) execution.setVariable("callHoming", true) inputMap.put("Homing_Solution", userParam.value) - } + } if ("Orchestrator".equalsIgnoreCase(userParam?.name)) { execution.setVariable("orchestrator", userParam.value) inputMap.put("orchestrator", userParam.value) } + if ("VfModuleNames".equals(userParam?.name)) { + utils.log("DEBUG", "VfModuleNames: " + userParam.value.toString(), isDebugEnabled) + def vfModuleNames = [:] + userParam.value.each { + entry -> + String vfModuleModelInvariantUuid = null; + String vfModuleName = null; + entry.each { + param -> + if ("VfModuleModelInvariantUuid".equals(param.key)) { + vfModuleModelInvariantUuid = param.value; + } else if ("VfModuleName".equals(param.key)) { + vfModuleName = param.value; + } + } + + if (vfModuleModelInvariantUuid != null && !vfModuleModelInvariantUuid.isEmpty() && vfModuleName != null && !vfModuleName.isEmpty()) { + vfModuleNames.put(vfModuleModelInvariantUuid, vfModuleName) + utils.log("DEBUG", "VfModuleModelInvariantUuid: " + vfModuleModelInvariantUuid + " VfModuleName: " + vfModuleName, isDebugEnabled) + } + } + execution.setVariable("vfModuleNames", vfModuleNames) + } } } @@ -263,7 +285,7 @@ public class CreateVcpeResCustService extends AbstractServiceTaskProcessor { } msoLogger.debug("User Input Parameters map: " + userParams.toString()) - execution.setVariable("serviceInputParams", inputMap) + execution.setVariable("serviceInputParams", inputMap) // DOES NOT SEEM TO BE USED msoLogger.debug("Incoming brgWanMacAddress is: " + execution.getVariable('brgWanMacAddress')) -- cgit 1.2.3-korg