aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-infrastructure-common/src/main/groovy
diff options
context:
space:
mode:
authorByung-Woo Jun <byung-woo.jun@est.tech>2020-09-29 16:07:40 +0000
committerGerrit Code Review <gerrit@onap.org>2020-09-29 16:07:40 +0000
commit90503c475233a7578f925199b5dccf251396db66 (patch)
tree1b03bc20b2e480cf6f2413c2b3f349d2ed7d3869 /bpmn/so-bpmn-infrastructure-common/src/main/groovy
parentaecdc1520d4afaacac8dde1fce0d66e2b5aeea22 (diff)
parent47397faa188acd9fa3c07e79018e0919c0055f3a (diff)
Merge "Enrich Deallocate and Modify Core NSSI sub-processes"
Diffstat (limited to 'bpmn/so-bpmn-infrastructure-common/src/main/groovy')
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSI.groovy289
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSI.groovy92
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSI.groovy106
3 files changed, 317 insertions, 170 deletions
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSI.groovy
index e225c360ed..567725246e 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSI.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSI.groovy
@@ -22,15 +22,9 @@ package org.onap.so.bpmn.infrastructure.scripts
import com.fasterxml.jackson.databind.ObjectMapper
import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.onap.aai.domain.yang.CloudRegion
-import org.onap.aai.domain.yang.GenericVnf
-import org.onap.aai.domain.yang.ModelVer
-import org.onap.aai.domain.yang.ServiceInstance
-import org.onap.aai.domain.yang.ServiceSubscription
-import org.onap.aai.domain.yang.SliceProfile
-import org.onap.aai.domain.yang.Tenant
-import org.onap.aai.domain.yang.VfModule
-import org.onap.aaiclient.client.aai.AAIObjectType
+import org.json.JSONArray
+import org.json.JSONObject
+import org.onap.aai.domain.yang.v19.*
import org.onap.aaiclient.client.aai.AAIResourcesClient
import org.onap.aaiclient.client.aai.entities.AAIResultWrapper
import org.onap.aaiclient.client.aai.entities.Relationships
@@ -39,35 +33,20 @@ import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory
import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder
import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types
import org.onap.logging.filter.base.ONAPComponents
-import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
-import org.onap.so.bpmn.common.scripts.ExceptionUtil
-import org.onap.so.bpmn.common.scripts.RequestDBUtil
+import org.onap.so.bpmn.common.scripts.*
import org.onap.so.bpmn.core.UrnPropertiesReader
import org.onap.so.bpmn.core.json.JsonUtils
import org.onap.so.client.HttpClient
-import org.onap.so.db.request.beans.OperationStatus
-import org.onap.so.requestsdb.RequestsDbConstant
-import org.onap.so.serviceinstancebeans.CloudConfiguration
-import org.onap.so.serviceinstancebeans.LineOfBusiness
-import org.onap.so.serviceinstancebeans.ModelInfo
-import org.onap.so.serviceinstancebeans.ModelType
-import org.onap.so.serviceinstancebeans.OwningEntity
-import org.onap.so.serviceinstancebeans.Project
-import org.onap.so.serviceinstancebeans.RequestDetails
-import org.onap.so.serviceinstancebeans.RequestInfo
-import org.onap.so.serviceinstancebeans.RequestParameters
-import org.onap.so.serviceinstancebeans.Resources
-import org.onap.so.serviceinstancebeans.Service
-import org.onap.so.serviceinstancebeans.SubscriberInfo
-import org.onap.so.serviceinstancebeans.VfModules
-import org.onap.so.serviceinstancebeans.Vnfs
+import org.onap.so.db.request.beans.ResourceOperationStatus
+import org.onap.so.serviceinstancebeans.*
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import javax.ws.rs.core.Response
+import static org.apache.commons.lang3.StringUtils.isBlank
- class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
+class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
private final String PREFIX ="DoCommonCoreNSSI"
@@ -83,10 +62,54 @@ import javax.ws.rs.core.Response
def currentNSSI = execution.getVariable("currentNSSI")
if (!currentNSSI) {
- String msg = "currentNSSI is null"
+ currentNSSI = [:]
+ }
+
+ // NSSI ID
+ String nssiId = execution.getVariable("serviceInstanceID")
+ if (isBlank(nssiId)) {
+ String msg = "NSSI service instance id is null"
LOGGER.error(msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
}
+ else {
+ currentNSSI['nssiId'] = nssiId
+ }
+
+ // NSI ID
+ String nsiId = execution.getVariable("nsiId")
+ if (isBlank(nsiId)) {
+ String msg = "nsiId is null"
+ LOGGER.error(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ }
+ else {
+ currentNSSI['nsiId'] = nsiId
+ }
+
+
+ // Slice Profile
+ String sliceProfile = jsonUtil.getJsonValue(execution.getVariable("sliceParams"), "sliceProfile")
+ if (isBlank(sliceProfile)) {
+ String msg = "Slice Profile is null"
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ } else {
+ currentNSSI['sliceProfile'] = sliceProfile
+ }
+
+ // S-NSSAI
+ def snssaiList = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(sliceProfile, "snssaiList"))
+
+ String sNssai = snssaiList.get(0)
+ currentNSSI['S-NSSAI'] = sNssai
+
+
+ // Slice Profile id
+ String sliceProfileId = jsonUtil.getJsonValue(sliceProfile, "sliceProfileId")
+ currentNSSI['sliceProfileId'] = sliceProfileId
+
+ execution.setVariable("currentNSSI", currentNSSI)
+
LOGGER.trace("***** ${getPrefix()} Exit preProcessRequest")
}
@@ -257,7 +280,7 @@ import javax.ws.rs.core.Response
List<String> snssais = new ArrayList<>()
- String isCreateSliceProfileInstanceVar = execution.getVariable("isCreateSliceProfileInstance" )
+ String isCreateSliceProfileInstanceVar = execution.getVariable("isCreateSliceProfileInstance" ) // Not exist in case of Deallocate
boolean isCreateSliceProfileInstance = Boolean.parseBoolean(isCreateSliceProfileInstanceVar)
@@ -294,14 +317,14 @@ import javax.ws.rs.core.Response
def currentNSSI = execution.getVariable("currentNSSI")
try {
- //url:/onap/so/infra/serviceInstantiation/v7/serviceInstances/{serviceInstanceId}/vnfs/{vnfId}"
- def nsmfЕndpoint = UrnPropertiesReader.getVariable("mso.infra.endpoint.url", execution) // ???
+ //url:/onap/so/infra/serviceInstantiation/v7/serviceInstances/{serviceInstanceId}"
+ def nsmfЕndPoint = UrnPropertiesReader.getVariable("mso.infra.endpoint.url", execution) // ???
ServiceInstance networkServiceInstance = (ServiceInstance)currentNSSI['networkServiceInstance']
- GenericVnf constituteVnf = (GenericVnf)currentNSSI['constituteVnf']
+ String url = String.format("${nsmfЕndPoint}/serviceInstantiation/v7/serviceInstances/%s", networkServiceInstance.getServiceInstanceId())
- String url = String.format("${nsmfЕndpoint}/serviceInstantiation/v7/serviceInstances/%s/vnfs/%s", networkServiceInstance.getServiceInstanceId(), constituteVnf.getVnfId())
+ currentNSSI['putServiceInstanceURL'] = url
String msoKey = UrnPropertiesReader.getVariable("mso.msoKey", execution)
String basicAuth = UrnPropertiesReader.getVariable("mso.infra.endpoint.auth", execution)
@@ -332,7 +355,7 @@ import javax.ws.rs.core.Response
String putServiceInstanceResponse = ""
if(errorCode == null || errorCode.isEmpty()) { // No error
- putServiceInstanceResponse = callPUTServiceInstanceResponse // check the response ???
+ putServiceInstanceResponse = callPUTServiceInstanceResponse
}
else {
LOGGER.error(jsonUtil.getJsonValue(callPUTServiceInstanceResponse, "errorMessage"))
@@ -430,9 +453,9 @@ import javax.ws.rs.core.Response
SubscriberInfo prepareSubscriberInfo(DelegateExecution execution) {
def currentNSSI = execution.getVariable("currentNSSI")
- String globalSubscriberId = currentNSSI['globalSubscriberId']
+ String globalSubscriberId = execution.getVariable("globalSubscriberId")
- String subscriberName = currentNSSI['subscriberName']
+ String subscriberName = execution.getVariable("subscriberName")
SubscriberInfo subscriberInfo = new SubscriberInfo()
subscriberInfo.setGlobalSubscriberId(globalSubscriberId)
@@ -484,13 +507,13 @@ import javax.ws.rs.core.Response
RequestInfo prepareRequestInfo(DelegateExecution execution, ServiceInstance networkServiceInstance) {
def currentNSSI = execution.getVariable("currentNSSI")
- String serviceId = currentNSSI['serviceId']
+ String productFamilyId = execution.getVariable("productFamilyId")
RequestInfo requestInfo = new RequestInfo()
requestInfo.setInstanceName(networkServiceInstance.getServiceInstanceName())
requestInfo.setSource("VID")
- requestInfo.setProductFamilyId(serviceId)
+ requestInfo.setProductFamilyId(productFamilyId)
requestInfo.setRequestorId("NBI")
return requestInfo
@@ -961,15 +984,15 @@ import javax.ws.rs.core.Response
SliceProfile sliceProfileContainsSNSSAI = (SliceProfile)currentNSSI['sliceProfileS-NSSAI']
- String globalSubscriberId = currentNSSI['globalSubscriberId']
- String serviceType = currentNSSI['serviceType']
+ String globalSubscriberId = execution.getVariable("globalSubscriberId")
+ String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
String nssiId = currentNSSI['nssiId']
// global-customer-id, service-type, service-instance-id, profile-id
- AAIResourceUri sliceProfileUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(nssiId).sliceProfile(sliceProfileContainsSNSSAI.getProfileId()))
+ AAIResourceUri sliceProfileUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(nssiId).sliceProfile(sliceProfileContainsSNSSAI.getProfileId()))
try {
- getAAIClient().delete(sliceProfileUri)
+ client.delete(sliceProfileUri)
}catch(Exception e){
exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile Instance delete call: " + e.getMessage())
}
@@ -979,27 +1002,180 @@ import javax.ws.rs.core.Response
/**
- * Updates operation status
+ * Prepares update resource operation status
* @param execution
*/
- void updateServiceOperationStatus(DelegateExecution execution) {
+ void prepareUpdateResourceOperationStatus(DelegateExecution execution) {
LOGGER.trace("${getPrefix()} Start updateServiceOperationStatus")
def currentNSSI = execution.getVariable("currentNSSI")
- OperationStatus operationStatus = new OperationStatus()
- operationStatus.setServiceId(currentNSSI['e2eServiceInstanceId'] as String)
- operationStatus.setOperationId(currentNSSI['operationId'] as String)
- operationStatus.setOperation(currentNSSI['operationType'] as String)
- operationStatus.setResult(RequestsDbConstant.Status.FINISHED)
+ //Prepare Update Status for PUT failure and success
+ String isTimeOutVar = execution.getVariable("isTimeOut")
+ if(!isBlank(isTimeOutVar) && isTimeOutVar.equals("YES")) {
+ LOGGER.error("TIMEOUT - SO PUT Failure")
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "SO PUT Failure")
+ } else {
+ execution.setVariable("progress", "100")
+ execution.setVariable("status", "finished")
+ execution.setVariable("operationContent", "${getAction()} Core NSSI successful.")
+ }
- requestDBUtil.prepareUpdateOperationStatus(execution, operationStatus)
+ setResourceOperationStatus(execution, "finished", "100", "Core NSSI ${getAction()} successful")
LOGGER.trace("${getPrefix()} Exit updateServiceOperationStatus")
}
/**
+ * Prepares ResourceOperation status
+ * @param execution
+ * @param operationType
+ */
+ void setResourceOperationStatus(DelegateExecution execution, String status, String progress, String statusDesc) {
+ LOGGER.trace("${getPrefix()} Start setResourceOperationStatus")
+
+ def currentNSSI = execution.getVariable("currentNSSI")
+
+ String serviceId = currentNSSI['nssiId']
+ String jobId = execution.getVariable("jobId")
+ String nsiId = currentNSSI['nsiId']
+ String operationType = execution.getVariable("operationType")
+
+ ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus()
+ resourceOperationStatus.setServiceId(serviceId)
+ resourceOperationStatus.setOperationId(jobId)
+ resourceOperationStatus.setResourceTemplateUUID(nsiId)
+ resourceOperationStatus.setOperType(operationType)
+ resourceOperationStatus.setStatus(status)
+ resourceOperationStatus.setProgress(progress)
+ resourceOperationStatus.setStatusDescription(statusDesc)
+ requestDBUtil.prepareUpdateResourceOperationStatus(execution, resourceOperationStatus)
+
+ LOGGER.trace("${getPrefix()} Exit setResourceOperationStatus")
+ }
+
+
+ /**
+ * Prepares failed operation status update
+ * @param execution
+ */
+ void prepareFailedOperationStatusUpdate(DelegateExecution execution) {
+ LOGGER.trace("${getPrefix()} Start prepareFailedOperationStatusUpdate")
+
+ setResourceOperationStatus(execution, "failed", "0", "Core NSSI ${getAction()} Failed")
+
+ LOGGER.trace("${getPrefix()} Exit prepareFailedOperationStatusUpdate")
+ }
+
+
+ /**
+ * Gets progress status of ServiceInstance PUT operation
+ * @param execution
+ */
+ public void getPUTServiceInstanceProgress(DelegateExecution execution) {
+ LOGGER.trace("${getPrefix()} Start getPUTServiceInstanceProgress")
+
+ def currentNSSI = execution.getVariable("currentNSSI")
+
+ String url = currentNSSI['putServiceInstanceURL']
+
+ getProgress(execution, url, "putStatus")
+
+ LOGGER.trace("${getPrefix()} Exit getPUTServiceInstanceProgress")
+ }
+
+
+ void getProgress(DelegateExecution execution, String url, String statusVariableName) {
+ String msg=""
+ try {
+
+ ExternalAPIUtil externalAPIUtil = getExternalAPIUtilFactory().create()
+ Response response = externalAPIUtil.executeExternalAPIGetCall(execution, url)
+ int responseCode = response.getStatus()
+ execution.setVariable("GetServiceOrderResponseCode", responseCode)
+ LOGGER.debug("Get ServiceOrder response code is: " + responseCode)
+
+ String extApiResponse = response.readEntity(String.class)
+ JSONObject responseObj = new JSONObject(extApiResponse)
+ execution.setVariable("GetServiceOrderResponse", extApiResponse)
+ LOGGER.debug("Create response body is: " + extApiResponse)
+ //Process Response //200 OK 201 CREATED 202 ACCEPTED
+ if(responseCode == 200 || responseCode == 201 || responseCode == 202 )
+ {
+ LOGGER.debug("Get Create ServiceOrder Received a Good Response")
+ String orderState = responseObj.get("state")
+ if("REJECTED".equalsIgnoreCase(orderState)) {
+ prepareFailedOperationStatusUpdate(execution)
+ return
+ }
+
+ JSONArray items = responseObj.getJSONArray("orderItem")
+ JSONObject item = items.get(0)
+ JSONObject service = item.get("service")
+ String networkServiceId = service.get("id")
+ if (networkServiceId == null || networkServiceId.equals("null")) {
+ prepareFailedOperationStatusUpdate(execution)
+ return
+ }
+
+ execution.setVariable("networkServiceId", networkServiceId)
+ String serviceOrderState = item.get("state")
+ execution.setVariable("ServiceOrderState", serviceOrderState)
+ // Get serviceOrder State and process progress
+ if("ACKNOWLEDGED".equalsIgnoreCase(serviceOrderState)) {
+ execution.setVariable(statusVariableName, "processing")
+ }
+ else if("INPROGRESS".equalsIgnoreCase(serviceOrderState)) {
+ execution.setVariable(statusVariableName, "processing")
+ }
+ else if("COMPLETED".equalsIgnoreCase(serviceOrderState)) {
+ execution.setVariable(statusVariableName, "completed")
+ }
+ else if("FAILED".equalsIgnoreCase(serviceOrderState)) {
+ msg = "ServiceOrder failed"
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ else {
+ msg = "ServiceOrder failed"
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ }
+ else{
+ msg = "Get ServiceOrder Received a Bad Response Code. Response Code is: " + responseCode
+ prepareFailedOperationStatusUpdate(execution)
+ }
+
+ }catch(Exception e){
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, e.getMessage())
+ }
+
+ }
+
+
+
+ /**
+ * Delays 5 sec
+ * @param execution
+ */
+ void timeDelay(DelegateExecution execution) {
+ LOGGER.trace("${getPrefix()} Start timeDelay")
+
+ try {
+ LOGGER.debug("${getPrefix()} timeDelay going to sleep for 5 sec")
+
+ Thread.sleep(5000)
+
+ LOGGER.debug("${getPrefix()} ::: timeDelay wakeup after 5 sec")
+ } catch(InterruptedException e) {
+ LOGGER.error("${getPrefix()} ::: timeDelay exception" + e)
+ }
+
+ LOGGER.trace("${getPrefix()} Exit timeDelay")
+ }
+
+
+ /**
* Returns AAI client
* @return AAI client
*/
@@ -1008,7 +1184,16 @@ import javax.ws.rs.core.Response
}
+ ExternalAPIUtilFactory getExternalAPIUtilFactory() {
+ return new ExternalAPIUtilFactory()
+ }
+
+
String getPrefix() {
return PREFIX
}
+
+ String getAction() {
+ return ""
+ }
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSI.groovy
index c94e2dd67d..055cbfc9cc 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSI.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSI.groovy
@@ -20,28 +20,14 @@
package org.onap.so.bpmn.infrastructure.scripts
-import com.fasterxml.jackson.databind.ObjectMapper
+
import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.onap.aai.domain.yang.CloudRegion
-import org.onap.aai.domain.yang.Customer
-import org.onap.aai.domain.yang.ModelVer
-import org.onap.aai.domain.yang.OwningEntities
-import org.onap.aai.domain.yang.ServiceSubscription
-import org.onap.aai.domain.yang.SliceProfile
-import org.onap.aai.domain.yang.GenericVnf
-import org.onap.aai.domain.yang.ServiceInstance
-import org.onap.aai.domain.yang.Tenant
-import org.onap.aai.domain.yang.VfModule
-import org.onap.aaiclient.client.aai.AAIClient
+import org.onap.aai.domain.yang.v19.ServiceInstance
import org.onap.aaiclient.client.aai.AAIResourcesClient
-import org.onap.aaiclient.client.aai.entities.AAIResultWrapper
-import org.onap.aaiclient.client.aai.entities.Relationships
import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri
import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory
-import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder
import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types
import org.onap.logging.filter.base.ONAPComponents
-import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.onap.so.bpmn.common.scripts.MsoUtils
import org.onap.so.bpmn.common.scripts.RequestDBUtil
@@ -49,22 +35,6 @@ import org.onap.so.bpmn.core.UrnPropertiesReader
import org.onap.so.bpmn.core.json.JsonUtils
import org.onap.so.client.HttpClient
import org.onap.so.client.HttpClientFactory
-import org.onap.so.db.request.beans.OperationStatus
-import org.onap.so.requestsdb.RequestsDbConstant
-import org.onap.so.serviceinstancebeans.CloudConfiguration
-import org.onap.so.serviceinstancebeans.LineOfBusiness
-import org.onap.so.serviceinstancebeans.ModelInfo
-import org.onap.so.serviceinstancebeans.ModelType
-import org.onap.so.serviceinstancebeans.OwningEntity
-import org.onap.so.serviceinstancebeans.Project
-import org.onap.so.serviceinstancebeans.RequestDetails
-import org.onap.so.serviceinstancebeans.RequestInfo
-import org.onap.so.serviceinstancebeans.RequestParameters
-import org.onap.so.serviceinstancebeans.Resources
-import org.onap.so.serviceinstancebeans.Service
-import org.onap.so.serviceinstancebeans.SubscriberInfo
-import org.onap.so.serviceinstancebeans.VfModules
-import org.onap.so.serviceinstancebeans.Vnfs
import org.slf4j.Logger
import org.slf4j.LoggerFactory
@@ -72,6 +42,7 @@ import javax.ws.rs.core.Response
class DoDeallocateCoreNSSI extends DoCommonCoreNSSI {
private final String PREFIX ="DoDeallocateCoreNSSI"
+ private final String ACTION = "Deallocate"
private ExceptionUtil exceptionUtil = new ExceptionUtil()
private RequestDBUtil requestDBUtil = new RequestDBUtil()
@@ -80,7 +51,7 @@ class DoDeallocateCoreNSSI extends DoCommonCoreNSSI {
private static final Logger LOGGER = LoggerFactory.getLogger( DoDeallocateCoreNSSI.class)
-/**
+ /**
* Queries OOF for NSSI termination
* @param execution
*/
@@ -191,36 +162,6 @@ class DoDeallocateCoreNSSI extends DoCommonCoreNSSI {
}
- String encryptBasicAuth(String basicAuth, String msoKey) {
- return utils.encrypt(basicAuth, msoKey)
- }
-
-
- String getAuthHeader(DelegateExecution execution, String basicAuthValue, String msokey) {
- String response = ""
- String errorCode = ""
- String errorMessage = ""
-
- LOGGER.debug("Obtained BasicAuth username and password for OOF: " + basicAuthValue)
- try {
- response = utils.getBasicAuth(basicAuthValue, msokey)
- } catch (Exception ex) {
- LOGGER.error("Unable to encode username and password string: ", ex)
-
- errorCode = "401"
- errorMessage = "Internal Error - Unable to encode username and password string"
-
- response = "{\n" +
- " \"errorCode\": \"${errorCode}\",\n" +
- " \"errorMessage\": \"${errorMessage}\"\n" +
- "}"
- }
-
- return response
- }
-
-
-
/**
* Builds OOF request
* @param execution
@@ -263,7 +204,9 @@ class DoDeallocateCoreNSSI extends DoCommonCoreNSSI {
ServiceInstance networkServiceInstance = (ServiceInstance)currentNSSI['networkServiceInstance']
- String url = String.format("${nbiEndpointUrl}/api/v4/serviceOrder/%s", networkServiceInstance.getServiceInstanceId()) // Service Order ID = Network Service Instance ID
+ String url = String.format("${nbiEndpointUrl}/api/v4/serviceOrder/%s", networkServiceInstance.getServiceInstanceId())
+
+ currentNSSI['deleteServiceOrderURL'] = url
String msoKey = UrnPropertiesReader.getVariable("mso.msoKey", execution)
String basicAuth = UrnPropertiesReader.getVariable("mso.infra.endpoint.auth", execution)
@@ -387,17 +330,36 @@ class DoDeallocateCoreNSSI extends DoCommonCoreNSSI {
try {
getAAIClient().delete(nssiUri)
}catch(Exception e){
- exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while NSSI Service Instance delete call: " + e.getMessage())
+ exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occurred while NSSI Service Instance delete call: " + e.getMessage())
}
LOGGER.trace("${PREFIX} Exit deleteNSSIServiceInstance")
}
+ /**
+ * Gets Delete Service Order progress
+ * @param execution
+ */
+ void getDeleteServiceOrderProgress(DelegateExecution execution) {
+ LOGGER.trace("${getPrefix()} Start getDeleteServiceOrderProgress")
+
+ def currentNSSI = execution.getVariable("currentNSSI")
+
+ String url = currentNSSI['deleteServiceOrderURL']
+
+ getProgress(execution, url, "deleteStatus")
+
+ }
+
@Override
String getPrefix() {
return PREFIX
}
+ @Override
+ String getAction() {
+ return ACTION
+ }
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSI.groovy
index ebeab3eb7d..4ccea61ed4 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSI.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSI.groovy
@@ -21,57 +21,28 @@
package org.onap.so.bpmn.infrastructure.scripts
import com.fasterxml.jackson.databind.ObjectMapper
-import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.onap.aai.domain.yang.CloudRegion
-import org.onap.aai.domain.yang.Customer
-import org.onap.aai.domain.yang.GenericVnf
-import org.onap.aai.domain.yang.ModelVer
-import org.onap.aai.domain.yang.ServiceInstance
-import org.onap.aai.domain.yang.ServiceSubscription
-import org.onap.aai.domain.yang.SliceProfile
-import org.onap.aai.domain.yang.Tenant
-import org.onap.aai.domain.yang.VfModule
-import org.onap.aaiclient.client.aai.AAIObjectType
+import org.onap.aai.domain.yang.v19.ServiceInstance
+import org.onap.aai.domain.yang.v19.SliceProfile
import org.onap.aaiclient.client.aai.AAIResourcesClient
import org.onap.aaiclient.client.aai.entities.AAIEdgeLabel
-import org.onap.aaiclient.client.aai.entities.AAIResultWrapper
-import org.onap.aaiclient.client.aai.entities.Relationships
import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri
import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory
import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder
import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types
-import org.onap.logging.filter.base.ONAPComponents
-import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.onap.so.bpmn.common.scripts.MsoUtils
import org.onap.so.bpmn.common.scripts.RequestDBUtil
-import org.onap.so.bpmn.core.UrnPropertiesReader
import org.onap.so.bpmn.core.json.JsonUtils
-import org.onap.so.client.HttpClient
-import org.onap.so.db.request.beans.OperationStatus
-import org.onap.so.requestsdb.RequestsDbConstant
-import org.onap.so.serviceinstancebeans.CloudConfiguration
-import org.onap.so.serviceinstancebeans.ModelInfo
-import org.onap.so.serviceinstancebeans.ModelType
-import org.onap.so.serviceinstancebeans.OwningEntity
-import org.onap.so.serviceinstancebeans.Project
-import org.onap.so.serviceinstancebeans.RequestDetails
-import org.onap.so.serviceinstancebeans.RequestInfo
-import org.onap.so.serviceinstancebeans.RequestParameters
-import org.onap.so.serviceinstancebeans.Resources
-import org.onap.so.serviceinstancebeans.Service
-import org.onap.so.serviceinstancebeans.SubscriberInfo
-import org.onap.so.serviceinstancebeans.VfModules
-import org.onap.so.serviceinstancebeans.Vnfs
import org.slf4j.Logger
import org.slf4j.LoggerFactory
-import javax.ws.rs.core.Response
+import static org.apache.commons.lang3.StringUtils.isBlank
class DoModifyCoreNSSI extends DoCommonCoreNSSI {
private final String PREFIX ="DoModifyCoreNSSI"
+ private final String ACTION = "Modify"
private ExceptionUtil exceptionUtil = new ExceptionUtil()
private RequestDBUtil requestDBUtil = new RequestDBUtil()
@@ -89,12 +60,11 @@ class DoModifyCoreNSSI extends DoCommonCoreNSSI {
def currentNSSI = execution.getVariable("currentNSSI")
- String sliceProfileID = execution.getVariable("sliceProfileID")
- Map<String, Object> sliceProfileMap = execution.getVariable("sliceProfileCn")
- Map<String, Object> serviceProfileMap = execution.getVariable("serviceProfile")
+ String sliceProfileID = currentNSSI['sliceProfileId']
+ Map<String,Object> sliceProfileMap = new ObjectMapper().readValue(currentNSSI['sliceProfile'], Map.class)
- String globalSubscriberId = currentNSSI['globalSubscriberId']
- String serviceType = currentNSSI['serviceType']
+ String globalSubscriberId = execution.getVariable("globalSubscriberId")
+ String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
String nssiId = currentNSSI['nssiId']
SliceProfile sliceProfile = new SliceProfile()
@@ -105,21 +75,46 @@ class DoModifyCoreNSSI extends DoCommonCoreNSSI {
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.setSNssai(currentNSSI['S-NSSAI'])
+
+ if(!isBlank(sliceProfileMap.get("expDataRateUL"))) {
+ sliceProfile.setExpDataRateUL(Integer.parseInt(sliceProfileMap.get("expDataRateUL").toString()))
+ }
+
+ if(!isBlank(sliceProfileMap.get("expDataRateDL"))) {
+ sliceProfile.setExpDataRateDL(Integer.parseInt(sliceProfileMap.get("expDataRateDL").toString()))
+ }
+
+ if(!isBlank(sliceProfileMap.get("activityFactor"))) {
+ sliceProfile.setActivityFactor(Integer.parseInt(sliceProfileMap.get("activityFactor").toString()))
+ }
+
+ if(!isBlank(sliceProfileMap.get("resourceSharingLevel"))) {
+ sliceProfile.setResourceSharingLevel(sliceProfileMap.get("resourceSharingLevel").toString())
+ }
+
+ if(!isBlank(sliceProfileMap.get("uEMobilityLevel"))) {
+ sliceProfile.setUeMobilityLevel(sliceProfileMap.get("uEMobilityLevel").toString())
+ }
+
+ if(!isBlank(sliceProfileMap.get("coverageAreaTAList"))) {
+ sliceProfile.setCoverageAreaTAList(sliceProfileMap.get("coverageAreaTAList").toString())
+ }
+
+ if(!isBlank(sliceProfileMap.get("maxNumberofUEs"))) {
+ sliceProfile.setMaxNumberOfUEs(Integer.parseInt(sliceProfileMap.get("maxNumberofUEs").toString()))
+ }
+
+ if(!isBlank(sliceProfileMap.get("latency"))) {
+ sliceProfile.setLatency(Integer.parseInt(sliceProfileMap.get("latency").toString()))
+ }
+
sliceProfile.setProfileId(sliceProfileID)
sliceProfile.setE2ELatency(0)
try {
AAIResourcesClient client = getAAIClient()
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(nssiId).sliceProfile(sliceProfileID))
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(nssiId).sliceProfile(sliceProfileID))
client.create(uri, sliceProfile)
currentNSSI['createdSliceProfile'] = sliceProfile
@@ -138,16 +133,16 @@ class DoModifyCoreNSSI extends DoCommonCoreNSSI {
void associateSliceProfileInstanceWithNSSI(DelegateExecution execution) {
LOGGER.trace("${PREFIX} Start associateSliceProfileInstanceWithNSSI")
- String sliceProfileID = execution.getVariable("sliceProfileID")
-
def currentNSSI = execution.getVariable("currentNSSI")
- String globalSubscriberId = currentNSSI['globalSubscriberId']
- String serviceType = currentNSSI['serviceType']
+ String sliceProfileID = currentNSSI['sliceProfileId']
+
+ String globalSubscriberId = execution.getVariable("globalSubscriberId")
+ String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
String nssiId = currentNSSI['nssiId']
AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId))
- AAIResourceUri sliceProfileUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(nssiId).sliceProfile(sliceProfileID))
+ AAIResourceUri sliceProfileUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(nssiId).sliceProfile(sliceProfileID))
try {
SliceProfile createdSliceProfile = (SliceProfile)currentNSSI['createdSliceProfile']
@@ -171,4 +166,9 @@ class DoModifyCoreNSSI extends DoCommonCoreNSSI {
return PREFIX
}
+
+ @Override
+ String getAction() {
+ return ACTION
+ }
}