summaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-infrastructure-common/src/main/groovy
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/so-bpmn-infrastructure-common/src/main/groovy')
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CheckServiceProcessStatus.groovy26
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy2
-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.groovy84
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy129
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy136
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy104
7 files changed, 234 insertions, 251 deletions
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CheckServiceProcessStatus.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CheckServiceProcessStatus.groovy
index 3233bfff61..17b37bfd86 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CheckServiceProcessStatus.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CheckServiceProcessStatus.groovy
@@ -128,8 +128,8 @@ class CheckServiceProcessStatus extends AbstractServiceTaskProcessor {
/**
* check service status through request operation id, update operation status
- */
- def preCheckServiceStatusReq = { DelegateExecution execution ->
+ */
+ void preCheckServiceStatusReq(DelegateExecution execution) {
logger.trace(Prefix + "preCheckServiceStatusReq Start")
String serviceInstanceId = execution.getVariable("serviceInstanceId") as String
String operationId = execution.getVariable("operationId") as String
@@ -142,7 +142,7 @@ class CheckServiceProcessStatus extends AbstractServiceTaskProcessor {
* handle service status, if service status is finished or error, set the service status
* @param execution
*/
- def handlerServiceStatusResp = { DelegateExecution execution ->
+ void handlerServiceStatusResp(DelegateExecution execution) {
logger.trace(Prefix + "handlerServiceStatusResp Start")
String msg
try {
@@ -203,7 +203,7 @@ class CheckServiceProcessStatus extends AbstractServiceTaskProcessor {
}
- def timeWaitDelay = { DelegateExecution execution ->
+ void timeWaitDelay(DelegateExecution execution) {
Long startTime = execution.getVariable("startTime") as Long
Long timeOut = execution.getVariable("timeOut") as Long
@@ -221,7 +221,7 @@ class CheckServiceProcessStatus extends AbstractServiceTaskProcessor {
}
- private handlerTimeOut = { DelegateExecution execution ->
+ private handlerTimeOut(DelegateExecution execution) {
Map<String, Object> paramMap = execution.getVariable("timeOutParamMap") as Map
@@ -229,7 +229,7 @@ class CheckServiceProcessStatus extends AbstractServiceTaskProcessor {
}
- private handlerSuccess = { DelegateExecution execution, String result ->
+ private handlerSuccess(DelegateExecution execution, String result) {
Map<String, Object> paramMap = execution.getVariable("successParamMap") as Map
@@ -237,7 +237,7 @@ class CheckServiceProcessStatus extends AbstractServiceTaskProcessor {
}
- private handlerError = { DelegateExecution execution, String result ->
+ private handlerError(DelegateExecution execution, String result) {
Map<String, Object> paramMap = execution.getVariable("errorParamMap") as Map
@@ -245,7 +245,7 @@ class CheckServiceProcessStatus extends AbstractServiceTaskProcessor {
}
- private handlerProcess = { DelegateExecution execution, String result, def paramMap, def status, def msg ->
+ private handlerProcess(DelegateExecution execution, String result, def paramMap, def status, def msg) {
if (paramMap != null) {
for (Map.Entry<String, Object> entry : paramMap.entrySet()) {
@@ -260,7 +260,7 @@ class CheckServiceProcessStatus extends AbstractServiceTaskProcessor {
if (isBlank(execution.getVariable("operationContent") as String)) {
- String operationContent = execution.getVariable("processServiceType") + " " +
+ String operationContent = execution.getVariable("processServiceType") + " " +
execution.getVariable("operationType") + " operation finished " + msg
execution.setVariable("operationContent", operationContent)
}
@@ -275,7 +275,7 @@ class CheckServiceProcessStatus extends AbstractServiceTaskProcessor {
/**
* judge if the service processing success finished
*/
- private isSuccessCompleted = { DelegateExecution execution, String result ->
+ private Boolean isSuccessCompleted(DelegateExecution execution, String result) {
//successConditions: processing end success conditions
List<String> successConditions = execution.getVariable("successConditions") as List
@@ -291,7 +291,7 @@ class CheckServiceProcessStatus extends AbstractServiceTaskProcessor {
/**
* judge if the service processing error finished
*/
- private isErrorCompleted = { DelegateExecution execution, String result ->
+ private Boolean isErrorCompleted(DelegateExecution execution, String result) {
//errorConditions: processing end error conditions
List<String> errorConditions = execution.getVariable("errorConditions") as List
@@ -304,7 +304,7 @@ class CheckServiceProcessStatus extends AbstractServiceTaskProcessor {
}
- def preUpdateOperationProgress = { DelegateExecution execution ->
+ void preUpdateOperationProgress(DelegateExecution execution) {
logger.trace(Prefix + "prepareUpdateOperationStatus Start")
def progress = execution.getVariable("progress") as Integer
@@ -314,7 +314,7 @@ class CheckServiceProcessStatus extends AbstractServiceTaskProcessor {
def resProgress = (initProgress + (endProgress - initProgress) / 100 * progress) as Integer
def operationType = execution.getVariable("operationType")
- def operationContent = execution.getVariable("processServiceType") + " " +
+ def operationContent = execution.getVariable("processServiceType") + " " +
operationType + " operation processing " + resProgress
// update status creating
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy
index 1b9df2cd68..84ff344cb0 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy
@@ -383,7 +383,7 @@ class CreateCommunicationService extends AbstractServiceTaskProcessor {
}
e2eInputMap.put("sNSSAI", execution.getVariable("sNSSAI_id"))
-
+ e2eInputMap.put("sST", execution.getVariable("csServiceType"))
execution.setVariable("e2eInputMap", e2eInputMap)
execution.setVariable("e2eServiceType", e2eServiceDecomposition.getServiceType())
execution.setVariable("e2eModelInvariantUuid", e2eServiceDecomposition.getModelInfo().getModelInvariantUuid())
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..b09bd8b1ae 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,45 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License")
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
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 +50,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 +80,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}",
@@ -95,17 +111,15 @@ class DoAllocateNSIandNSSI extends org.onap.so.bpmn.common.scripts.AbstractServi
}
void updateRelationship(DelegateExecution execution) {
- logger.trace("Enter update relationship in DoAllocateNSIandNSSI()")
- String nsiServiceInstanceId = execution.getVariable("nsiServiceInstanceId")
+ logger.debug("Enter update relationship in DoAllocateNSIandNSSI()")
String allottedResourceId = execution.getVariable("allottedResourceId")
//Need to check whether nsi exist : Begin
org.onap.aai.domain.yang.ServiceInstance nsiServiceInstance = new org.onap.aai.domain.yang.ServiceInstance()
SliceTaskParams sliceParams = execution.getVariable("sliceParams")
-
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 {
@@ -120,14 +134,8 @@ class DoAllocateNSIandNSSI extends org.onap.so.bpmn.common.scripts.AbstractServi
// exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service instance was not found in aai to " +
// "associate for service :"+serviceInstanceId)
// }
- }catch(BpmnError e) {
- throw e;
- }catch (Exception ex){
- String msg = "NSI suggested in the option doesn't exist. " + nsiServiceInstanceID
- logger.debug(msg)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
- }
- AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.ALLOTTED_RESOURCE, execution.getVariable("globalSubscriberId"), execution.getVariable("serviceType"), nsiServiceInstanceId, allottedResourceId)
+
+ AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.ALLOTTED_RESOURCE, execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), execution.getVariable("sliceServiceInstanceId"), allottedResourceId)
getAAIClient().connect(allottedResourceUri,nsiServiceuri)
List<String> nssiAssociated = new ArrayList<>()
@@ -144,7 +152,14 @@ class DoAllocateNSIandNSSI extends org.onap.so.bpmn.common.scripts.AbstractServi
}
execution.setVariable("nssiAssociated",nssiAssociated)
execution.setVariable("nsiServiceInstanceName",nsiServiceInstance.getServiceInstanceName())
- logger.trace("Exit update relationship in DoAllocateNSIandNSSI()")
+ }catch(BpmnError e) {
+ throw e
+ }catch (Exception ex){
+ String msg = "NSI suggested in the option doesn't exist. " + nsiServiceInstanceID
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ logger.debug("Exit update relationship in DoAllocateNSIandNSSI()")
}
void prepareNssiModelInfo(DelegateExecution execution){
@@ -156,7 +171,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 +194,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 +217,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 +267,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 +295,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..4ab6647a38 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,138 +152,82 @@ 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) {
- logger.trace("Enter updateRelationship in DoAllocateNSSI()")
+ logger.debug("Enter updateRelationship in DoAllocateNSSI()")
String nssiInstanceId = execution.getVariable("nssiInstanceId")
String nsiInstanceId = execution.getVariable("nsiServiceInstanceId")
try{
@@ -298,7 +239,7 @@ class DoAllocateNSSI extends org.onap.so.bpmn.common.scripts.AbstractServiceTask
logger.info(msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
}
- logger.trace("Exit updateRelationship in DoAllocateNSSI()")
+ logger.debug("Exit updateRelationship in DoAllocateNSSI()")
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy
index 303b8c892e..a4b360276d 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy
@@ -66,11 +66,6 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{
void getNSIOptionfromOOF(DelegateExecution execution) {
- //解析sliceProfile
- logger.debug("start parseServiceProfile")
- parseServiceProfile(execution)
- logger.debug("end parseServiceProfile")
-
String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution)
logger.debug( "get NSI option OOF Url: " + urlString)
@@ -120,6 +115,11 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{
Response httpResponse = httpClient.post(oofRequest)
processOOFResponse(httpResponse, execution)
+
+ //解析sliceProfile
+ logger.debug("start parseServiceProfile")
+ parseServiceProfile(execution)
+ logger.debug("end parseServiceProfile")
}
private void processOOFResponse(Response httpResponse, DelegateExecution execution) {
@@ -141,17 +141,15 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{
Map OOFResponseObject = new JsonSlurper().parseText(OOFResponse)
Map solutions = OOFResponseObject.get("solutions")
- Boolean isSharable = false
String resourceSharingLevel = execution.getVariable("resourceSharingLevel")
- if (resourceSharingLevel.equals("shared"))
- isSharable = true
+ Boolean isSharable = resourceSharingLevel.equals("shared")
if (solutions != null) {
if (isSharable) {
//sharedNSISolution
processSharedNSISolutions(solutions, execution)
} else {
- //TODO test OOF don't implement in Frankfurt release
+ //TODO test OOF
if (solutions.containsKey("newNSISolutions")) {
List<Map> newNSISolutions = solutions.get("newNSISolutions")
List<Map> NSSImap = new ArrayList<>()
@@ -185,7 +183,7 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{
}
}
execution.setVariable("sliceTaskParams", sliceTaskParams)
- logger.debug("Info: No NSI suggested by OOF")
+ logger.debug("sliceTaskParams: "+sliceTaskParams.convertToJson())
}
logger.debug("*** Completed options Call to OOF ***")
}
@@ -203,7 +201,7 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{
Map sharedNSIsolution = ((List) solutions.get("sharedNSISolutions")).get(0)
nsiInstanceId = sharedNSIsolution.getOrDefault("NSIId", "")
nsiName = sharedNSIsolution.getOrDefault("NSIName", "")
- sliceTaskParams.setNstId(nsiInstanceId)
+ sliceTaskParams.setSuggestNsiId(nsiInstanceId)
sliceTaskParams.setSuggestNsiName(nsiName)
//Temporary modification
@@ -213,8 +211,9 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{
nssiId = nssi.getOrDefault("NSSIId","")
nssiName = nssi.getOrDefault("NSSIName","")
sliceTaskParams.setCnSuggestNssiId(nssiId)
- sliceTaskParams.setCnSuggestNssiName(nssiName)
+ //TODO Need update after OOF return camel key and domainType
sliceProfile = ((List)nssi.get("sliceProfile"))?.get(0)
+ sliceTaskParams.setCnSuggestNssiName(nssiName)
// execution.setVariable("sliceProfileCn", sliceProfile)
// sliceTaskParams.setSliceProfileCn(sliceProfile)
}
@@ -226,51 +225,90 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{
logger.debug("Start parseServiceProfile")
String serviceType = execution.getVariable("serviceType")
Map<String, Object> serviceProfile = execution.getVariable("serviceProfile")
-
+ SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams")
// set sliceProfile for three domains
- Map<String, Object> sliceProfileTn = getSliceProfile(serviceType, "TN", serviceProfile)
- Map<String, Object> sliceProfileCn = getSliceProfile(serviceType, "CN", serviceProfile)
- Map<String, Object> sliceProfileAn = getSliceProfile(serviceType, "AN", serviceProfile)
+ if(!sliceTaskParams.getSliceProfileAn()){
+ Map<String, Object> sliceProfileAn = getSliceProfile(serviceType, "AN", serviceProfile)
+ execution.setVariable("sliceProfileAn", sliceProfileAn)
+ sliceTaskParams.setSliceProfileAn(sliceProfileAn)
+ logger.debug("sliceProfileAn: " + sliceProfileAn)
+ }
- execution.setVariable("sliceProfileTn", sliceProfileTn)
- execution.setVariable("sliceProfileCn", sliceProfileCn)
- execution.setVariable("sliceProfileAn", sliceProfileAn)
- logger.debug("sliceProfileTn: " + sliceProfileTn)
- logger.debug("sliceProfileCn: " + sliceProfileCn)
- logger.debug("sliceProfileAn: " + sliceProfileAn)
+ if(!sliceTaskParams.getSliceProfileTn()){
+ Map<String, Object> sliceProfileTn = getSliceProfile(serviceType, "TN", serviceProfile)
+ execution.setVariable("sliceProfileTn", sliceProfileTn)
+ sliceTaskParams.setSliceProfileTn(sliceProfileTn)
+ logger.debug("sliceProfileTn: " + sliceProfileTn)
+ }
+
+ if(!sliceTaskParams.getSliceProfileCn()){
+ Map<String, Object> sliceProfileCn = getSliceProfile(serviceType, "CN", serviceProfile)
+ execution.setVariable("sliceProfileCn", sliceProfileCn)
+ sliceTaskParams.setSliceProfileCn(sliceProfileCn)
+ logger.debug("sliceProfileCn: " + sliceProfileCn)
+ }
logger.debug("Finish parseServiceProfile")
}
- Map getSliceProfile(String serviceType, String domain, Map<String, Object> serviceProfile) {
- //String variablePath = "nsmf." + serviceType + ".profileMap" + domain
- //String profileMapStr = UrnPropertiesReader.getVariable(variablePath)
- String profileMapStr = """ {
- "skip_post_instantiation_configuration":"skip_post_instantiation_configuration",
- "controller_actor":"controller_actor",
- "areaTrafficCapDL":"areaTrafficCapDL",
- "maxNumberofUEs":"maxNumberofUEs",
- "latency":"latency",
- "expDataRateUL":"expDataRateUL",
- "sNSSAI":"sNSSAI",
- "plmnIdList":"plmnIdList",
- "sST":"sST",
- "areaTrafficCapUL":"areaTrafficCapUL",
- "uEMobilityLevel":"uEMobilityLevel",
- "expDataRateDL":"expDataRateDL",
- "coverageAreaTAList":"coverageAreaTAList",
- "activityFactor":"activityFactor",
- "resourceSharingLevel":"resourceSharingLevel"
- }
- """.trim().replaceAll(" ", "")
- logger.debug("Profile map for " + domain + " : " + profileMapStr)
- Map<String, String> profileMaps = objectMapper.readValue(profileMapStr, new TypeReference<Map<String, String>>(){})
- Map<String, Object> sliceProfileTn = [:]
+ Map getSliceProfile(String serviceType, String domain, Map<String, Object> serviceProfile) {
+ String profileMapStr
+ Integer domainLatency = (Integer) serviceProfile.get("latency")/3
+
+ switch (domain) {
+ case "AN":
+ profileMapStr = """ {
+ "latency": ${domainLatency},
+ "sNSSAI": "sNSSAI",
+ "uEMobilityLevel": "uEMobilityLevel",
+ "coverageAreaTAList": "coverageAreaTAList",
+ "5QI": 100
+ }
+ """.trim().replaceAll(" ", "")
+ break
+ case "TN":
+ profileMapStr =""" {
+ "latency":${domainLatency},
+ "sNSSAI":"sNSSAI",
+ "e2eLatency":"latency",
+ "bandwidth": 100
+ }
+ """.trim().replaceAll(" ", "")
+ break
+ case "CN":
+ profileMapStr = """ {
+ "areaTrafficCapDL":"areaTrafficCapDL",
+ "maxNumberofUEs":"maxNumberofUEs",
+ "latency":${domainLatency},
+ "expDataRateUL":"expDataRateUL",
+ "sNSSAI":"sNSSAI",
+ "areaTrafficCapUL":"areaTrafficCapUL",
+ "uEMobilityLevel":"uEMobilityLevel",
+ "expDataRateDL":"expDataRateDL",
+ "activityFactor":"activityFactor",
+ "resourceSharingLevel":"resourceSharingLevel"
+ }
+ """.trim().replaceAll(" ", "")
+ break
+ default:
+ break
+ }
+
+ logger.debug("Profile map for " + domain + " : " + profileMapStr)
+ Map<String, Object> profileMaps = objectMapper.readValue(profileMapStr, new TypeReference<Map<String, String>>(){})
+ Map<String, Object> sliceProfile = [:]
for (Map.Entry<String, String> profileMap : profileMaps) {
- sliceProfileTn.put(profileMap.key, serviceProfile.get(profileMap.value))
+ String key = profileMap.key
+ String value = profileMaps.get(key)
+ if(serviceProfile.keySet().contains(value)){
+ sliceProfile.put(key, serviceProfile.get(value))
+ }
+ else{
+ sliceProfile.put(key, profileMaps.get(key))
+ }
}
- return sliceProfileTn
+ return sliceProfile
}
void processDecomposition(DelegateExecution execution){
@@ -279,8 +317,8 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{
ServiceDecomposition serviceDecomposition= execution.getVariable("serviceDecomposition")
SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams")
String nstName = serviceDecomposition.getModelInfo().getModelName()
- sliceTaskParams.setNstName(nstName)
String nstId = serviceDecomposition.getModelInfo().getModelUuid()
+ sliceTaskParams.setNstName(nstName)
sliceTaskParams.setNstId(nstId)
logger.debug("End processDecomposition")
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)
{