summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhetengjiao <hetengjiao@chinamobile.com>2020-05-13 09:47:41 +0800
committerHE TENGJIAO <hetengjiao@chinamobile.com>2020-05-13 10:30:31 +0000
commitbd190c64e89ffbcbfa7b02d9140650c08d555ef9 (patch)
tree253999482e92231411d98be3b29b4497da87b6cc
parente19e22cceef71e01f64f83eec9c438f42a81e412 (diff)
Change bpmn for NSMF to adpte the interface OOF
Issue-ID: SO-2919 Change-Id: I07619e47b4e15f12326f83f5ca3b716fd15871a6 Signed-off-by: hetengjiao <hetengjiao@chinamobile.com>
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy51
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy4
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy41
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy125
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy104
-rw-r--r--bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateSliceService.bpmn8
-rw-r--r--bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteSliceService.bpmn5
7 files changed, 142 insertions, 196 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy
index 40d76af0ba..8f4dbf7ed0 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy
@@ -24,8 +24,6 @@ package org.onap.so.bpmn.common.scripts
import com.fasterxml.jackson.databind.ObjectMapper
import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
-import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.onap.so.bpmn.common.util.OofInfraUtils
import org.onap.so.bpmn.core.UrnPropertiesReader
import org.onap.so.bpmn.core.domain.HomingSolution
@@ -37,26 +35,12 @@ import org.onap.so.bpmn.core.domain.ServiceInstance
import org.onap.so.bpmn.core.domain.Subscriber
import org.onap.so.bpmn.core.domain.VnfResource
import org.onap.so.bpmn.core.json.JsonUtils
-import org.onap.so.client.HttpClient
-import org.onap.so.client.HttpClientFactory
import org.onap.so.db.catalog.beans.CloudSite
import org.onap.so.db.catalog.beans.HomingInstance
-import org.onap.logging.filter.base.ONAPComponents;
-import org.springframework.http.HttpEntity
-import org.springframework.http.HttpHeaders
-import org.springframework.http.HttpMethod
-import org.springframework.http.ResponseEntity
-import org.springframework.http.client.BufferingClientHttpRequestFactory
-import org.springframework.http.client.HttpComponentsClientHttpRequestFactory
-import org.springframework.web.client.RestTemplate
-import org.springframework.web.util.UriComponentsBuilder
import org.slf4j.Logger
import org.slf4j.LoggerFactory
-import javax.ws.rs.core.MediaType
-import javax.ws.rs.core.Response
import javax.ws.rs.core.UriBuilder
-import javax.xml.ws.http.HTTPException
import static org.onap.so.bpmn.common.scripts.GenericUtils.*
@@ -330,7 +314,7 @@ class OofUtils {
logger.debug( "Completed Building OOF Request")
return request
} catch (Exception ex) {
- logger.debug( "buildRequest Exception: " + ex)
+ logger.debug( "buildRequest Exception: " + ex)
}
}
@@ -548,10 +532,41 @@ class OofUtils {
" \"callbackUrl\": \"${callbackUrl}\"\n" +
" },\n")
response.append(" \"serviceProfile\": {\n" +
- " \"serviceProfileParameters\": \n")
+ " \"serviceProfileParameters\": ")
response.append(json);
response.append("\n }\n")
response.append("\n}\n")
return response.toString()
}
+
+ public String buildSelectNSIRequest(String requestId, String nstInfo, Map<String, Object> profileInfo){
+
+ def transactionId = requestId
+ logger.debug( "transactionId is: " + transactionId)
+ String callbackUrl = "http://0.0.0.0:9000/callback/"
+ ObjectMapper objectMapper = new ObjectMapper();
+ String json = objectMapper.writeValueAsString(profileInfo);
+ StringBuilder response = new StringBuilder();
+ response.append(
+ "{\n" +
+ " \"requestInfo\": {\n" +
+ " \"transactionId\": \"${transactionId}\",\n" +
+ " \"requestId\": \"${requestId}\",\n" +
+ " \"sourceId\": \"so\",\n" +
+ " \"timeout\": 600,\n" +
+ " \"callbackUrl\": \"${callbackUrl}\"\n" +
+ " },\n" +
+ " \"serviceInfo\": {\n" +
+ " \"serviceInstanceId\": \"\",\n" +
+ " \"serviceName\": \"\"\n" +
+ " },\n" +
+ " \"NSTInfoList\": [\n")
+ response.append(nstInfo);
+ response.append("\n ],\n")
+ response.append("\n \"serviceProfile\": \n")
+ response.append(json);
+ response.append("\n }\n")
+ return response.toString()
+ }
+
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy
index 12aa0434ea..ba7483d007 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy
@@ -349,7 +349,7 @@ public class CreateSliceService extends AbstractServiceTaskProcessor {
String orchStatus = execution.getVariable("orchestrationStatus")
try {
- ServiceInstance si = execution.getVariable("serviceInstanceData")
+ ServiceInstance si = new ServiceInstance()
si.setOrchestrationStatus(orchStatus)
AAIResourcesClient client = new AAIResourcesClient()
AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId)
@@ -375,7 +375,7 @@ public class CreateSliceService extends AbstractServiceTaskProcessor {
String result = "processing"
String progress = "0"
String reason = ""
- String operationContent = "Prepare service creation"
+ String operationContent = "NSMF creation operation start"
logger.debug("Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId)
serviceId = UriUtils.encode(serviceId,"UTF-8")
execution.setVariable("serviceInstanceId", serviceId)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy
index d5b554d841..b75fa6715d 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy
@@ -1,31 +1,25 @@
package org.onap.so.bpmn.infrastructure.scripts
-import com.google.common.reflect.TypeToken
-import com.google.gson.Gson
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.onap.aai.domain.yang.AllottedResource
import org.onap.aai.domain.yang.Relationship
import org.onap.aai.domain.yang.RelationshipList
import org.onap.aai.domain.yang.ServiceInstance
import org.onap.so.beans.nsmf.SliceTaskParams
import org.onap.so.bpmn.common.scripts.ExceptionUtil
+import org.onap.so.bpmn.common.scripts.NssmfAdapterUtils
import org.onap.so.bpmn.core.domain.ServiceDecomposition
import org.onap.so.bpmn.core.domain.ServiceProxy
import org.onap.so.bpmn.core.json.JsonUtils
import org.onap.so.client.aai.AAIObjectType
import org.onap.so.client.aai.AAIResourcesClient
-import org.onap.so.client.aai.entities.AAIEdgeLabel
import org.onap.so.client.aai.entities.AAIResultWrapper
import org.onap.so.client.aai.entities.uri.AAIResourceUri
import org.onap.so.client.aai.entities.uri.AAIUriFactory
-import org.onap.so.db.request.client.RequestsDbClient
-import org.onap.so.db.request.beans.OrchestrationTask
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import javax.ws.rs.NotFoundException
-import javax.ws.rs.core.UriBuilder
import static org.apache.commons.lang3.StringUtils.isBlank
@@ -36,7 +30,8 @@ class DoAllocateNSIandNSSI extends org.onap.so.bpmn.common.scripts.AbstractServi
ExceptionUtil exceptionUtil = new ExceptionUtil()
JsonUtils jsonUtil = new JsonUtils()
- RequestsDbClient requestsDbClient = new RequestsDbClient()
+
+ private NssmfAdapterUtils nssmfAdapterUtils = new NssmfAdapterUtils(httpClientFactory, jsonUtil)
/**
* Pre Process the BPMN Flow Request
@@ -65,8 +60,9 @@ class DoAllocateNSIandNSSI extends org.onap.so.bpmn.common.scripts.AbstractServi
SliceTaskParams sliceParams = execution.getVariable("sliceTaskParams")
try
{
- String modelUuid = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs.nstar0_allottedresource0_providing_service_uuid")
- String modelInvariantUuid = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs.nstar0_allottedresource0_providing_service_invariant_uuid")
+ Map<String, Object> nstSolution = execution.getVariable("nstSolution") as Map
+ String modelUuid = nstSolution.get("UUID")
+ String modelInvariantUuid = nstSolution.get("invariantUUID")
String serviceModelInfo = """{
"modelInvariantUuid":"${modelInvariantUuid}",
"modelUuid":"${modelUuid}",
@@ -105,7 +101,7 @@ class DoAllocateNSIandNSSI extends org.onap.so.bpmn.common.scripts.AbstractServi
String nsiServiceInstanceID = sliceParams.getSuggestNsiId()
AAIResourcesClient resourceClient = new AAIResourcesClient()
- AAIResourceUri nsiServiceuri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("serviceType"), nsiServiceInstanceID)
+ AAIResourceUri nsiServiceuri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), nsiServiceInstanceID)
//AAIResourceUri nsiServiceuri = AAIUriFactory.createResourceUri(AAIObjectType.QUERY_ALLOTTED_RESOURCE, execution.getVariable("globalSubscriberId"), execution.getVariable("serviceType"), nsiServiceInstanceID)
try {
@@ -156,7 +152,7 @@ class DoAllocateNSIandNSSI extends org.onap.so.bpmn.common.scripts.AbstractServi
{
try {
AAIResourcesClient resourceClient = new AAIResourcesClient()
- AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("serviceType"), nssiID)
+ AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), nssiID)
AAIResultWrapper wrapper = resourceClient.get(serviceInstanceUri, NotFoundException.class)
Optional<org.onap.aai.domain.yang.ServiceInstance> si = wrapper.asBean(org.onap.aai.domain.yang.ServiceInstance.class)
org.onap.aai.domain.yang.ServiceInstance nssi = si.get()
@@ -179,13 +175,13 @@ class DoAllocateNSIandNSSI extends org.onap.so.bpmn.common.scripts.AbstractServi
}
void createNSIinAAI(DelegateExecution execution) {
- logger.trace("Enter CreateNSIinAAI in DoAllocateNSIandNSSI()")
+ logger.debug("Enter CreateNSIinAAI in DoAllocateNSIandNSSI()")
ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
org.onap.aai.domain.yang.ServiceInstance nsi = new ServiceInstance();
String sliceInstanceId = UUID.randomUUID().toString()
execution.setVariable("sliceInstanceId",sliceInstanceId)
nsi.setServiceInstanceId(sliceInstanceId)
- String sliceInstanceName = "nsi_"+execution.getVariable("serviceInstanceName")
+ String sliceInstanceName = "nsi_"+execution.getVariable("sliceServiceInstanceName")
nsi.setServiceInstanceName(sliceInstanceName)
String serviceType = execution.getVariable("serviceType")
nsi.setServiceType(serviceType)
@@ -202,11 +198,20 @@ class DoAllocateNSIandNSSI extends org.onap.so.bpmn.common.scripts.AbstractServi
//nsi.setEnvironmentContext(snssai)
String serviceRole = "nsi"
nsi.setServiceRole(serviceRole)
+ String msg = ""
try {
AAIResourcesClient client = new AAIResourcesClient()
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), sliceInstanceId)
- client.create(uri, nsi)
+ AAIResourceUri nsiServiceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), sliceInstanceId)
+ client.create(nsiServiceUri, nsi)
+
+ Relationship relationship = new Relationship()
+ logger.info("Creating Allotted resource relationship, nsiServiceUri: " + nsiServiceUri.build().toString())
+ relationship.setRelatedLink(nsiServiceUri.build().toString())
+ AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.ALLOTTED_RESOURCE,
+ execution.getVariable("globalSubscriberId"),execution.getVariable("subscriptionServiceType"),
+ execution.getVariable("sliceServiceInstanceId"), execution.getVariable("allottedResourceId")).relationshipAPI()
+ client.create(allottedResourceUri, relationship)
} catch (BpmnError e) {
throw e
@@ -243,7 +248,7 @@ class DoAllocateNSIandNSSI extends org.onap.so.bpmn.common.scripts.AbstractServi
execution.setVariable("maxIndex",maxIndex)
execution.setVariable('nsiServiceInstanceId',sliceInstanceId)
execution.setVariable("nsiServiceInstanceName",sliceInstanceName)
- logger.trace("Exit CreateNSIinAAI in DoAllocateNSIandNSSI()")
+ logger.debug("Exit CreateNSIinAAI in DoAllocateNSIandNSSI()")
}
void getOneNsstInfo(DelegateExecution execution){
@@ -271,7 +276,7 @@ class DoAllocateNSIandNSSI extends org.onap.so.bpmn.common.scripts.AbstractServi
String domain = jsonUtil.getJsonValue(content, "metadata.domainType")
Map<String, Object> nssiMap = execution.getVariable("nssiMap")
- String servicename = execution.getVariable("serviceInstanceName")
+ String servicename = execution.getVariable("sliceServiceInstanceName")
String nsiname = "nsi_"+servicename
nssiMap.put(domain,"""{
"serviceInstanceId":"",
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy
index d786cb0ba1..9d40274400 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy
@@ -4,7 +4,6 @@ import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
import org.onap.aai.domain.yang.ServiceInstance
import org.onap.aai.domain.yang.SliceProfile
-import org.onap.logging.filter.base.ONAPComponents
import org.onap.so.beans.nsmf.AllocateAnNssi
import org.onap.so.beans.nsmf.AllocateCnNssi
import org.onap.so.beans.nsmf.AllocateTnNssi
@@ -19,18 +18,15 @@ import org.onap.so.beans.nsmf.PerfReq
import org.onap.so.beans.nsmf.PerfReqEmbbList
import org.onap.so.beans.nsmf.PerfReqUrllcList
import org.onap.so.beans.nsmf.ResourceSharingLevel
-import org.onap.so.beans.nsmf.ServiceProfile
import org.onap.so.beans.nsmf.SliceTaskParams
import org.onap.so.beans.nsmf.TnSliceProfile
import org.onap.so.beans.nsmf.UeMobilityLevel
import org.onap.so.bpmn.common.scripts.ExceptionUtil
+import org.onap.so.bpmn.common.scripts.NssmfAdapterUtils
import org.onap.so.bpmn.core.RollbackData
-import org.onap.so.bpmn.core.UrnPropertiesReader
import org.onap.so.bpmn.core.domain.ModelInfo
import org.onap.so.bpmn.core.domain.ServiceDecomposition
import org.onap.so.bpmn.core.json.JsonUtils
-import org.onap.so.client.HttpClient
-import org.onap.so.client.HttpClientFactory
import org.onap.so.client.aai.AAIObjectType
import org.onap.so.client.aai.AAIResourcesClient
import org.onap.so.client.aai.entities.AAIEdgeLabel
@@ -39,7 +35,6 @@ import org.onap.so.client.aai.entities.uri.AAIUriFactory
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import com.fasterxml.jackson.databind.ObjectMapper;
-import javax.ws.rs.core.Response
import static org.apache.commons.lang3.StringUtils.isBlank
@@ -53,6 +48,8 @@ class DoAllocateNSSI extends org.onap.so.bpmn.common.scripts.AbstractServiceTask
JsonUtils jsonUtil = new JsonUtils()
+ private NssmfAdapterUtils nssmfAdapterUtils = new NssmfAdapterUtils(httpClientFactory, jsonUtil)
+
/**
* Pre Process the BPMN Flow Request
* Inclouds:
@@ -155,134 +152,78 @@ class DoAllocateNSSI extends org.onap.so.bpmn.common.scripts.AbstractServiceTask
void sendUpdateRequestNSSMF(DelegateExecution execution) {
- logger.trace("Enter sendUpdateRequestNSSMF in DoAllocateNSSI()")
- String urlString = UrnPropertiesReader.getVariable("mso.adapters.nssmf.endpoint", execution)
- logger.debug( "get NSSMF: " + urlString)
-
- //Prepare auth for NSSMF - Begin
- def authHeader = ""
- String basicAuth = UrnPropertiesReader.getVariable("mso.nssmf.auth", execution)
+ logger.debug("Enter sendUpdateRequestNSSMF in DoAllocateNSSI()")
String domain = execution.getVariable("nsstDomain")
String nssmfRequest = buildUpdateNSSMFRequest(execution, domain.toUpperCase())
- //send request to update NSSI option - Begin
- URL url = new URL(urlString+"/api/rest/provMns/v1/NSS/SliceProfiles")
- HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.EXTERNAL)
- Response httpResponse = httpClient.post(nssmfRequest)
-
- int responseCode = httpResponse.getStatus()
- logger.debug("NSSMF sync response code is: " + responseCode)
-
- if(responseCode < 199 && responseCode > 299){
- String nssmfResponse ="NSSMF response have nobody"
- if(httpResponse.hasEntity())
- nssmfResponse = httpResponse.readEntity(String.class)
- logger.trace("received error message from NSSMF : "+nssmfResponse)
- logger.trace("Exit sendCreateRequestNSSMF in DoAllocateNSSI()")
- exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from NSSMF.")
- }
+ String urlString = "/api/rest/provMns/v1/NSS/SliceProfiles"
+
+ String nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, nssmfRequest)
- if(httpResponse.hasEntity()){
- String nssmfResponse = httpResponse.readEntity(String.class)
+ if (nssmfResponse != null) {
execution.setVariable("nssmfResponse", nssmfResponse)
String nssiId = jsonUtil.getJsonValue(nssmfResponse, "nssiId")
String jobId = jsonUtil.getJsonValue(nssmfResponse, "jobId")
execution.setVariable("nssiId",nssiId)
execution.setVariable("jobId",jobId)
- }else{
- exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from NSSMF.")
+
+ } else {
+ logger.error("received error message from NSSMF : "+ nssmfResponse)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.")
}
logger.trace("Exit sendUpdateRequestNSSMF in DoAllocateNSSI()")
}
void sendCreateRequestNSSMF(DelegateExecution execution) {
- logger.trace("Enter sendCreateRequestNSSMF in DoAllocateNSSI()")
- String urlString = UrnPropertiesReader.getVariable("mso.adapters.nssmf.endpoint", execution)
- logger.debug( "get NSSMF: " + urlString)
-
+ logger.debug("Enter sendCreateRequestNSSMF in DoAllocateNSSI()")
//Prepare auth for NSSMF - Begin
String domain = execution.getVariable("nsstDomain")
String nssmfRequest = buildCreateNSSMFRequest(execution, domain.toUpperCase())
- //send request to get NSI option - Begin
- URL url = new URL(urlString+"/api/rest/provMns/v1/NSS/SliceProfiles")
- HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.EXTERNAL)
- Response httpResponse = httpClient.post(nssmfRequest)
-
- int responseCode = httpResponse.getStatus()
- logger.debug("NSSMF sync response code is: " + responseCode)
-
- if(responseCode < 199 || responseCode > 299 ){
- String nssmfResponse ="NSSMF response have nobody"
- if(httpResponse.hasEntity())
- nssmfResponse = httpResponse.readEntity(String.class)
- logger.trace("received error message from NSSMF : "+nssmfResponse)
- logger.trace("Exit sendCreateRequestNSSMF in DoAllocateNSSI()")
- exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from NSSMF.")
- }
+ String urlString = "/api/rest/provMns/v1/NSS/SliceProfiles"
+
+ String nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, nssmfRequest)
- if(httpResponse.hasEntity()){
- String nssmfResponse = httpResponse.readEntity(String.class)
+ if (nssmfResponse != null) {
execution.setVariable("nssmfResponse", nssmfResponse)
String nssiId = jsonUtil.getJsonValue(nssmfResponse, "nssiId")
String jobId = jsonUtil.getJsonValue(nssmfResponse, "jobId")
execution.setVariable("nssiId",nssiId)
execution.setVariable("jobId",jobId)
- }else{
- exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from NSSMF.")
+
+ } else {
+ logger.error("received error message from NSSMF : "+ nssmfResponse)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.")
}
- logger.trace("Exit sendCreateRequestNSSMF in DoAllocateNSSI()")
+ logger.debug("Exit sendCreateRequestNSSMF in DoAllocateNSSI()")
}
void getNSSMFProgresss(DelegateExecution execution) {
- logger.trace("Enter getNSSMFProgresss in DoAllocateNSSI()")
-
- String endpoint = UrnPropertiesReader.getVariable("mso.adapters.nssmf.endpoint", execution)
- logger.debug( "get NSSMF: " + endpoint)
-
- //Prepare auth for NSSMF - Begin
- def authHeader = ""
- String basicAuth = UrnPropertiesReader.getVariable("mso.nssmf.auth", execution)
+ logger.debug("Enter getNSSMFProgresss in DoAllocateNSSI()")
String nssmfRequest = buildNSSMFProgressRequest(execution)
- String strUrl="/api/rest/provMns/v1/NSS/jobs/"+execution.getVariable("jobId")
- //send request to update NSSI option - Begin
- URL url = new URL(endpoint+strUrl)
- HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.EXTERNAL)
- Response httpResponse = httpClient.post(nssmfRequest)
-
- int responseCode = httpResponse.getStatus()
- logger.debug("NSSMF sync response code is: " + responseCode)
-
- if(responseCode < 199 || responseCode > 299){
- String nssmfResponse ="NSSMF response have nobody"
- if(httpResponse.hasEntity())
- nssmfResponse = httpResponse.readEntity(String.class)
- logger.trace("received error message from NSSMF : "+nssmfResponse)
- logger.trace("Exit sendCreateRequestNSSMF in DoAllocateNSSI()")
- exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from NSSMF.")
- }
+ String strUrl="/api/rest/provMns/v1/NSS/jobs/" + execution.getVariable("jobId")
+
+ String nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, strUrl, nssmfRequest)
- if(httpResponse.hasEntity()){
- String nssmfResponse = httpResponse.readEntity(String.class)
+ if(nssmfResponse != null){
Boolean isNSSICreated = false
execution.setVariable("nssmfResponse", nssmfResponse)
- Integer progress = java.lang.Integer.parseInt(jsonUtil.getJsonValue(nssmfResponse, "responseDescriptor.progress"))
+ Integer progress = Integer.parseInt(jsonUtil.getJsonValue(nssmfResponse, "responseDescriptor.progress"))
String status = jsonUtil.getJsonValue(nssmfResponse, "responseDescriptor.status")
String statusDescription = jsonUtil.getJsonValue(nssmfResponse, "responseDescriptor.statusDescription")
execution.setVariable("nssmfProgress",progress)
execution.setVariable("nssmfStatus",status)
execution.setVariable("nddmfStatusDescription",statusDescription)
- if(progress>99)
+ if(progress > 99)
isNSSICreated = true
execution.setVariable("isNSSICreated",isNSSICreated)
-
- }else{
- exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from NSSMF.")
+ } else {
+ logger.error("received error message from NSSMF : "+ nssmfResponse)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.")
}
- logger.trace("Exit getNSSMFProgresss in DoAllocateNSSI()")
-
+ logger.debug("Exit getNSSMFProgresss in DoAllocateNSSI()")
}
void updateRelationship(DelegateExecution execution) {
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy
index 8d8e97328d..c7015de3d7 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy
@@ -21,7 +21,6 @@ package org.onap.so.bpmn.infrastructure.scripts
import com.fasterxml.jackson.databind.ObjectMapper
import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.onap.logging.filter.base.ONAPComponents
import org.onap.so.beans.nsmf.DeAllocateNssi
import org.onap.so.beans.nsmf.EsrInfo
import org.onap.so.beans.nsmf.JobStatusRequest
@@ -31,22 +30,18 @@ import org.onap.so.beans.nsmf.NssiDeAllocateRequest
import org.onap.so.beans.nsmf.NssiResponse
import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.onap.so.bpmn.common.scripts.ExceptionUtil
+import org.onap.so.bpmn.common.scripts.NssmfAdapterUtils
import org.onap.so.bpmn.common.scripts.RequestDBUtil
-import org.onap.so.bpmn.core.UrnPropertiesReader
import org.onap.so.bpmn.core.domain.ServiceArtifact
import org.onap.so.bpmn.core.domain.ServiceDecomposition
import org.onap.so.bpmn.core.json.JsonUtils
-import org.onap.so.client.HttpClient
-import org.onap.so.client.HttpClientFactory
import org.onap.so.client.aai.AAIObjectType
-import org.onap.so.client.aai.AAIResourcesClient
import org.onap.so.client.aai.entities.uri.AAIResourceUri
import org.onap.so.client.aai.entities.uri.AAIUriFactory
import org.onap.so.db.request.beans.OperationStatus
import org.slf4j.Logger
import org.slf4j.LoggerFactory
-import javax.ws.rs.core.Response
class DoDeallocateNSSI extends AbstractServiceTaskProcessor
@@ -56,6 +51,8 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor
private ExceptionUtil exceptionUtil = new ExceptionUtil()
private JsonUtils jsonUtil = new JsonUtils()
private RequestDBUtil requestDBUtil = new RequestDBUtil()
+ private NssmfAdapterUtils nssmfAdapterUtils = new NssmfAdapterUtils(httpClientFactory, jsonUtil)
+
private static final Logger LOGGER = LoggerFactory.getLogger( DoDeallocateNSSI.class)
@Override
@@ -103,7 +100,7 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor
* get vendor Info
* @param execution
*/
- void processDecomposition(DelegateExecution execution) {
+ void processDecomposition(DelegateExecution execution) {
LOGGER.debug("*****${PREFIX} start processDecomposition *****")
try {
@@ -150,26 +147,21 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor
deAllocateRequest.setEsrInfo(getEsrInfo(currentNSSI))
ObjectMapper mapper = new ObjectMapper()
- String json = mapper.writeValueAsString(deAllocateRequest)
-
- //Prepare auth for NSSMF - Begin
- String nssmfRequest = UrnPropertiesReader.getVariable("mso.adapters.nssmf.endpoint", execution)
- nssmfRequest = nssmfRequest + String.format("/api/rest/provMns/v1/NSS/SliceProfiles/%s",profileId)
- //nssmfRequest = nssmfRequest + String.format(NssmfAdapterUtil.NSSMI_DEALLOCATE_URL,profileId)
- //send request to active NSSI TN option
- URL url = new URL(nssmfRequest)
- LOGGER.info("deallocate nssmfRequest:${nssmfRequest}, reqBody: ${json}")
-
- HttpClient httpClient = getHttpClientFactory().newJsonClient(url, ONAPComponents.EXTERNAL)
- Response httpResponse = httpClient.post(json)
- checkNssmfResponse(httpResponse, execution)
-
- NssiResponse nssmfResponse = httpResponse.readEntity(NssiResponse.class)
- currentNSSI['jobId']= nssmfResponse.getJobId() ?: ""
- currentNSSI['jobProgress'] = 0
- execution.setVariable("currentNSSI", currentNSSI)
-
- LOGGER.debug("*****${PREFIX} Exit sendRequestToNSSMF *****")
+ String nssmfRequest = mapper.writeValueAsString(deAllocateRequest)
+
+ String urlStr = String.format("/api/rest/provMns/v1/NSS/SliceProfiles/%s",profileId)
+
+ NssiResponse nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlStr, nssmfRequest, NssiResponse.class)
+ if (nssmfResponse != null) {
+ currentNSSI['jobId']= nssmfResponse.getJobId() ?: ""
+ currentNSSI['jobProgress'] = 0
+ execution.setVariable("currentNSSI", currentNSSI)
+
+ LOGGER.debug("*****${PREFIX} Exit sendRequestToNSSMF *****")
+ } else {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Received a Bad Response from NSSMF.")
+ }
+
}
/**
@@ -189,48 +181,36 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor
jobStatusRequest.setEsrInfo(getEsrInfo(currentNSSI))
ObjectMapper mapper = new ObjectMapper()
- String json = mapper.writeValueAsString(jobStatusRequest)
-
- //Prepare auth for NSSMF - Begin
- String nssmfRequest = UrnPropertiesReader.getVariable("mso.adapters.nssmf.endpoint", execution)
- nssmfRequest = nssmfRequest + String.format("/api/rest/provMns/v1/NSS/jobs/%s",jobId)
- //send request to active NSSI TN option
- URL url = new URL(nssmfRequest)
- LOGGER.info("get deallocate job status, nssmfRequest:${nssmfRequest}, requestBody: ${json}")
-
- HttpClient httpClient = getHttpClientFactory().newJsonClient(url, ONAPComponents.EXTERNAL)
- Response httpResponse = httpClient.post(json)
- checkNssmfResponse(httpResponse, execution)
-
- JobStatusResponse jobStatusResponse = httpResponse.readEntity(JobStatusResponse.class)
- def progress = jobStatusResponse?.getResponseDescriptor()?.getProgress()
- if(!progress)
- {
- LOGGER.error("job progress is null or empty!")
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Received a Bad Job progress from NSSMF.")
- }
- int oldProgress = currentNSSI['jobProgress']
- int currentProgress = progress
+ String nssmfRequest = mapper.writeValueAsString(jobStatusRequest)
- execution.setVariable("isNSSIDeAllocated", (currentProgress == 100))
- execution.setVariable("isNeedUpdateDB", (oldProgress != currentProgress))
- currentNSSI['jobProgress'] = currentProgress
+ String urlStr = String.format("/api/rest/provMns/v1/NSS/jobs/%s", jobId)
- def statusDescription = jobStatusResponse?.getResponseDescriptor()?.getStatusDescription()
- currentNSSI['statusDescription'] = statusDescription
+ JobStatusResponse jobStatusResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlStr, nssmfRequest, JobStatusResponse.class)
- LOGGER.debug("job status result: nsiId = ${nsiId}, nssiId=${nssiId}, oldProgress=${oldProgress}, progress = ${currentProgress}" )
- }
+ if (jobStatusResponse != null) {
+ def progress = jobStatusResponse?.getResponseDescriptor()?.getProgress()
+ if(!progress)
+ {
+ LOGGER.error("job progress is null or empty!")
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Received a Bad Job progress from NSSMF.")
+ }
+ int oldProgress = currentNSSI['jobProgress']
+ int currentProgress = progress
+
+ execution.setVariable("isNSSIDeAllocated", (currentProgress == 100))
+ execution.setVariable("isNeedUpdateDB", (oldProgress != currentProgress))
+ currentNSSI['jobProgress'] = currentProgress
- private void checkNssmfResponse(Response httpResponse, DelegateExecution execution) {
- int responseCode = httpResponse.getStatus()
- LOGGER.debug("NSSMF response code is: " + responseCode)
+ def statusDescription = jobStatusResponse?.getResponseDescriptor()?.getStatusDescription()
+ currentNSSI['statusDescription'] = statusDescription
- if ( responseCode < 200 || responseCode > 204 || !httpResponse.hasEntity()) {
- exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Response from NSSMF.")
+ LOGGER.debug("job status result: nsiId = ${nsiId}, nssiId=${nssiId}, oldProgress=${oldProgress}, progress = ${currentProgress}" )
+
+ } else {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Received a Bad Response from NSSMF.")
}
- }
+ }
private EsrInfo getEsrInfo(def currentNSSI)
{
diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateSliceService.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateSliceService.bpmn
index cb12c307fb..f27794a389 100644
--- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateSliceService.bpmn
+++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateSliceService.bpmn
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1wio50w" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.1.2">
+<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1wio50w" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.4.1">
<bpmn:process id="CreateSliceService" name="CreateSliceService" isExecutable="true">
<bpmn:startEvent id="StartEvent_1nbljfd" name="Create Slice Service Creation Flow">
<bpmn:outgoing>SequenceFlow_03s744c</bpmn:outgoing>
@@ -369,6 +369,7 @@ css.sendSyncResponse(execution)</bpmn:script>
<camunda:out source="rollbackData" target="rollbackData" />
<camunda:out source="rolledBack" target="rolledBack" />
<camunda:in source="allottedResourceId" target="allottedResourceId" />
+ <camunda:in source="nstSolution" target="nstSolution" />
</bpmn:extensionElements>
<bpmn:incoming>SequenceFlow_1bevt3a</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_0mlrlbv</bpmn:outgoing>
@@ -435,6 +436,10 @@ css.sendSyncResponse(execution)</bpmn:script>
<camunda:in source="globalSubscriberId" target="globalSubscriberId" />
<camunda:in source="subscriptionServiceType" target="subscriptionServiceType" />
<camunda:in source="serviceType" target="serviceType" />
+ <camunda:in source="nstSolution" target="nstSolution" />
+ <camunda:out source="sliceProfileTn" target="sliceProfileTn" />
+ <camunda:out source="sliceProfileCn" target="sliceProfileCn" />
+ <camunda:out source="sliceProfileAn" target="sliceProfileAn" />
</bpmn:extensionElements>
<bpmn:incoming>SequenceFlow_1ey6m1e</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_1aaozcg</bpmn:outgoing>
@@ -802,4 +807,3 @@ css.updateAAIOrchStatus(execution)</bpmn:script>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
-
diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteSliceService.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteSliceService.bpmn
index 6d9df5240d..d84dc35d15 100644
--- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteSliceService.bpmn
+++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteSliceService.bpmn
@@ -143,14 +143,15 @@ dss.prepareEndOperationStatus(execution)</bpmn:script>
<bpmn:extensionElements>
<camunda:connector>
<camunda:inputOutput>
- <camunda:inputParameter name="url">${CVFMI_dbAdapterEndpoint}</camunda:inputParameter>
+ <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter>
<camunda:inputParameter name="headers">
<camunda:map>
<camunda:entry key="content-type">application/soap+xml</camunda:entry>
<camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry>
</camunda:map>
</camunda:inputParameter>
- <camunda:inputParameter name="payload">${CVFMI_updateServiceOperStatusRequest}</camunda:inputParameter>
+ <camunda:inputParameter name="payload">${updateOperationStatus}
+</camunda:inputParameter>
<camunda:inputParameter name="method">POST</camunda:inputParameter>
<camunda:outputParameter name="CVFMI_dbResponseCode">${statusCode}</camunda:outputParameter>
<camunda:outputParameter name="CVFMI_dbResponse">${response}</camunda:outputParameter>