aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-infrastructure-common/src
diff options
context:
space:
mode:
authorChuanyu Chen <chenchuanyu@huawei.com>2020-09-18 09:38:48 +0000
committerGerrit Code Review <gerrit@onap.org>2020-09-18 09:38:48 +0000
commit150548c32b0d38d5465f81b8b45923d20bb18f1b (patch)
tree0dad1e5ec8fa49be0ad52241bd4cfbcc77a4d6f9 /bpmn/so-bpmn-infrastructure-common/src
parenta65d2595848132a3241889ca3843b2308f9d0862 (diff)
parent177987a9c3bc89a61e211f0fa31781f7abdc3ce8 (diff)
Merge "Update NSMF workflow to for the E2E Network Slicing requirements"
Diffstat (limited to 'bpmn/so-bpmn-infrastructure-common/src')
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy338
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy887
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSIV2.groovy613
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy733
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSIV2.groovy117
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceInstance.groovy247
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy855
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOptionV2.groovy907
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceServiceTest.groovy39
9 files changed, 1479 insertions, 3257 deletions
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 dcbaf746ea..342fce75a5 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
@@ -2,19 +2,19 @@
* ============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.
+ # Copyright (c) 2020, CMCC Technologies Co., Ltd.
+ #
+ # 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=========================================================
*/
@@ -22,21 +22,22 @@ package org.onap.so.bpmn.infrastructure.scripts
import com.fasterxml.jackson.databind.ObjectMapper
import org.onap.aai.domain.yang.ServiceInstance
-import org.onap.so.client.HttpClient
-import org.onap.so.client.HttpClientFactory
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
-
-import javax.ws.rs.core.Response
+import org.onap.so.beans.nsmf.EsrInfo
+import org.onap.so.beans.nsmf.NssmfAdapterNBIRequest
+import org.onap.so.beans.nsmf.SliceTaskParamsAdapter
+import org.onap.so.beans.nsmf.oof.TemplateInfo
+import org.onap.so.bpmn.common.scripts.NssmfAdapterUtils
+import org.onap.so.bpmn.core.domain.ServiceDecomposition
import static org.apache.commons.lang3.StringUtils.*
import org.springframework.web.util.UriUtils
import groovy.json.JsonSlurper
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.onap.logging.filter.base.ONAPComponents
import org.onap.so.beans.nsmf.SliceTaskParams
import org.onap.so.db.request.beans.OrchestrationTask
import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
@@ -59,8 +60,10 @@ public class CreateSliceService extends AbstractServiceTaskProcessor {
JsonSlurper jsonSlurper = new JsonSlurper()
ObjectMapper objectMapper = new ObjectMapper()
OofUtils oofUtils = new OofUtils()
- private static final Logger logger = LoggerFactory.getLogger(CreateSliceService.class)
+ NssmfAdapterUtils nssmfAdapterUtils = new NssmfAdapterUtils(httpClientFactory, jsonUtil)
+ AAIResourcesClient client = getAAIClient()
+ private static final Logger logger = LoggerFactory.getLogger(CreateSliceService.class)
public void preProcessRequest(DelegateExecution execution) {
logger.debug("Start preProcessRequest")
@@ -150,7 +153,7 @@ public class CreateSliceService extends AbstractServiceTaskProcessor {
logger.debug("User Input Parameters map: " + inputMap.toString())
String uuiRequest = inputMap.get("UUIRequest")
- Map uuiReqMap = jsonSlurper.parseText(uuiRequest)
+ Map uuiReqMap = jsonSlurper.parseText(uuiRequest) as Map
Map<String, Object> serviceObject = (Map<String, Object>) uuiReqMap.get("service")
Map<String, Object> parameterObject = (Map<String, Object>) serviceObject.get("parameters")
Map<String, Object> requestInputs = (Map<String, Object>) parameterObject.get("requestInputs")
@@ -162,7 +165,8 @@ public class CreateSliceService extends AbstractServiceTaskProcessor {
execution.setVariable("serviceInputParams", inputMap)
execution.setVariable("uuiRequest", uuiRequest)
- execution.setVariable("serviceProfile", serviceProfile)
+ execution.setVariable("se" +
+ "rviceProfile", serviceProfile)
//TODO
//execution.setVariable("serviceInputParams", jsonUtil.getJsonValue(siRequest, "requestDetails.requestParameters.userParams"))
@@ -178,76 +182,69 @@ public class CreateSliceService extends AbstractServiceTaskProcessor {
logger.debug("Finish preProcessRequest")
}
- public void prepareSelectNSTRequest(DelegateExecution execution) {
- logger.debug("Start prepareSelectNSTRequest")
- String requestId = execution.getVariable("msoRequestId")
- String messageType = "NSTSelectionResponse"
- Map<String, Object> serviceProfile = execution.getVariable("serviceProfile")
- execution.setVariable("nstSelectionUrl", "/api/oof/v1/selection/nst")
- execution.setVariable("nstSelection_messageType",messageType)
- execution.setVariable("nstSelection_correlator",requestId)
- String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution);
- execution.setVariable("nstSelection_timeout",timeout)
- String oofRequest = oofUtils.buildSelectNSTRequest(requestId,messageType, serviceProfile)
- execution.setVariable("nstSelection_oofRequest",oofRequest)
- logger.debug("Finish prepareSelectNSTRequest")
-
- }
-
- public void processNSTSolutions(DelegateExecution execution) {
- Map<String, Object> nstSolution
- try {
- logger.debug("Start processing NSTSolutions")
- Map<String, Object> resMap = objectMapper.readValue(execution.getVariable("nstSelection_oofResponse"),Map.class)
- List<Map<String, Object>> nstSolutions = (List<Map<String, Object>>) resMap.get("solutions")
- nstSolution = nstSolutions.get(0)
- execution.setVariable("nstSolution", nstSolution)
- } catch (Exception ex) {
- logger.debug( "Failed to get NST solution suggested by OOF.")
- exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Failed to get NST solution suggested by OOF.")
- }
-
- }
-
- public void prepareDecomposeService(DelegateExecution execution) {
- logger.debug("Start prepareDecomposeService")
- String uuiRequest = execution.getVariable("uuiRequest")
- String ssModelInvariantUuid = jsonUtil.getJsonValue(uuiRequest, "service.serviceInvariantUuid")
- String ssModelUuid = jsonUtil.getJsonValue(uuiRequest, "service.serviceUuid")
- String ssServiceModelInfo = """{
- "modelInvariantUuid":"${ssModelInvariantUuid}",
- "modelUuid":"${ssModelUuid}",
- "modelVersion":""
- }"""
- execution.setVariable("ssServiceModelInfo", ssServiceModelInfo)
-
- logger.debug("Finish prepareDecomposeService")
- }
-
- public void processDecomposition(DelegateExecution execution) {
- logger.debug("Start processDecomposition")
- String uuiRequest = execution.getVariable("uuiRequest")
- Map<String, Object> serviceProfile = execution.getVariable("serviceProfile")
- Map<String, Object> nstSolution = execution.getVariable("nstSolution")
-
- Map uuiReqMap = jsonSlurper.parseText(uuiRequest)
- Map<String, Object> serviceObject = (Map<String, Object>) uuiReqMap.get("service")
- String subscriptionServiceType = serviceObject.get("serviceType")
+ /**
+ *
+ * @param execution
+ */
+ public void prepareInitServiceOperationStatus(DelegateExecution execution) {
+ logger.debug("Start prepareInitServiceOperationStatus")
+ try{
+ String serviceId = execution.getVariable("serviceInstanceId")
+ String operationId = execution.getVariable("operationId")
+ String operationType = "CREATE"
+ String userId = execution.getVariable("globalSubscriberId")
+ String result = "processing"
+ String progress = "0"
+ String reason = ""
+ String operationContent = "Prepare service creation"
+ logger.debug("Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId)
+ serviceId = UriUtils.encode(serviceId,"UTF-8")
+ execution.setVariable("serviceInstanceId", serviceId)
+ execution.setVariable("operationType", operationType)
- String serviceType = (String) serviceProfile.get("sST")
- String resourceSharingLevel = (String) serviceProfile.get("resourceSharingLevel")
- String nstModelUuid = (String) nstSolution.get("UUID")
- String nstModelInvariantUuid = (String) nstSolution.get("invariantUUID")
+ def dbAdapterEndpoint = UrnPropertiesReader.getVariable("mso.adapters.openecomp.db.endpoint",execution)
+ execution.setVariable("CSSOS_dbAdapterEndpoint", dbAdapterEndpoint)
+ logger.debug("DB Adapter Endpoint is: " + dbAdapterEndpoint)
+ def dbAdapterAuth = UrnPropertiesReader.getVariable("mso.requestDb.auth")
+ Map<String, String> CSSOS_headerMap = [:]
+ CSSOS_headerMap.put("content-type", "application/soap+xml")
+ CSSOS_headerMap.put("Authorization", dbAdapterAuth)
+ execution.setVariable("CSSOS_headerMap", CSSOS_headerMap)
+ logger.debug("DB Adapter Header is: " + CSSOS_headerMap)
- execution.setVariable("subscriptionServiceType", subscriptionServiceType)
- execution.setVariable("serviceType", serviceType)
- execution.setVariable("resourceSharingLevel", resourceSharingLevel)
- execution.setVariable("nstModelUuid", nstModelUuid)
- execution.setVariable("nstModelInvariantUuid", nstModelInvariantUuid)
+ String payload =
+ """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
+ xmlns:ns="http://org.onap.so/requestsdb">
+ <soapenv:Header/>
+ <soapenv:Body>
+ <ns:initServiceOperationStatus xmlns:ns="http://org.onap.so/requestsdb">
+ <serviceId>${MsoUtils.xmlEscape(serviceId)}</serviceId>
+ <operationId>${MsoUtils.xmlEscape(operationId)}</operationId>
+ <operationType>${MsoUtils.xmlEscape(operationType)}</operationType>
+ <userId>${MsoUtils.xmlEscape(userId)}</userId>
+ <result>${MsoUtils.xmlEscape(result)}</result>
+ <operationContent>${MsoUtils.xmlEscape(operationContent)}</operationContent>
+ <progress>${MsoUtils.xmlEscape(progress)}</progress>
+ <reason>${MsoUtils.xmlEscape(reason)}</reason>
+ </ns:initServiceOperationStatus>
+ </soapenv:Body>
+ </soapenv:Envelope>"""
- logger.debug("Finish processDecomposition")
+ payload = utils.formatXml(payload)
+ execution.setVariable("CSSOS_updateServiceOperStatusRequest", payload)
+ logger.debug("Outgoing updateServiceOperStatusRequest: \n" + payload)
+ }catch(Exception e){
+ logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ "Exception Occured Processing prepareInitServiceOperationStatus.", "BPMN",
+ ErrorCode.UnknownError.getValue(), "Exception is:\n" + e)
+ }
+ logger.debug("Finish prepareInitServiceOperationStatus")
}
+ /**
+ * prepare create OrchestrationTask
+ * @param execution
+ */
public void prepareCreateOrchestrationTask(DelegateExecution execution) {
logger.debug("Start createOrchestrationTask")
String taskId = execution.getBusinessKey()
@@ -265,21 +262,104 @@ public class CreateSliceService extends AbstractServiceTaskProcessor {
execution.setVariable("CSSOT_isManual", isManual)
execution.setVariable("CSSOT_requestMethod", requestMethod)
- Map<String, Object> serviceProfile = execution.getVariable("serviceProfile")
+ Map<String, Object> serviceProfile = execution.getVariable("serviceProfile") as Map<String, Object>
- SliceTaskParams sliceTaskParams = new SliceTaskParams()
+ SliceTaskParamsAdapter sliceTaskParams = new SliceTaskParamsAdapter()
sliceTaskParams.setServiceId(serviceInstanceId)
sliceTaskParams.setServiceName(serviceInstanceName)
sliceTaskParams.setServiceProfile(serviceProfile)
+
execution.setVariable("sliceTaskParams", sliceTaskParams)
- String paramJson = sliceTaskParams.convertToJson()
- execution.setVariable("CSSOT_paramJson", paramJson)
- logger.debug("CSSOT_paramJson: " + paramJson)
+ //todo:----------------------------------------
+// String paramJson = sliceTaskParams.convertToJson()
+// execution.setVariable("CSSOT_paramJson", paramJson)
+ /*-------------------------------------------*/
logger.debug("Finish createOrchestrationTask")
}
+ /**
+ * send sync response to csmf
+ * @param execution
+ */
+ public void sendSyncResponse(DelegateExecution execution) {
+ logger.debug("Start sendSyncResponse")
+ try {
+ String operationId = execution.getVariable("operationId")
+ String serviceInstanceId = execution.getVariable("serviceInstanceId")
+ // RESTResponse for API Handler (APIH) Reply Task
+ String createServiceRestRequest = """
+ {
+ "service": {
+ "serviceId":"${serviceInstanceId}",
+ "operationId":"${operationId}"
+ }
+ }
+ """.trim()
+
+ logger.debug("sendSyncResponse to APIH:" + "\n" + createServiceRestRequest)
+ sendWorkflowResponse(execution, 202, createServiceRestRequest)
+ execution.setVariable("sentSyncResponse", true)
+ } catch (Exception e) {
+ String msg = "Exceptuion in sendSyncResponse:" + e.getMessage()
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ logger.debug("Finish sendSyncResponse")
+ }
+
+ public void prepareSelectNSTRequest(DelegateExecution execution) {
+ logger.debug("Start prepareSelectNSTRequest")
+ String requestId = execution.getVariable("msoRequestId")
+ String messageType = "NSTSelectionResponse"
+ Map<String, Object> serviceProfile = execution.getVariable("serviceProfile") as Map<String, Object>
+ execution.setVariable("nstSelectionUrl", "/api/oof/v1/selection/nst")
+ execution.setVariable("nstSelection_messageType", messageType)
+ execution.setVariable("nstSelection_correlator", requestId)
+ String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution);
+ execution.setVariable("nstSelection_timeout", timeout)
+ String oofRequest = oofUtils.buildSelectNSTRequest(requestId, messageType, serviceProfile)
+ execution.setVariable("nstSelection_oofRequest", oofRequest)
+ logger.debug("Finish prepareSelectNSTRequest")
+
+ }
+
+ /**
+ * process async response of oof, put the {@solutions} at {@nstSolution}
+ * @param execution
+ */
+ public void processNSTSolutions(DelegateExecution execution) {
+ Map<String, Object> nstSolution
+ try {
+ logger.debug("Start processing NSTSolutions")
+ Map<String, Object> resMap =
+ objectMapper.readValue(execution.getVariable("nstSelection_oofResponse") as String,
+ Map.class)
+
+ List<Map<String, Object>> nstSolutions = (List<Map<String, Object>>) resMap.get("solutions")
+ nstSolution = nstSolutions.get(0)
+ execution.setVariable("nstSolution", nstSolution)
+
+ //set nst info into sliceTaskParams
+ SliceTaskParamsAdapter sliceTaskParams =
+ execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
+ TemplateInfo nstInfo = new TemplateInfo()
+ nstInfo.setUUID(nstSolution.get("UUID") as String)
+ nstInfo.setInvariantUUID(nstSolution.get("invariantUUID") as String)
+ nstInfo.setName(nstSolution.get("name") as String)
+
+ sliceTaskParams.setNSTInfo(nstInfo)
+
+ execution.setVariable("sliceTaskParams", sliceTaskParams)
+
+ } catch (Exception ex) {
+ logger.debug( "Failed to get NST solution suggested by OOF.")
+ exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Failed to get NST solution suggested by OOF.")
+ }
+
+ }
+
public void prepareUpdateOrchestrationTask(DelegateExecution execution) {
logger.debug("Start prepareUpdateOrchestrationTask")
String requestMethod = "PUT"
@@ -292,6 +372,7 @@ public class CreateSliceService extends AbstractServiceTaskProcessor {
logger.debug("Finish prepareUpdateOrchestrationTask")
}
+
public void prepareGetUserOptions(DelegateExecution execution) {
logger.debug("Start prepareGetUserOptions")
String requestMethod = "GET"
@@ -325,7 +406,7 @@ public class CreateSliceService extends AbstractServiceTaskProcessor {
String orchStatus = execution.getVariable("orchestrationStatus")
try {
- ServiceInstance si = ServiceInstance si = new ServiceInstance()
+ ServiceInstance si = new ServiceInstance()
si.setOrchestrationStatus(orchStatus)
AAIResourcesClient client = new AAIResourcesClient()
AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId)
@@ -341,61 +422,6 @@ public class CreateSliceService extends AbstractServiceTaskProcessor {
logger.debug("Finish updateAAIOrchStatus")
}
- public void prepareInitServiceOperationStatus(DelegateExecution execution) {
- logger.debug("Start prepareInitServiceOperationStatus")
- try{
- String serviceId = execution.getVariable("serviceInstanceId")
- String operationId = execution.getVariable("operationId")
- String operationType = "CREATE"
- String userId = execution.getVariable("globalSubscriberId")
- String result = "processing"
- String progress = "0"
- String reason = ""
- String operationContent = "Prepare service creation"
- logger.debug("Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId)
- serviceId = UriUtils.encode(serviceId,"UTF-8")
- execution.setVariable("serviceInstanceId", serviceId)
- execution.setVariable("operationType", operationType)
-
- def dbAdapterEndpoint = UrnPropertiesReader.getVariable("mso.adapters.openecomp.db.endpoint",execution)
- execution.setVariable("CSSOS_dbAdapterEndpoint", dbAdapterEndpoint)
- logger.debug("DB Adapter Endpoint is: " + dbAdapterEndpoint)
- def dbAdapterAuth = UrnPropertiesReader.getVariable("mso.requestDb.auth")
- Map<String, String> CSSOS_headerMap = [:]
- CSSOS_headerMap.put("content-type", "application/soap+xml")
- CSSOS_headerMap.put("Authorization", dbAdapterAuth)
- execution.setVariable("CSSOS_headerMap", CSSOS_headerMap)
- logger.debug("DB Adapter Header is: " + CSSOS_headerMap)
-
- String payload =
- """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
- xmlns:ns="http://org.onap.so/requestsdb">
- <soapenv:Header/>
- <soapenv:Body>
- <ns:initServiceOperationStatus xmlns:ns="http://org.onap.so/requestsdb">
- <serviceId>${MsoUtils.xmlEscape(serviceId)}</serviceId>
- <operationId>${MsoUtils.xmlEscape(operationId)}</operationId>
- <operationType>${MsoUtils.xmlEscape(operationType)}</operationType>
- <userId>${MsoUtils.xmlEscape(userId)}</userId>
- <result>${MsoUtils.xmlEscape(result)}</result>
- <operationContent>${MsoUtils.xmlEscape(operationContent)}</operationContent>
- <progress>${MsoUtils.xmlEscape(progress)}</progress>
- <reason>${MsoUtils.xmlEscape(reason)}</reason>
- </ns:initServiceOperationStatus>
- </soapenv:Body>
- </soapenv:Envelope>"""
-
- payload = utils.formatXml(payload)
- execution.setVariable("CSSOS_updateServiceOperStatusRequest", payload)
- logger.debug("Outgoing updateServiceOperStatusRequest: \n" + payload)
- }catch(Exception e){
- logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
- "Exception Occured Processing prepareInitServiceOperationStatus.", "BPMN",
- ErrorCode.UnknownError.getValue(), "Exception is:\n" + e)
- }
- logger.debug("Finish prepareInitServiceOperationStatus")
- }
-
public void prepareUpdateServiceOperationStatus(DelegateExecution execution) {
logger.debug("Start preUpdateServiceOperationStatus")
try{
@@ -438,23 +464,7 @@ public class CreateSliceService extends AbstractServiceTaskProcessor {
logger.debug("Finish preUpdateServiceOperationStatus")
}
- public void sendSyncResponse(DelegateExecution execution) {
- logger.debug("Start sendSyncResponse")
- try {
- String operationId = execution.getVariable("operationId")
- String serviceInstanceId = execution.getVariable("serviceInstanceId")
- // RESTResponse for API Handler (APIH) Reply Task
- String createServiceRestRequest = """{"service":{"serviceId":"${serviceInstanceId}","operationId":"${operationId}"}}""".trim()
- logger.debug("sendSyncResponse to APIH:" + "\n" + createServiceRestRequest)
- sendWorkflowResponse(execution, 202, createServiceRestRequest)
- execution.setVariable("sentSyncResponse", true)
- } catch (Exception e) {
- String msg = "Exceptuion in sendSyncResponse:" + e.getMessage()
- logger.debug(msg)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
- }
- logger.debug("Finish sendSyncResponse")
- }
+
public void prepareCompletionRequest (DelegateExecution execution) {
logger.trace("Start prepareCompletionRequest")
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 4a8469cc8d..c4068d2d5e 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
@@ -2,19 +2,19 @@
* ============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.
+ # Copyright (c) 2020, CMCC Technologies Co., Ltd.
+ #
+ # 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=========================================================
*/
@@ -23,19 +23,29 @@ package org.onap.so.bpmn.infrastructure.scripts
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
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.aai.domain.yang.SliceProfile
import org.onap.aaiclient.client.aai.AAIObjectType
import org.onap.aaiclient.client.aai.AAIResourcesClient
import org.onap.aaiclient.client.aai.entities.AAIResultWrapper
import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri
import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory
+import org.onap.so.beans.nsmf.AllocateAnNssi
+import org.onap.so.beans.nsmf.AllocateCnNssi
+import org.onap.so.beans.nsmf.AllocateTnNssi
+import org.onap.so.beans.nsmf.AnSliceProfile
+import org.onap.so.beans.nsmf.CnSliceProfile
+import org.onap.so.beans.nsmf.EsrInfo
+import org.onap.so.beans.nsmf.NssiResponse
+import org.onap.so.beans.nsmf.NssmfAdapterNBIRequest
+import org.onap.so.beans.nsmf.ResponseDescriptor
+import org.onap.so.beans.nsmf.ServiceInfo
+import org.onap.so.beans.nsmf.SliceTaskInfo
+import org.onap.so.beans.nsmf.SliceTaskParamsAdapter
+import org.onap.so.beans.nsmf.TnSliceProfile
+import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
+import org.onap.so.bpmn.common.scripts.ExceptionUtil
+import org.onap.so.bpmn.core.json.JsonUtils
import org.slf4j.Logger
import org.slf4j.LoggerFactory
@@ -43,15 +53,15 @@ import javax.ws.rs.NotFoundException
import static org.apache.commons.lang3.StringUtils.isBlank
-class DoAllocateNSIandNSSI extends org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor{
+class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{
- private static final Logger logger = LoggerFactory.getLogger( DoAllocateNSIandNSSI.class);
+ private static final Logger logger = LoggerFactory.getLogger(DoAllocateNSIandNSSI.class);
ExceptionUtil exceptionUtil = new ExceptionUtil()
JsonUtils jsonUtil = new JsonUtils()
- private NssmfAdapterUtils nssmfAdapterUtils = new NssmfAdapterUtils(httpClientFactory, jsonUtil)
+ AAIResourcesClient client = getAAIClient()
/**
* Pre Process the BPMN Flow Request
@@ -72,165 +82,77 @@ class DoAllocateNSIandNSSI extends org.onap.so.bpmn.common.scripts.AbstractServi
logger.trace("Exit preProcessRequest")
}
+ /**
+ * Process NSI options
+ * @param execution
+ */
void retriveSliceOption(DelegateExecution execution) {
logger.trace("Enter retriveSliceOption() of DoAllocateNSIandNSSI")
- String uuiRequest = execution.getVariable("uuiRequest")
- boolean isNSIOptionAvailable = false
- List<String> nssiAssociated = new ArrayList<>()
- SliceTaskParams sliceParams = execution.getVariable("sliceTaskParams")
- try
- {
- 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}",
- "modelVersion":""
- }"""
- execution.setVariable("serviceModelInfo", serviceModelInfo)
- //Params sliceParams = new Gson().fromJson(params, new TypeToken<Params>() {}.getType());
- execution.setVariable("sliceParams", sliceParams)
- }catch (Exception ex) {
- logger.debug( "Unable to get the task information from request DB: " + ex)
- exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Unable to get task information from request DB.")
- }
- if(isBlank(sliceParams.getSuggestNsiId()))
- {
- isNSIOptionAvailable=false
- }
- else
- {
- isNSIOptionAvailable=true
- execution.setVariable('nsiServiceInstanceId',sliceParams.getSuggestNsiId())
- execution.setVariable('nsiServiceInstanceName',sliceParams.getSuggestNsiName())
- }
- execution.setVariable("isNSIOptionAvailable",isNSIOptionAvailable)
- logger.trace("Exit retriveSliceOption() of DoAllocateNSIandNSSI")
- }
+ boolean isNSIOptionAvailable
- void updateRelationship(DelegateExecution execution) {
- 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()
+ SliceTaskParamsAdapter sliceParams =
+ execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
- AAIResourcesClient resourceClient = new AAIResourcesClient()
- 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 {
- AAIResultWrapper wrapper = resourceClient.get(nsiServiceuri, NotFoundException.class)
- Optional<org.onap.aai.domain.yang.ServiceInstance> si = wrapper.asBean(org.onap.aai.domain.yang.ServiceInstance.class)
- nsiServiceInstance = si.get()
- //allottedResourceId=nsiServiceInstance.getAllottedResources().getAllottedResource().get(0).getId()
-
-// if(resourceClient.exists(nsiServiceuri)){
-// execution.setVariable("nsi_resourceLink", nsiServiceuri.build().toString())
-// }else{
-// exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service instance was not found in aai to " +
-// "associate for service :"+serviceInstanceId)
-// }
-
- 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<>()
- RelationshipList relationshipList = nsiServiceInstance.getRelationshipList()
- List<Relationship> relationships = relationshipList.getRelationship()
- for(Relationship relationship in relationships)
- {
- if(relationship.getRelatedTo().equalsIgnoreCase("service-instance"))
- {
- String NSSIassociated = relationship.getRelatedLink().substring(relationship.getRelatedLink().lastIndexOf("/") + 1);
- if(!NSSIassociated.equals(nsiServiceInstanceID))
- nssiAssociated.add(NSSIassociated)
- }
+ if(isBlank(sliceParams.getSuggestNsiId())) {
+ isNSIOptionAvailable = false
}
- execution.setVariable("nssiAssociated",nssiAssociated)
- execution.setVariable("nsiServiceInstanceName",nsiServiceInstance.getServiceInstanceName())
- }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)
+ else {
+ isNSIOptionAvailable = true
+ execution.setVariable('nsiServiceInstanceId', sliceParams.getSuggestNsiId())
+ execution.setVariable('nsiServiceInstanceName', sliceParams.getSuggestNsiName())
}
- logger.debug("Exit update relationship in DoAllocateNSIandNSSI()")
+ execution.setVariable("isNSIOptionAvailable", isNSIOptionAvailable)
+ logger.trace("Exit retriveSliceOption() of DoAllocateNSIandNSSI")
}
- void prepareNssiModelInfo(DelegateExecution execution){
- logger.trace("Enter prepareNssiModelInfo in DoAllocateNSIandNSSI()")
- List<String> nssiAssociated = new ArrayList<>()
- Map<String, Object> nssiMap = new HashMap<>()
- nssiAssociated=execution.getVariable("nssiAssociated")
- for(String nssiID in nssiAssociated)
- {
- try {
- AAIResourcesClient resourceClient = new AAIResourcesClient()
- 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()
- nssiMap.put(nssi.getEnvironmentContext(),"""{
- "serviceInstanceId":"${nssi.getServiceInstanceId()}",
- "modelUuid":"${nssi.getModelVersionId()}"
- }""")
-
- }catch(NotFoundException e)
- {
- logger.debug("NSSI Service Instance not found in AAI: " + nssiID)
- }catch(Exception e)
- {
- logger.debug("NSSI Service Instance not found in AAI: " + nssiID)
- }
- execution.setVariable("nssiMap",nssiMap)
-
- }
- logger.trace("Exit prepareNssiModelInfo in DoAllocateNSIandNSSI()")
- }
+ /**
+ * create nsi instance in aai
+ * @param execution
+ */
void createNSIinAAI(DelegateExecution execution) {
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)
+ SliceTaskParamsAdapter sliceParams =
+ execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
+
+ //set new nsiId to sliceParams suggestNsiId
+ sliceParams.setSuggestNsiId(sliceInstanceId)
+
+ ServiceInstance nsi = new ServiceInstance()
+
+
String sliceInstanceName = "nsi_"+execution.getVariable("sliceServiceInstanceName")
- nsi.setServiceInstanceName(sliceInstanceName)
String serviceType = execution.getVariable("serviceType")
- nsi.setServiceType(serviceType)
String serviceStatus = "deactivated"
+ String modelInvariantUuid = sliceParams.getNSTInfo().invariantUUID
+ String modelUuid = sliceParams.getNSTInfo().UUID
+
+ String uuiRequest = execution.getVariable("uuiRequest")
+ String serviceInstanceLocationid = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs.plmnIdList")
+ String serviceRole = "nsi"
+
+ execution.setVariable("sliceInstanceId", sliceInstanceId)
+ nsi.setServiceInstanceId(sliceInstanceId)
+ nsi.setServiceInstanceName(sliceInstanceName)
+ nsi.setServiceType(serviceType)
nsi.setOrchestrationStatus(serviceStatus)
- String modelInvariantUuid = serviceDecomposition.getModelInfo().getModelInvariantUuid()
- String modelUuid = serviceDecomposition.getModelInfo().getModelUuid()
nsi.setModelInvariantId(modelInvariantUuid)
nsi.setModelVersionId(modelUuid)
- String uuiRequest = execution.getVariable("uuiRequest")
- String serviceInstanceLocationid = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs.plmnIdList")
nsi.setServiceInstanceLocationId(serviceInstanceLocationid)
- //String snssai = jsonUtil.getJsonValue(uuiRequest, "service.requestInputs.snssai")
- //nsi.setEnvironmentContext(snssai)
- String serviceRole = "nsi"
nsi.setServiceRole(serviceRole)
- String msg = ""
+ String msg
try {
- AAIResourcesClient client = new AAIResourcesClient()
- AAIResourceUri nsiServiceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), sliceInstanceId)
+ 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)
+ execution.setVariable("nsiServiceUri", nsiServiceUri)
} catch (BpmnError e) {
throw e
@@ -239,124 +161,565 @@ class DoAllocateNSIandNSSI extends org.onap.so.bpmn.common.scripts.AbstractServi
logger.info(msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
}
- Map<String, Object> nssiMap = new HashMap<>()
- List<ServiceProxy> serviceProxyList = serviceDecomposition.getServiceProxy()
- List<String> nsstModelInfoList = new ArrayList<>()
- for(ServiceProxy serviceProxy : serviceProxyList)
- {
- //String nsstModelUuid = serviceProxy.getModelInfo().getModelUuid()
- String nsstModelUuid = serviceProxy.getSourceModelUuid()
- //String nsstModelInvariantUuid = serviceProxy.getModelInfo().getModelInvariantUuid()
- String nsstServiceModelInfo = """{
- "modelInvariantUuid":"",
- "modelUuid":"${nsstModelUuid}",
- "modelVersion":""
- }"""
- nsstModelInfoList.add(nsstServiceModelInfo)
- }
- int currentIndex=0
- int maxIndex=nsstModelInfoList.size()
- if(maxIndex < 1)
- {
- msg = "Exception in DoAllocateNSIandNSSI. There is no NSST associated with NST "
- logger.info(msg)
+
+ logger.debug("Exit CreateNSIinAAI in DoAllocateNSIandNSSI()")
+ }
+
+
+ /**
+ * create relationship between nsi and service profile instance
+ * @param execution
+ */
+ void createRelationship(DelegateExecution execution) {
+ //relation ship
+ String allottedResourceId = execution.getVariable("allottedResourceId")
+ SliceTaskParamsAdapter sliceParams =
+ execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
+
+ AAIResourceUri nsiServiceUri = execution.getVariable("nsiServiceUri") as AAIResourceUri
+ logger.info("Creating Allotted resource relationship, nsiServiceUri: " + nsiServiceUri)
+
+ AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(
+ AAIObjectType.ALLOTTED_RESOURCE,
+ execution.getVariable("globalSubscriberId"),
+ execution.getVariable("subscriptionServiceType"),
+ sliceParams.suggestNsiId,
+ allottedResourceId)
+
+ client.connect(allottedResourceUri, nsiServiceUri)
+ }
+
+ /**
+ *
+ * @param execution
+ */
+ void updateRelationship(DelegateExecution execution) {
+ logger.debug("Enter update relationship in DoAllocateNSIandNSSI()")
+ //todo: allottedResourceId
+ String allottedResourceId = execution.getVariable("allottedResourceId")
+ //Need to check whether nsi exist : Begin
+
+ SliceTaskParamsAdapter sliceParams =
+ execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
+
+ String nsiServiceInstanceID = sliceParams.getSuggestNsiId()
+ //sliceParams.setServiceId(nsiServiceInstanceID)
+
+ AAIResourceUri nsiServiceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,
+ execution.getVariable("globalSubscriberId"),
+ execution.getVariable("subscriptionServiceType"),
+ nsiServiceInstanceID)
+
+ try {
+ AAIResultWrapper wrapper = client.get(nsiServiceUri, NotFoundException.class)
+ Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class)
+ //todo: if exists
+ if (!si.ifPresent()) {
+ 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("subscriptionServiceType"),
+ sliceParams.suggestNsiId, //nsiId
+ allottedResourceId)
+
+ client.connect(allottedResourceUri, nsiServiceUri)
+
+ execution.setVariable("sliceTaskParams", sliceParams)
+ }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)
}
- execution.setVariable("nsstModelInfoList",nsstModelInfoList)
- execution.setVariable("currentIndex",currentIndex)
- execution.setVariable("maxIndex",maxIndex)
- execution.setVariable('nsiServiceInstanceId',sliceInstanceId)
- execution.setVariable("nsiServiceInstanceName",sliceInstanceName)
- logger.debug("Exit CreateNSIinAAI in DoAllocateNSIandNSSI()")
+ logger.debug("Exit update relationship in DoAllocateNSIandNSSI()")
}
- void getOneNsstInfo(DelegateExecution execution){
- List<String> nsstModelInfoList = new ArrayList<>()
- nsstModelInfoList = execution.getVariable("nsstModelInfoList")
- int currentIndex = execution.getVariable("currentIndex")
- int maxIndex = execution.getVariable("maxIndex")
- boolean isMoreNSSTtoProcess = true
- String nsstServiceModelInfo = nsstModelInfoList.get(currentIndex)
- execution.setVariable("serviceModelInfo", nsstServiceModelInfo)
- execution.setVariable("currentIndex", currentIndex)
- currentIndex = currentIndex+1
- if(currentIndex <= maxIndex )
- isMoreNSSTtoProcess = false
- execution.setVariable("isMoreNSSTtoProcess", isMoreNSSTtoProcess)
+ /**
+ * create RAN Slice Profile Instance
+ * @param execution
+ */
+ void createAnSliceProfileInstance(DelegateExecution execution) {
+
+ String globalSubscriberId = execution.getVariable("globalSubscriberId")
+ String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
+ String serviceInstanceId = UUID.randomUUID().toString()
+ execution.setVariable("ranSliceProfileInstanceId", serviceInstanceId) //todo:
+
+ String serviceType = ""
+ String serviceRole = "slice-profile"
+ String oStatus = "deactivated"
+
+ SliceTaskParamsAdapter sliceParams =
+ execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
+ SliceTaskInfo<AnSliceProfile> sliceTaskInfo = sliceParams.anSliceTaskInfo
+ sliceTaskInfo.setSliceInstanceId(serviceInstanceId)
+
+ // create slice profile
+ ServiceInstance rspi = new ServiceInstance()
+ rspi.setServiceInstanceName(sliceTaskInfo.NSSTInfo.name)
+ rspi.setServiceType(serviceType)
+ rspi.setServiceRole(serviceRole)
+ rspi.setOrchestrationStatus(oStatus)
+ rspi.setModelInvariantId(sliceTaskInfo.NSSTInfo.invariantUUID)
+ rspi.setModelVersionId(sliceTaskInfo.NSSTInfo.UUID)
+ rspi.setInputParameters(uuiRequest)
+ rspi.setWorkloadContext(useInterval)
+ rspi.setEnvironmentContext(sNSSAI_id)
+
+ //timestamp format YYYY-MM-DD hh:mm:ss
+ rspi.setCreatedAt(new Date(System.currentTimeMillis()).format("yyyy-MM-dd HH:mm:ss", TimeZone.getDefault()))
+
+ execution.setVariable("communicationServiceInstance", rspi)
+
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,
+ globalSubscriberId,
+ subscriptionServiceType,
+ serviceInstanceId)
+ client.create(uri, rspi)
+
+ execution.setVariable("sliceTaskParams", sliceParams)
}
- void createNSSTMap(DelegateExecution execution){
- ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
- String modelUuid= serviceDecomposition.getModelInfo().getModelUuid()
- String content = serviceDecomposition.getServiceInfo().getServiceArtifact().get(0).getContent()
- //String nsstID = jsonUtil.getJsonValue(content, "metadata.id")
- //String vendor = jsonUtil.getJsonValue(content, "metadata.vendor")
- //String type = jsonUtil.getJsonValue(content, "metadata.type")
- String domain = jsonUtil.getJsonValue(content, "metadata.domainType")
-
- Map<String, Object> nssiMap = execution.getVariable("nssiMap")
- String servicename = execution.getVariable("sliceServiceInstanceName")
- String nsiname = "nsi_"+servicename
- nssiMap.put(domain,"""{
- "serviceInstanceId":"",
- "modelUuid":"${modelUuid}"
- }""")
- execution.setVariable("nssiMap",nssiMap)
+ /**
+ * create An Slice Profile
+ * @param execution
+ */
+ void createAnSliceProfile(DelegateExecution execution) {
+
+ String globalSubscriberId = execution.getVariable("globalSubscriberId")
+ String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
+ //String serviceInstanceId = execution.getVariable("ranSliceProfileInstanceId")
+
+ SliceTaskParamsAdapter sliceParams =
+ execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
+ SliceTaskInfo<AnSliceProfile> sliceTaskInfo = sliceParams.anSliceTaskInfo
+ AnSliceProfile anSliceProfile = sliceTaskInfo.sliceProfile
+
+ String profileId = UUID.randomUUID().toString()
+ anSliceProfile.setSliceProfileId(profileId)
+
+ SliceProfile sliceProfile = new SliceProfile()
+ sliceProfile.setProfileId(profileId)
+ sliceProfile.setCoverageAreaTAList(anSliceProfile.coverageAreaTAList as String)
+ //todo:...
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE,
+ globalSubscriberId,
+ subscriptionServiceType,
+ sliceTaskInfo.sliceInstanceId,
+ profileId
+ )
+ client.create(uri, sliceProfile)
+ execution.setVariable("sliceTaskParams", sliceParams)
}
- void prepareNSSIList(DelegateExecution execution){
- logger.trace("Enter prepareNSSIList in DoAllocateNSIandNSSI()")
- Map<String, Object> nssiMap = new HashMap<>()
- Boolean isMoreNSSI = false
- nssiMap = execution.getVariable("nssiMap")
- List<String> keys=new ArrayList<String>(nssiMap.values())
- List<String> nsstSequence = execution.getVariable("nsstSequence")
- Integer currentIndex=0;
- execution.setVariable("currentNssiIndex",currentIndex)
- Integer maxIndex=keys.size()
- execution.setVariable("maxIndex",maxIndex)
- if(maxIndex>0)
- isMoreNSSI=true
- execution.setVariable("isMoreNSSI",isMoreNSSI)
- logger.trace("Exit prepareNSSIList in DoAllocateNSIandNSSI()")
+ /**
+ * prepare AllocateAnNssi
+ * @param execution
+ */
+ void prepareAllocateAnNssi(DelegateExecution execution) {
+
+ //todo:
+ SliceTaskParamsAdapter sliceParams =
+ execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
+ SliceTaskInfo<AnSliceProfile> sliceTaskInfo = sliceParams.anSliceTaskInfo
+
+ NssmfAdapterNBIRequest nbiRequest = new NssmfAdapterNBIRequest()
+
+ AllocateAnNssi allocateAnNssi = new AllocateAnNssi()
+ allocateAnNssi.nsstId = sliceTaskInfo.NSSTInfo.UUID
+ allocateAnNssi.nssiId = sliceTaskInfo.NSSTInfo.UUID
+ allocateAnNssi.nssiName = sliceTaskInfo.NSSTInfo.name
+ allocateAnNssi.sliceProfile = sliceTaskInfo.sliceProfile
+ allocateAnNssi.nsiInfo.nsiId = sliceParams.suggestNsiId
+
+ EsrInfo esrInfo = new EsrInfo()
+ //todo: vendor and network
+ esrInfo.setVendor(sliceTaskInfo.getVendor())
+ esrInfo.setNetworkType(sliceTaskInfo.getNetworkType())
+
+ String globalSubscriberId = execution.getVariable("globalSubscriberId")
+ String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
+
+ //todo: service info
+ ServiceInfo serviceInfo = new ServiceInfo()
+ serviceInfo.globalSubscriberId = globalSubscriberId
+ serviceInfo.subscriptionServiceType = subscriptionServiceType
+ serviceInfo.nsiId = sliceParams.suggestNsiId
+ serviceInfo.serviceInvariantUuid = sliceTaskInfo.NSSTInfo.invariantUUID
+ serviceInfo.serviceUuid = sliceTaskInfo.NSSTInfo.UUID
+
+ nbiRequest.setServiceInfo(serviceInfo)
+ nbiRequest.setEsrInfo(esrInfo)
+ nbiRequest.setAllocateAnNssi(allocateAnNssi)
+
+ execution.setVariable("AnAllocateNssiNbiRequest", nbiRequest)
+ execution.setVariable("anBHSliceTaskInfo", sliceTaskInfo)
}
- void getOneNSSIInfo(DelegateExecution execution){
- logger.trace("Enter getOneNSSIInfo in DoAllocateNSIandNSSI()")
-
- //ServiceDecomposition serviceDecompositionObj = execution.getVariable("serviceDecompositionObj")
- Map<String, Object> nssiMap=execution.getVariable("nssiMap")
- List<String> nsstSequence = execution.getVariable("nsstSequence")
- String currentNSST= nsstSequence.get(execution.getVariable("currentNssiIndex"))
- boolean isNSSIOptionAvailable = false
- String nsstInput=nssiMap.get(currentNSST)
- execution.setVariable("nsstInput",nsstInput)
- String modelUuid = jsonUtil.getJsonValue(nsstInput, "modelUuid")
- String nssiInstanceId = jsonUtil.getJsonValue(nsstInput, "serviceInstanceId")
- String nssiserviceModelInfo = """{
- "modelInvariantUuid":"",
- "modelUuid":"${modelUuid}",
- "modelVersion":""
- }"""
- Integer currentIndex = execution.getVariable("currentNssiIndex")
- currentIndex=currentIndex+1;
- execution.setVariable("currentNssiIndex",currentIndex)
- execution.setVariable("nssiserviceModelInfo",nssiserviceModelInfo)
- execution.setVariable("nssiInstanceId",nssiInstanceId)
- logger.trace("Exit getOneNSSIInfo in DoAllocateNSIandNSSI()")
+ /**
+ * create RAN Slice Profile Instance
+ * @param execution
+ */
+ void createCnSliceProfileInstance(DelegateExecution execution) {
+
+ String globalSubscriberId = execution.getVariable("globalSubscriberId")
+ String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
+ String serviceInstanceId = UUID.randomUUID().toString()
+ execution.setVariable("cnSliceProfileInstanceId", serviceInstanceId) //todo:
+
+ String serviceType = ""
+ String serviceRole = "slice-profile"
+ String oStatus = "deactivated"
+
+ SliceTaskParamsAdapter sliceParams =
+ execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
+ SliceTaskInfo<CnSliceProfile> sliceTaskInfo = sliceParams.cnSliceTaskInfo
+ sliceTaskInfo.setSliceInstanceId(serviceInstanceId)
+
+ // create slice profile
+ ServiceInstance rspi = new ServiceInstance()
+ rspi.setServiceInstanceName(sliceTaskInfo.NSSTInfo.name)
+ rspi.setServiceType(serviceType)
+ rspi.setServiceRole(serviceRole)
+ rspi.setOrchestrationStatus(oStatus)
+ rspi.setModelInvariantId(sliceTaskInfo.NSSTInfo.invariantUUID)
+ rspi.setModelVersionId(sliceTaskInfo.NSSTInfo.UUID)
+ rspi.setInputParameters(uuiRequest)
+ rspi.setWorkloadContext(useInterval)
+ rspi.setEnvironmentContext(sNSSAI_id)
+
+ //timestamp format YYYY-MM-DD hh:mm:ss
+ rspi.setCreatedAt(new Date(System.currentTimeMillis()).format("yyyy-MM-dd HH:mm:ss", TimeZone.getDefault()))
+
+ execution.setVariable("communicationServiceInstance", rspi)
+
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,
+ globalSubscriberId,
+ subscriptionServiceType,
+ serviceInstanceId)
+ client.create(uri, rspi)
+ execution.setVariable("sliceTaskParams", sliceParams)
}
- void updateCurrentIndex(DelegateExecution execution){
+ /**
+ * create An Slice Profile
+ * @param execution
+ */
+ void createCnSliceProfile(DelegateExecution execution) {
+
+ String globalSubscriberId = execution.getVariable("globalSubscriberId")
+ String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
+ //String serviceInstanceId = execution.getVariable("ranSliceProfileInstanceId")
+
+ SliceTaskParamsAdapter sliceParams =
+ execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
+
+ SliceTaskInfo<CnSliceProfile> sliceTaskInfo = sliceParams.cnSliceTaskInfo
+ CnSliceProfile cnSliceProfile = sliceTaskInfo.sliceProfile
+
+ String profileId = UUID.randomUUID().toString()
+ cnSliceProfile.setSliceProfileId(profileId)
+
+ SliceProfile sliceProfile = new SliceProfile()
+ sliceProfile.setProfileId(profileId)
+ sliceProfile.setCoverageAreaTAList(cnSliceProfile.coverageAreaTAList as String)
+ //todo:...
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE,
+ globalSubscriberId,
+ subscriptionServiceType,
+ sliceTaskInfo.sliceInstanceId,
+ profileId
+ )
+ client.create(uri, sliceProfile)
+ execution.setVariable("sliceTaskParams", sliceParams)
+ }
- logger.trace("Enter updateCurrentIndex in DoAllocateNSIandNSSI()")
- Integer currentIndex = execution.getVariable("currentNssiIndex")
- Integer maxIndex = execution.getVariable("maxIndex")
- if(currentIndex>=maxIndex)
- {
- Boolean isMoreNSSI=false
- execution.setVariable("isMoreNSSI",isMoreNSSI)
- }
- logger.trace("Exit updateCurrentIndex in DoAllocateNSIandNSSI()")
+ /**
+ * prepare AllocateCnNssi
+ * @param execution
+ */
+ void prepareAllocateCnNssi(DelegateExecution execution) {
+
+ //todo:
+ SliceTaskParamsAdapter sliceParams =
+ execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
+ SliceTaskInfo<CnSliceProfile> sliceTaskInfo = sliceParams.cnSliceTaskInfo
+
+ NssmfAdapterNBIRequest nbiRequest = new NssmfAdapterNBIRequest()
+
+ AllocateCnNssi allocateCnNssi = new AllocateCnNssi()
+ allocateCnNssi.nsstId = sliceTaskInfo.NSSTInfo.UUID
+ allocateCnNssi.nssiId = sliceTaskInfo.NSSTInfo.UUID
+ allocateCnNssi.nssiName = sliceTaskInfo.NSSTInfo.name
+ allocateCnNssi.sliceProfile = sliceTaskInfo.sliceProfile
+ allocateCnNssi.nsiInfo.nsiId = sliceParams.suggestNsiId
+
+ EsrInfo esrInfo = new EsrInfo()
+ //todo: vendor and network
+ esrInfo.setVendor(sliceTaskInfo.getVendor())
+ esrInfo.setNetworkType(sliceTaskInfo.getNetworkType())
+
+ String globalSubscriberId = execution.getVariable("globalSubscriberId")
+ String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
+
+ //todo: service info
+ ServiceInfo serviceInfo = new ServiceInfo()
+ serviceInfo.globalSubscriberId = globalSubscriberId
+ serviceInfo.subscriptionServiceType = subscriptionServiceType
+ serviceInfo.nsiId = sliceParams.suggestNsiId
+ serviceInfo.serviceInvariantUuid = sliceTaskInfo.NSSTInfo.invariantUUID
+ serviceInfo.serviceUuid = sliceTaskInfo.NSSTInfo.UUID
+
+ nbiRequest.setServiceInfo(serviceInfo)
+ nbiRequest.setEsrInfo(esrInfo)
+ nbiRequest.setAllocateCnNssi(allocateCnNssi)
+
+ execution.setVariable("CnAllocateNssiNbiRequest", nbiRequest)
+ execution.setVariable("cnSliceTaskInfo", sliceTaskInfo)
}
+
+
+ /**
+ * create TN Slice Profile Instance
+ * @param execution
+ */
+ void createTnBHSliceProfileInstance(DelegateExecution execution) {
+ String globalSubscriberId = execution.getVariable("globalSubscriberId")
+ String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
+
+ String serviceType = ""
+ String serviceRole = "slice-profile"
+ String oStatus = "deactivated"
+
+ SliceTaskParamsAdapter sliceParams =
+ execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
+
+ SliceTaskInfo<TnSliceProfile> sliceTaskInfo = sliceParams.tnBHSliceTaskInfo
+ String serviceInstanceId = UUID.randomUUID().toString()
+
+ sliceTaskInfo.setSliceInstanceId(serviceInstanceId)
+ //execution.setVariable("cnSliceProfileInstanceId", serviceInstanceId) //todo:
+
+ // create slice profile
+ ServiceInstance rspi = new ServiceInstance()
+ rspi.setServiceInstanceName(sliceTaskInfo.NSSTInfo.name)
+ rspi.setServiceType(serviceType)
+ rspi.setServiceRole(serviceRole)
+ rspi.setOrchestrationStatus(oStatus)
+ rspi.setModelInvariantId(sliceTaskInfo.NSSTInfo.invariantUUID)
+ rspi.setModelVersionId(sliceTaskInfo.NSSTInfo.UUID)
+ rspi.setInputParameters(uuiRequest)
+ rspi.setWorkloadContext(useInterval)
+ rspi.setEnvironmentContext(sNSSAI_id)
+
+ //timestamp format YYYY-MM-DD hh:mm:ss
+ rspi.setCreatedAt(new Date(System.currentTimeMillis()).format("yyyy-MM-dd HH:mm:ss", TimeZone.getDefault()))
+
+ execution.setVariable("communicationServiceInstance", rspi)
+
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,
+ globalSubscriberId,
+ subscriptionServiceType,
+ serviceInstanceId)
+ client.create(uri, rspi)
+
+ execution.setVariable("sliceTaskParams", sliceParams)
+ }
+
+ /**
+ * create An Slice Profile
+ * @param execution
+ */
+ void createTnBHSliceProfile(DelegateExecution execution) {
+
+ String globalSubscriberId = execution.getVariable("globalSubscriberId")
+ String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
+
+ SliceTaskParamsAdapter sliceParams =
+ execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
+
+ SliceTaskInfo<TnSliceProfile> sliceTaskInfo = sliceParams.tnBHSliceTaskInfo
+
+ TnSliceProfile tnSliceProfile = sliceTaskInfo.sliceProfile
+ String profileId = UUID.randomUUID().toString()
+ tnSliceProfile.setSliceProfileId(profileId)
+
+ SliceProfile sliceProfile = new SliceProfile()
+ sliceProfile.setProfileId(profileId)
+ //todo:...
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE,
+ globalSubscriberId,
+ subscriptionServiceType,
+ sliceTaskInfo.sliceInstanceId,
+ profileId
+ )
+ client.create(uri, sliceProfile)
+
+ execution.setVariable("sliceTaskParams", sliceParams)
+ }
+
+ /**
+ * prepare AllocateCnNssi
+ * @param execution
+ */
+ void prepareAllocateTnBHNssi(DelegateExecution execution) {
+
+ //todo:
+ SliceTaskParamsAdapter sliceParams =
+ execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
+ SliceTaskInfo<TnSliceProfile> sliceTaskInfo = sliceParams.tnBHSliceTaskInfo
+
+ NssmfAdapterNBIRequest nbiRequest = new NssmfAdapterNBIRequest()
+
+ AllocateTnNssi allocateTnNssi = new AllocateTnNssi()
+ //todo: AllocateTnNssi
+ allocateTnNssi.setTransportSliceNetworks()
+ allocateTnNssi.setNetworkSliceInfos()
+
+
+ //allocateTnNssi.networkSliceInfos
+
+ EsrInfo esrInfo = new EsrInfo()
+ esrInfo.setVendor(sliceTaskInfo.getVendor())
+ esrInfo.setNetworkType(sliceTaskInfo.getNetworkType())
+
+ String globalSubscriberId = execution.getVariable("globalSubscriberId")
+ String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
+
+ ServiceInfo serviceInfo = new ServiceInfo()
+ serviceInfo.globalSubscriberId = globalSubscriberId
+ serviceInfo.subscriptionServiceType = subscriptionServiceType
+ serviceInfo.nsiId = sliceParams.suggestNsiId
+ serviceInfo.serviceInvariantUuid = sliceTaskInfo.NSSTInfo.invariantUUID
+ serviceInfo.serviceUuid = sliceTaskInfo.NSSTInfo.UUID
+
+ nbiRequest.setServiceInfo(serviceInfo)
+ nbiRequest.setEsrInfo(esrInfo)
+ nbiRequest.setAllocateTnNssi(allocateTnNssi)
+
+ execution.setVariable("TnBHAllocateNssiNbiRequest", nbiRequest)
+ execution.setVariable("tnBHSliceTaskInfo", sliceTaskInfo)
+ }
+
+ /**
+ * Update relationship between
+ * 1. NSI and NSSI
+ * 2. Slice Profile and Service Profile
+ * 3. SliceProfile and NSSI
+ * 4. sliceProfile and endpoint
+ *
+ * @param execution
+ */
+ public void updateAnRelationship(DelegateExecution execution) {
+ //todo:
+ SliceTaskParamsAdapter sliceParams =
+ execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
+
+ ResponseDescriptor result = execution.getVariable("anNssiAllocateResult") as ResponseDescriptor
+ String nssiId = result.getNssiId()
+ String endPointId = result.getEndPointId()
+ String nsiId = sliceParams.getSuggestNsiId()
+ String sliceProfileInstanceId = sliceParams.anSliceTaskInfo.sliceInstanceId
+ String serviceProfileInstanceId = sliceParams.serviceId
+ //nsi id
+
+ updateRelationship(execution, nsiId, nssiId)
+
+ updateRelationship(execution, serviceProfileInstanceId, sliceProfileInstanceId)
+
+ updateRelationship(execution, sliceProfileInstanceId, nssiId)
+
+ updateRelationship(execution, sliceProfileInstanceId, endPointId)
+
+ }
+
+
+ /**
+ * Update relationship between
+ * 1. NSI and NSSI
+ * 2. Slice Profile and Service Profile
+ * 3. SliceProfile and NSSI
+ *
+ * @param execution
+ */
+ public void updateCnRelationship(DelegateExecution execution) {
+ //todo:
+ SliceTaskParamsAdapter sliceParams =
+ execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
+
+ NssiResponse result = execution.getVariable("cnNssiAllocateResult") as NssiResponse
+ String nssiId = result.getNssiId()
+ String nsiId = sliceParams.getSuggestNsiId()
+ String sliceProfileInstanceId = sliceParams.cnSliceTaskInfo.sliceInstanceId
+ String serviceProfileInstanceId = sliceParams.serviceId
+ //nsi id
+
+ updateRelationship(execution, nsiId, nssiId)
+
+ updateRelationship(execution, serviceProfileInstanceId, sliceProfileInstanceId)
+
+ updateRelationship(execution,sliceProfileInstanceId, nssiId)
+
+
+ }
+
+ /**
+ * Update relationship between
+ * 1. NSI and NSSI
+ * 2. Slice Profile and Service Profile
+ * 3. SliceProfile and NSSI
+ *
+ * @param execution
+ */
+ public void updateTnBHRelationship(DelegateExecution execution) {
+ SliceTaskParamsAdapter sliceParams =
+ execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
+
+ NssiResponse result = execution.getVariable("tnBHNssiAllocateResult") as NssiResponse
+ String nssiId = result.getNssiId()
+ String nsiId = sliceParams.getSuggestNsiId()
+ String sliceProfileInstanceId = sliceParams.tnBHSliceTaskInfo.sliceInstanceId
+ String serviceProfileInstanceId = sliceParams.serviceId
+ //nsi id
+
+ updateRelationship(execution, nsiId, nssiId)
+
+ updateRelationship(execution, serviceProfileInstanceId, sliceProfileInstanceId)
+
+ updateRelationship(execution,sliceProfileInstanceId, nssiId)
+ }
+
+ /**
+ * sourceId -> targetId
+ * @param execution
+ * @param sourceId
+ * @param targetId
+ */
+ void updateRelationship(DelegateExecution execution, String sourceId, String targetId) {
+ //relation ship
+ Relationship relationship = new Relationship()
+
+ AAIResourceUri nsiServiceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,
+ execution.getVariable("globalSubscriberId"),
+ execution.getVariable("subscriptionServiceType"),
+ targetId)
+
+ logger.info("Creating Allotted resource relationship, nsiServiceUri: " + nsiServiceUri)
+
+ relationship.setRelatedLink(nsiServiceUri.build().toString())
+
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,
+ execution.getVariable("globalSubscriberId"),
+ execution.getVariable("subscriptionServiceType"),
+ sourceId).relationshipAPI()
+ client.create(uri, relationship)
+ }
+
} \ No newline at end of file
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSIV2.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSIV2.groovy
deleted file mode 100644
index 924b42fe9f..0000000000
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSIV2.groovy
+++ /dev/null
@@ -1,613 +0,0 @@
-/*-
- * ============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 org.apache.commons.lang3.StringUtils
-import org.camunda.bpm.engine.delegate.BpmnError
-import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.onap.aai.domain.yang.Relationship
-import org.onap.aai.domain.yang.ServiceInstance
-import org.onap.aai.domain.yang.SliceProfile
-import org.onap.aaiclient.client.aai.AAIObjectType
-import org.onap.aaiclient.client.aai.AAIResourcesClient
-import org.onap.aaiclient.client.aai.entities.AAIResultWrapper
-import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri
-import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory
-import org.onap.so.beans.nsmf.*
-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.core.json.JsonUtils
-import org.slf4j.Logger
-import org.slf4j.LoggerFactory
-
-import javax.ws.rs.NotFoundException
-
-class DoAllocateNSIandNSSIV2 extends AbstractServiceTaskProcessor{
-
- private static final Logger logger = LoggerFactory.getLogger( DoAllocateNSIandNSSIV2.class);
-
- ExceptionUtil exceptionUtil = new ExceptionUtil()
-
- JsonUtils jsonUtil = new JsonUtils()
-
- private NssmfAdapterUtils nssmfAdapterUtils = new NssmfAdapterUtils(httpClientFactory, jsonUtil)
-
- AAIResourcesClient client = getAAIClient()
-
- /**
- * Pre Process the BPMN Flow Request
- * Inclouds:
- * generate the nsOperationKey
- * generate the nsParameters
- */
-
- void preProcessRequest (DelegateExecution execution) {
- String msg = ""
- logger.trace("Enter preProcessRequest()")
- Map<String, Object> nssiMap = new HashMap<>()
- execution.setVariable("nssiMap", nssiMap)
- boolean isMoreNSSTtoProcess = true
- execution.setVariable("isMoreNSSTtoProcess", isMoreNSSTtoProcess)
- List<String> nsstSequence = new ArrayList<>(Arrays.asList("cn"))
- execution.setVariable("nsstSequence", nsstSequence)
- logger.trace("Exit preProcessRequest")
- }
-
- /**
- * Process NSI options
- * @param execution
- */
- void retriveSliceOption(DelegateExecution execution) {
- logger.trace("Enter retriveSliceOption() of DoAllocateNSIandNSSI")
-
- boolean isNSIOptionAvailable
-
- SliceTaskParamsAdapter sliceParams =
- execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
-// try
-// {
-// 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}",
-// "modelVersion":""
-// }"""
-// execution.setVariable("serviceModelInfo", serviceModelInfo)
-//
-// execution.setVariable("sliceParams", sliceParams)
-// }catch (Exception ex) {
-// logger.debug( "Unable to get the task information from request DB: " + ex)
-// exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Unable to get task information from request DB.")
-// }
-
- if(StringUtils.isBlank(sliceParams.getSuggestNsiId())) {
- isNSIOptionAvailable = false
- }
- else {
- isNSIOptionAvailable = true
- execution.setVariable('nsiServiceInstanceId', sliceParams.getSuggestNsiId())
- execution.setVariable('nsiServiceInstanceName', sliceParams.getSuggestNsiName())
- }
- execution.setVariable("isNSIOptionAvailable", isNSIOptionAvailable)
- logger.trace("Exit retriveSliceOption() of DoAllocateNSIandNSSI")
- }
-
-
- /**
- * create nsi instance in aai
- * @param execution
- */
- void createNSIinAAI(DelegateExecution execution) {
- logger.debug("Enter CreateNSIinAAI in DoAllocateNSIandNSSI()")
-
- String sliceInstanceId = UUID.randomUUID().toString()
- SliceTaskParamsAdapter sliceParams =
- execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
-
- sliceParams.setServiceId(sliceInstanceId)
-
- ServiceInstance nsi = new ServiceInstance()
-
-
- String sliceInstanceName = "nsi_"+execution.getVariable("sliceServiceInstanceName")
- String serviceType = execution.getVariable("serviceType")
- String serviceStatus = "deactivated"
- String modelInvariantUuid = sliceParams.getNSTInfo().invariantUUID
- String modelUuid = sliceParams.getNSTInfo().UUID
-
- String uuiRequest = execution.getVariable("uuiRequest")
- String serviceInstanceLocationid = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs.plmnIdList")
- String serviceRole = "nsi"
-
- execution.setVariable("sliceInstanceId", sliceInstanceId)
- nsi.setServiceInstanceId(sliceInstanceId)
- nsi.setServiceInstanceName(sliceInstanceName)
- nsi.setServiceType(serviceType)
- nsi.setOrchestrationStatus(serviceStatus)
- nsi.setModelInvariantId(modelInvariantUuid)
- nsi.setModelVersionId(modelUuid)
- nsi.setServiceInstanceLocationId(serviceInstanceLocationid)
- nsi.setServiceRole(serviceRole)
- String msg
- try {
-
- AAIResourceUri nsiServiceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,
- execution.getVariable("globalSubscriberId"),
- execution.getVariable("subscriptionServiceType"),
- sliceInstanceId)
- client.create(nsiServiceUri, nsi)
-
- execution.setVariable("nsiServiceUri", nsiServiceUri.build().toString())
-
- } catch (BpmnError e) {
- throw e
- } catch (Exception ex) {
- msg = "Exception in DoCreateSliceServiceInstance.instantiateSliceService. " + ex.getMessage()
- logger.info(msg)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
- }
-
- logger.debug("Exit CreateNSIinAAI in DoAllocateNSIandNSSI()")
- }
-
-
- /**
- * create relationship between nsi and service profile instance
- * @param execution
- */
- void createRelationship(DelegateExecution execution) {
- //relation ship
- Relationship relationship = new Relationship()
- String nsiServiceUri = execution.getVariable("nsiServiceUri") as String
- logger.info("Creating Allotted resource relationship, nsiServiceUri: " + nsiServiceUri)
-
- relationship.setRelatedLink(nsiServiceUri)
-
- AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(
- AAIObjectType.ALLOTTED_RESOURCE,
- execution.getVariable("globalSubscriberId"),
- execution.getVariable("subscriptionServiceType"),
- execution.getVariable("sliceServiceInstanceId"),
- execution.getVariable("allottedResourceId"))
- .relationshipAPI()
- client.create(allottedResourceUri, relationship)
- }
-
- /**
- *
- * @param execution
- */
- void updateRelationship(DelegateExecution execution) {
- logger.debug("Enter update relationship in DoAllocateNSIandNSSI()")
- String allottedResourceId = execution.getVariable("allottedResourceId")
- //Need to check whether nsi exist : Begin
-
- SliceTaskParamsAdapter sliceParams =
- execution.getVariable("sliceParams") as SliceTaskParamsAdapter
-
- String nsiServiceInstanceID = sliceParams.getSuggestNsiId()
- sliceParams.setServiceId(nsiServiceInstanceID)
-
- AAIResourceUri nsiServiceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,
- execution.getVariable("globalSubscriberId"),
- execution.getVariable("subscriptionServiceType"),
- nsiServiceInstanceID)
-
- try {
- AAIResultWrapper wrapper = client.get(nsiServiceUri, NotFoundException.class)
- Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class)
- //todo: if exists
- if (!si.ifPresent()) {
- 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("subscriptionServiceType"),
- execution.getVariable("sliceServiceInstanceId"),
- allottedResourceId)
-
- client.connect(allottedResourceUri, nsiServiceUri)
-
- execution.setVariable("sliceParams", sliceParams)
- }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()")
- }
-
- /**
- * create RAN Slice Profile Instance
- * @param execution
- */
- void createAnSliceProfileInstance(DelegateExecution execution) {
-
- String globalSubscriberId = execution.getVariable("globalSubscriberId")
- String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
- String serviceInstanceId = UUID.randomUUID().toString()
- execution.setVariable("ranSliceProfileInstanceId", serviceInstanceId) //todo:
-
- String serviceType = ""
- String serviceRole = "slice-profile"
- String oStatus = "deactivated"
-
- SliceTaskParamsAdapter sliceParams =
- execution.getVariable("sliceParams") as SliceTaskParamsAdapter
- SliceTaskInfo<AnSliceProfile> sliceTaskInfo = sliceParams.anSliceTaskInfo
- sliceTaskInfo.setServiceInstanceId(serviceInstanceId)
-
- // create slice profile
- ServiceInstance rspi = new ServiceInstance()
- rspi.setServiceInstanceName(sliceTaskInfo.NSSTInfo.name)
- rspi.setServiceType(serviceType)
- rspi.setServiceRole(serviceRole)
- rspi.setOrchestrationStatus(oStatus)
- rspi.setModelInvariantId(sliceTaskInfo.NSSTInfo.invariantUUID)
- rspi.setModelVersionId(sliceTaskInfo.NSSTInfo.UUID)
- rspi.setInputParameters(uuiRequest)
- rspi.setWorkloadContext(useInterval)
- rspi.setEnvironmentContext(sNSSAI_id)
-
- //timestamp format YYYY-MM-DD hh:mm:ss
- rspi.setCreatedAt(new Date(System.currentTimeMillis()).format("yyyy-MM-dd HH:mm:ss", TimeZone.getDefault()))
-
- execution.setVariable("communicationServiceInstance", rspi)
-
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,
- globalSubscriberId,
- subscriptionServiceType,
- serviceInstanceId)
- client.create(uri, rspi)
-
- execution.setVariable("sliceParams", sliceParams)
- }
-
- /**
- * create An Slice Profile
- * @param execution
- */
- void createAnSliceProfile(DelegateExecution execution) {
-
- String globalSubscriberId = execution.getVariable("globalSubscriberId")
- String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
- //String serviceInstanceId = execution.getVariable("ranSliceProfileInstanceId")
-
- SliceTaskParamsAdapter sliceParams =
- execution.getVariable("sliceParams") as SliceTaskParamsAdapter
- SliceTaskInfo<AnSliceProfile> sliceTaskInfo = sliceParams.anSliceTaskInfo
- AnSliceProfile anSliceProfile = sliceTaskInfo.sliceProfile
-
- String profileId = UUID.randomUUID().toString()
- anSliceProfile.setSliceProfileId(profileId)
-
- SliceProfile sliceProfile = new SliceProfile()
- sliceProfile.setProfileId(profileId)
- sliceProfile.setCoverageAreaTAList(anSliceProfile.coverageAreaTAList as String)
- //todo:...
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE,
- globalSubscriberId,
- subscriptionServiceType,
- sliceTaskInfo.serviceInstanceId,
- profileId
- )
- client.create(uri, sliceProfile)
- execution.setVariable("sliceParams", sliceParams)
- }
-
- /**
- * prepare AllocateAnNssi
- * @param execution
- */
- void prepareAllocateAnNssi(DelegateExecution execution) {
-
- //todo:
- SliceTaskParamsAdapter sliceParams =
- execution.getVariable("sliceParams") as SliceTaskParamsAdapter
- SliceTaskInfo<AnSliceProfile> sliceTaskInfo = sliceParams.anSliceTaskInfo
-
- NssmfAdapterNBIRequest nbiRequest = new NssmfAdapterNBIRequest()
-
- AllocateAnNssi allocateAnNssi = new AllocateAnNssi()
- allocateAnNssi.nsstId = sliceTaskInfo.NSSTInfo.UUID
- allocateAnNssi.nssiId = sliceTaskInfo.NSSTInfo.UUID
- allocateAnNssi.nssiName = sliceTaskInfo.NSSTInfo.name
- allocateAnNssi.sliceProfile = sliceTaskInfo.sliceProfile
- allocateAnNssi.nsiInfo.nsiId = sliceParams
-
- EsrInfo esrInfo = new EsrInfo()
- //todo: vendor and network
- esrInfo.setVendor(sliceTaskInfo.getVendor())
- esrInfo.setNetworkType(sliceTaskInfo.getNetworkType())
-
- String globalSubscriberId = execution.getVariable("globalSubscriberId")
- String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
-
- //todo: service info
- ServiceInfo serviceInfo = new ServiceInfo()
- serviceInfo.globalSubscriberId = globalSubscriberId
- serviceInfo.subscriptionServiceType = subscriptionServiceType
- serviceInfo.nsiId = sliceParams.serviceId
- serviceInfo.serviceInvariantUuid = sliceTaskInfo.NSSTInfo.invariantUUID
- serviceInfo.serviceUuid = sliceTaskInfo.NSSTInfo.UUID
-
- nbiRequest.setServiceInfo(serviceInfo)
- nbiRequest.setEsrInfo(esrInfo)
- nbiRequest.setAllocateAnNssi(allocateAnNssi)
-
- execution.setVariable("AnAllocateNssiNbiRequest", nbiRequest)
- execution.setVariable("anBHSliceTaskInfo", sliceTaskInfo)
- }
-
-
- /**
- * create RAN Slice Profile Instance
- * @param execution
- */
- void createCnSliceProfileInstance(DelegateExecution execution) {
-
- String globalSubscriberId = execution.getVariable("globalSubscriberId")
- String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
- String serviceInstanceId = UUID.randomUUID().toString()
- execution.setVariable("cnSliceProfileInstanceId", serviceInstanceId) //todo:
-
- String serviceType = ""
- String serviceRole = "slice-profile"
- String oStatus = "deactivated"
-
- SliceTaskParamsAdapter sliceParams =
- execution.getVariable("sliceParams") as SliceTaskParamsAdapter
- SliceTaskInfo<CnSliceProfile> sliceTaskInfo = sliceParams.cnSliceTaskInfo
- sliceTaskInfo.setServiceInstanceId(serviceInstanceId)
-
- // create slice profile
- ServiceInstance rspi = new ServiceInstance()
- rspi.setServiceInstanceName(sliceTaskInfo.NSSTInfo.name)
- rspi.setServiceType(serviceType)
- rspi.setServiceRole(serviceRole)
- rspi.setOrchestrationStatus(oStatus)
- rspi.setModelInvariantId(sliceTaskInfo.NSSTInfo.invariantUUID)
- rspi.setModelVersionId(sliceTaskInfo.NSSTInfo.UUID)
- rspi.setInputParameters(uuiRequest)
- rspi.setWorkloadContext(useInterval)
- rspi.setEnvironmentContext(sNSSAI_id)
-
- //timestamp format YYYY-MM-DD hh:mm:ss
- rspi.setCreatedAt(new Date(System.currentTimeMillis()).format("yyyy-MM-dd HH:mm:ss", TimeZone.getDefault()))
-
- execution.setVariable("communicationServiceInstance", rspi)
-
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,
- globalSubscriberId,
- subscriptionServiceType,
- serviceInstanceId)
- client.create(uri, rspi)
- execution.setVariable("sliceParams", sliceParams)
- }
-
- /**
- * create An Slice Profile
- * @param execution
- */
- void createCnSliceProfile(DelegateExecution execution) {
-
- String globalSubscriberId = execution.getVariable("globalSubscriberId")
- String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
- //String serviceInstanceId = execution.getVariable("ranSliceProfileInstanceId")
-
- SliceTaskParamsAdapter sliceParams =
- execution.getVariable("sliceParams") as SliceTaskParamsAdapter
-
- SliceTaskInfo<CnSliceProfile> sliceTaskInfo = sliceParams.cnSliceTaskInfo
- CnSliceProfile cnSliceProfile = sliceTaskInfo.sliceProfile
-
- String profileId = UUID.randomUUID().toString()
- cnSliceProfile.setSliceProfileId(profileId)
-
- SliceProfile sliceProfile = new SliceProfile()
- sliceProfile.setProfileId(profileId)
- sliceProfile.setCoverageAreaTAList(cnSliceProfile.coverageAreaTAList as String)
- //todo:...
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE,
- globalSubscriberId,
- subscriptionServiceType,
- sliceTaskInfo.serviceInstanceId,
- profileId
- )
- client.create(uri, sliceProfile)
- execution.setVariable("sliceParams", sliceParams)
- }
-
- /**
- * prepare AllocateCnNssi
- * @param execution
- */
- void prepareAllocateCnNssi(DelegateExecution execution) {
-
- //todo:
- SliceTaskParamsAdapter sliceParams =
- execution.getVariable("sliceParams") as SliceTaskParamsAdapter
- SliceTaskInfo<CnSliceProfile> sliceTaskInfo = sliceParams.cnSliceTaskInfo
-
- NssmfAdapterNBIRequest nbiRequest = new NssmfAdapterNBIRequest()
-
- AllocateCnNssi allocateCnNssi = new AllocateCnNssi()
- allocateCnNssi.nsstId = sliceTaskInfo.NSSTInfo.UUID
- allocateCnNssi.nssiId = sliceTaskInfo.NSSTInfo.UUID
- allocateCnNssi.nssiName = sliceTaskInfo.NSSTInfo.name
- allocateCnNssi.sliceProfile = sliceTaskInfo.sliceProfile
- allocateCnNssi.nsiInfo.nsiId = sliceParams
-
- EsrInfo esrInfo = new EsrInfo()
- //todo: vendor and network
- esrInfo.setVendor(sliceTaskInfo.getVendor())
- esrInfo.setNetworkType(sliceTaskInfo.getNetworkType())
-
- String globalSubscriberId = execution.getVariable("globalSubscriberId")
- String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
-
- //todo: service info
- ServiceInfo serviceInfo = new ServiceInfo()
- serviceInfo.globalSubscriberId = globalSubscriberId
- serviceInfo.subscriptionServiceType = subscriptionServiceType
- serviceInfo.nsiId = sliceParams.serviceId
- serviceInfo.serviceInvariantUuid = sliceTaskInfo.NSSTInfo.invariantUUID
- serviceInfo.serviceUuid = sliceTaskInfo.NSSTInfo.UUID
-
- nbiRequest.setServiceInfo(serviceInfo)
- nbiRequest.setEsrInfo(esrInfo)
- nbiRequest.setAllocateCnNssi(allocateCnNssi)
-
- execution.setVariable("CnAllocateNssiNbiRequest", nbiRequest)
- execution.setVariable("cnSliceTaskInfo", sliceTaskInfo)
- }
-
-
- /**
- * create TN Slice Profile Instance
- * @param execution
- */
- void createTnBHSliceProfileInstance(DelegateExecution execution) {
- String globalSubscriberId = execution.getVariable("globalSubscriberId")
- String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
-
- String serviceType = ""
- String serviceRole = "slice-profile"
- String oStatus = "deactivated"
-
- SliceTaskParamsAdapter sliceParams =
- execution.getVariable("sliceParams") as SliceTaskParamsAdapter
-
- SliceTaskInfo<TnSliceProfile> sliceTaskInfo = sliceParams.tnBHSliceTaskInfo
- String serviceInstanceId = UUID.randomUUID().toString()
-
- sliceTaskInfo.setServiceInstanceId(serviceInstanceId)
- //execution.setVariable("cnSliceProfileInstanceId", serviceInstanceId) //todo:
-
- // create slice profile
- ServiceInstance rspi = new ServiceInstance()
- rspi.setServiceInstanceName(sliceTaskInfo.NSSTInfo.name)
- rspi.setServiceType(serviceType)
- rspi.setServiceRole(serviceRole)
- rspi.setOrchestrationStatus(oStatus)
- rspi.setModelInvariantId(sliceTaskInfo.NSSTInfo.invariantUUID)
- rspi.setModelVersionId(sliceTaskInfo.NSSTInfo.UUID)
- rspi.setInputParameters(uuiRequest)
- rspi.setWorkloadContext(useInterval)
- rspi.setEnvironmentContext(sNSSAI_id)
-
- //timestamp format YYYY-MM-DD hh:mm:ss
- rspi.setCreatedAt(new Date(System.currentTimeMillis()).format("yyyy-MM-dd HH:mm:ss", TimeZone.getDefault()))
-
- execution.setVariable("communicationServiceInstance", rspi)
-
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,
- globalSubscriberId,
- subscriptionServiceType,
- serviceInstanceId)
- client.create(uri, rspi)
-
- execution.setVariable("sliceParams", sliceParams)
- }
-
- /**
- * create An Slice Profile
- * @param execution
- */
- void createTnBHSliceProfile(DelegateExecution execution) {
-
- String globalSubscriberId = execution.getVariable("globalSubscriberId")
- String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
- String serviceInstanceId = execution.getVariable("ranSliceProfileInstanceId")
-
- SliceTaskParamsAdapter sliceParams =
- execution.getVariable("sliceParams") as SliceTaskParamsAdapter
-
- SliceTaskInfo<TnSliceProfile> sliceTaskInfo = sliceParams.tnBHSliceTaskInfo
-
- TnSliceProfile tnSliceProfile = sliceTaskInfo.sliceProfile
- String profileId = UUID.randomUUID().toString()
- tnSliceProfile.setSliceProfileId(profileId)
-
- SliceProfile sliceProfile = new SliceProfile()
- sliceProfile.setProfileId(profileId)
- //todo:...
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE,
- globalSubscriberId,
- subscriptionServiceType,
- serviceInstanceId,
- profileId
- )
- client.create(uri, sliceProfile)
-
- execution.setVariable("sliceParams", sliceParams)
- }
-
- /**
- * prepare AllocateCnNssi
- * @param execution
- */
- void prepareAllocateTnBHNssi(DelegateExecution execution) {
-
- //todo:
- SliceTaskParamsAdapter sliceParams =
- execution.getVariable("sliceParams") as SliceTaskParamsAdapter
- SliceTaskInfo<TnSliceProfile> sliceTaskInfo = sliceParams.tnBHSliceTaskInfo
-
- NssmfAdapterNBIRequest nbiRequest = new NssmfAdapterNBIRequest()
-
- AllocateTnNssi allocateTnNssi = new AllocateTnNssi()
- //todo: AllocateTnNssi
- //allocateTnNssi.networkSliceInfos
-
- EsrInfo esrInfo = new EsrInfo()
- //todo: vendor and network
- esrInfo.setVendor(sliceTaskInfo.getVendor())
- esrInfo.setNetworkType(sliceTaskInfo.getNetworkType())
-
- String globalSubscriberId = execution.getVariable("globalSubscriberId")
- String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
-
- //todo: service info
- ServiceInfo serviceInfo = new ServiceInfo()
- serviceInfo.globalSubscriberId = globalSubscriberId
- serviceInfo.subscriptionServiceType = subscriptionServiceType
- serviceInfo.nsiId = sliceParams.serviceId
- serviceInfo.serviceInvariantUuid = sliceTaskInfo.NSSTInfo.invariantUUID
- serviceInfo.serviceUuid = sliceTaskInfo.NSSTInfo.UUID
-
- nbiRequest.setServiceInfo(serviceInfo)
- nbiRequest.setEsrInfo(esrInfo)
- nbiRequest.setAllocateTnNssi(allocateTnNssi)
-
- execution.setVariable("TnBHAllocateNssiNbiRequest", nbiRequest)
- execution.setVariable("tnBHSliceTaskInfo", sliceTaskInfo)
- }
-
-} \ No newline at end of file
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 88edd79d6d..9aa044a649 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
@@ -1,713 +1,114 @@
package org.onap.so.bpmn.infrastructure.scripts
-import org.camunda.bpm.engine.delegate.BpmnError
+import com.fasterxml.jackson.databind.ObjectMapper
import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.onap.aai.domain.yang.ServiceInstance
-import org.onap.aai.domain.yang.SliceProfile
-import org.onap.so.beans.nsmf.AllocateAnNssi
-import org.onap.so.beans.nsmf.AllocateCnNssi
-import org.onap.so.beans.nsmf.AllocateTnNssi
-import org.onap.so.beans.nsmf.AnSliceProfile
-import org.onap.so.beans.nsmf.CnSliceProfile
import org.onap.so.beans.nsmf.EsrInfo
-import org.onap.so.beans.nsmf.JobStatusRequest
-import org.onap.so.beans.nsmf.NetworkType
-import org.onap.so.beans.nsmf.NsiInfo
-import org.onap.so.beans.nsmf.NssiAllocateRequest
-import org.onap.so.beans.nsmf.PerfReq
-import org.onap.so.beans.nsmf.PerfReqEmbb
-import org.onap.so.beans.nsmf.PerfReqUrllc
-import org.onap.so.beans.nsmf.ResourceSharingLevel
-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.beans.nsmf.NssiResponse
+import org.onap.so.beans.nsmf.NssmfAdapterNBIRequest
+import org.onap.so.beans.nsmf.ResponseDescriptor
+import org.onap.so.beans.nsmf.ServiceInfo
+import org.onap.so.beans.nsmf.SliceTaskInfo
+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.core.RollbackData
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.aaiclient.client.aai.AAIObjectType
-import org.onap.aaiclient.client.aai.AAIResourcesClient
-import org.onap.aaiclient.client.aai.entities.AAIEdgeLabel
-import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri
-import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory
import org.slf4j.Logger
import org.slf4j.LoggerFactory
-import com.fasterxml.jackson.databind.ObjectMapper;
+import org.springframework.http.ResponseEntity
import static org.apache.commons.lang3.StringUtils.isBlank
+class DoAllocateNSSI extends AbstractServiceTaskProcessor {
-class DoAllocateNSSI extends org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor{
-
- private static final Logger logger = LoggerFactory.getLogger( DoAllocateNSSI.class);
- private static final ObjectMapper MAPPER = new ObjectMapper();
+ private static final Logger logger = LoggerFactory.getLogger(DoAllocateNSSI.class);
ExceptionUtil exceptionUtil = new ExceptionUtil()
JsonUtils jsonUtil = new JsonUtils()
- private NssmfAdapterUtils nssmfAdapterUtils = new NssmfAdapterUtils(httpClientFactory, jsonUtil)
-
- /**
- * Pre Process the BPMN Flow Request
- * Inclouds:
- * generate the nsOperationKey
- * generate the nsParameters
- */
- void preProcessRequest (DelegateExecution execution) {
- logger.trace("Enter preProcessRequest()")
- String msg = ""
- String nssmfOperation = ""
- String msoRequestId = execution.getVariable("msoRequestId")
- String nsstInput = execution.getVariable("nsstInput")
- String modelUuid = jsonUtil.getJsonValue(nsstInput, "modelUuid")
- //modelUuid="2763777c-27bd-4df7-93b8-c690e23f4d3f"
- String nssiInstanceId = jsonUtil.getJsonValue(nsstInput, "serviceInstanceId")
- String serviceModelInfo = """{
- "modelInvariantUuid":"",
- "modelUuid":"${modelUuid}",
- "modelVersion":""
- }"""
- execution.setVariable("serviceModelInfo",serviceModelInfo)
- execution.setVariable("nssiInstanceId",nssiInstanceId)
- String nssiProfileID = UUID.randomUUID().toString()
- execution.setVariable("nssiProfileID",nssiProfileID)
- if(isBlank(nssiInstanceId))
- {
- nssmfOperation="create"
- nssiInstanceId = UUID.randomUUID().toString()
- }else {
- nssmfOperation = "update"
- }
- execution.setVariable("nssmfOperation",nssmfOperation)
- execution.setVariable("nssiInstanceId",nssiInstanceId)
-
- def isDebugLogEnabled ="false"
- def isNSSICreated = false
- execution.setVariable("isNSSICreated",isNSSICreated)
-
- int currentCycle = 0
- execution.setVariable("currentCycle", currentCycle)
-
- logger.trace("Exit preProcessRequest")
- }
-
-
- void getNSSTInfo(DelegateExecution execution){
- logger.trace("Enter getNSSTInfo in DoAllocateNSSI()")
- ServiceDecomposition serviceDecomposition= execution.getVariable("serviceDecomposition")
- ModelInfo modelInfo = serviceDecomposition.getModelInfo()
- String serviceRole = "nssi"
- String nssiServiceInvariantUuid = serviceDecomposition.modelInfo.getModelInvariantUuid()
- String nssiServiceUuid = serviceDecomposition.modelInfo.getModelUuid()
- String nssiServiceType = serviceDecomposition.getServiceType()
- String uuiRequest = execution.getVariable("uuiRequest")
- String nssiServiceName = "nssi_"+jsonUtil.getJsonValue(uuiRequest, "service.name")
- execution.setVariable("nssiServiceName",nssiServiceName)
- execution.setVariable("nssiServiceType",nssiServiceType)
- execution.setVariable("nssiServiceInvariantUuid",nssiServiceInvariantUuid)
- execution.setVariable("nssiServiceUuid",nssiServiceUuid)
- execution.setVariable("serviceRole",serviceRole)
-
- String content = serviceDecomposition.getServiceInfo().getServiceArtifact().get(0).getContent()
- String nsstID = jsonUtil.getJsonValue(content, "metadata.id")
- String nsstVendor = jsonUtil.getJsonValue(content, "metadata.vendor")
- String nsstDomain = jsonUtil.getJsonValue(content, "metadata.domainType")
- String nsstType = jsonUtil.getJsonValue(content, "metadata.type")
+ ObjectMapper objectMapper = new ObjectMapper()
- execution.setVariable("nsstID",nsstID)
- execution.setVariable("nsstVendor",nsstVendor)
- execution.setVariable("nsstDomain",nsstDomain)
- execution.setVariable("nssiServiceUuid",nssiServiceUuid)
- execution.setVariable("nsstType",nsstType)
-
- String nsstContentInfo = """{
- "NsstID":"${nsstID}",
- "Vendor":"${nsstVendor}",
- "type":"${nsstType}"
- }"""
-
- logger.trace("Exit getNSSTInfo in DoAllocateNSSI()")
- }
-
- void timeDelay(DelegateExecution execution) {
- logger.trace("Enter timeDelay in DoAllocateNSSI()")
- try {
- Thread.sleep(60000);
- int currentCycle = execution.getVariable("currentCycle")
- currentCycle=currentCycle+1
- if(currentCycle>60)
- {
- logger.trace("Completed all the retry times... but still nssmf havent completed the creation process...")
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, "NSSMF creation didnt complete by time...")
- }
- execution.setVariable("currentCycle",currentCycle)
- } catch(InterruptedException e) {
- logger.info("Time Delay exception" + e)
- }
- logger.trace("Exit timeDelay in DoAllocateNSSI()")
- }
+ private NssmfAdapterUtils nssmfAdapterUtils = new NssmfAdapterUtils(httpClientFactory, jsonUtil)
+ private static final NSSMF_ALLOCATE_URL = "/api/rest/provMns/v1/NSS/SliceProfiles"
- void sendUpdateRequestNSSMF(DelegateExecution execution) {
- logger.debug("Enter sendUpdateRequestNSSMF in DoAllocateNSSI()")
- String domain = execution.getVariable("nsstDomain")
- String nssmfRequest = buildUpdateNSSMFRequest(execution, domain.toUpperCase())
+ private static final NSSMF_QUERY_JOB_STATUS_URL = "/NSS/jobs/%s"
- String urlString = "/api/rest/provMns/v1/NSS/SliceProfiles"
+ @Override
+ void preProcessRequest(DelegateExecution execution) {
+ logger.trace("Enter preProcessRequest()")
- String nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, nssmfRequest)
+ NssmfAdapterNBIRequest nbiRequest = execution.getVariable("nbiRequest") as NssmfAdapterNBIRequest
- 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)
+ //SliceTaskInfo sliceTaskInfo = execution.getVariable("sliceTaskInfo") as SliceTaskInfo
+ boolean isNSIOptionAvailable = execution.getVariable("isNSIOptionAvailable") as Boolean
+ if (isNSIOptionAvailable) {
+ nbiRequest.serviceInfo.setActionType("modify")
} else {
- logger.error("received error message from NSSMF : "+ nssmfResponse)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.")
+ nbiRequest.serviceInfo.setActionType("allocate")
}
- logger.trace("Exit sendUpdateRequestNSSMF in DoAllocateNSSI()")
+ execution.setVariable("nbiRequest", nbiRequest)
+ logger.trace("Exit preProcessRequest")
}
+ /**
+ * send Create Request NSSMF
+ * @param execution
+ */
void sendCreateRequestNSSMF(DelegateExecution execution) {
- logger.debug("Enter sendCreateRequestNSSMF in DoAllocateNSSI()")
- //Prepare auth for NSSMF - Begin
- String domain = execution.getVariable("nsstDomain")
- String nssmfRequest = buildCreateNSSMFRequest(execution, domain.toUpperCase())
-
- String urlString = "/api/rest/provMns/v1/NSS/SliceProfiles"
-
- String nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, nssmfRequest)
-
- 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 {
- logger.error("received error message from NSSMF : "+ nssmfResponse)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.")
- }
-
- logger.debug("Exit sendCreateRequestNSSMF in DoAllocateNSSI()")
+ NssmfAdapterNBIRequest nbiRequest = execution.getVariable("nbiRequest") as NssmfAdapterNBIRequest
+ String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, NSSMF_ALLOCATE_URL,
+ objectMapper.writeValueAsString(nbiRequest))
+ ResponseEntity responseEntity = objectMapper.readValue(response, ResponseEntity.class)
+ String respBody = responseEntity.getBody()
+ NssiResponse result = objectMapper.readValue(respBody, NssiResponse.class)
+ //todo: if success
+ //todo:
+ execution.setVariable("serviceInfo", nbiRequest.getServiceInfo())
+ execution.setVariable("esrInfo", nbiRequest.getEsrInfo())
}
- void getNSSMFProgresss(DelegateExecution execution) {
- logger.debug("Enter getNSSMFProgresss in DoAllocateNSSI()")
-
- String nssmfRequest = buildNSSMFProgressRequest(execution)
- String strUrl="/api/rest/provMns/v1/NSS/jobs/" + execution.getVariable("jobId")
-
- String nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, strUrl, nssmfRequest)
-
- if(nssmfResponse != null){
- Boolean isNSSICreated = false
- execution.setVariable("nssmfResponse", nssmfResponse)
- 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)
- isNSSICreated = true
- execution.setVariable("isNSSICreated",isNSSICreated)
- } else {
- logger.error("received error message from NSSMF : "+ nssmfResponse)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.")
- }
- logger.debug("Exit getNSSMFProgresss in DoAllocateNSSI()")
- }
-
- void updateRelationship(DelegateExecution execution) {
- logger.debug("Enter updateRelationship in DoAllocateNSSI()")
- String nssiInstanceId = execution.getVariable("nssiInstanceId")
- String nsiInstanceId = execution.getVariable("nsiServiceInstanceId")
- try{
- AAIResourceUri nsiServiceuri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, nsiInstanceId);
- AAIResourceUri nssiServiceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, nssiInstanceId)
- getAAIClient().connect(nsiServiceuri, nssiServiceUri, AAIEdgeLabel.COMPOSED_OF);
- }catch(Exception ex) {
- String msg = "Exception in DoAllocateNSSI InstantiateNSSI service while creating relationship " + ex.getMessage()
- logger.info(msg)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
- }
- logger.debug("Exit updateRelationship in DoAllocateNSSI()")
- }
-
-
- void instantiateNSSIService(DelegateExecution execution) {
- logger.trace("Enter instantiateNSSIService in DoAllocateNSSI()")
- //String nssiInstanceId = execution.getVariable("nssiInstanceId")
- String nssiInstanceId = execution.getVariable("nssiId")
- execution.setVariable("nssiInstanceId",nssiInstanceId)
- String sliceInstanceId = execution.getVariable("nsiServiceInstanceId")
- try {
- org.onap.aai.domain.yang.ServiceInstance nssi = new ServiceInstance();
- Map<String, Object> serviceProfileMap = execution.getVariable("serviceProfile")
-
- nssi.setServiceInstanceId(nssiInstanceId)
- nssi.setServiceInstanceName(execution.getVariable("nssiServiceName"))
- //nssi.setServiceType(execution.getVariable("nssiServiceType"))
- nssi.setServiceType(serviceProfileMap.get("sST").toString())
- String serviceStatus = "deactivated"
- nssi.setOrchestrationStatus(serviceStatus)
- String modelInvariantUuid = execution.getVariable("nssiServiceInvariantUuid")
- String modelUuid = execution.getVariable("nssiServiceUuid")
- nssi.setModelInvariantId(modelInvariantUuid)
- nssi.setModelVersionId(modelUuid)
- String uuiRequest = execution.getVariable("uuiRequest")
- String serviceInstanceLocationid = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs.plmnIdList")
- nssi.setServiceInstanceLocationId(serviceInstanceLocationid)
- //String snssai = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs.sNSSAI")
- String envContext=execution.getVariable("nsstDomain")
- nssi.setEnvironmentContext(envContext)
- nssi.setServiceRole(execution.getVariable("serviceRole"))
- AAIResourcesClient client = new AAIResourcesClient()
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), nssiInstanceId)
- client.create(uri, nssi)
- } catch (BpmnError e) {
- throw e
- } catch (Exception ex) {
- String msg = "Exception in DoCreateSliceServiceInstance.instantiateSliceService. " + ex.getMessage()
- logger.info(msg)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
- }
- try{
- AAIResourceUri nsiServiceuri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, sliceInstanceId);
- AAIResourceUri nssiServiceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, nssiInstanceId)
- getAAIClient().connect(nsiServiceuri, nssiServiceUri, AAIEdgeLabel.COMPOSED_OF);
- }catch(Exception ex) {
- String msg = "Exception in DoAllocateNSSI InstantiateNSSI service while creating relationship " + ex.getMessage()
- logger.info(msg)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
- }
-
-
-
- def rollbackData = execution.getVariable("RollbackData")
- if (rollbackData == null) {
- rollbackData = new RollbackData();
- }
- //rollbackData.put("SERVICEINSTANCE", "disableRollback", idisableRollback.toStrng())
- rollbackData.put("SERVICEINSTANCE", "rollbackAAI", "true")
- rollbackData.put("SERVICEINSTANCE", "serviceInstanceId", nssiInstanceId)
- rollbackData.put("SERVICEINSTANCE", "subscriptionServiceType", execution.getVariable("subscriptionServiceType"))
- rollbackData.put("SERVICEINSTANCE", "globalSubscriberId", execution.getVariable("globalSubscriberId"))
- execution.setVariable("rollbackData", rollbackData)
- execution.setVariable("RollbackData", rollbackData)
- logger.debug("RollbackData:" + rollbackData)
- logger.trace("Exit instantiateNSSIService in DoAllocateNSSI()")
- }
-
-
- void createSliceProfile(DelegateExecution execution) {
- logger.trace("Enter createSliceProfile in DoAllocateNSSI()")
- String sliceserviceInstanceId = execution.getVariable("nssiInstanceId")
- String nssiProfileID = execution.getVariable("nssiProfileID")
- Map<String, Object> sliceProfileMap = execution.getVariable("sliceProfileCn")
- Map<String, Object> serviceProfileMap = execution.getVariable("serviceProfile")
- SliceProfile sliceProfile = new SliceProfile()
- sliceProfile.setServiceAreaDimension("")
- sliceProfile.setPayloadSize(0)
- sliceProfile.setJitter(0)
- sliceProfile.setSurvivalTime(0)
- //sliceProfile.setCsAvailability()
- //sliceProfile.setReliability()
- sliceProfile.setExpDataRate(0)
- sliceProfile.setTrafficDensity(0)
- sliceProfile.setConnDensity(0)
- sliceProfile.setSNssai(sliceProfileMap.get("sNSSAI").toString())
- sliceProfile.setExpDataRateUL(Integer.parseInt(sliceProfileMap.get("expDataRateUL").toString()))
- sliceProfile.setExpDataRateDL(Integer.parseInt(sliceProfileMap.get("expDataRateDL").toString()))
- sliceProfile.setActivityFactor(Integer.parseInt(sliceProfileMap.get("activityFactor").toString()))
- sliceProfile.setResourceSharingLevel(sliceProfileMap.get("activityFactor").toString())
- sliceProfile.setUeMobilityLevel(serviceProfileMap.get("uEMobilityLevel").toString())
- sliceProfile.setCoverageAreaTAList(serviceProfileMap.get("coverageAreaTAList").toString())
- sliceProfile.setMaxNumberOfUEs(Integer.parseInt(sliceProfileMap.get("activityFactor").toString()))
- sliceProfile.setLatency(Integer.parseInt(sliceProfileMap.get("latency").toString()))
- sliceProfile.setProfileId(nssiProfileID)
- sliceProfile.setE2ELatency(0)
-
- try {
- AAIResourcesClient client = new AAIResourcesClient()
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE,
- execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), sliceserviceInstanceId, nssiProfileID)
- client.create(uri, sliceProfile)
- } catch (BpmnError e) {
- throw e
- } catch (Exception ex) {
- String msg = "Exception in DoCreateSliceServiceInstance.instantiateSliceService. " + ex.getMessage()
- logger.info(msg)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
- }
-
- def rollbackData = execution.getVariable("RollbackData")
- if (rollbackData == null) {
- rollbackData = new RollbackData();
- }
- //rollbackData.put("SERVICEINSTANCE", "disableRollback", disableRollback.toString())
- rollbackData.put("SERVICEINSTANCE", "rollbackAAI", "true")
- rollbackData.put("SERVICEINSTANCE", "serviceInstanceId", sliceserviceInstanceId)
- rollbackData.put("SERVICEINSTANCE", "subscriptionServiceType", execution.getVariable("serviceType"))
- rollbackData.put("SERVICEINSTANCE", "globalSubscriberId", execution.getVariable("globalSubscriberId"))
- execution.setVariable("rollbackData", rollbackData)
- execution.setVariable("RollbackData", rollbackData)
- logger.debug("RollbackData:" + rollbackData)
- logger.trace("Exit createSliceProfile in DoAllocateNSSI()")
- }
-
-
- String buildCreateNSSMFRequest(DelegateExecution execution, String domain) {
-
- NssiAllocateRequest request = new NssiAllocateRequest()
- String strRequest = ""
- //String uuiRequest = execution.getVariable("uuiRequest")
- SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams")
-
- switch (domain) {
- case "AN":
- EsrInfo esrInfo = new EsrInfo()
- esrInfo.setNetworkType(execution.getVariable("networkType"))
- esrInfo.setVendor(execution.getVariable("nsstVendor"))
-
- NsiInfo nsiInfo = new NsiInfo()
- nsiInfo.setNsiId(execution.getVariable("nsiInstanceID"))
- nsiInfo.setNsiName(execution.getVariable("nsiInstanceName"))
-
- AnSliceProfile anSliceProfile = new AnSliceProfile()
- anSliceProfile.setLatency(execution.getVariable("latency"))
- anSliceProfile.setCoverageAreaTAList(execution.getVariable("coverageAreaList"))
- anSliceProfile.setQi(execution.getVariable("qi"))
-
- AllocateAnNssi allocateAnNssi = new AllocateAnNssi()
- allocateAnNssi.setNsstId(execution.getVariable("nsstId"))
- allocateAnNssi.setNssiName(execution.getVariable("nssiName"))
- allocateAnNssi.setNsiInfo(nsiInfo)
- allocateAnNssi.setSliceProfile(anSliceProfile)
- String anScriptName = sliceTaskParams.getAnScriptName()
- allocateAnNssi.setScriptName(anScriptName)
-
- request.setAllocateAnNssi(allocateAnNssi)
- request.setEsrInfo(esrInfo)
- break;
- case "CN":
- Map<String, Object> sliceProfileCn =execution.getVariable("sliceProfileCn")
- Map<String, Object> serviceProfile = execution.getVariable("serviceProfile")
- NsiInfo nsiInfo = new NsiInfo()
- nsiInfo.setNsiId(execution.getVariable("nsiServiceInstanceId"))
- nsiInfo.setNsiName(execution.getVariable("nsiServiceInstanceName"))
-
- EsrInfo esrInfo = new EsrInfo()
- esrInfo.setNetworkType(NetworkType.fromString(domain))
- esrInfo.setVendor(execution.getVariable("nsstVendor"))
- execution.setVariable("esrInfo",esrInfo)
-
-
- PerfReqEmbb perfReqEmbb = new PerfReqEmbb()
- perfReqEmbb.setActivityFactor(sliceProfileCn.get("activityFactor"))
- perfReqEmbb.setAreaTrafficCapDL(sliceProfileCn.get("areaTrafficCapDL"))
- perfReqEmbb.setAreaTrafficCapUL(sliceProfileCn.get("areaTrafficCapUL"))
- perfReqEmbb.setExpDataRateDL(sliceProfileCn.get("expDataRateDL"))
- perfReqEmbb.setExpDataRateUL(sliceProfileCn.get("expDataRateUL"))
-
- List<PerfReqEmbb> listPerfReqEmbbList = new ArrayList<>()
- listPerfReqEmbbList.add(perfReqEmbb)
-
- PerfReq perfReq = new PerfReq()
- perfReq.setPerfReqEmbbList(listPerfReqEmbbList)
-
- PerfReqUrllc perfReqUrllc = new PerfReqUrllc()
- perfReqUrllc.setConnDensity(0)
- perfReqUrllc.setTrafficDensity(0)
- perfReqUrllc.setExpDataRate(0)
- perfReqUrllc.setReliability(0)
- perfReqUrllc.setCsAvailability(0)
- perfReqUrllc.setSurvivalTime(0)
- perfReqUrllc.setJitter(0)
- perfReqUrllc.setE2eLatency(0)
- perfReqUrllc.setPayloadSize("0")
- perfReqUrllc.setServiceAreaDimension("")
-
- List<PerfReqUrllc> perfReqUrllcList = new ArrayList<>()
- perfReqUrllcList.add(perfReqUrllc)
- perfReq.setPerfReqUrllcList(perfReqUrllcList)
-
- CnSliceProfile cnSliceProfile = new CnSliceProfile()
- cnSliceProfile.setSliceProfileId(execution.getVariable("nssiProfileID"))
- String plmnStr = serviceProfile.get("plmnIdList")
- List<String> plmnIdList=Arrays.asList(plmnStr.split("\\|"))
- cnSliceProfile.setPlmnIdList(plmnIdList)
-
- String resourceSharingLevel = serviceProfile.get("resourceSharingLevel").toString()
- cnSliceProfile.setResourceSharingLevel(ResourceSharingLevel.fromString(resourceSharingLevel))
-
- String coverageArea = serviceProfile.get("coverageAreaTAList")
- List<String> coverageAreaList=Arrays.asList(coverageArea.split("\\|"))
- cnSliceProfile.setCoverageAreaTAList(coverageAreaList)
-
- String ueMobilityLevel = serviceProfile.get("uEMobilityLevel").toString()
- cnSliceProfile.setUeMobilityLevel(UeMobilityLevel.fromString(ueMobilityLevel))
-
- int latency = serviceProfile.get("latency")
- cnSliceProfile.setLatency(latency)
-
- int maxUE = serviceProfile.get("maxNumberofUEs")
- cnSliceProfile.setMaxNumberofUEs(maxUE)
-
- String snssai = serviceProfile.get("sNSSAI")
- List<String> snssaiList = Arrays.asList(snssai.split("\\|"))
- cnSliceProfile.setSnssaiList(snssaiList)
-
- cnSliceProfile.setPerfReq(perfReq)
-
- AllocateCnNssi allocateCnNssi = new AllocateCnNssi()
- allocateCnNssi.setNsstId(execution.getVariable("nsstid"))
- allocateCnNssi.setNssiName(execution.getVariable("nssiName"))
- allocateCnNssi.setSliceProfile(cnSliceProfile)
- allocateCnNssi.setNsiInfo(nsiInfo)
- String cnScriptName = sliceTaskParams.getCnScriptName()
- allocateCnNssi.setScriptName(cnScriptName)
- request.setAllocateCnNssi(allocateCnNssi)
- request.setEsrInfo(esrInfo)
- break;
- case "TN":
- EsrInfo esrInfo = new EsrInfo()
- esrInfo.setNetworkType(execution.getVariable("networkType"))
- esrInfo.setVendor(execution.getVariable("vendor"))
-
- TnSliceProfile tnSliceProfile = new TnSliceProfile()
- tnSliceProfile.setLatency(execution.getVariable("latency"))
- tnSliceProfile.setBandwidth(execution.getVariable("bandWidth"))
-
- NsiInfo nsiInfo = new NsiInfo()
- nsiInfo.setNsiId(execution.getVariable("nsiInstanceID"))
- nsiInfo.setNsiName(execution.getVariable("nsiInstanceName"))
-
- AllocateTnNssi allocateTnNssi = new AllocateTnNssi()
- allocateTnNssi.setSliceProfile(tnSliceProfile)
- allocateTnNssi.setNsiInfo(nsiInfo)
- allocateTnNssi.setNsstId(execution.getVariable("nsstid"))
- String tnScriptName = sliceTaskParams.getTnScriptName()
- allocateTnNssi.setScriptName(tnScriptName)
-
- request.setAllocateTnNssi(allocateTnNssi)
- request.setEsrInfo(esrInfo)
- break;
- default:
- break;
- }
- try {
- strRequest = MAPPER.writeValueAsString(request);
- } catch (IOException e) {
- logger.error("Invalid get progress request bean to convert as string");
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Invalid get progress request bean to convert as string")
- }
- return strRequest
- }
-
-
- String buildUpdateNSSMFRequest(DelegateExecution execution, String domain) {
- NssiAllocateRequest request = new NssiAllocateRequest()
- String nsstInput = execution.getVariable("nsstInput")
- String nssiId = jsonUtil.getJsonValue(nsstInput, "serviceInstanceId")
- String strRequest = ""
- SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams")
- switch (domain) {
- case "AN":
- EsrInfo esrInfo = new EsrInfo()
- esrInfo.setNetworkType(execution.getVariable("nsstType"))
- esrInfo.setVendor(execution.getVariable("vendor"))
-
- NsiInfo nsiInfo = new NsiInfo()
- nsiInfo.setNsiId(execution.getVariable("nsiInstanceID"))
- nsiInfo.setNsiName(execution.getVariable("nsiInstanceName"))
-
- AnSliceProfile anSliceProfile = new AnSliceProfile()
- anSliceProfile.setLatency(execution.getVariable("latency"))
- anSliceProfile.setCoverageAreaTAList(execution.getVariable("coverageAreaList"))
- anSliceProfile.setQi(execution.getVariable("qi"))
-
- AllocateAnNssi allocateAnNssi = new AllocateAnNssi()
- allocateAnNssi.setNsstId(execution.getVariable("nsstId"))
- allocateAnNssi.setNssiName(execution.getVariable("nssiName"))
- allocateAnNssi.setNsiInfo(nsiInfo)
- allocateAnNssi.setSliceProfile(anSliceProfile)
- String anScriptName = sliceTaskParams.getAnScriptName()
- allocateAnNssi.setScriptName(anScriptName)
- request.setAllocateAnNssi(allocateAnNssi)
- request.setEsrInfo(esrInfo)
- break;
- case "CN":
- Map<String, Object> sliceProfileCn =execution.getVariable("sliceProfileCn")
- Map<String, Object> serviceProfile = execution.getVariable("serviceProfile")
- NsiInfo nsiInfo = new NsiInfo()
- nsiInfo.setNsiId(execution.getVariable("nsiServiceInstanceId"))
- nsiInfo.setNsiName(execution.getVariable("nsiServiceInstanceName"))
-
- EsrInfo esrInfo = new EsrInfo()
- esrInfo.setNetworkType(NetworkType.fromString(domain))
- esrInfo.setVendor(execution.getVariable("nsstVendor"))
- execution.setVariable("esrInfo",esrInfo)
-
-
- PerfReqEmbb perfReqEmbb = new PerfReqEmbb()
- perfReqEmbb.setActivityFactor(sliceProfileCn.get("activityFactor"))
- perfReqEmbb.setAreaTrafficCapDL(sliceProfileCn.get("areaTrafficCapDL"))
- perfReqEmbb.setAreaTrafficCapUL(sliceProfileCn.get("areaTrafficCapUL"))
- perfReqEmbb.setExpDataRateDL(sliceProfileCn.get("expDataRateDL"))
- perfReqEmbb.setExpDataRateUL(sliceProfileCn.get("expDataRateUL"))
-
- List<PerfReqEmbb> listPerfReqEmbbList = new ArrayList<>()
- listPerfReqEmbbList.add(perfReqEmbb)
-
- PerfReq perfReq = new PerfReq()
- perfReq.setPerfReqEmbbList(listPerfReqEmbbList)
-
- PerfReqUrllc perfReqUrllc = new PerfReqUrllc()
- perfReqUrllc.setConnDensity(0)
- perfReqUrllc.setTrafficDensity(0)
- perfReqUrllc.setExpDataRate(0)
- perfReqUrllc.setReliability(0)
- perfReqUrllc.setCsAvailability(0)
- perfReqUrllc.setSurvivalTime(0)
- perfReqUrllc.setJitter(0)
- perfReqUrllc.setE2eLatency(0)
- perfReqUrllc.setPayloadSize("0")
- perfReqUrllc.setServiceAreaDimension("")
-
- List<PerfReqUrllc> perfReqUrllcList = new ArrayList<>()
- perfReqUrllcList.add(perfReqUrllc)
- perfReq.setPerfReqUrllcList(perfReqUrllcList)
-
- CnSliceProfile cnSliceProfile = new CnSliceProfile()
- cnSliceProfile.setSliceProfileId(execution.getVariable("nssiProfileID"))
- String plmnStr = serviceProfile.get("plmnIdList")
- List<String> plmnIdList=Arrays.asList(plmnStr.split("\\|"))
- cnSliceProfile.setPlmnIdList(plmnIdList)
-
- String resourceSharingLevel = serviceProfile.get("resourceSharingLevel").toString()
- cnSliceProfile.setResourceSharingLevel(ResourceSharingLevel.fromString(resourceSharingLevel))
-
- String coverageArea = serviceProfile.get("coverageAreaTAList")
- List<String> coverageAreaList=Arrays.asList(coverageArea.split("\\|"))
- cnSliceProfile.setCoverageAreaTAList(coverageAreaList)
-
- String ueMobilityLevel = serviceProfile.get("uEMobilityLevel").toString()
- cnSliceProfile.setUeMobilityLevel(UeMobilityLevel.fromString(ueMobilityLevel))
-
- int latency = serviceProfile.get("latency")
- cnSliceProfile.setLatency(latency)
-
- int maxUE = serviceProfile.get("maxNumberofUEs")
- cnSliceProfile.setMaxNumberofUEs(maxUE)
+ /**
+ * query nssi allocate status
+ * @param execution
+ */
+ void queryNSSIStatus(DelegateExecution execution) {
+ NssmfAdapterNBIRequest nbiRequest = new NssmfAdapterNBIRequest()
+ NssiResponse nssiAllocateResult = execution.getVariable("nssiAllocateResult") as NssiResponse
+ String jobId = nssiAllocateResult.getJobId()
+ String nssiId = nssiAllocateResult.getNssiId()
- String snssai = serviceProfile.get("sNSSAI")
- List<String> snssaiList = Arrays.asList(snssai.split("\\|"))
- cnSliceProfile.setSnssaiList(snssaiList)
+ ServiceInfo serviceInfo = execution.getVariable("serviceInfo") as ServiceInfo
+ serviceInfo.setNssiId(nssiId)
+ EsrInfo esrInfo = execution.getVariable("esrInfo") as EsrInfo
- cnSliceProfile.setPerfReq(perfReq)
+ //nbiRequest.setResponseId(jobId)
+ nbiRequest.setServiceInfo(serviceInfo)
+ nbiRequest.setEsrInfo(esrInfo)
- AllocateCnNssi allocateCnNssi = new AllocateCnNssi()
- allocateCnNssi.setNsstId(execution.getVariable("nsstid"))
- allocateCnNssi.setNssiName(execution.getVariable("nssiName"))
- allocateCnNssi.setSliceProfile(cnSliceProfile)
- allocateCnNssi.setNsiInfo(nsiInfo)
- allocateCnNssi.setNssiId(nssiId) // need to check this
- String cnScriptName = sliceTaskParams.getCnScriptName()
- allocateCnNssi.setScriptName(cnScriptName)
- request.setAllocateCnNssi(allocateCnNssi)
- request.setEsrInfo(esrInfo)
- break;
- case "TN":
- EsrInfo esrInfo = new EsrInfo()
- esrInfo.setNetworkType(execution.getVariable("networkType"))
- esrInfo.setVendor(execution.getVariable("vendor"))
+ String endpoint = String.format(NSSMF_QUERY_JOB_STATUS_URL, jobId)
- TnSliceProfile tnSliceProfile = new TnSliceProfile()
- tnSliceProfile.setLatency(execution.getVariable("latency"))
- tnSliceProfile.setBandwidth(execution.getVariable("bandWidth"))
+ String response =
+ nssmfAdapterUtils.sendPostRequestNSSMF(execution, endpoint, objectMapper.writeValueAsString(nbiRequest))
- NsiInfo nsiInfo = new NsiInfo()
- nsiInfo.setNsiId(execution.getVariable("nsiInstanceID"))
- nsiInfo.setNsiName(execution.getVariable("nsiInstanceName"))
+ ResponseEntity responseEntity = objectMapper.readValue(response, ResponseEntity.class)
+ String result = responseEntity.getBody()
+ //todo;if success
+ ResponseDescriptor responseDescriptor = objectMapper.readValue(result, ResponseDescriptor.class)
- AllocateTnNssi allocateTnNssi = new AllocateTnNssi()
- allocateTnNssi.setSliceProfile(tnSliceProfile)
- allocateTnNssi.setNsiInfo(nsiInfo)
- allocateTnNssi.setNsstId(execution.getVariable("nsstid"))
- String tnScriptName = sliceTaskParams.getTnScriptName()
- allocateTnNssi.setScriptName(tnScriptName)
- request.setAllocateTnNssi(allocateTnNssi)
- request.setEsrInfo(esrInfo)
- break;
- default:
- break;
- }
- try {
- strRequest = MAPPER.writeValueAsString(request);
- } catch (IOException e) {
- logger.error("Invalid get progress request bean to convert as string");
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Invalid get progress request bean to convert as string")
- }
- return strRequest
+ //todo: handle status
+ execution.setVariable("nssiAllocateResult", responseDescriptor)
}
- String buildNSSMFProgressRequest(DelegateExecution execution){
- JobStatusRequest request = new JobStatusRequest()
- String strRequest = ""
- EsrInfo esrInfo = execution.getVariable("esrInfo")
- request.setNsiId(execution.getVariable("nsiServiceInstanceId"))
- request.setNssiId(execution.getVariable("nssiId"))
- request.setEsrInfo(esrInfo)
-
- try {
- strRequest = MAPPER.writeValueAsString(request);
- } catch (IOException e) {
- logger.error("Invalid get progress request bean to convert as string");
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Invalid get progress request bean to convert as string")
- }
- return strRequest
+ void prepareUpdateOrchestrationTask(DelegateExecution execution) {
+ //todo;update orchestration task
}
- public void prepareUpdateOrchestrationTask(DelegateExecution execution) {
- logger.debug("Start prepareUpdateOrchestrationTask progress")
- String requestMethod = "PUT"
- String progress = execution.getVariable("nssmfProgress")
- String status = execution.getVariable("nssmfStatus")
- String statusDescription=execution.getVariable("nddmfStatusDescription")
- SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams")
- String domain = execution.getVariable("nsstDomain")
- switch (domain.toUpperCase()) {
- case "AN":
- sliceTaskParams.setAnProgress(progress)
- sliceTaskParams.setAnStatus(status)
- sliceTaskParams.setAnStatusDescription(statusDescription)
- break;
- case "CN":
- sliceTaskParams.setCnProgress(progress)
- sliceTaskParams.setCnStatus(status)
- sliceTaskParams.setCnStatusDescription(statusDescription)
- break;
- case "TN":
- sliceTaskParams.setTnProgress(progress)
- sliceTaskParams.setTnStatus(status)
- sliceTaskParams.setTnStatusDescription(statusDescription)
- break;
- default:
- break;
- }
- String paramJson = sliceTaskParams.convertToJson()
- execution.setVariable("CSSOT_paramJson", paramJson)
- execution.setVariable("CSSOT_requestMethod", requestMethod)
- logger.debug("Finish prepareUpdateOrchestrationTask progress")
+ void timeDelay(DelegateExecution execution) {
+ //todo: time delay
}
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSIV2.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSIV2.groovy
deleted file mode 100644
index 05bb53a61e..0000000000
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSIV2.groovy
+++ /dev/null
@@ -1,117 +0,0 @@
-package org.onap.so.bpmn.infrastructure.scripts
-
-import com.fasterxml.jackson.databind.ObjectMapper
-import org.apache.commons.lang3.StringUtils
-import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.onap.so.beans.nsmf.SliceTaskInfo
-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.core.domain.ModelInfo
-import org.onap.so.bpmn.core.domain.ServiceDecomposition
-import org.onap.so.bpmn.core.json.JsonUtils
-import org.slf4j.Logger
-import org.slf4j.LoggerFactory
-
-class DoAllocateNSSIV2 extends AbstractServiceTaskProcessor {
-
- private static final Logger logger = LoggerFactory.getLogger( DoAllocateNSSIV2.class);
- private static final ObjectMapper MAPPER = new ObjectMapper();
-
- ExceptionUtil exceptionUtil = new ExceptionUtil()
-
- JsonUtils jsonUtil = new JsonUtils()
-
- private NssmfAdapterUtils nssmfAdapterUtils = new NssmfAdapterUtils(httpClientFactory, jsonUtil)
-
- @Override
- void preProcessRequest(DelegateExecution execution) {
- logger.trace("Enter preProcessRequest()")
-
-// String nssmfOperation
-//
-// String nsstInput = execution.getVariable("nsstInput")
-// String modelUuid = jsonUtil.getJsonValue(nsstInput, "modelUuid")
-// //modelUuid="2763777c-27bd-4df7-93b8-c690e23f4d3f"
-// String nssiInstanceId = jsonUtil.getJsonValue(nsstInput, "serviceInstanceId")
-// String serviceModelInfo = """{
-// "modelInvariantUuid":"",
-// "modelUuid":"${modelUuid}",
-// "modelVersion":""
-// }"""
-// execution.setVariable("serviceModelInfo", serviceModelInfo)
-// execution.setVariable("nssiInstanceId", nssiInstanceId)
-// String nssiProfileID = UUID.randomUUID().toString()
-// execution.setVariable("nssiProfileID", nssiProfileID)
-// if(isBlank(nssiInstanceId))
-// {
-// nssmfOperation="create"
-// nssiInstanceId = UUID.randomUUID().toString()
-// }else {
-// nssmfOperation = "update"
-// }
-// execution.setVariable("nssmfOperation",nssmfOperation)
-// execution.setVariable("nssiInstanceId",nssiInstanceId)
-//
-// def isNSSICreated = false
-// execution.setVariable("isNSSICreated",isNSSICreated)
-//
-// int currentCycle = 0
-// execution.setVariable("currentCycle", currentCycle)
-
-
- SliceTaskInfo sliceTaskInfo = execution.getVariable("sliceTaskInfo") as SliceTaskInfo
- if (StringUtils.isBlank(sliceTaskInfo.suggestNssiId)) {
- execution.setVariable("nssmfOperation", "create")
- } else {
- execution.setVariable("nssmfOperation", "update")
- }
- logger.trace("Exit preProcessRequest")
- }
-
- /**
- * prepare nssi request
- * @param execution
- */
- void prepareNSSIReq(DelegateExecution execution) {
-
- }
-
- void getNSSTInfo(DelegateExecution execution){
- logger.trace("Enter getNSSTInfo in DoAllocateNSSI()")
- ServiceDecomposition serviceDecomposition= execution.getVariable("serviceDecomposition")
- ModelInfo modelInfo = serviceDecomposition.getModelInfo()
- String serviceRole = "nssi"
- String nssiServiceInvariantUuid = serviceDecomposition.modelInfo.getModelInvariantUuid()
- String nssiServiceUuid = serviceDecomposition.modelInfo.getModelUuid()
- String nssiServiceType = serviceDecomposition.getServiceType()
- String uuiRequest = execution.getVariable("uuiRequest")
- String nssiServiceName = "nssi_"+jsonUtil.getJsonValue(uuiRequest, "service.name")
- execution.setVariable("nssiServiceName",nssiServiceName)
- execution.setVariable("nssiServiceType",nssiServiceType)
- execution.setVariable("nssiServiceInvariantUuid",nssiServiceInvariantUuid)
- execution.setVariable("nssiServiceUuid",nssiServiceUuid)
- execution.setVariable("serviceRole",serviceRole)
-
- String content = serviceDecomposition.getServiceInfo().getServiceArtifact().get(0).getContent()
- String nsstID = jsonUtil.getJsonValue(content, "metadata.id")
- String nsstVendor = jsonUtil.getJsonValue(content, "metadata.vendor")
- String nsstDomain = jsonUtil.getJsonValue(content, "metadata.domainType")
- String nsstType = jsonUtil.getJsonValue(content, "metadata.type")
-
- execution.setVariable("nsstID",nsstID)
- execution.setVariable("nsstVendor",nsstVendor)
- execution.setVariable("nsstDomain",nsstDomain)
- execution.setVariable("nssiServiceUuid",nssiServiceUuid)
- execution.setVariable("nsstType",nsstType)
-
- String nsstContentInfo = """{
- "NsstID":"${nsstID}",
- "Vendor":"${nsstVendor}",
- "type":"${nsstType}"
- }"""
-
- logger.trace("Exit getNSSTInfo in DoAllocateNSSI()")
- }
-
-}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceInstance.groovy
index b71379449e..181e9d062a 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceInstance.groovy
@@ -1,28 +1,37 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2020, CMCC Technologies Co., Ltd.
+ #
+ # 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 org.onap.aai.domain.yang.AllottedResource
-
-import static org.apache.commons.lang3.StringUtils.*;
-
+import org.onap.aai.domain.yang.ServiceInstance
+import org.onap.so.beans.nsmf.SliceTaskParamsAdapter
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.onap.aai.domain.yang.OwningEntity
-import org.onap.aai.domain.yang.ServiceProfile;
+import org.onap.aai.domain.yang.ServiceProfile
import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
-import org.onap.so.bpmn.common.scripts.CatalogDbUtils
-import org.onap.so.bpmn.common.scripts.CatalogDbUtilsFactory
import org.onap.so.bpmn.common.scripts.ExceptionUtil
-import org.onap.so.bpmn.common.scripts.MsoUtils
-import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
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.domain.ModelInfo
import org.onap.so.bpmn.core.domain.ServiceDecomposition
-import org.onap.so.bpmn.core.domain.ServiceInstance
import org.onap.so.bpmn.core.json.JsonUtils
-import org.onap.so.bpmn.infrastructure.aai.groovyflows.AAICreateResources
import org.onap.aaiclient.client.aai.AAIObjectType
import org.onap.aaiclient.client.aai.AAIResourcesClient
import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri
@@ -34,13 +43,13 @@ import org.slf4j.LoggerFactory
class DoCreateSliceServiceInstance extends AbstractServiceTaskProcessor{
- private static final Logger logger = LoggerFactory.getLogger( DoCreateSliceServiceInstance.class);
+ private static final Logger logger = LoggerFactory.getLogger( DoCreateSliceServiceInstance.class)
+
JsonUtils jsonUtil = new JsonUtils()
ExceptionUtil exceptionUtil = new ExceptionUtil()
- CatalogDbUtils catalogDbUtils = new CatalogDbUtilsFactory().create()
-
+ AAIResourcesClient client = getAAIClient()
/**
* Pre Process the BPMN Flow Request
* Inclouds:
@@ -48,86 +57,54 @@ class DoCreateSliceServiceInstance extends AbstractServiceTaskProcessor{
* generate the nsParameters
*/
void preProcessRequest (DelegateExecution execution) {
- String msg = ""
logger.trace("Enter preProcessRequest()")
- //Need update
- //1. Prepare service parameter.
- //2. Prepare slice profile parameters.
+ //here modelVersion is not set, we use modelUuid to decompose the service.
+ def isDebugLogEnabled = true
+ execution.setVariable("isDebugLogEnabled", isDebugLogEnabled)
- String sliceserviceInstanceId = execution.getVariable("serviceInstanceId")
- String allottedResourceId = UUID.randomUUID().toString()
- execution.setVariable("sliceserviceInstanceId", sliceserviceInstanceId)
- execution.setVariable("allottedResourceId", allottedResourceId)
+ logger.trace("Exit preProcessRequest")
+ }
+
+ /**
+ * prepare decompose service profile instance template
+ * @param execution
+ */
+ public void prepareDecomposeService(DelegateExecution execution) {
String uuiRequest = execution.getVariable("uuiRequest")
String modelInvariantUuid = jsonUtil.getJsonValue(uuiRequest, "service.serviceInvariantUuid")
String modelUuid = jsonUtil.getJsonValue(uuiRequest, "service.serviceUuid")
- //here modelVersion is not set, we use modelUuid to decompose the service.
- def isDebugLogEnabled = true
- execution.setVariable("serviceInstanceId",sliceserviceInstanceId)
- execution.setVariable("isDebugLogEnabled",isDebugLogEnabled)
String serviceModelInfo = """{
"modelInvariantUuid":"${modelInvariantUuid}",
"modelUuid":"${modelUuid}",
"modelVersion":""
}"""
execution.setVariable("serviceModelInfo", serviceModelInfo)
-
- logger.trace("Exit preProcessRequest")
}
+ /**
+ * create service-profile instance in aai
+ * @param execution
+ */
+ void createServiceProfileInstance(DelegateExecution execution) {
- void createServiceProfile(DelegateExecution execution) {
-
- String sliceserviceInstanceId = execution.getVariable("sliceserviceInstanceId")
- Map<String, Object> serviceProfileMap = execution.getVariable("serviceProfile")
- String serviceProfileID = UUID.randomUUID().toString()
- ServiceProfile serviceProfile = new ServiceProfile();
- serviceProfile.setProfileId(serviceProfileID)
- serviceProfile.setLatency(Integer.parseInt(serviceProfileMap.get("latency").toString()))
- serviceProfile.setMaxNumberOfUEs(Integer.parseInt(serviceProfileMap.get("maxNumberofUEs").toString()))
- serviceProfile.setCoverageAreaTAList(serviceProfileMap.get("coverageAreaTAList").toString())
- serviceProfile.setUeMobilityLevel(serviceProfileMap.get("uEMobilityLevel").toString())
- serviceProfile.setResourceSharingLevel(serviceProfileMap.get("resourceSharingLevel").toString())
- serviceProfile.setExpDataRateUL(Integer.parseInt(serviceProfileMap.get("expDataRateUL").toString()))
- serviceProfile.setExpDataRateDL(Integer.parseInt(serviceProfileMap.get("expDataRateDL").toString()))
- serviceProfile.setAreaTrafficCapUL(Integer.parseInt(serviceProfileMap.get("areaTrafficCapUL").toString()))
- serviceProfile.setAreaTrafficCapDL(Integer.parseInt(serviceProfileMap.get("areaTrafficCapDL").toString()))
- serviceProfile.setActivityFactor(Integer.parseInt(serviceProfileMap.get("activityFactor").toString()))
-
- serviceProfile.setJitter(0)
- serviceProfile.setSurvivalTime(0)
- serviceProfile.setCsAvailability(new Object())
- serviceProfile.setReliability(new Object())
- serviceProfile.setExpDataRate(0)
- serviceProfile.setTrafficDensity(0)
- serviceProfile.setConnDensity(0)
- try {
- AAIResourcesClient client = new AAIResourcesClient()
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_PROFILE, execution.getVariable("globalSubscriberId"),
- execution.getVariable("subscriptionServiceType"), sliceserviceInstanceId, serviceProfileID)
- client.create(uri, serviceProfile)
-
- } catch (BpmnError e) {
- throw e
- } catch (Exception ex) {
- String msg = "Exception in DoCreateSliceServiceInstance.instantiateSliceService. " + ex.getMessage()
- logger.info(msg)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
- }
- }
-
- void instantiateSliceService(DelegateExecution execution) {
+ SliceTaskParamsAdapter sliceParams =
+ execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
- ServiceDecomposition serviceDecomposition= execution.getVariable("sliceServiceDecomposition")
- String uuiRequest = execution.getVariable("uuiRequest")
+ ServiceDecomposition serviceDecomposition =
+ execution.getVariable("serviceProfileDecomposition") as ServiceDecomposition
ModelInfo modelInfo = serviceDecomposition.getModelInfo()
- String serviceRole = "e2eslice-service"
+ //String serviceRole = "e2eslice-service"
+ /**
+ * todo: ServiceProfile params changed
+ * todo: role
+ */
+ String serviceRole = "service-profile"
String serviceType = execution.getVariable("serviceType")
- Map<String, Object> serviceProfile = execution.getVariable("serviceProfile")
+ Map<String, Object> serviceProfile = sliceParams.getServiceProfile()
String ssInstanceId = execution.getVariable("serviceInstanceId")
try {
- org.onap.aai.domain.yang.ServiceInstance ss = new org.onap.aai.domain.yang.ServiceInstance()
+ ServiceInstance ss = new ServiceInstance()
ss.setServiceInstanceId(ssInstanceId)
String sliceInstanceName = execution.getVariable("serviceInstanceName")
ss.setServiceInstanceName(sliceInstanceName)
@@ -143,8 +120,11 @@ class DoCreateSliceServiceInstance extends AbstractServiceTaskProcessor{
String snssai = serviceProfile.get("sNSSAI")
ss.setEnvironmentContext(snssai)
ss.setServiceRole(serviceRole)
- AAIResourcesClient client = new AAIResourcesClient()
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), ssInstanceId)
+
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,
+ execution.getVariable("globalSubscriberId"),
+ execution.getVariable("subscriptionServiceType"),
+ ssInstanceId)
client.create(uri, ss)
} catch (BpmnError e) {
throw e
@@ -157,7 +137,7 @@ class DoCreateSliceServiceInstance extends AbstractServiceTaskProcessor{
def rollbackData = execution.getVariable("RollbackData")
if (rollbackData == null) {
- rollbackData = new RollbackData();
+ rollbackData = new RollbackData()
}
//rollbackData.put("SERVICEINSTANCE", "disableRollback", disableRollback.toString())
rollbackData.put("SERVICEINSTANCE", "rollbackAAI", "true")
@@ -170,57 +150,100 @@ class DoCreateSliceServiceInstance extends AbstractServiceTaskProcessor{
}
+ /**
+ * create service profile in aai
+ * @param execution
+ */
+ void createServiceProfile(DelegateExecution execution) {
+
+ /**
+ * todo: ServiceProfile params changed
+ */
+ SliceTaskParamsAdapter sliceParams =
+ execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
+ Map<String, Object> serviceProfileMap = sliceParams.getServiceProfile()
- void createAllottedResource(DelegateExecution execution) {
- String serviceInstanceId = execution.getVariable('sliceserviceInstanceId')
-
- AAIResourcesClient resourceClient = new AAIResourcesClient()
- AAIResourceUri ssServiceuri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId)
-
-// try {
-//
-// if(resourceClient.exists(ssServiceuri)){
-// execution.setVariable("ssi_resourceLink", uri.build().toString())
-// }else{
-// exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service instance was not found in aai to " +
-// "associate allotted resource for service :"+serviceInstanceId)
-// }
-// }catch(BpmnError e) {
-// throw e;
-// }catch (Exception ex){
-// String msg = "Exception in getServiceInstance. " + ex.getMessage()
-// logger.debug(msg)
-// exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
-// }
+ String serviceProfileInstanceId = execution.getVariable("serviceInstanceId")
+ String serviceProfileId = UUID.randomUUID().toString()
+ sliceParams.serviceProfile.put("profileId", serviceProfileId)
+
+ ServiceProfile serviceProfile = new ServiceProfile()
+ serviceProfile.setProfileId(serviceProfileId)
+ serviceProfile.setLatency(Integer.parseInt(serviceProfileMap.get("latency").toString()))
+ serviceProfile.setMaxNumberOfUEs(Integer.parseInt(serviceProfileMap.get("maxNumberofUEs").toString()))
+ serviceProfile.setCoverageAreaTAList(serviceProfileMap.get("coverageAreaTAList").toString())
+ serviceProfile.setUeMobilityLevel(serviceProfileMap.get("uEMobilityLevel").toString())
+ serviceProfile.setResourceSharingLevel(serviceProfileMap.get("resourceSharingLevel").toString())
+ serviceProfile.setExpDataRateUL(Integer.parseInt(serviceProfileMap.get("expDataRateUL").toString()))
+ serviceProfile.setExpDataRateDL(Integer.parseInt(serviceProfileMap.get("expDataRateDL").toString()))
+ serviceProfile.setAreaTrafficCapUL(Integer.parseInt(serviceProfileMap.get("areaTrafficCapUL").toString()))
+ serviceProfile.setAreaTrafficCapDL(Integer.parseInt(serviceProfileMap.get("areaTrafficCapDL").toString()))
+ serviceProfile.setActivityFactor(Integer.parseInt(serviceProfileMap.get("activityFactor").toString()))
+
+ serviceProfile.setJitter(0)
+ serviceProfile.setSurvivalTime("0")
+ serviceProfile.setCsAvailability(new Object())
+ serviceProfile.setReliability("")
+ serviceProfile.setExpDataRate(0)
+ serviceProfile.setTrafficDensity(0)
+ serviceProfile.setConnDensity(0)
+ try {
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_PROFILE,
+ execution.getVariable("globalSubscriberId"),
+ execution.getVariable("subscriptionServiceType"),
+ serviceProfileInstanceId,
+ serviceProfileId)
+ client.create(uri, serviceProfile)
+ execution.setVariable("sliceTaskParams", sliceParams)
+
+ } catch (BpmnError e) {
+ throw e
+ } catch (Exception ex) {
+ String msg = "Exception in DoCreateSliceServiceInstance.instantiateSliceService. " + ex.getMessage()
+ logger.info(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ }
+
+ /**
+ * create allotted resource
+ * todo: unfinished
+ * @param execution
+ */
+ public void createAllottedResource(DelegateExecution execution) {
try {
- String allottedResourceId = execution.getVariable("allottedResourceId")
- ServiceDecomposition serviceDecomposition = execution.getVariable("sliceServiceDecomposition")
+
+ ServiceDecomposition serviceDecomposition =
+ execution.getVariable("serviceProfileDecomposition") as ServiceDecomposition
+
List<org.onap.so.bpmn.core.domain.AllottedResource> allottedResourceList = serviceDecomposition.getAllottedResources()
- for(org.onap.so.bpmn.core.domain.AllottedResource allottedResource : allottedResourceList)
- {
- //AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceFromParentURI(ssServiceuri, AAIObjectType.ALLOTTED_RESOURCE, allottedResourceId)
+ for(org.onap.so.bpmn.core.domain.AllottedResource allottedResource : allottedResourceList) {
+ String allottedResourceId = UUID.randomUUID().toString()
+
AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.ALLOTTED_RESOURCE,
- execution.getVariable("globalSubscriberId"),execution.getVariable("subscriptionServiceType"),
- execution.getVariable("sliceserviceInstanceId"), allottedResourceId)
+ execution.getVariable("globalSubscriberId"),
+ execution.getVariable("subscriptionServiceType"),
+ execution.getVariable("serviceInstanceId"),
+ allottedResourceId)
+
execution.setVariable("allottedResourceUri", allottedResourceUri)
String arType = allottedResource.getAllottedResourceType()
String arRole = allottedResource.getAllottedResourceRole()
String modelInvariantId = allottedResource.getModelInfo().getModelInvariantUuid()
String modelVersionId = allottedResource.getModelInfo().getModelUuid()
- org.onap.aai.domain.yang.AllottedResource resource = new org.onap.aai.domain.yang.AllottedResource()
+ AllottedResource resource = new AllottedResource()
resource.setId(allottedResourceId)
resource.setType(arType)
resource.setAllottedResourceName("Allotted_"+ execution.getVariable("serviceInstanceName"))
resource.setRole(arRole)
resource.setModelInvariantId(modelInvariantId)
resource.setModelVersionId(modelVersionId)
- getAAIClient().create(allottedResourceUri, resource)
- //AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.SERVICE_INSTANCE, UriBuilder.fromPath(ssServiceuri).build())
- //getAAIClient().connect(allottedResourceUri,ssServiceuri)
+
+ client.create(allottedResourceUri, resource)
+
}
- //execution.setVariable("aaiARPath", allottedResourceUri.build().toString());
}catch (Exception ex) {
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Exception in createAaiAR " + ex.getMessage())
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 9b78afba03..5cde856251 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
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP - SO
* ================================================================================
- # Copyright (c) 2019, CMCC Technologies Co., Ltd.
+ # Copyright (c) 2020, CMCC Technologies Co., Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License")
# you may not use this file except in compliance with the License.
@@ -20,37 +20,36 @@
package org.onap.so.bpmn.infrastructure.scripts
-import com.fasterxml.jackson.core.type.TypeReference
import com.fasterxml.jackson.databind.ObjectMapper
-import groovy.json.JsonSlurper
import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.onap.logging.filter.base.ONAPComponents
+import org.onap.so.beans.nsmf.AnSliceProfile
+import org.onap.so.beans.nsmf.CnSliceProfile
+import org.onap.so.beans.nsmf.EsrInfo
+import org.onap.so.beans.nsmf.NetworkType
+import org.onap.so.beans.nsmf.NssmfAdapterNBIRequest
import org.onap.so.beans.nsmf.SliceTaskParams
+import org.onap.so.beans.nsmf.SliceTaskParamsAdapter
+import org.onap.so.beans.nsmf.TnSliceProfile
+import org.onap.so.beans.nsmf.oof.SubnetCapability
+import org.onap.so.beans.nsmf.oof.SubnetType
+import org.onap.so.beans.nsmf.oof.TemplateInfo
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.OofUtils
import org.onap.so.bpmn.core.UrnPropertiesReader
+import org.onap.so.bpmn.core.domain.AllottedResource
+import org.onap.so.bpmn.core.domain.ModelInfo
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.HttpClient
-import org.onap.so.client.HttpClientFactory
-import org.onap.aaiclient.client.aai.AAIObjectType
-import org.onap.aaiclient.client.aai.AAIResourcesClient
-import org.onap.aaiclient.client.aai.entities.AAIResultWrapper
-import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri
-import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory
+
import org.slf4j.Logger
import org.slf4j.LoggerFactory
-
-import javax.ws.rs.NotFoundException
-import javax.ws.rs.core.Response
-
-import static org.apache.commons.lang3.StringUtils.isBlank
+import org.springframework.http.ResponseEntity
class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{
- private static final Logger logger = LoggerFactory.getLogger( DoCreateSliceServiceOption.class)
+ private static final Logger logger = LoggerFactory.getLogger(DoCreateSliceServiceOption.class)
ExceptionUtil exceptionUtil = new ExceptionUtil()
@@ -58,426 +57,528 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{
OofUtils oofUtils = new OofUtils()
- ObjectMapper objectMapper = new ObjectMapper()
+ private static final ObjectMapper objectMapper = new ObjectMapper()
+
+ private NssmfAdapterUtils nssmfAdapterUtils = new NssmfAdapterUtils(httpClientFactory, jsonUtil)
+
+ private static final String QUERY_SUB_NET_CAPABILITY = "/api/rest/provMns/v1/NSS/subnetCapabilityQuery"
+
+ private static final String QUERY_NSSI_SELECTION_CAPABILITY = "/api/rest/provMns/v1/NSS/NSSISelectionCapability"
void preProcessRequest (DelegateExecution execution) {
}
+ /**
+ * prepare the params for decompose nst
+ * @param execution
+ */
+ public void prepareDecomposeNST(DelegateExecution execution) {
- void prepareSelectNSIRequest(DelegateExecution execution) {
+ SliceTaskParamsAdapter sliceTaskParams =
+ execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
- String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution)
- logger.debug( "get NSI option OOF Url: " + urlString)
-
- boolean isNSISuggested = true
- execution.setVariable("isNSISuggested",isNSISuggested)
- String requestId = execution.getVariable("msoRequestId")
- String messageType = "NSISelectionResponse"
-
- Map<String, Object> profileInfo = execution.getVariable("serviceProfile")
- Map<String, Object> nstSolution = execution.getVariable("nstSolution")
- logger.debug("Get NST selection from OOF: " + nstSolution.toString())
- String nstInfo = """{
- "modelInvariantId":"${nstSolution.invariantUUID}",
- "modelVersionId":"${nstSolution.UUID}",
- "modelName":"${nstSolution.NSTName}"
- }"""
-
- execution.setVariable("nsiSelectionUrl", "/api/oof/selection/nsi/v1")
- execution.setVariable("nsiSelection_messageType",messageType)
- execution.setVariable("nsiSelection_correlator",requestId)
- String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution);
- execution.setVariable("nsiSelection_timeout",timeout)
- String oofRequest = oofUtils.buildSelectNSIRequest(requestId, nstInfo,messageType, profileInfo)
- execution.setVariable("nsiSelection_oofRequest",oofRequest)
- logger.debug("Sending request to OOF: " + oofRequest)
- }
+ String modelUuid = sliceTaskParams.getNSTInfo().getUUID()
+ String modelInvariantUuid = sliceTaskParams.getNSTInfo().getInvariantUUID()
- void processOOFResponse(Response httpResponse, DelegateExecution execution) {
- int responseCode = httpResponse.getStatus()
- SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams")
- String OOFResponse = execution.getVariable("nsiSelection_oofResponse")
- logger.debug("NSI OOFResponse is: " + OOFResponse)
- execution.setVariable("OOFResponse", OOFResponse)
- //This needs to be changed to derive a value when we add policy to decide the solution options.
- Map OOFResponseObject = new JsonSlurper().parseText(OOFResponse)
- Map solutions = OOFResponseObject.get("solutions")
-
- String resourceSharingLevel = execution.getVariable("resourceSharingLevel")
- Boolean isSharable = resourceSharingLevel.equals("shared")
-
- if (solutions != null) {
- if (isSharable && hasSharedNSIsolutions(solutions)) {
- //sharedNSISolution
- processSharedNSISolutions(solutions, execution)
- }
- else if(solutions.containsKey("newNSISolutions")) {
- processNewNSISolutions(solutions, execution)
- }
- }
- execution.setVariable("sliceTaskParams", sliceTaskParams)
- logger.debug("sliceTaskParams: "+sliceTaskParams.convertToJson())
- logger.debug("*** Completed options Call to OOF ***")
- //解析sliceProfile
- logger.debug("start parseServiceProfile")
- parseServiceProfile(execution)
- logger.debug("end parseServiceProfile")
+ String serviceModelInfo = """{
+ "modelInvariantUuid":"${modelInvariantUuid}",
+ "modelUuid":"${modelUuid}",
+ "modelVersion":""
+ }"""
+ execution.setVariable("nstServiceModelInfo", serviceModelInfo)
}
- private boolean hasSharedNSIsolutions( Map solutions){
- if(solutions.containsKey("sharedNSISolutions")){
- List sharedNSIsolutions = solutions.get("sharedNSISolutions")
- if (sharedNSIsolutions != null && !sharedNSIsolutions.isEmpty()) {
- return true
- }
+ /**
+ * process the result of NST Decomposition
+ * @param execution
+ */
+ public void processDecompositionNST(DelegateExecution execution) {
+
+ List<TemplateInfo> nsstInfos = new ArrayList<>()
+ ServiceDecomposition nstServiceDecomposition =
+ execution.getVariable("nstServiceDecomposition") as ServiceDecomposition
+ //todo:
+ List<AllottedResource> allottedResources = nstServiceDecomposition.getAllottedResources()
+ for (AllottedResource allottedResource : allottedResources) {
+ TemplateInfo nsstInfo = new TemplateInfo()
+ nsstInfo.setUUID(allottedResource.getProvidingServiceModelUuid())
+ nsstInfo.setInvariantUUID(allottedResource.getProvidingServiceModelInvariantUuid())
+ nsstInfo.setName(allottedResource.getProvidingServiceModelName())
+ nsstInfos.add(nsstInfo)
}
- return false
+ execution.setVariable("nsstInfos", nsstInfos)
+
+ execution.setVariable("maxNsstIndex", allottedResources.size() - 1)
+ execution.setVariable("currentNsstIndex", 0)
+
+ List<ServiceDecomposition> nsstServiceDecompositions = new ArrayList<>()
+ execution.setVariable("nsstServiceDecompositions", nsstServiceDecompositions)
}
- private void processNewNSISolutions(Map solutions, DelegateExecution execution) {
- int index = 0
- List<Map> newNSISolutions = solutions.get("newNSISolutions")
- List<Map> NSSImap = new ArrayList<>()
- if (newNSISolutions != null && newNSISolutions.size() > 0) {
- NSSImap = newNSISolutions.get(index).get("NSSISolutions") as List<Map>
- for (Map nssi : NSSImap) {
- Map oofSliceProfile = nssi.get("sliceProfile")
- String domain = oofSliceProfile.getOrDefault("domainType","")
- logger.debug("OOF newNSISolutions SliceProfile: " +oofSliceProfile.toString()+",domain:${domain}")
- if(null != domain){
- //TODO
-// def nssiSolution = nssi.get("NSSISolution") as Map<String, ?>
-// String nssiName = nssiSolution.getOrDefault("NSSIName", "")
-// String nssiId = nssiSolution.getOrDefault("NSSIId", "")
-// saveNSSIId(nssi, sliceTaskParams)
- Map<String, Object> sliceProfile = getSliceProfile(domain, execution, oofSliceProfile)
- saveSliceProfile(execution, domain, sliceProfile)
-
- }
- }
- }
+ /**
+ * prepare the params for decompose nsst
+ * @param execution
+ */
+ public void prepareDecomposeNSST(DelegateExecution execution) {
+
+ List<TemplateInfo> nsstInfos = execution.getVariable("nsstInfos") as List<TemplateInfo>
+ int index = execution.getVariable("currentNsstIndex") as Integer
+
+ String modelUuid = nsstInfos.get(index).getUUID()
+ String modelInvariantUuid = nsstInfos.get(index).getInvariantUUID()
+
+ String serviceModelInfo = """{
+ "modelInvariantUuid":"${modelInvariantUuid}",
+ "modelUuid":"${modelUuid}",
+ "modelVersion":""
+ }"""
+ execution.setVariable("nsstServiceModelInfo", serviceModelInfo)
+
}
- private void processSharedNSISolutions(Map solutions, DelegateExecution execution) {
- String nsiName, nsiInstanceId, nssiId, nssiName
- SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams")
-
- Map sharedNSIsolution = ((List) solutions.get("sharedNSISolutions"))?.get(0)
- nsiInstanceId = sharedNSIsolution.getOrDefault("NSIId", "")
- nsiName = sharedNSIsolution.getOrDefault("NSIName", "")
- sliceTaskParams.setSuggestNsiId(nsiInstanceId)
- sliceTaskParams.setSuggestNsiName(nsiName)
-
- //Temporary modification
- List NSSIs = sharedNSIsolution.get("NSSIs")
- for(Map nssi : NSSIs){
- Map oofSliceProfile = ((List)nssi.get("sliceProfile"))?.get(0)
- String domain = oofSliceProfile.getOrDefault("domainType","")
- nssiId = nssi.getOrDefault("NSSIId","")
- nssiName = nssi.getOrDefault("NSSIName","")
- saveNSSIId(domain, nssiId, nssiName,execution)
- Map<String, Object> sliceProfile = getSliceProfile(domain, execution, oofSliceProfile)
- saveSliceProfile(execution, domain, sliceProfile)
- logger.debug("OOF sharedNSISolution SliceProfile:"+oofSliceProfile.toString()+",domain:${domain}")
- logger.debug("OOF sharedNSISolution nsiInstanceId:${nsiInstanceId}, nsiName:${nsiName}, nssiId:${nssiId}, nssiName:${nssiName}")
+ /**
+ * process the result of NSST Decomposition
+ * @param execution
+ */
+ public void processDecompositionNSST(DelegateExecution execution) {
+
+ List<ServiceDecomposition> nsstServiceDecompositions =
+ execution.getVariable("nsstServiceDecompositions") as List<ServiceDecomposition>
+
+ ServiceDecomposition nsstServiceDecomposition =
+ execution.getVariable("nsstServiceDecomposition") as ServiceDecomposition
+
+ nsstServiceDecompositions.add(nsstServiceDecomposition)
+
+ execution.setVariable("nsstServiceDecompositions", nsstServiceDecompositions)
+
+
+
+
+ int num = execution.getVariable("maxNsstIndex") as Integer
+ int index = execution.getVariable("currentNsstIndex") as Integer
+
+ execution.setVariable("currentNsstIndex", index + 1)
+
+ if (index >= num) {
+ execution.setVariable("nsstHandleContinue", false)
+ } else {
+ execution.setVariable("nsstHandleContinue", true)
}
+
}
- private void parseServiceProfile(DelegateExecution execution) {
- 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
- if(!sliceTaskParams.getSliceProfileAn()){
- Map<String, Object> sliceProfileAn = getSliceProfile( "AN", execution,null)
- saveSliceProfile(execution,"AN",sliceProfileAn)
- }
+ /**
+ * set nsst info to sliceTaskParams by type
+ * @param execution
+ */
+ public void handleNsstByType(DelegateExecution execution) {
+ //todo: set to sliceTaskParams by type
- if(!sliceTaskParams.getSliceProfileTn()){
- Map<String, Object> sliceProfileTn = getSliceProfile( "TN", execution,null)
- saveSliceProfile(execution,"TN",sliceProfileTn)
- }
+ SliceTaskParamsAdapter sliceParams =
+ execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
+
+ List<ServiceDecomposition> nsstServiceDecompositions =
+ execution.getVariable("nsstServiceDecompositions") as List<ServiceDecomposition>
+
+ List<SubnetCapability> subnetCapabilities = new ArrayList<>()
+
+
+
+ for (ServiceDecomposition serviceDecomposition : nsstServiceDecompositions) {
+ //todo:
+ SubnetCapability subnetCapability = new SubnetCapability()
- if(!sliceTaskParams.getSliceProfileCn()){
- Map<String, Object> sliceProfileCn = getSliceProfile( "CN", execution,null, )
- saveSliceProfile(execution,"CN",sliceProfileCn)
+ handleByType(execution, serviceDecomposition, sliceParams, subnetCapability)
+
+ subnetCapabilities.add(subnetCapability)
}
- logger.debug("Finish parseServiceProfile")
+ execution.setVariable("sliceTaskParams", sliceParams)
+ execution.setVariable("subnetCapabilities", subnetCapabilities)
}
- private void saveSliceProfile(DelegateExecution execution, String domain, Map<String, Object> sliceProfile){
- SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams")
- if(domain.equalsIgnoreCase("AN")){
- execution.setVariable("sliceProfileAn", sliceProfile)
- sliceTaskParams.setSliceProfileAn(sliceProfile)
- logger.debug("sliceProfileAn: " + sliceProfile)
+ private void handleByType(DelegateExecution execution, ServiceDecomposition serviceDecomposition,
+ SliceTaskParamsAdapter sliceParams, SubnetCapability subnetCapability) {
+ //todo:
+ String domainType = ""
+ ModelInfo modelInfo = serviceDecomposition.getModelInfo()
+ String vendor = serviceDecomposition.getServiceRole()
+ SubnetType subnetType
+
+ switch (domainType) {
+ case "tn_bh":
+ subnetType = SubnetType.TN_BH
+ sliceParams.tnBHSliceTaskInfo.vendor = vendor
+ sliceParams.tnBHSliceTaskInfo.subnetType = subnetType
+ sliceParams.tnBHSliceTaskInfo.networkType = subnetType.networkType
+ sliceParams.tnBHSliceTaskInfo.NSSTInfo.UUID = modelInfo.getModelUuid()
+ sliceParams.tnBHSliceTaskInfo.NSSTInfo.invariantUUID = modelInfo.getModelInvariantUuid()
+ sliceParams.tnBHSliceTaskInfo.NSSTInfo.name = modelInfo.getModelName()
+
+ break
+ case "tn_mh":
+ subnetType = SubnetType.TN_MH
+ sliceParams.tnMHSliceTaskInfo.vendor = vendor
+ sliceParams.tnMHSliceTaskInfo.subnetType = subnetType
+ sliceParams.tnMHSliceTaskInfo.networkType = subnetType.networkType
+ sliceParams.tnMHSliceTaskInfo.NSSTInfo.UUID = modelInfo.getModelUuid()
+ sliceParams.tnMHSliceTaskInfo.NSSTInfo.invariantUUID = modelInfo.getModelInvariantUuid()
+ sliceParams.tnMHSliceTaskInfo.NSSTInfo.name = modelInfo.getModelName()
+
+ break
+ case "an_nf":
+ subnetType = SubnetType.AN_NF
+ sliceParams.anSliceTaskInfo.vendor = vendor
+ sliceParams.anSliceTaskInfo.subnetType = subnetType
+ sliceParams.anSliceTaskInfo.networkType = subnetType.networkType
+ sliceParams.anSliceTaskInfo.NSSTInfo.UUID = modelInfo.getModelUuid()
+ sliceParams.anSliceTaskInfo.NSSTInfo.invariantUUID = modelInfo.getModelInvariantUuid()
+ sliceParams.anSliceTaskInfo.NSSTInfo.name = modelInfo.getModelName()
+ break
+ case "cn":
+ subnetType = SubnetType.CN
+ sliceParams.cnSliceTaskInfo.vendor = vendor
+ sliceParams.cnSliceTaskInfo.subnetType = subnetType
+ sliceParams.cnSliceTaskInfo.networkType = subnetType.networkType
+ sliceParams.cnSliceTaskInfo.NSSTInfo.UUID = modelInfo.getModelUuid()
+ sliceParams.cnSliceTaskInfo.NSSTInfo.invariantUUID = modelInfo.getModelInvariantUuid()
+ sliceParams.cnSliceTaskInfo.NSSTInfo.name = modelInfo.getModelName()
+ break
+ default:
+ subnetType = null
+ break
+
+ //todo
+
}
- else if(domain.equalsIgnoreCase("TN")){
- execution.setVariable("sliceProfileTn", sliceProfile)
- sliceTaskParams.setSliceProfileTn(sliceProfile)
- logger.debug("sliceProfileTn: " + sliceProfile)
+ if (subnetType == null) {
+ //todo: throw error
+ return
}
- else if(domain.equalsIgnoreCase("CN")){
- execution.setVariable("sliceProfileCn", sliceProfile)
- sliceTaskParams.setSliceProfileCn(sliceProfile)
- logger.debug("sliceProfileCn: " + sliceProfile)
+ String response = querySubnetCapability(execution, vendor, subnetType)
+ ResponseEntity responseEntity = objectMapper.readValue(response, ResponseEntity.class)
+
+ Map<String, Object> result = responseEntity.getBody() as Map
+ for (Map.Entry<String, Object> entry : result.entrySet()) {
+ subnetCapability.setDomainType(entry.getKey())
+ subnetCapability.setCapabilityDetails(entry.getValue())
}
}
- private void saveNSSIId(String domain, String nssiId, String nssiName, DelegateExecution execution) {
- SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams")
- if(domain.equalsIgnoreCase("AN")){
- sliceTaskParams.setAnSuggestNssiId(nssiId)
- sliceTaskParams.setAnSuggestNssiName(nssiName)
- }
- else if(domain.equalsIgnoreCase("CN")){
- sliceTaskParams.setCnSuggestNssiId(nssiId)
- sliceTaskParams.setCnSuggestNssiName(nssiName)
- }
- else if(domain.equalsIgnoreCase("TN")){
- sliceTaskParams.setTnSuggestNssiId(nssiId)
- sliceTaskParams.setTnSuggestNssiName(nssiName)
- }
+ /**
+ * query Subnet Capability of TN AN CN
+ * @param execution
+ */
+ private String querySubnetCapability(DelegateExecution execution, String vendor, SubnetType subnetType) {
+
+ String strRequest = objectMapper.writeValueAsString(buildQuerySubnetCapRequest(vendor, subnetType))
+
+ String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, QUERY_SUB_NET_CAPABILITY, strRequest)
+ return response
}
- private Map getSliceProfile(String domain, DelegateExecution execution, Map<String, Object> oofSliceProfile) {
- String profileMapStr
- Map<String, Object> serviceProfile = execution.getVariable("serviceProfile")
- Integer domainLatency = (Integer) serviceProfile.get("latency")/3
-
- if(domain.equalsIgnoreCase("AN")){
- profileMapStr = """ {
- "latency": ${domainLatency},
- "sNSSAI": "sNSSAI",
- "uEMobilityLevel": "uEMobilityLevel",
- "coverageAreaTAList": "coverageAreaTAList",
- "5QI": 100
- }"""
- }
- else if(domain.equalsIgnoreCase("TN")){
- profileMapStr =""" {
- "latency":${domainLatency},
- "sNSSAI":"sNSSAI",
- "e2eLatency":"latency",
- "bandwidth": 100
- }"""
- }
- else if(domain.equalsIgnoreCase("CN")){
- profileMapStr = """ {
- "areaTrafficCapDL":"areaTrafficCapDL",
- "maxNumberofUEs":"maxNumberofUEs",
- "latency":${domainLatency},
- "expDataRateUL":"expDataRateUL",
- "sNSSAI":"sNSSAI",
- "areaTrafficCapUL":"areaTrafficCapUL",
- "uEMobilityLevel":"uEMobilityLevel",
- "expDataRateDL":"expDataRateDL",
- "activityFactor":"activityFactor",
- "resourceSharingLevel":"resourceSharingLevel"
- }"""
- }
+ /**
+ * build request body for querying Subnet Capability
+ * @param vendor
+ * @param subnetTypes
+ * @param networkType
+ * @return
+ */
+ private static String buildQuerySubnetCapRequest(String vendor, SubnetType subnetType) {
+ NssmfAdapterNBIRequest request = new NssmfAdapterNBIRequest()
+
+ List<String> subnetTypes = new ArrayList<>()
+ subnetTypes.add(subnetType.subnetType)
+ Map<String, Object> paramMap = new HashMap()
+ paramMap.put("subnetTypes", subnetTypes)
+
+ request.setSubnetCapabilityQuery(objectMapper.writeValueAsString(paramMap))
+
+ EsrInfo esrInfo = new EsrInfo()
+ esrInfo.setVendor(vendor)
+ esrInfo.setNetworkType(subnetType.networkType)
+
+ request.setEsrInfo(esrInfo)
+
+ String strRequest = objectMapper.writeValueAsString(request)
+
+ return strRequest
+ }
+
+ /**
+ * todo: need rewrite
+ * prepare select nsi request
+ * @param execution
+ */
+ public void preNSIRequest(DelegateExecution execution) {
- logger.debug("Profile map for " + domain + " : " + profileMapStr)
- Map<String, Object> profileMaps = objectMapper.readValue(profileMapStr.trim().replaceAll(" ", ""), new TypeReference<Map<String, String>>(){})
- Map<String, Object> sliceProfile = [:]
- for (Map.Entry<String, String> profileMap : profileMaps) {
- String key = profileMap.key
- String value = profileMaps.get(key)
- if(null != oofSliceProfile && oofSliceProfile.keySet().contains(key)){
- sliceProfile.put(key, oofSliceProfile.get(key))
- logger.debug("Get from oof, key:${key}, value: ${oofSliceProfile.get(key)}")
+ String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution)
+ logger.debug( "get NSI option OOF Url: " + urlString)
+
+
+ String requestId = execution.getVariable("msoRequestId")
+ String messageType = "NSISelectionResponse"
+
+ execution.setVariable("nsiSelectionUrl", "/api/oof/selection/nsi/v1")
+ execution.setVariable("nsiSelection_messageType", messageType)
+ execution.setVariable("nsiSelection_correlator", requestId)
+ String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution)
+ execution.setVariable("nsiSelection_timeout", timeout)
+
+ SliceTaskParamsAdapter sliceParams =
+ execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
+
+ Map<String, Object> profileInfo = sliceParams.getServiceProfile()
+ TemplateInfo nstInfo = sliceParams.getNSTInfo()
+
+ List<TemplateInfo> nsstInfos = execution.getVariable("nsstInfos") as List<TemplateInfo>
+
+ List<SubnetCapability> subnetCapabilities =
+ execution.getVariable("subnetCapabilities") as List<SubnetCapability>
+
+ String oofRequest = oofUtils.buildSelectNSIRequest(requestId, nstInfo, nsstInfos,
+ messageType, profileInfo, subnetCapabilities, timeout as Integer)
+
+ execution.setVariable("nsiSelection_oofRequest", oofRequest)
+ logger.debug("Sending request to OOF: " + oofRequest)
+ }
+
+ /**
+ * todo: need rewrite
+ * process select nsi response
+ * @param execution
+ */
+ public void processNSIResp(DelegateExecution execution) {
+
+ SliceTaskParamsAdapter sliceTaskParams =
+ execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
+
+ String OOFResponse = execution.getVariable("nsiSelection_oofResponse")
+ logger.debug("NSI OOFResponse is: " + OOFResponse)
+ execution.setVariable("OOFResponse", OOFResponse)
+ //This needs to be changed to derive a value when we add policy to decide the solution options.
+
+ Map<String, Object> resMap = objectMapper.readValue(OOFResponse, Map.class)
+ List<Map<String, Object>> nsiSolutions = (List<Map<String, Object>>) resMap.get("solutions")
+ Map<String, Object> solution = nsiSolutions.get(0)
+
+ String resourceSharingLevel = execution.getVariable("resourceSharingLevel")
+ Boolean isSharable = resourceSharingLevel == "shared"
+
+ if (solution != null) {
+ if (isSharable && solution.get("existingNSI")) {
+ //sharedNSISolution
+ processSharedNSI(solution, sliceTaskParams)
}
- else if(serviceProfile.keySet().contains(value)){
- sliceProfile.put(key, serviceProfile.get(value))
+ else if(solution.containsKey("newNSISolution")) {
+ processNewNSI(solution, sliceTaskParams)
}
- else{
- sliceProfile.put(key, profileMaps.get(key))
+ }
+ execution.setVariable("sliceTaskParams", sliceTaskParams)
+ //logger.debug("sliceTaskParams: " + sliceTaskParams.convertToJson())
+ logger.debug("*** Completed options Call to OOF ***")
+ }
+
+ private void processSharedNSI(Map<String, Object> solution, SliceTaskParamsAdapter sliceParams) {
+ Map<String, Object> sharedNSISolution = solution.get("sharedNSISolution") as Map
+
+ String nsiId = sharedNSISolution.get("NSIId")
+ String nsiName = sharedNSISolution.get("NSIName")
+ sliceParams.setSuggestNsiId(nsiId)
+ sliceParams.setSuggestNsiName(nsiName)
+ }
+
+ private void processNewNSI(Map<String, Object> solution, SliceTaskParamsAdapter sliceParams) {
+ Map<String, Object> newNSISolution = solution.get("newNSISolution") as Map
+ List<Map> sliceProfiles = newNSISolution.get("sliceProfiles") as List<Map>
+ for (Map sliceProfile : sliceProfiles) {
+ String domainType = sliceProfile.get("domainType")
+ switch (domainType.toLowerCase()) {
+ case "tn-bh":
+ sliceParams.tnBHSliceTaskInfo.sliceProfile = sliceProfile as TnSliceProfile
+ break
+ case "an-nf":
+ sliceParams.anSliceTaskInfo.sliceProfile = sliceProfile as AnSliceProfile
+ break
+ case "cn":
+ sliceParams.cnSliceTaskInfo.sliceProfile = sliceProfile as CnSliceProfile
+ break
+ default:
+ break
}
+
+ //todo
+
}
- return sliceProfile
}
- void processDecomposition(DelegateExecution execution){
- logger.debug("Start processDecomposition")
+ /**
+ * get NSSI Selection Capability for AN
+ * @param execution
+ */
+ public void getNSSISelectionCap4AN(DelegateExecution execution) {
+
+ def vendor = execution.getVariable("vendor") as String
+
+ String strRequest = buildNSSISelectionReq(vendor, NetworkType.ACCESS)
- ServiceDecomposition serviceDecomposition= execution.getVariable("serviceDecomposition")
- SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams")
- String nstName = serviceDecomposition.getModelInfo().getModelName()
- String nstId = serviceDecomposition.getModelInfo().getModelUuid()
- sliceTaskParams.setNstName(nstName)
- sliceTaskParams.setNstId(nstId)
+ String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, QUERY_NSSI_SELECTION_CAPABILITY, strRequest)
- logger.debug("End processDecomposition")
+ Map<String, Object> resMap = objectMapper.readValue(response, Map.class)
+
+ String selection = resMap.get("selection")
+
+
+ if ("NSMF".equalsIgnoreCase(selection)) {
+ execution.setVariable("NEED_AN_NSSI_SELECTION", true)
+ }
}
+ /**
+ * get NSSI Selection Capability for TN
+ * @param execution
+ */
+ public void getNSSISelectionCap4TN(DelegateExecution execution) {
- void prepareNSTDecompose(DelegateExecution execution) {
+ def vendor = execution.getVariable("vendor") as String
- String modelUuid = execution.getVariable("nstModelUuid")
- String modelInvariantUuid = execution.getVariable("nstModelInvariantUuid")
+ String strRequest = buildNSSISelectionReq(vendor, NetworkType.TRANSPORT)
- String serviceModelInfo = """{
- "modelInvariantUuid":"${modelInvariantUuid}",
- "modelUuid":"${modelUuid}",
- "modelVersion":""
- }"""
- execution.setVariable("serviceModelInfo", serviceModelInfo)
+ String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, QUERY_NSSI_SELECTION_CAPABILITY, strRequest)
+
+ Map<String, Object> resMap = objectMapper.readValue(response, Map.class)
+
+ String selection = resMap.get("selection")
+
+ if ("NSMF".equalsIgnoreCase(selection)) {
+ execution.setVariable("NEED_TN_NSSI_SELECTION", true)
+ }
}
- void prepareNSSTDecompose(DelegateExecution execution) {
- Boolean isMoreNSSTtoProcess = false
- Integer maxNSST = execution.getVariable("maxNSST")
- Integer currentNSST=execution.getVariable("currentNSST")
- List<String> nsstModelUUIDList = new ArrayList<>()
- nsstModelUUIDList = execution.getVariable("nsstModelUUIDList")
- String modelUuid = nsstModelUUIDList.get(currentNSST)
- String serviceModelInfo = """{
- "modelInvariantUuid":"",
- "modelUuid":"${modelUuid}",
- "modelVersion":""
- }"""
- execution.setVariable("serviceModelInfo", serviceModelInfo)
- currentNSST=currentNSST+1
- if(currentNSST<maxNSST)
- isMoreNSSTtoProcess=true
- execution.setVariable("isMoreNSSTtoProcess",isMoreNSSTtoProcess)
- execution.setVariable("maxNSST",maxNSST)
- execution.setVariable("currentNSST",currentNSST)
+ /**
+ * get NSSI Selection Capability for CN
+ * @param execution
+ */
+ public void getNSSISelectionCap4CN(DelegateExecution execution) {
+
+ def vendor = execution.getVariable("vendor") as String
+
+ String strRequest = buildNSSISelectionReq(vendor, NetworkType.CORE)
+
+ String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, QUERY_NSSI_SELECTION_CAPABILITY, strRequest)
+
+ Map<String, Object> resMap = objectMapper.readValue(response, Map.class)
+
+ String selection = resMap.get("selection")
+
+ if ("NSMF".equalsIgnoreCase(selection)) {
+ execution.setVariable("NEED_CN_NSSI_SELECTION", true)
+ }
}
+ /**
+ * build NSSI Selection Capability Request body to nssmf adapter
+ * @param vendor
+ * @param networkType
+ * @return
+ */
+ private static String buildNSSISelectionReq(String vendor, NetworkType networkType) {
+ NssmfAdapterNBIRequest request = new NssmfAdapterNBIRequest()
+ EsrInfo esrInfo = new EsrInfo()
+ esrInfo.setVendor(vendor)
+ esrInfo.setNetworkType(networkType)
+ request.setEsrInfo(esrInfo)
+
+ return objectMapper.writeValueAsString(request)
+ }
+
+ /**
+ * if exist nssi need to select?
+ * @param execution
+ */
+ public void handleNssiSelect(DelegateExecution execution) {
- void prepareNSSTlistfromNST(DelegateExecution execution) {
- //Need to update this part from decomposition.
- logger.trace("Enter prepareNSSTlistfromNST()")
- Boolean isMoreNSSTtoProcess = false
- ServiceDecomposition serviceDecomposition= execution.getVariable("serviceDecomposition")
- SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams")
- String nstName = serviceDecomposition.getModelInfo().getModelName()
- sliceTaskParams.setNstName(nstName)
- String nstId = serviceDecomposition.getModelInfo().getModelUuid()
- sliceTaskParams.setNstId(nstId)
- execution.setVariable("sliceTaskParams",sliceTaskParams)
-
- List<ServiceProxy> proxyList = serviceDecomposition.getServiceProxy()
- List<String> nsstModelUUIDList = new ArrayList<>()
- for(ServiceProxy serviceProxy:proxyList)
- nsstModelUUIDList.add(serviceProxy.getSourceModelUuid())
- execution.setVariable("nsstModelUUIDList",nsstModelUUIDList)
- Integer maxNSST = nsstModelUUIDList.size()
- Integer currentNSST=0
- execution.setVariable("maxNSST",maxNSST)
- execution.setVariable("currentNSST",currentNSST)
- if(currentNSST<maxNSST)
- isMoreNSSTtoProcess=true
- execution.setVariable("isMoreNSSTtoProcess",isMoreNSSTtoProcess)
- logger.trace("Exit prepareNSSTlistfromNST()")
+ SliceTaskParamsAdapter sliceTaskParams =
+ execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
+ //todo
}
- void getNSSTOption(DelegateExecution execution) {
- ServiceDecomposition serviceDecomposition= execution.getVariable("serviceDecomposition")
+ /**
+ * todo: need rewrite
+ * prepare select nssi request
+ * @param execution
+ */
+ public void preNSSIRequest(DelegateExecution execution) {
+
String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution)
- String globalSubscriberId = execution.getVariable("globalSubscriberId")
- String serviceType = execution.getVariable("subscriptionServiceType")
- String nssiInstanceId =""
- String nssiName =""
- SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams")
logger.debug( "get NSI option OOF Url: " + urlString)
- boolean isNSISuggested = false
- execution.setVariable("isNSISuggested",isNSISuggested)
-
- //Prepare auth for OOF - Begin
- def authHeader = ""
- String basicAuth = UrnPropertiesReader.getVariable("mso.oof.auth", execution)
- String msokey = UrnPropertiesReader.getVariable("mso.msoKey", execution)
-
- String basicAuthValue = utils.encrypt(basicAuth, msokey)
- if (basicAuthValue != null) {
- logger.debug( "Obtained BasicAuth username and password for OOF: " + basicAuthValue)
- try {
- authHeader = utils.getBasicAuth(basicAuthValue, msokey)
- execution.setVariable("BasicAuthHeaderValue", authHeader)
- } catch (Exception ex) {
- logger.debug( "Unable to encode username and password string: " + ex)
- exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - Unable to " +
- "encode username and password string")
- }
- } else {
- logger.debug( "Unable to obtain BasicAuth - BasicAuth value null")
- exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - BasicAuth " +
- "value null")
- }
- //Prepare auth for OOF - End
- //Prepare send request to OOF - Begin
+
+ boolean isNSISuggested = true
+ execution.setVariable("isNSISuggested", isNSISuggested)
String requestId = execution.getVariable("msoRequestId")
- Map<String, Object> profileInfo = execution.getVariable("serviceProfile")
- String nsstModelInvariantUuid = serviceDecomposition.getModelInfo().getModelInvariantUuid()
- String nsstModelUuid = serviceDecomposition.getModelInfo().getModelUuid()
- String nsstInfo = """"NSSTInfo": {
- "invariantUUID":"${nsstModelInvariantUuid}",
- "UUID":"${nsstModelUuid}"
- }"""
- String oofRequest = oofUtils.buildSelectNSSIRequest(execution, requestId, nsstInfo ,profileInfo)
+ String messageType = "NSISelectionResponse"
+ Map<String, Object> profileInfo = execution.getVariable("serviceProfile") as Map
+ Map<String, Object> nstSolution = execution.getVariable("nstSolution") as Map
+ logger.debug("Get NST selection from OOF: " + nstSolution.toString())
+ String nstInfo = """{
+ "modelInvariantId":"${nstSolution.invariantUUID}",
+ "modelVersionId":"${nstSolution.UUID}",
+ "modelName":"${nstSolution.NSTName}"
+ }"""
- URL url = new URL(urlString+"/api/oof/v1/selectnssi")
- HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.OOF)
- httpClient.addAdditionalHeader("Authorization", authHeader)
- Response httpResponse = httpClient.post(oofRequest)
+ execution.setVariable("nsiSelectionUrl", "/api/oof/selection/nsi/v1")
+ execution.setVariable("nsiSelection_messageType", messageType)
+ execution.setVariable("nsiSelection_correlator", requestId)
+ String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution)
+ execution.setVariable("nsiSelection_timeout", timeout)
- int responseCode = httpResponse.getStatus()
- logger.debug("OOF sync response code is: " + responseCode)
+ //todo
+ String oofRequest = oofUtils.buildSelectNSIRequest(requestId, nstInfo, messageType, profileInfo)
- if(responseCode != 200){
- exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from OOF.")
- }
+ execution.setVariable("nsiSelection_oofRequest", oofRequest)
+ logger.debug("Sending request to OOF: " + oofRequest)
+ }
- if(httpResponse.hasEntity()){
- String OOFResponse = httpResponse.readEntity(String.class)
- execution.setVariable("OOFResponse", OOFResponse)
- nssiInstanceId = jsonUtil.getJsonValue(OOFResponse, "NSSIIInfo.NSSIID")
- nssiName = jsonUtil.getJsonValue(OOFResponse, "NSSIInfo.NSSIName")
- execution.setVariable("nssiInstanceId",nssiInstanceId)
- execution.setVariable("nssiName",nssiName)
- }
- if(isBlank(nssiInstanceId)){
- logger.debug( "There is no valid NSST suggested by OOF.")
- }else
- {
- try {
- AAIResourcesClient resourceClient = new AAIResourcesClient()
- AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, serviceType, nssiInstanceId)
- 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()
-
- String domain = nssi.getEnvironmentContext().toString().toUpperCase()
- switch (domain) {
- case "AN":
- sliceTaskParams.setAnSuggestNssiId(nssi.getServiceInstanceId())
- sliceTaskParams.setAnSuggestNssiName(nssi.getServiceInstanceName())
- break
- case "CN":
- sliceTaskParams.setCnSuggestNssiId(nssi.getServiceInstanceId())
- sliceTaskParams.setCnSuggestNssiName(nssi.getServiceInstanceName())
- break
- case "TN":
- sliceTaskParams.setTnSuggestNssiId(nssi.getServiceInstanceId())
- sliceTaskParams.setTnSuggestNssiName(nssi.getServiceInstanceName())
- break
- default:
- break
- }
- }catch(NotFoundException e)
- {
- logger.debug("NSSI Service Instance not found in AAI: " + nssiInstanceId)
- }catch(Exception e)
- {
- logger.debug("NSSI Service Instance not found in AAI: " + nssiInstanceId)
+ /**
+ * process select nssi response
+ * todo: unfinished
+ * @param execution
+ */
+ public void processNSSIResp(DelegateExecution execution) {
+
+ SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") as SliceTaskParams
+ String OOFResponse = execution.getVariable("nsiSelection_oofResponse")
+ logger.debug("NSI OOFResponse is: " + OOFResponse)
+ execution.setVariable("OOFResponse", OOFResponse)
+ //This needs to be changed to derive a value when we add policy to decide the solution options.
+
+ Map<String, Object> resMap = objectMapper.readValue(OOFResponse, Map.class)
+ List<Map<String, Object>> nsiSolutions = (List<Map<String, Object>>) resMap.get("solutions")
+ Map<String, Object> solutions = nsiSolutions.get(0)
+
+ String resourceSharingLevel = execution.getVariable("resourceSharingLevel")
+ Boolean isSharable = resourceSharingLevel == "shared"
+
+ if (solutions != null) {
+ if (isSharable && solutions.get("existingNSI")) {
+ //sharedNSISolution
+ //processSharedNSISolutions(solutions, execution)
+ }
+ else if(solutions.containsKey("newNSISolution")) {
+ //processNewNSISolutions(solutions, execution)
}
}
- logger.debug("Prepare NSSI option completed ")
+ execution.setVariable("sliceTaskParams", sliceTaskParams)
+ logger.debug("sliceTaskParams: "+sliceTaskParams.convertToJson())
+ logger.debug("*** Completed options Call to OOF ***")
+
+ logger.debug("start parseServiceProfile")
+ //parseServiceProfile(execution)
+ logger.debug("end parseServiceProfile")
}
+
+
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOptionV2.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOptionV2.groovy
deleted file mode 100644
index ca262172d0..0000000000
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOptionV2.groovy
+++ /dev/null
@@ -1,907 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- # Copyright (c) 2019, CMCC Technologies Co., Ltd.
- #
- # 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.fasterxml.jackson.core.type.TypeReference
-import com.fasterxml.jackson.databind.ObjectMapper
-import org.apache.commons.lang3.StringUtils
-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.AAIResultWrapper
-import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri
-import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory
-import org.onap.logging.filter.base.ONAPComponents
-import org.onap.so.beans.nsmf.*
-import org.onap.so.beans.nsmf.oof.SubnetCapability
-import org.onap.so.beans.nsmf.oof.TemplateInfo
-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.OofUtils
-import org.onap.so.bpmn.core.UrnPropertiesReader
-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.HttpClient
-import org.onap.so.client.HttpClientFactory
-import org.slf4j.Logger
-import org.slf4j.LoggerFactory
-
-import javax.ws.rs.NotFoundException
-import javax.ws.rs.core.Response
-
-class DoCreateSliceServiceOptionV2 extends AbstractServiceTaskProcessor{
-
- private static final Logger logger = LoggerFactory.getLogger( DoCreateSliceServiceOptionV2.class)
-
- ExceptionUtil exceptionUtil = new ExceptionUtil()
-
- JsonUtils jsonUtil = new JsonUtils()
-
- OofUtils oofUtils = new OofUtils()
-
- ObjectMapper objectMapper = new ObjectMapper()
-
- void preProcessRequest (DelegateExecution execution) {
- }
-
-
- /**
- * prepare select nsi request
- * @param execution
- */
- void prepareSelectNSIRequest(DelegateExecution execution) {
-
- String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution)
- logger.debug( "get NSI option OOF Url: " + urlString)
-
- boolean isNSISuggested = true
- execution.setVariable("isNSISuggested",isNSISuggested)
- String requestId = execution.getVariable("msoRequestId")
- String messageType = "NSISelectionResponse"
-
- Map<String, Object> profileInfo = execution.getVariable("serviceProfile")
- Map<String, Object> nstSolution = execution.getVariable("nstSolution")
- logger.debug("Get NST selection from OOF: " + nstSolution.toString())
- String nstInfo = """{
- "modelInvariantId":"${nstSolution.invariantUUID}",
- "modelVersionId":"${nstSolution.UUID}",
- "modelName":"${nstSolution.NSTName}"
- }"""
-
- execution.setVariable("nsiSelectionUrl", "/api/oof/selection/nsi/v1")
- execution.setVariable("nsiSelection_messageType",messageType)
- execution.setVariable("nsiSelection_correlator",requestId)
- String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution);
- execution.setVariable("nsiSelection_timeout",timeout)
- String oofRequest = oofUtils.buildSelectNSIRequest(requestId, nstInfo,messageType, profileInfo)
- execution.setVariable("nsiSelection_oofRequest",oofRequest)
- logger.debug("Sending request to OOF: " + oofRequest)
- }
-
- /**
- * process select nsi response
- * @param execution
- */
- void processOOFResponse(DelegateExecution execution) {
-
- SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") as SliceTaskParams
- String OOFResponse = execution.getVariable("nsiSelection_oofResponse")
- logger.debug("NSI OOFResponse is: " + OOFResponse)
- execution.setVariable("OOFResponse", OOFResponse)
- //This needs to be changed to derive a value when we add policy to decide the solution options.
-
- Map<String, Object> resMap = objectMapper.readValue(OOFResponse, Map.class)
- List<Map<String, Object>> nsiSolutions = (List<Map<String, Object>>) resMap.get("solutions")
- Map<String, Object> solutions = nsiSolutions.get(0)
-
- String resourceSharingLevel = execution.getVariable("resourceSharingLevel")
- Boolean isSharable = resourceSharingLevel == "shared"
-
- if (solutions != null) {
- if (isSharable && solutions.get("existingNSI")) {
- //sharedNSISolution
- processSharedNSISolutions(solutions, execution)
- }
- else if(solutions.containsKey("newNSISolution")) {
- processNewNSISolutions(solutions, execution)
- }
- }
- execution.setVariable("sliceTaskParams", sliceTaskParams)
- logger.debug("sliceTaskParams: "+sliceTaskParams.convertToJson())
- logger.debug("*** Completed options Call to OOF ***")
-
- logger.debug("start parseServiceProfile")
- parseServiceProfile(execution)
- logger.debug("end parseServiceProfile")
- }
-
-
- private void processNewNSISolutions(Map solutions, DelegateExecution execution) {
- int index = 0
- List<Map> newNSISolutions = solutions.get("newNSISolution")
- List<Map> NSSImap = new ArrayList<>()
- if (newNSISolutions != null && newNSISolutions.size() > 0) {
- NSSImap = newNSISolutions.get(index).get("NSSISolutions") as List<Map>
- for (Map nssi : NSSImap) {
- Map oofSliceProfile = nssi.get("sliceProfile")
- String domain = oofSliceProfile.getOrDefault("domainType","")
- logger.debug("OOF newNSISolutions SliceProfile: " +oofSliceProfile.toString()+",domain:${domain}")
- if(null != domain){
- //TODO
-// def nssiSolution = nssi.get("NSSISolution") as Map<String, ?>
-// String nssiName = nssiSolution.getOrDefault("NSSIName", "")
-// String nssiId = nssiSolution.getOrDefault("NSSIId", "")
-// saveNSSIId(nssi, sliceTaskParams)
- Map<String, Object> sliceProfile = getSliceProfile(domain, execution, oofSliceProfile)
- saveSliceProfile(execution, domain, sliceProfile)
-
- }
- }
- }
- }
-
- private void processSharedNSISolutions(Map solutions, DelegateExecution execution) {
- String nsiName, nsiInstanceId, nssiId, nssiName
- SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams")
-
- Map sharedNSIsolution = ((List) solutions.get("sharedNSISolutions"))?.get(0)
- nsiInstanceId = sharedNSIsolution.getOrDefault("NSIId", "")
- nsiName = sharedNSIsolution.getOrDefault("NSIName", "")
- sliceTaskParams.setSuggestNsiId(nsiInstanceId)
- sliceTaskParams.setSuggestNsiName(nsiName)
-
- //Temporary modification
- List NSSIs = sharedNSIsolution.get("NSSIs")
- for(Map nssi : NSSIs){
- Map oofSliceProfile = ((List)nssi.get("sliceProfile"))?.get(0)
- String domain = oofSliceProfile.getOrDefault("domainType","")
- nssiId = nssi.getOrDefault("NSSIId","")
- nssiName = nssi.getOrDefault("NSSIName","")
- saveNSSIId(domain, nssiId, nssiName,execution)
- Map<String, Object> sliceProfile = getSliceProfile(domain, execution, oofSliceProfile)
- saveSliceProfile(execution, domain, sliceProfile)
- logger.debug("OOF sharedNSISolution SliceProfile:"+oofSliceProfile.toString()+",domain:${domain}")
- logger.debug("OOF sharedNSISolution nsiInstanceId:${nsiInstanceId}, nsiName:${nsiName}, nssiId:${nssiId}, nssiName:${nssiName}")
- }
- }
-
- private void parseServiceProfile(DelegateExecution execution) {
- 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
- if(!sliceTaskParams.getSliceProfileAn()){
- Map<String, Object> sliceProfileAn = getSliceProfile( "AN", execution,null)
- saveSliceProfile(execution,"AN",sliceProfileAn)
- }
-
- if(!sliceTaskParams.getSliceProfileTn()){
- Map<String, Object> sliceProfileTn = getSliceProfile( "TN", execution,null)
- saveSliceProfile(execution,"TN",sliceProfileTn)
- }
-
- if(!sliceTaskParams.getSliceProfileCn()){
- Map<String, Object> sliceProfileCn = getSliceProfile( "CN", execution,null, )
- saveSliceProfile(execution,"CN",sliceProfileCn)
- }
-
- logger.debug("Finish parseServiceProfile")
- }
-
- private void saveSliceProfile(DelegateExecution execution, String domain, Map<String, Object> sliceProfile){
- SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams")
- if(domain.equalsIgnoreCase("AN")){
- execution.setVariable("sliceProfileAn", sliceProfile)
- sliceTaskParams.setSliceProfileAn(sliceProfile)
- logger.debug("sliceProfileAn: " + sliceProfile)
- }
- else if(domain.equalsIgnoreCase("TN")){
- execution.setVariable("sliceProfileTn", sliceProfile)
- sliceTaskParams.setSliceProfileTn(sliceProfile)
- logger.debug("sliceProfileTn: " + sliceProfile)
- }
- else if(domain.equalsIgnoreCase("CN")){
- execution.setVariable("sliceProfileCn", sliceProfile)
- sliceTaskParams.setSliceProfileCn(sliceProfile)
- logger.debug("sliceProfileCn: " + sliceProfile)
- }
- }
-
- private void saveNSSIId(String domain, String nssiId, String nssiName, DelegateExecution execution) {
- SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams")
- if(domain.equalsIgnoreCase("AN")){
- sliceTaskParams.setAnSuggestNssiId(nssiId)
- sliceTaskParams.setAnSuggestNssiName(nssiName)
- }
- else if(domain.equalsIgnoreCase("CN")){
- sliceTaskParams.setCnSuggestNssiId(nssiId)
- sliceTaskParams.setCnSuggestNssiName(nssiName)
- }
- else if(domain.equalsIgnoreCase("TN")){
- sliceTaskParams.setTnSuggestNssiId(nssiId)
- sliceTaskParams.setTnSuggestNssiName(nssiName)
- }
- }
-
- private Map getSliceProfile(String domain, DelegateExecution execution, Map<String, Object> oofSliceProfile) {
- String profileMapStr
- Map<String, Object> serviceProfile = execution.getVariable("serviceProfile")
- Integer domainLatency = (Integer) serviceProfile.get("latency")/3
-
- if(domain.equalsIgnoreCase("AN")){
- profileMapStr = """ {
- "latency": ${domainLatency},
- "sNSSAI": "sNSSAI",
- "uEMobilityLevel": "uEMobilityLevel",
- "coverageAreaTAList": "coverageAreaTAList",
- "5QI": 100
- }"""
- }
- else if(domain.equalsIgnoreCase("TN")){
- profileMapStr =""" {
- "latency":${domainLatency},
- "sNSSAI":"sNSSAI",
- "e2eLatency":"latency",
- "bandwidth": 100
- }"""
- }
- else if(domain.equalsIgnoreCase("CN")){
- profileMapStr = """ {
- "areaTrafficCapDL":"areaTrafficCapDL",
- "maxNumberofUEs":"maxNumberofUEs",
- "latency":${domainLatency},
- "expDataRateUL":"expDataRateUL",
- "sNSSAI":"sNSSAI",
- "areaTrafficCapUL":"areaTrafficCapUL",
- "uEMobilityLevel":"uEMobilityLevel",
- "expDataRateDL":"expDataRateDL",
- "activityFactor":"activityFactor",
- "resourceSharingLevel":"resourceSharingLevel"
- }"""
- }
-
- logger.debug("Profile map for " + domain + " : " + profileMapStr)
- Map<String, Object> profileMaps = objectMapper.readValue(profileMapStr.trim().replaceAll(" ", ""), new TypeReference<Map<String, String>>(){})
- Map<String, Object> sliceProfile = [:]
- for (Map.Entry<String, String> profileMap : profileMaps) {
- String key = profileMap.key
- String value = profileMaps.get(key)
- if(null != oofSliceProfile && oofSliceProfile.keySet().contains(key)){
- sliceProfile.put(key, oofSliceProfile.get(key))
- logger.debug("Get from oof, key:${key}, value: ${oofSliceProfile.get(key)}")
- }
- else if(serviceProfile.keySet().contains(value)){
- sliceProfile.put(key, serviceProfile.get(value))
- }
- else{
- sliceProfile.put(key, profileMaps.get(key))
- }
- }
- return sliceProfile
- }
-
- void processDecomposition(DelegateExecution execution){
- logger.debug("Start processDecomposition")
-
- ServiceDecomposition serviceDecomposition= execution.getVariable("serviceDecomposition")
- SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams")
- String nstName = serviceDecomposition.getModelInfo().getModelName()
- String nstId = serviceDecomposition.getModelInfo().getModelUuid()
- sliceTaskParams.setNstName(nstName)
- sliceTaskParams.setNstId(nstId)
-
- logger.debug("End processDecomposition")
- }
-
-
- void prepareNSTDecompose(DelegateExecution execution) {
-
- String modelUuid = execution.getVariable("nstModelUuid")
- String modelInvariantUuid = execution.getVariable("nstModelInvariantUuid")
-
- String serviceModelInfo = """{
- "modelInvariantUuid":"${modelInvariantUuid}",
- "modelUuid":"${modelUuid}",
- "modelVersion":""
- }"""
- execution.setVariable("serviceModelInfo", serviceModelInfo)
- }
-
- void prepareNSSTDecompose(DelegateExecution execution) {
- Boolean isMoreNSSTtoProcess = false
- Integer maxNSST = execution.getVariable("maxNSST")
- Integer currentNSST=execution.getVariable("currentNSST")
- List<String> nsstModelUUIDList = new ArrayList<>()
- nsstModelUUIDList = execution.getVariable("nsstModelUUIDList")
- String modelUuid = nsstModelUUIDList.get(currentNSST)
- String serviceModelInfo = """{
- "modelInvariantUuid":"",
- "modelUuid":"${modelUuid}",
- "modelVersion":""
- }"""
- execution.setVariable("serviceModelInfo", serviceModelInfo)
- currentNSST=currentNSST+1
- if(currentNSST<maxNSST)
- isMoreNSSTtoProcess=true
- execution.setVariable("isMoreNSSTtoProcess",isMoreNSSTtoProcess)
- execution.setVariable("maxNSST",maxNSST)
- execution.setVariable("currentNSST",currentNSST)
- }
-
-
- void prepareNSSTlistfromNST(DelegateExecution execution) {
- //Need to update this part from decomposition.
- logger.trace("Enter prepareNSSTlistfromNST()")
- Boolean isMoreNSSTtoProcess = false
- ServiceDecomposition serviceDecomposition= execution.getVariable("serviceDecomposition")
- SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams")
- String nstName = serviceDecomposition.getModelInfo().getModelName()
- sliceTaskParams.setNstName(nstName)
- String nstId = serviceDecomposition.getModelInfo().getModelUuid()
- sliceTaskParams.setNstId(nstId)
- execution.setVariable("sliceTaskParams",sliceTaskParams)
-
- List<ServiceProxy> proxyList = serviceDecomposition.getServiceProxy()
- List<String> nsstModelUUIDList = new ArrayList<>()
- for(ServiceProxy serviceProxy:proxyList)
- nsstModelUUIDList.add(serviceProxy.getSourceModelUuid())
- execution.setVariable("nsstModelUUIDList",nsstModelUUIDList)
- Integer maxNSST = nsstModelUUIDList.size()
- Integer currentNSST=0
- execution.setVariable("maxNSST",maxNSST)
- execution.setVariable("currentNSST",currentNSST)
- if(currentNSST<maxNSST)
- isMoreNSSTtoProcess=true
- execution.setVariable("isMoreNSSTtoProcess",isMoreNSSTtoProcess)
- logger.trace("Exit prepareNSSTlistfromNST()")
-
- }
-
- void getNSSTOption(DelegateExecution execution) {
- ServiceDecomposition serviceDecomposition= execution.getVariable("serviceDecomposition")
- String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution)
- String globalSubscriberId = execution.getVariable("globalSubscriberId")
- String serviceType = execution.getVariable("subscriptionServiceType")
- String nssiInstanceId =""
- String nssiName =""
- SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams")
- logger.debug( "get NSI option OOF Url: " + urlString)
- boolean isNSISuggested = false
- execution.setVariable("isNSISuggested",isNSISuggested)
-
- //Prepare auth for OOF - Begin
- def authHeader = ""
- String basicAuth = UrnPropertiesReader.getVariable("mso.oof.auth", execution)
- String msokey = UrnPropertiesReader.getVariable("mso.msoKey", execution)
-
- String basicAuthValue = utils.encrypt(basicAuth, msokey)
- if (basicAuthValue != null) {
- logger.debug( "Obtained BasicAuth username and password for OOF: " + basicAuthValue)
- try {
- authHeader = utils.getBasicAuth(basicAuthValue, msokey)
- execution.setVariable("BasicAuthHeaderValue", authHeader)
- } catch (Exception ex) {
- logger.debug( "Unable to encode username and password string: " + ex)
- exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - Unable to " +
- "encode username and password string")
- }
- } else {
- logger.debug( "Unable to obtain BasicAuth - BasicAuth value null")
- exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - BasicAuth " +
- "value null")
- }
- //Prepare auth for OOF - End
- //Prepare send request to OOF - Begin
- String requestId = execution.getVariable("msoRequestId")
- Map<String, Object> profileInfo = execution.getVariable("serviceProfile")
- String nsstModelInvariantUuid = serviceDecomposition.getModelInfo().getModelInvariantUuid()
- String nsstModelUuid = serviceDecomposition.getModelInfo().getModelUuid()
- String nsstInfo = """"NSSTInfo": {
- "invariantUUID":"${nsstModelInvariantUuid}",
- "UUID":"${nsstModelUuid}"
- }"""
- String oofRequest = oofUtils.buildSelectNSSIRequest(execution, requestId, nsstInfo ,profileInfo)
-
-
- URL url = new URL(urlString+"/api/oof/v1/selectnssi")
- HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.OOF)
- httpClient.addAdditionalHeader("Authorization", authHeader)
- Response httpResponse = httpClient.post(oofRequest)
-
- int responseCode = httpResponse.getStatus()
- logger.debug("OOF sync response code is: " + responseCode)
-
- if(responseCode != 200){
- exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from OOF.")
- }
-
- if(httpResponse.hasEntity()){
- String OOFResponse = httpResponse.readEntity(String.class)
- execution.setVariable("OOFResponse", OOFResponse)
- nssiInstanceId = jsonUtil.getJsonValue(OOFResponse, "NSSIIInfo.NSSIID")
- nssiName = jsonUtil.getJsonValue(OOFResponse, "NSSIInfo.NSSIName")
- execution.setVariable("nssiInstanceId",nssiInstanceId)
- execution.setVariable("nssiName",nssiName)
- }
- if(StringUtils.isBlank(nssiInstanceId)){
- logger.debug( "There is no valid NSST suggested by OOF.")
- }else
- {
- try {
- AAIResourcesClient resourceClient = new AAIResourcesClient()
- AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, serviceType, nssiInstanceId)
- AAIResultWrapper wrapper = resourceClient.get(serviceInstanceUri, NotFoundException.class)
- Optional<ServiceInstance> si = wrapper.asBean(org.onap.aai.domain.yang.ServiceInstance.class)
- org.onap.aai.domain.yang.ServiceInstance nssi = si.get()
-
- String domain = nssi.getEnvironmentContext().toString().toUpperCase()
- switch (domain) {
- case "AN":
- sliceTaskParams.setAnSuggestNssiId(nssi.getServiceInstanceId())
- sliceTaskParams.setAnSuggestNssiName(nssi.getServiceInstanceName())
- break
- case "CN":
- sliceTaskParams.setCnSuggestNssiId(nssi.getServiceInstanceId())
- sliceTaskParams.setCnSuggestNssiName(nssi.getServiceInstanceName())
- break
- case "TN":
- sliceTaskParams.setTnSuggestNssiId(nssi.getServiceInstanceId())
- sliceTaskParams.setTnSuggestNssiName(nssi.getServiceInstanceName())
- break
- default:
- break
- }
- }catch(NotFoundException e)
- {
- logger.debug("NSSI Service Instance not found in AAI: " + nssiInstanceId)
- }catch(Exception e)
- {
- logger.debug("NSSI Service Instance not found in AAI: " + nssiInstanceId)
- }
- }
- logger.debug("Prepare NSSI option completed ")
- }
-
-
- /**
- * new
- */
-
- private static final ObjectMapper MAPPER = new ObjectMapper()
-
- private NssmfAdapterUtils nssmfAdapterUtils = new NssmfAdapterUtils(httpClientFactory, jsonUtil)
-
- private static final String QUERY_SUB_NET_CAPABILITY = "/api/rest/provMns/v1/NSS/subnetCapabilityQuery"
-
- private static final String QUERY_NSSI_SELECTION_CAPABILITY = "/api/rest/provMns/v1/NSS/NSSISelectionCapability"
-
- /**
- * query Subnet Capability of TN
- * @param execution
- */
- public void queryTNSubnetCapability(DelegateExecution execution) {
-
- String vendor = execution.getVariable("vendor")
-
- List<String> subnetTypes = new ArrayList<>()
- subnetTypes.add("TN_FH")
- subnetTypes.add("TN_MH")
- subnetTypes.add("TN_BH")
-
- String strRequest = MAPPER.writeValueAsString(
- buildQuerySubnetCapRequest(vendor, subnetTypes, NetworkType.TRANSPORT))
-
- String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, QUERY_SUB_NET_CAPABILITY, strRequest)
- execution.setVariable("subnetCapabilityOfTN", response)
- }
-
- /**
- * query Subnet Capability of CN
- * @param execution
- */
- public void queryCNSubnetCapability(DelegateExecution execution) {
-
- String vendor = execution.getVariable("vendor")
-
- List<String> subnetTypes = new ArrayList<>()
- subnetTypes.add("CN")
-
- String strRequest = MAPPER.writeValueAsString(buildQuerySubnetCapRequest(vendor, subnetTypes, NetworkType.CORE))
-
- String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, QUERY_SUB_NET_CAPABILITY, strRequest)
-
- execution.setVariable("subnetCapabilityOfCN", response)
- }
-
- /**
- * query Subnet Capability of AN
- * @param execution
- */
- public void queryANSubnetCapability(DelegateExecution execution) {
-
- String vendor = execution.getVariable("vendor")
-
- List<String> subnetTypes = new ArrayList<>()
- subnetTypes.add("AN-NF")
-
- String strRequest = MAPPER.writeValueAsString(buildQuerySubnetCapRequest(vendor, subnetTypes, NetworkType.ACCESS))
-
- String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, QUERY_SUB_NET_CAPABILITY, strRequest)
-
- execution.setVariable("subnetCapabilityOfAN", response)
- }
-
- /**
- * build request body for querying Subnet Capability
- * @param vendor
- * @param subnetTypes
- * @param networkType
- * @return
- */
- private static String buildQuerySubnetCapRequest(String vendor, List<String> subnetTypes, NetworkType networkType) {
- NssmfAdapterNBIRequest request = new NssmfAdapterNBIRequest()
-
- Map<String, Object> paramMap = new HashMap()
- paramMap.put("subnetTypes", subnetTypes)
-
- request.setSubnetCapabilityQuery(MAPPER.writeValueAsString(paramMap))
-
- EsrInfo esrInfo = new EsrInfo()
- esrInfo.setVendor(vendor)
- esrInfo.setNetworkType(networkType)
-
- request.setEsrInfo(esrInfo)
-
- String strRequest = MAPPER.writeValueAsString(request)
-
- return strRequest
- }
-
- /**
- * handle response of Subnet Capability, generate SubnetCapabilities Info for request to oof
- * @param execution
- */
- public void generateSubnetCapabilities(DelegateExecution execution) {
- //todo:
- execution.setVariable("subnetCapabilities", [])
- }
-
- /**
- * prepare the params for decompose nst
- * @param execution
- */
- public void prepareDecomposeNST(DelegateExecution execution) {
-
- String modelUuid = execution.getVariable("nstModelUuid")
- String modelInvariantUuid = execution.getVariable("nstModelInvariantUuid")
-
- String serviceModelInfo = """{
- "modelInvariantUuid":"${modelInvariantUuid}",
- "modelUuid":"${modelUuid}",
- "modelVersion":""
- }"""
- execution.setVariable("nstServiceModelInfo", serviceModelInfo)
- }
-
- /**
- * process the result of NST Decomposition
- * @param execution
- */
- public void processDecompositionNST(DelegateExecution execution) {
-
- ServiceDecomposition nstServiceDecomposition = execution.getVariable("nstServiceDecomposition")
- //todo:
-
- }
-
-
- /**
- * prepare the params for decompose nsst
- * @param execution
- */
- public void prepareDecomposeNSST(DelegateExecution execution) {
- Boolean isMoreNSSTtoProcess = false
- def maxNSST = execution.getVariable("maxNSST") as Integer
- def currentNSST = execution.getVariable("currentNSST") as Integer
- def nsstModelUUIDList = execution.getVariable("nsstModelUUIDList") as List
- String modelUuid = nsstModelUUIDList.get(currentNSST)
- String serviceModelInfo = """{
- "modelInvariantUuid":"",
- "modelUuid":"${modelUuid}",
- "modelVersion":""
- }"""
- execution.setVariable("nsstServiceModelInfo", serviceModelInfo)
- currentNSST = currentNSST + 1
-
- if(currentNSST < maxNSST) {
- isMoreNSSTtoProcess = true
- }
-
- execution.setVariable("isMoreNSSTtoProcess", isMoreNSSTtoProcess)
- execution.setVariable("maxNSST", maxNSST)
- execution.setVariable("currentNSST", currentNSST)
-
- //todo:
- }
-
- /**
- * process the result of NSST Decomposition
- * @param execution
- */
- public void processDecompositionNSST(DelegateExecution execution) {
- ServiceDecomposition nsstServiceDecomposition = execution.getVariable("nsstServiceDecomposition")
- //todo:
- }
-
- /**
- * todo: need rewrite
- * prepare select nsi request
- * @param execution
- */
- public void preNSIRequest(DelegateExecution execution) {
-
- String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution)
- logger.debug( "get NSI option OOF Url: " + urlString)
-
- boolean isNSISuggested = true
- execution.setVariable("isNSISuggested", isNSISuggested)
- String requestId = execution.getVariable("msoRequestId")
- String messageType = "NSISelectionResponse"
-
- ServiceProfile profileInfo = execution.getVariable("serviceProfile") as ServiceProfile
- Map<String, Object> nstSolution = execution.getVariable("nstSolution") as Map
- logger.debug("Get NST selection from OOF: " + nstSolution.toString())
-
- execution.setVariable("nsiSelectionUrl", "/api/oof/selection/nsi/v1")
- execution.setVariable("nsiSelection_messageType", messageType)
- execution.setVariable("nsiSelection_correlator", requestId)
- String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution)
- execution.setVariable("nsiSelection_timeout", timeout)
-
-
- TemplateInfo nstInfo = new TemplateInfo()
- nstInfo.setInvariantUUID(nstSolution.get("invariantUUID") as String)
- nstInfo.setUUID(nstSolution.get("UUID") as String)
- nstInfo.setName(nstSolution.get("NSTName") as String)
-
- execution.setVariable("NSTInfo", nstInfo)
-
- List<TemplateInfo> nsstInfos = execution.getVariable("NSSTInfos") as List<TemplateInfo>
-
- List<SubnetCapability> subnetCapabilities = execution.getVariable("subnetCapabilities") as List<SubnetCapability>
-
- String oofRequest = oofUtils.buildSelectNSIRequest(requestId, nstInfo, nsstInfos,
- messageType, profileInfo, subnetCapabilities, timeout as Integer)
-
- execution.setVariable("nsiSelection_oofRequest", oofRequest)
- logger.debug("Sending request to OOF: " + oofRequest)
- }
-
- /**
- * todo: need rewrite
- * process select nsi response
- * @param execution
- */
- public void processNSIResp(DelegateExecution execution) {
-
- SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") as SliceTaskParams
- String OOFResponse = execution.getVariable("nsiSelection_oofResponse")
- logger.debug("NSI OOFResponse is: " + OOFResponse)
- execution.setVariable("OOFResponse", OOFResponse)
- //This needs to be changed to derive a value when we add policy to decide the solution options.
-
- Map<String, Object> resMap = objectMapper.readValue(OOFResponse, Map.class)
- List<Map<String, Object>> nsiSolutions = (List<Map<String, Object>>) resMap.get("solutions")
- Map<String, Object> solutions = nsiSolutions.get(0)
-
- String resourceSharingLevel = execution.getVariable("resourceSharingLevel")
- Boolean isSharable = resourceSharingLevel == "shared"
-
- if (solutions != null) {
- if (isSharable && solutions.get("existingNSI")) {
- //sharedNSISolution
- processSharedNSISolutions(solutions, execution)
- }
- else if(solutions.containsKey("newNSISolution")) {
- processNewNSISolutions(solutions, execution)
- }
- }
- execution.setVariable("sliceTaskParams", sliceTaskParams)
- logger.debug("sliceTaskParams: " + sliceTaskParams.convertToJson())
- logger.debug("*** Completed options Call to OOF ***")
-
- logger.debug("start parseServiceProfile")
- parseServiceProfile(execution)
- logger.debug("end parseServiceProfile")
- }
-
- /**
- * get NSSI Selection Capability for AN
- * @param execution
- */
- public void getNSSISelectionCap4AN(DelegateExecution execution) {
-
- def vendor = execution.getVariable("vendor") as String
-
- String strRequest = buildNSSISelectionReq(vendor, NetworkType.ACCESS)
-
- String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, QUERY_NSSI_SELECTION_CAPABILITY, strRequest)
-
- Map<String, Object> resMap = objectMapper.readValue(response, Map.class)
-
- String selection = resMap.get("selection")
-
-
- if ("NSMF".equalsIgnoreCase(selection)) {
- execution.setVariable("NEED_AN_NSSI_SELECTION", true)
- }
- }
-
- /**
- * get NSSI Selection Capability for TN
- * @param execution
- */
- public void getNSSISelectionCap4TN(DelegateExecution execution) {
-
- def vendor = execution.getVariable("vendor") as String
-
- String strRequest = buildNSSISelectionReq(vendor, NetworkType.TRANSPORT)
-
- String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, QUERY_NSSI_SELECTION_CAPABILITY, strRequest)
-
- Map<String, Object> resMap = objectMapper.readValue(response, Map.class)
-
- String selection = resMap.get("selection")
-
- if ("NSMF".equalsIgnoreCase(selection)) {
- execution.setVariable("NEED_TN_NSSI_SELECTION", true)
- }
- }
-
- /**
- * get NSSI Selection Capability for CN
- * @param execution
- */
- public void getNSSISelectionCap4CN(DelegateExecution execution) {
-
- def vendor = execution.getVariable("vendor") as String
-
- String strRequest = buildNSSISelectionReq(vendor, NetworkType.CORE)
-
- String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, QUERY_NSSI_SELECTION_CAPABILITY, strRequest)
-
- Map<String, Object> resMap = objectMapper.readValue(response, Map.class)
-
- String selection = resMap.get("selection")
-
- if ("NSMF".equalsIgnoreCase(selection)) {
- execution.setVariable("NEED_CN_NSSI_SELECTION", true)
- }
- }
-
- /**
- * build NSSI Selection Capability Request body to nssmf adapter
- * @param vendor
- * @param networkType
- * @return
- */
- private static String buildNSSISelectionReq(String vendor, NetworkType networkType) {
- NssmfAdapterNBIRequest request = new NssmfAdapterNBIRequest()
- EsrInfo esrInfo = new EsrInfo()
- esrInfo.setVendor(vendor)
- esrInfo.setNetworkType(networkType)
- request.setEsrInfo(esrInfo)
-
- return MAPPER.writeValueAsString(request)
- }
-
- /**
- * if exist nssi need to select?
- * @param execution
- */
- public void handleNssiSelect(DelegateExecution execution) {
-
- SliceTaskParamsAdapter sliceTaskParams =
- execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
-
- execution.setVariable()
- }
-
- /**
- * todo: need rewrite
- * prepare select nssi request
- * @param execution
- */
- public void preNSSIRequest(DelegateExecution execution) {
-
- String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution)
- logger.debug( "get NSI option OOF Url: " + urlString)
-
- boolean isNSISuggested = true
- execution.setVariable("isNSISuggested", isNSISuggested)
- String requestId = execution.getVariable("msoRequestId")
- String messageType = "NSISelectionResponse"
-
- Map<String, Object> profileInfo = execution.getVariable("serviceProfile") as Map
- Map<String, Object> nstSolution = execution.getVariable("nstSolution") as Map
- logger.debug("Get NST selection from OOF: " + nstSolution.toString())
- String nstInfo = """{
- "modelInvariantId":"${nstSolution.invariantUUID}",
- "modelVersionId":"${nstSolution.UUID}",
- "modelName":"${nstSolution.NSTName}"
- }"""
-
- execution.setVariable("nsiSelectionUrl", "/api/oof/selection/nsi/v1")
- execution.setVariable("nsiSelection_messageType", messageType)
- execution.setVariable("nsiSelection_correlator", requestId)
- String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution)
- execution.setVariable("nsiSelection_timeout", timeout)
-
- //todo
- String oofRequest = oofUtils.buildSelectNSIRequest(requestId, nstInfo, messageType, profileInfo)
-
- execution.setVariable("nsiSelection_oofRequest", oofRequest)
- logger.debug("Sending request to OOF: " + oofRequest)
- }
-
- /**
- * process select nssi response
- * @param execution
- */
- public void processNSSIResp(DelegateExecution execution) {
-
- SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") as SliceTaskParams
- String OOFResponse = execution.getVariable("nsiSelection_oofResponse")
- logger.debug("NSI OOFResponse is: " + OOFResponse)
- execution.setVariable("OOFResponse", OOFResponse)
- //This needs to be changed to derive a value when we add policy to decide the solution options.
-
- Map<String, Object> resMap = objectMapper.readValue(OOFResponse, Map.class)
- List<Map<String, Object>> nsiSolutions = (List<Map<String, Object>>) resMap.get("solutions")
- Map<String, Object> solutions = nsiSolutions.get(0)
-
- String resourceSharingLevel = execution.getVariable("resourceSharingLevel")
- Boolean isSharable = resourceSharingLevel == "shared"
-
- if (solutions != null) {
- if (isSharable && solutions.get("existingNSI")) {
- //sharedNSISolution
- processSharedNSISolutions(solutions, execution)
- }
- else if(solutions.containsKey("newNSISolution")) {
- processNewNSISolutions(solutions, execution)
- }
- }
- execution.setVariable("sliceTaskParams", sliceTaskParams)
- logger.debug("sliceTaskParams: "+sliceTaskParams.convertToJson())
- logger.debug("*** Completed options Call to OOF ***")
-
- logger.debug("start parseServiceProfile")
- parseServiceProfile(execution)
- logger.debug("end parseServiceProfile")
- }
-
-
-}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceServiceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceServiceTest.groovy
index 46f061d89c..01f4d6b97b 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceServiceTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceServiceTest.groovy
@@ -160,45 +160,6 @@ class CreateSliceServiceTest extends MsoGroovyTest {
}
@Test
- void testPrepareDecomposeService() {
- when(mockExecution.getVariable("uuiRequest")).thenReturn(uuiRequest)
- when(mockExecution.getVariable("serviceProfile")).thenReturn(serviceProfile)
- CreateSliceService sliceService = new CreateSliceService()
- sliceService.prepareDecomposeService(mockExecution)
-
- String serviceModelInfoExcept = """{
- "modelInvariantUuid":"123456",
- "modelUuid":"123456",
- "modelVersion":""
- }"""
- Mockito.verify(mockExecution, times(1)).setVariable(eq("ssServiceModelInfo"), captor.capture())
- String serviceModelInfo = captor.getValue()
- assertEquals(serviceModelInfoExcept.replaceAll("\\s+", ""),
- serviceModelInfo.replaceAll("\\s+", ""))
- }
-
- @Test
- void testProcessDecomposition() {
- when(mockExecution.getVariable("uuiRequest")).thenReturn(uuiRequest)
- when(mockExecution.getVariable("serviceProfile")).thenReturn(serviceProfile)
- when(mockExecution.getVariable("nstSolution")).thenReturn(nstSolution)
-
- CreateSliceService sliceService = new CreateSliceService()
- sliceService.processDecomposition(mockExecution)
-
- Mockito.verify(mockExecution, times(1)).setVariable(eq("subscriptionServiceType"), captor.capture())
- assertEquals(captor.getValue(), "5G")
- Mockito.verify(mockExecution, times(1)).setVariable(eq("serviceType"), captor.capture())
- assertEquals(captor.getValue(), "embb")
- Mockito.verify(mockExecution, times(1)).setVariable(eq("resourceSharingLevel"), captor.capture())
- assertEquals(captor.getValue(), "shared")
- Mockito.verify(mockExecution, times(1)).setVariable(eq("nstModelUuid"), captor.capture())
- assertEquals(captor.getValue(), "aaaaaa")
- Mockito.verify(mockExecution, times(1)).setVariable(eq("nstModelInvariantUuid"), captor.capture())
- assertEquals(captor.getValue(), "bbbbbb")
- }
-
- @Test
void testPrepareCreateOrchestrationTask() {
when(mockExecution.getVariable("serviceInstanceId")).thenReturn("123456")
when(mockExecution.getVariable("serviceInstanceName")).thenReturn("test")