From d9fb2fbfa7f8c6b481bc8553f3035395f687664a Mon Sep 17 00:00:00 2001 From: hyu2010 Date: Mon, 21 Dec 2020 10:37:26 -0500 Subject: Fixes for bugs found in Transport Slicing integration This update contains for the fixes for the following JIRAs: SO-3429: Transport Slicing integration: fix resource operation status table mapping SO-3434: Transport Slicing integration: modelUuid and modelInvariantUuid are missing from service-instance Issue-ID: SO-3429 Issue-ID: SO-3434 Signed-off-by: hyu2010 Change-Id: I7a9b7b7a3e40d967c138067a01f2c045fb3e4b56 Signed-off-by: hyu2010 --- .../infrastructure/scripts/DoActivateTnNssi.groovy | 13 ++++-------- .../scripts/DoCreateTnNssiInstance.groovy | 13 ++++++++---- .../scripts/DoDeallocateTnNssi.groovy | 16 ++++++--------- .../infrastructure/scripts/TnAllocateNssi.groovy | 2 +- .../infrastructure/scripts/TnNssmfUtils.groovy | 24 +++++++++++++++++++++- .../subprocess/DoAllocateTransportNSSI.bpmn | 2 +- .../subprocess/DoDeallocateTransportNSSI.bpmn | 2 +- 7 files changed, 45 insertions(+), 27 deletions(-) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssi.groovy index 05996d3671..37e3df1505 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssi.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssi.groovy @@ -142,20 +142,15 @@ public class DoActivateTnNssi extends AbstractServiceTaskProcessor { String status, String progress, String statusDescription) { - String serviceId = execution.getVariable("sliceServiceInstanceId") + String ssInstanceId = execution.getVariable("sliceServiceInstanceId") + String modelUuid = execution.getVariable("modelUuid") String jobId = execution.getVariable("jobId") String nsiId = execution.getVariable("nsiId") String operType = execution.getVariable("actionType") + ResourceOperationStatus roStatus = tnNssmfUtils.buildRoStatus(modelUuid, ssInstanceId, + jobId, nsiId, operType, status, progress, statusDescription) - ResourceOperationStatus roStatus = new ResourceOperationStatus() - roStatus.setServiceId(serviceId) - roStatus.setOperationId(jobId) - roStatus.setResourceTemplateUUID(nsiId) - roStatus.setOperType(operType) - roStatus.setProgress(progress) - roStatus.setStatus(status) - roStatus.setStatusDescription(statusDescription) requestDBUtil.prepareUpdateResourceOperationStatus(execution, roStatus) } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy index 4eb70a5302..0b028e6c13 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy @@ -34,6 +34,8 @@ import org.onap.so.bpmn.core.json.JsonUtils import org.slf4j.Logger import org.slf4j.LoggerFactory +import static org.apache.commons.lang3.StringUtils.isBlank + class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { private static final Logger logger = LoggerFactory.getLogger(DoCreateTnNssiInstance.class); @@ -109,15 +111,18 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { org.onap.aai.domain.yang.ServiceInstance ss = new org.onap.aai.domain.yang.ServiceInstance() ss.setServiceInstanceId(ssInstanceId) String sliceInstanceName = execution.getVariable("sliceServiceInstanceName") + if (isBlank(sliceInstanceName)) { + logger.error("ERROR: createServiceInstance: sliceInstanceName is null") + sliceInstanceName = ssInstanceId + } ss.setServiceInstanceName(sliceInstanceName) ss.setServiceType(serviceType) - String serviceStatus = "activated" + String serviceStatus = "deactivated" ss.setOrchestrationStatus(serviceStatus) String modelInvariantUuid = execution.getVariable("modelInvariantUuid") String modelUuid = execution.getVariable("modelUuid") - //TODO: need valid model ID from the caller, as AAI does not accept invalid IDs - //ss.setModelInvariantId(modelInvariantUuid) - //ss.setModelVersionId(modelUuid) + ss.setModelInvariantId(modelInvariantUuid) + ss.setModelVersionId(modelUuid) String serviceInstanceLocationid = tnNssmfUtils.getFirstPlmnIdFromSliceProfile(sliceProfileStr) ss.setServiceInstanceLocationId(serviceInstanceLocationid) String snssai = tnNssmfUtils.getFirstSnssaiFromSliceProfile(sliceProfileStr) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy index c817eaad61..a8622b9253 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy @@ -25,7 +25,6 @@ import groovy.json.JsonSlurper import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.ServiceInstance -import org.onap.aaiclient.client.aai.AAIObjectType import org.onap.aaiclient.client.aai.AAIResourcesClient import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory @@ -150,18 +149,15 @@ class DoDeallocateTnNssi extends AbstractServiceTaskProcessor { String status, String progress, String statusDescription) { - String serviceId = execution.getVariable("sliceServiceInstanceId") + String ssInstanceId = execution.getVariable("sliceServiceInstanceId") + String modelUuid = execution.getVariable("modelUuid") String jobId = execution.getVariable("jobId") String nsiId = execution.getVariable("nsiId") - ResourceOperationStatus roStatus = new ResourceOperationStatus() - roStatus.setServiceId(serviceId) - roStatus.setOperationId(jobId) - roStatus.setResourceTemplateUUID(nsiId) - roStatus.setOperType("Deallocate") - roStatus.setProgress(progress) - roStatus.setStatus(status) - roStatus.setStatusDescription(statusDescription) + ResourceOperationStatus roStatus = tnNssmfUtils.buildRoStatus(modelUuid, ssInstanceId, + jobId, nsiId, "deallocate", status, progress, statusDescription) + + logger.debug("DoDeallocateTnNssi: roStatus={}", roStatus) requestDBUtil.prepareUpdateResourceOperationStatus(execution, roStatus) } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy index 88db2161f7..deeec94b74 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy @@ -72,7 +72,7 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor { String additionalPropJsonStr = execution.getVariable("sliceParams") - String tnNssiId = execution.getVariable("serviceInstanceID") + String tnNssiId = jsonUtil.getJsonValue(additionalPropJsonStr, "serviceInstanceID") //for debug if (isBlank(tnNssiId)) { tnNssiId = UUID.randomUUID().toString() } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy index d97f416db9..cfee1aa0cf 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy @@ -32,6 +32,7 @@ import org.onap.so.bpmn.core.RollbackData import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.db.request.beans.ResourceOperationStatus import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -122,7 +123,7 @@ class TnNssmfUtils { } String sdncRequest = - """ @@ -332,4 +333,25 @@ class TnNssmfUtils { createRelationShipInAAI(execution, aaiResourceUri, relationship) } + + ResourceOperationStatus buildRoStatus(String nsstId, + String nssiId, + String jobId, + String nsiId, + String action, + String status, + String progress, + String statusDescription) { + ResourceOperationStatus roStatus = new ResourceOperationStatus() + roStatus.setResourceTemplateUUID(nsstId) + roStatus.setResourceInstanceID(nssiId) + roStatus.setServiceId(nsiId) + roStatus.setOperationId(jobId) + roStatus.setOperType(action) + roStatus.setProgress(progress) + roStatus.setStatus(status) + roStatus.setStatusDescription(statusDescription) + + return roStatus + } } diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateTransportNSSI.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateTransportNSSI.bpmn index 4f83c872a1..f3bd700d9a 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateTransportNSSI.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateTransportNSSI.bpmn @@ -164,7 +164,7 @@ css.prepareOofSelection(execution) SequenceFlow_0n4xku8 SequenceFlow_0kixzdj import org.onap.so.bpmn.infrastructure.scripts.* -execution.setVariable("orchestrationStatus", "activated") +execution.setVariable("orchestrationStatus", "deactivated") def runScript = new TnAllocateNssi() runScript.updateAAIOrchStatus(execution) diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeallocateTransportNSSI.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeallocateTransportNSSI.bpmn index bd759caffd..9dbc9909fc 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeallocateTransportNSSI.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeallocateTransportNSSI.bpmn @@ -29,7 +29,7 @@ ex.processJavaException(execution) SequenceFlow_1jygjln SequenceFlow_1qv8qw1 import org.onap.so.bpmn.infrastructure.scripts.* -def runScript = new TnAllocateNssi() +def runScript = new DoDeallocateTnNssi() runScript.prepareUpdateJobStatus(execution,"finished","100","Deallocated TN NSSI successfully") -- cgit 1.2.3-korg