aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSI.groovy
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSI.groovy')
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSI.groovy703
1 files changed, 458 insertions, 245 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 646861a6a0..67e4b9227d 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
@@ -21,6 +21,7 @@
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.json.JSONArray
import org.json.JSONObject
@@ -42,6 +43,7 @@ import org.onap.so.serviceinstancebeans.*
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
@@ -50,6 +52,8 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
private final String PREFIX ="DoCommonCoreNSSI"
+ private static final String SLICE_PROFILE_TEMPLATE = "{\"sliceProfileId\": \"%s\"}"
+
private static final Logger LOGGER = LoggerFactory.getLogger( DoCommonCoreNSSI.class)
private JsonUtils jsonUtil = new JsonUtils()
@@ -58,7 +62,7 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
@Override
void preProcessRequest(DelegateExecution execution) {
- LOGGER.trace("${getPrefix()} Start preProcessRequest")
+ LOGGER.debug("${getPrefix()} Start preProcessRequest")
def currentNSSI = execution.getVariable("currentNSSI")
if (!currentNSSI) {
@@ -89,19 +93,33 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
// 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
+ String sliceProfile = execution.getVariable("sliceParams")
+
+ /* if(jsonUtil.jsonValueExists(execution.getVariable("sliceParams"), "sliceProfile")) {
+ sliceProfile = jsonUtil.getJsonValue(execution.getVariable("sliceParams"), "sliceProfile")
}
+ else { // In case of Deallocate flow or Modify flow with deletion of Slice Profile Instance
+ if(jsonUtil.jsonValueExists(execution.getVariable("sliceParams"), "sliceProfileId")) {
+ sliceProfile = String.format(SLICE_PROFILE_TEMPLATE, jsonUtil.getJsonValue(execution.getVariable("sliceParams"), "sliceProfileId"))
+ }
+ else {
+ String msg = "Either Slice Profile or Slice Profile Id should be provided"
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ }
+ } */
+
+ LOGGER.debug("sliceProfile=" + sliceProfile)
+ currentNSSI['sliceProfile'] = sliceProfile
// S-NSSAI
- def snssaiList = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(sliceProfile, "snssaiList"))
+ String strList = jsonUtil.getJsonValue(sliceProfile, "snssaiList")
+
+ if(strList != null) {
+ def snssaiList = jsonUtil.StringArrayToList(strList)
- String sNssai = snssaiList.get(0)
- currentNSSI['S-NSSAI'] = sNssai
+ String sNssai = snssaiList.get(0)
+ currentNSSI['S-NSSAI'] = sNssai
+ }
// Slice Profile id
@@ -110,8 +128,7 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
execution.setVariable("currentNSSI", currentNSSI)
-
- LOGGER.trace("***** ${getPrefix()} Exit preProcessRequest")
+ LOGGER.debug("***** ${getPrefix()} Exit preProcessRequest")
}
@@ -120,7 +137,7 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
* @param execution
*/
void getNetworkServiceInstance(DelegateExecution execution) {
- LOGGER.trace("${getPrefix()} Start getNetworkServiceInstance")
+ LOGGER.debug("${getPrefix()} Start getNetworkServiceInstance")
AAIResourcesClient client = getAAIClient()
@@ -144,7 +161,7 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
}
- LOGGER.trace("${getPrefix()} Exit getNetworkServiceInstance")
+ LOGGER.debug("${getPrefix()} Exit getNetworkServiceInstance")
}
@@ -156,6 +173,8 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
* @return Network Service Instance
*/
private ServiceInstance handleNetworkInstance(DelegateExecution execution, String nssiId, AAIResourceUri nssiUri, AAIResourcesClient client ) {
+ LOGGER.debug("${getPrefix()} Start handleNetworkInstance")
+
ServiceInstance networkServiceInstance = null
def currentNSSI = execution.getVariable("currentNSSI")
@@ -169,7 +188,7 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
if (networkServiceInstanceOpt.isPresent()) {
networkServiceInstance = networkServiceInstanceOpt.get()
- if (networkServiceInstance.getServiceRole() == "Network Service") { // Network Service role
+ if (networkServiceInstance.getServiceRole() == null /* WorkAround */ || networkServiceInstance.getServiceRole() == "Network Service") { // Network Service role
currentNSSI['networkServiceInstanceUri'] = networkServiceInstanceUri
break
}
@@ -180,6 +199,12 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
}
}
+
+ if (currentNSSI['networkServiceInstanceUri'] == null) {
+ String msg = String.format("Network Service Instance URI is null")
+ LOGGER.error(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
+ }
}
else {
String msg = String.format("No relationship presented for NSSI %s in AAI", nssiId)
@@ -193,6 +218,8 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
}
+ LOGGER.debug("${getPrefix()} Exit handleNetworkInstance")
+
return networkServiceInstance
}
@@ -202,7 +229,7 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
* @param execution
*/
void getConstituteVNFFromNetworkServiceInst(DelegateExecution execution) {
- LOGGER.trace("${getPrefix()} Start getConstituteVNFFromNetworkServiceInst")
+ LOGGER.debug("${getPrefix()} Start getConstituteVNFFromNetworkServiceInst")
def currentNSSI = execution.getVariable("currentNSSI")
@@ -211,6 +238,7 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
AAIResourceUri networkServiceInstanceUri = (AAIResourceUri)currentNSSI['networkServiceInstanceUri']
AAIResultWrapper wrapper = client.get(networkServiceInstanceUri);
Optional<Relationships> relationships = wrapper.getRelationships()
+
if (relationships.isPresent()) {
for (AAIResourceUri constituteVnfUri : relationships.get().getRelatedUris(Types.GENERIC_VNF)) {
currentNSSI['constituteVnfUri'] = constituteVnfUri
@@ -234,126 +262,8 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
}
- LOGGER.trace("${getPrefix()} Exit getConstituteVNFFromNetworkServiceInst")
-
- }
-
-
- /**
- * Retrieves NSSI associated profiles from AAI
- * @param execution
- */
- void getNSSIAssociatedProfiles(DelegateExecution execution) {
- LOGGER.trace("${getPrefix()} Start getNSSIAssociatedProfiles")
-
- List<SliceProfile> associatedProfiles = new ArrayList<>()
-
- AAIResourcesClient client = getAAIClient()
-
- def currentNSSI = execution.getVariable("currentNSSI")
-
- ServiceInstance nssi = (ServiceInstance)currentNSSI['nssi']
-
- String nssiId = currentNSSI['nssiId']
-
- // NSSI
- AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId))
- AAIResultWrapper nssiWrapper = client.get(nssiUri)
- Optional<Relationships> nssiRelationships = nssiWrapper.getRelationships()
-
- if (nssiRelationships.isPresent()) {
- // Allotted Resource
- for (AAIResourceUri allottedResourceUri : nssiRelationships.get().getRelatedUris(Types.ALLOTTED_RESOURCE)) {
- AAIResultWrapper arWrapper = client.get(allottedResourceUri)
- Optional<Relationships> arRelationships = arWrapper.getRelationships()
-
- boolean isFound = false
- if(arRelationships.isPresent()) {
- // Slice Profile Instance
- for (AAIResourceUri sliceProfileInstanceUri : arRelationships.get().getRelatedUris(Types.SERVICE_INSTANCE)) {
- Optional<ServiceInstance> sliceProfileInstanceOpt = client.get(ServiceInstance.class, sliceProfileInstanceUri)
-
- if (sliceProfileInstanceOpt.isPresent()) {
- ServiceInstance sliceProfileInstance = sliceProfileInstanceOpt.get()
- if(sliceProfileInstance.getServiceRole().equals("slice-profile-instance")) { // Service instance as a Slice Profile Instance
- associatedProfiles = sliceProfileInstance.getSliceProfiles()?.getSliceProfile()
-
- currentNSSI['sliceProfileInstanceUri'] = sliceProfileInstanceUri
-
- isFound = true
- break // Should be only one
- }
- }
- else {
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, "No Slice Profile Instance found")
- }
- }
- }
- else {
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, "No relationships found for Allotted Resource")
- }
-
- if(isFound) {
- break
- }
- }
- }
- else {
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, "No relationships found for nssi id = " + nssiId)
- }
-
- if(associatedProfiles.isEmpty()) {
- String msg = String.format("No associated profiles found for NSSI %s in AAI", nssi.getServiceInstanceId())
- LOGGER.error(msg)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
- }
- else {
- currentNSSI['associatedProfiles'] = associatedProfiles
- }
-
- LOGGER.trace("${getPrefix()} Exit getNSSIAssociatedProfiles")
- }
-
-
- /**
- * Calculates a final list of S-NSSAI
- * @param execution
- */
- void calculateSNSSAI(DelegateExecution execution) {
- LOGGER.trace("${getPrefix()} Start calculateSNSSAI")
-
- def currentNSSI = execution.getVariable("currentNSSI")
-
- List<SliceProfile> associatedProfiles = (List<SliceProfile>)currentNSSI['associatedProfiles']
-
- String currentSNSSAI = currentNSSI['S-NSSAI']
-
- List<String> snssais = new ArrayList<>()
-
- String isCreateSliceProfileInstanceVar = execution.getVariable("isCreateSliceProfileInstance" ) // Not exist in case of Deallocate
-
- boolean isCreateSliceProfileInstance = Boolean.parseBoolean(isCreateSliceProfileInstanceVar)
-
- if(isCreateSliceProfileInstance) { // Slice Profile Instance has to be created
- for (SliceProfile associatedProfile : associatedProfiles) {
- snssais.add(associatedProfile.getSNssai())
- }
-
- snssais.add(currentSNSSAI)
- }
- else { // Slice profile instance has to be deleted
- for (SliceProfile associatedProfile : associatedProfiles) {
- if (!associatedProfile.getSNssai().equals(currentSNSSAI)) { // not current S-NSSAI
- snssais.add(associatedProfile.getSNssai())
- } else {
- currentNSSI['sliceProfileS-NSSAI'] = associatedProfile
- }
- }
- }
-
- currentNSSI['S-NSSAIs'] = snssais
+ LOGGER.debug("${getPrefix()} Exit getConstituteVNFFromNetworkServiceInst")
- LOGGER.trace("${getPrefix()} Exit calculateSNSSAI")
}
@@ -362,7 +272,7 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
* @param execution
*/
void invokePUTServiceInstance(DelegateExecution execution) {
- LOGGER.trace("${getPrefix()} Start invokePUTServiceInstance")
+ LOGGER.debug("${getPrefix()} Start invokePUTServiceInstance")
def currentNSSI = execution.getVariable("currentNSSI")
@@ -372,15 +282,18 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
ServiceInstance networkServiceInstance = (ServiceInstance)currentNSSI['networkServiceInstance']
- String url = String.format("${nsmfЕndPoint}/serviceInstantiation/v7/serviceInstances/%s", networkServiceInstance.getServiceInstanceId())
+ GenericVnf constituteVnf = (GenericVnf)currentNSSI['constituteVnf']
- currentNSSI['putServiceInstanceURL'] = url
+ // http://so.onap:8080/onap/so/infra/serviceInstantiation/v7/serviceInstances/de6a0aa2-19f2-41fe-b313-a5a9f159acd7/vnfs/3abbb373-8d33-4977-aa4b-2bfee496b6d5
+ String url = String.format("${nsmfЕndPoint}/serviceInstantiation/v7/serviceInstances/%s/vnfs/%s", networkServiceInstance.getServiceInstanceId(), constituteVnf.getVnfId())
String msoKey = UrnPropertiesReader.getVariable("mso.msoKey", execution)
- String basicAuth = UrnPropertiesReader.getVariable("mso.infra.endpoint.auth", execution)
- def authHeader = ""
- String basicAuthValue = encryptBasicAuth(basicAuth, msoKey) //utils.encrypt(basicAuth, msoKey)
+ String basicAuth = UrnPropertiesReader.getVariable("mso.adapters.po.auth", execution)
+
+ def authHeader = utils.getBasicAuth(basicAuth, msoKey) // ""
+ /* String basicAuthValue = encryptBasicAuth(basicAuth, msoKey) //utils.encrypt(basicAuth, msoKey)
+
String responseAuthHeader = getAuthHeader(execution, basicAuthValue, msoKey) //utils.getBasicAuth(basicAuthValue, msoKey)
String errorCode = jsonUtil.getJsonValue(responseAuthHeader, "errorCode")
@@ -389,11 +302,15 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
}
else {
exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(errorCode), jsonUtil.getJsonValue(responseAuthHeader, "errorMessage"))
- }
+ } */
def requestDetails = ""
+
String prepareRequestDetailsResponse = prepareRequestDetails(execution)
- errorCode = jsonUtil.getJsonValue(prepareRequestDetailsResponse, "errorCode")
+ LOGGER.debug("invokePUTServiceInstance: prepareRequestDetailsResponse=" + prepareRequestDetailsResponse)
+
+ String errorCode = jsonUtil.getJsonValue(prepareRequestDetailsResponse, "errorCode")
+ LOGGER.debug("invokePUTServiceInstance: errorCode=" + errorCode)
if(errorCode == null || errorCode.isEmpty()) { // No error
requestDetails = prepareRequestDetailsResponse
}
@@ -402,15 +319,13 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
}
String callPUTServiceInstanceResponse = callPUTServiceInstance(url, authHeader, requestDetails)
- String putServiceInstanceResponse = ""
- if(errorCode == null || errorCode.isEmpty()) { // No error
- putServiceInstanceResponse = callPUTServiceInstanceResponse
- }
- else {
- LOGGER.error(jsonUtil.getJsonValue(callPUTServiceInstanceResponse, "errorMessage"))
- exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(errorCode), jsonUtil.getJsonValue(callPUTServiceInstanceResponse, "errorMessage"))
- }
+ String macroOperationId = jsonUtil.getJsonValue(callPUTServiceInstanceResponse, "requestReferences.requestId")
+ String requestSelfLink = jsonUtil.getJsonValue(callPUTServiceInstanceResponse, "requestReferences.requestSelfLink")
+
+ execution.setVariable("macroOperationId", macroOperationId)
+ execution.setVariable("requestSelfLink", requestSelfLink)
+ currentNSSI['requestSelfLink'] = requestSelfLink
} catch (any) {
String msg = "Exception in ${getPrefix()}.invokePUTServiceInstance. " + any.getCause()
@@ -418,29 +333,36 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
}
- LOGGER.trace("${getPrefix()} Exit invokePUTServiceInstance")
+ LOGGER.debug("${getPrefix()} Exit invokePUTServiceInstance")
}
String callPUTServiceInstance(String url, String authHeader, String requestDetailsStr) {
+ LOGGER.debug("${getPrefix()} Start callPUTServiceInstance")
+
String errorCode = ""
String errorMessage = ""
String response
+ LOGGER.debug("callPUTServiceInstance: url = " + url)
+ LOGGER.debug("callPUTServiceInstance: authHeader = " + authHeader)
+
try {
- HttpClient httpClient = getHttpClientFactory().newJsonClient(new URL(url), ONAPComponents.EXTERNAL)
+ HttpClient httpClient = getHttpClientFactory().newJsonClient(new URL(url), ONAPComponents.SO)
httpClient.addAdditionalHeader("Authorization", authHeader)
httpClient.addAdditionalHeader("Accept", "application/json")
- Response httpResponse = httpClient.put(requestDetailsStr) // check http code ???
-
+ Response httpResponse = httpClient.put(requestDetailsStr)
- if (httpResponse.hasEntity()) {
+ int soResponseCode = httpResponse.getStatus()
+ if (soResponseCode >= 200 && soResponseCode < 204 && httpResponse.hasEntity()) {
response = httpResponse.readEntity(String.class)
+
+ LOGGER.debug("callPUTServiceInstance: response = " + response)
}
else {
errorCode = 500
- errorMessage = "No response received."
+ errorMessage = "Response code is " + soResponseCode
response = "{\n" +
" \"errorCode\": \"${errorCode}\",\n" +
@@ -461,6 +383,7 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
return response
+ LOGGER.debug("${getPrefix()} Exit callPUTServiceInstance")
}
@@ -471,6 +394,7 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
* @return ModelInfo
*/
ModelInfo prepareModelInfo(DelegateExecution execution) {
+ LOGGER.debug("${getPrefix()} Start prepareModelInfo")
def currentNSSI = execution.getVariable("currentNSSI")
ServiceInstance networkServiceInstance = (ServiceInstance)currentNSSI['networkServiceInstance']
@@ -491,6 +415,8 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
modelInfo.setModelVersion(modelVerOpt.get().getModelVersion())
}
+ LOGGER.debug("${getPrefix()} Exit prepareModelInfo")
+
return modelInfo
}
@@ -501,6 +427,8 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
* @return SubscriberInfo
*/
SubscriberInfo prepareSubscriberInfo(DelegateExecution execution) {
+ LOGGER.debug("${getPrefix()} Start prepareSubscriberInfo")
+
def currentNSSI = execution.getVariable("currentNSSI")
String globalSubscriberId = execution.getVariable("globalSubscriberId")
@@ -545,6 +473,8 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
} */
+ LOGGER.debug("${getPrefix()} Exit prepareSubscriberInfo")
+
return subscriberInfo
}
@@ -555,6 +485,8 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
* @return RequestInfo
*/
RequestInfo prepareRequestInfo(DelegateExecution execution, ServiceInstance networkServiceInstance) {
+ LOGGER.debug("${getPrefix()} Start prepareRequestInfo")
+
def currentNSSI = execution.getVariable("currentNSSI")
String productFamilyId = execution.getVariable("productFamilyId")
@@ -566,6 +498,8 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
requestInfo.setProductFamilyId(productFamilyId)
requestInfo.setRequestorId("NBI")
+ LOGGER.debug("${getPrefix()} Exit prepareRequestInfo")
+
return requestInfo
}
@@ -577,6 +511,7 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
* @return ModelInfo
*/
ModelInfo prepareServiceModelInfo(ServiceInstance networkServiceInstance, ModelInfo modelInfo) {
+ LOGGER.debug("${getPrefix()} Start prepareServiceModelInfo")
ModelInfo serviceModelInfo = new ModelInfo()
serviceModelInfo.setModelType(ModelType.service)
@@ -586,6 +521,8 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
serviceModelInfo.setModelName(modelInfo.getModelName())
serviceModelInfo.setModelVersion(modelInfo.getModelVersion())
+ LOGGER.debug("${getPrefix()} Exit prepareServiceModelInfo")
+
return serviceModelInfo
}
@@ -596,6 +533,8 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
* @return CloudConfiguration
*/
CloudConfiguration prepareCloudConfiguration(DelegateExecution execution) {
+ LOGGER.debug("${getPrefix()} Start prepareCloudConfiguration")
+
def currentNSSI = execution.getVariable("currentNSSI")
CloudConfiguration cloudConfiguration = new CloudConfiguration()
@@ -603,6 +542,7 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
AAIResourcesClient client = getAAIClient()
AAIResourceUri constituteVnfUri = currentNSSI['constituteVnfUri']
+
AAIResultWrapper wrapper = client.get(constituteVnfUri)
Optional<Relationships> cloudRegionRelationshipsOps = wrapper.getRelationships()
@@ -617,9 +557,29 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
if (cloudRegionrOpt.isPresent()) {
cloudRegion = cloudRegionrOpt.get()
cloudConfiguration.setLcpCloudRegionId(cloudRegion.getCloudRegionId())
- for (Tenant tenant : cloudRegion.getTenants().getTenant()) {
- cloudConfiguration.setTenantId(tenant.getTenantId())
- break // only one is required
+
+ if(cloudRegion.getTenants() != null && cloudRegion.getTenants().getTenant() != null) {
+ for (Tenant tenant : cloudRegion.getTenants().getTenant()) {
+ cloudConfiguration.setTenantId(tenant.getTenantId())
+ cloudConfiguration.setTenantName(tenant.getTenantName())
+ break // only one is required
+ }
+ }
+ else {
+ List<AAIResourceUri> tenantRelatedAAIUris = cloudRegionRelationshipsOps.get().getRelatedUris(Types.TENANT)
+ if (!(tenantRelatedAAIUris == null || tenantRelatedAAIUris.isEmpty())) {
+ Optional<Tenant> tenantOpt = client.get(Tenant.class, tenantRelatedAAIUris.get(0))
+ Tenant tenant = null
+ if (tenantOpt.isPresent()) {
+ tenant = tenantOpt.get()
+
+ LOGGER.debug("prepareCloudConfiguration: tenantId=" + tenant.getTenantId())
+ LOGGER.debug("prepareCloudConfiguration: tenantName=" + tenant.getTenantName())
+
+ cloudConfiguration.setTenantId(tenant.getTenantId())
+ cloudConfiguration.setTenantName(tenant.getTenantName())
+ }
+ }
}
cloudConfiguration.setCloudOwner(cloudRegion.getCloudOwner())
@@ -627,6 +587,8 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
}
}
+ LOGGER.debug("${getPrefix()} Exit prepareCloudConfiguration")
+
return cloudConfiguration
}
@@ -638,33 +600,100 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
* @return List<VfModules>
*/
List<org.onap.so.serviceinstancebeans.VfModules> prepareVfModules(DelegateExecution execution, GenericVnf constituteVnf) {
+ LOGGER.debug("${getPrefix()} Start prepareVfModules")
AAIResourcesClient client = getAAIClient()
+ def currentNSSI = execution.getVariable("currentNSSI")
+
List<org.onap.so.serviceinstancebeans.VfModules> vfModuless = new ArrayList<>()
- for (VfModule vfModule : constituteVnf.getVfModules().getVfModule()) {
- org.onap.so.serviceinstancebeans.VfModules vfmodules = new org.onap.so.serviceinstancebeans.VfModules()
- ModelInfo vfModuleModelInfo = new ModelInfo()
- vfModuleModelInfo.setModelInvariantUuid(vfModule.getModelInvariantId())
- vfModuleModelInfo.setModelCustomizationId(vfModule.getModelCustomizationId())
+ ServiceInstance networkServiceInstance = (ServiceInstance)currentNSSI['networkServiceInstance']
+
+ String networkServiceModelInvariantUuid = networkServiceInstance.getModelInvariantId()
+
+ String serviceVnfs="";
+ String msg=""
+ try{
+ CatalogDbUtils catalogDbUtils = getCatalogDbUtilsFactory().create()
+
+ String json = catalogDbUtils.getServiceResourcesByServiceModelInvariantUuidString(execution, networkServiceModelInvariantUuid)
+ LOGGER.debug("***** JSON IS: "+json)
- AAIResourceUri vfModuleUrl = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.serviceDesignAndCreation().model(vfModule.getModelInvariantId()).modelVer(vfModule.getModelVersionId()))
+ serviceVnfs = jsonUtil.getJsonValue(json, "serviceResources.serviceVnfs") ?: ""
- Optional<ModelVer> vfModuleModelVerOpt = client.get(ModelVer.class, vfModuleUrl)
+ ObjectMapper mapper = new ObjectMapper()
- if (vfModuleModelVerOpt.isPresent()) {
- vfModuleModelInfo.setModelVersionId(vfModuleModelVerOpt.get().getModelVersionId())
- vfModuleModelInfo.setModelName(vfModuleModelVerOpt.get().getModelName())
- vfModuleModelInfo.setModelVersion(vfModuleModelVerOpt.get().getModelVersion())
+ List<Object> vnfList = mapper.readValue(serviceVnfs, List.class)
+ LOGGER.debug("vnfList: "+vnfList)
+
+ Map vnfMap = vnfList.get(0)
+ ModelInfo vnfModelInfo = vnfMap.get("modelInfo")
+ vnfModelInfo.setModelCustomizationId(vnfModelInfo.getModelCustomizationUuid())
+ vnfModelInfo.setModelVersionId(vnfModelInfo.getModelId())
+ LOGGER.debug("vnfModelInfo "+vnfModelInfo)
+
+ //List of VFModules
+ List<Map<String, Object>> vfModuleList = vnfMap.get("vfModules")
+ LOGGER.debug("vfModuleList "+vfModuleList)
+
+ //List of VfModules
+ List<ModelInfo> vfModelInfoList = new ArrayList<>()
+
+ //Traverse VFModules List and add in vfModelInfoList
+ for (vfModule in vfModuleList) {
+ ModelInfo vfModelInfo = vfModule.get("modelInfo")
+ vfModelInfo.setModelCustomizationId(vfModelInfo.getModelCustomizationUuid())
+ vfModelInfo.setModelVersionId(vfModelInfo.getModelId())
+ LOGGER.debug("vfModelInfo "+vfModelInfo)
+ vfModelInfoList.add(vfModelInfo)
}
- vfmodules.setModelInfo(vfModuleModelInfo)
- vfmodules.setInstanceName(vfModule.getVfModuleName())
+ for (ModelInfo vfModuleModelInfo : vfModelInfoList) {
+ org.onap.so.serviceinstancebeans.VfModules vfModules = new org.onap.so.serviceinstancebeans.VfModules()
+ vfModules.setModelInfo(vfModuleModelInfo)
+ vfModules.setInstanceName(vfModuleModelInfo.getModelName())
+
+ List<Map<String, Object>> vfModuleInstanceParams = new ArrayList<>()
+ vfModules.setInstanceParams(vfModuleInstanceParams)
+ vfModuless.add(vfModules)
+ }
- vfModuless.add(vfmodules)
+ } catch (Exception ex){
+ msg = "Exception in prepareVfModules " + ex.getMessage()
+ LOGGER.error(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
}
+ /*
+ List<org.onap.so.serviceinstancebeans.VfModules> vfModuless = new ArrayList<>()
+ if(constituteVnf.getVfModules() != null && constituteVnf.getVfModules().getVfModule() != null) {
+ for (VfModule vfModule : constituteVnf.getVfModules().getVfModule()) {
+ org.onap.so.serviceinstancebeans.VfModules vfmodules = new org.onap.so.serviceinstancebeans.VfModules()
+
+ ModelInfo vfModuleModelInfo = new ModelInfo()
+ vfModuleModelInfo.setModelInvariantUuid(vfModule.getModelInvariantId())
+ vfModuleModelInfo.setModelCustomizationId(vfModule.getModelCustomizationId())
+
+ AAIResourceUri vfModuleUrl = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.serviceDesignAndCreation().model(vfModule.getModelInvariantId()).modelVer(vfModule.getModelVersionId()))
+
+ Optional<ModelVer> vfModuleModelVerOpt = client.get(ModelVer.class, vfModuleUrl)
+
+ if (vfModuleModelVerOpt.isPresent()) {
+ vfModuleModelInfo.setModelVersionId(vfModuleModelVerOpt.get().getModelVersionId())
+ vfModuleModelInfo.setModelName(vfModuleModelVerOpt.get().getModelName())
+ vfModuleModelInfo.setModelVersion(vfModuleModelVerOpt.get().getModelVersion())
+ }
+ vfmodules.setModelInfo(vfModuleModelInfo)
+
+ vfmodules.setInstanceName(vfModule.getVfModuleName())
+
+ vfModuless.add(vfmodules)
+ }
+ } */
+
+ LOGGER.debug("${getPrefix()} Exit prepareVfModules")
+
return vfModuless
}
@@ -676,6 +705,8 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
* @return ModelInfo
*/
ModelInfo prepareVNFModelInfo(DelegateExecution execution, GenericVnf constituteVnf) {
+ LOGGER.debug("${getPrefix()} Start prepareVNFModelInfo")
+
ModelInfo vnfModelInfo = new ModelInfo()
AAIResourcesClient client = getAAIClient()
@@ -694,11 +725,15 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
vnfModelInfo.setModelVersion(vnfModelVerOpt.get().getModelVersion())
}
+ LOGGER.debug("${getPrefix()} Exit prepareVNFModelInfo")
+
return vnfModelInfo
}
List<Map<String, Object>> prepareInstanceParams(DelegateExecution execution) {
+ LOGGER.debug("${getPrefix()} Start prepareInstanceParams")
+
def currentNSSI = execution.getVariable("currentNSSI")
List<Map<String, Object>> instanceParams = new ArrayList<>()
@@ -734,6 +769,8 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
instanceParamsMap.put("supportedNssai", supportedNssaiDetailsStr)
instanceParams.add(instanceParamsMap)
+ LOGGER.debug("${getPrefix()} Exit prepareInstanceParams")
+
return instanceParams
}
@@ -743,6 +780,8 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
* @return Resources
*/
Resources prepareResources(DelegateExecution execution) {
+ LOGGER.debug("${getPrefix()} Start prepareResources")
+
def currentNSSI = execution.getVariable("currentNSSI")
Resources resources = new Resources()
@@ -781,6 +820,8 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
vnfs.add(vnf)
resources.setVnfs(vnfs)
+ LOGGER.debug("${getPrefix()} Exit prepareResources")
+
return resources
}
@@ -790,6 +831,8 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
* @return Service
*/
org.onap.so.serviceinstancebeans.Service prepareService(DelegateExecution execution, ServiceInstance networkServiceInstance, ModelInfo modelInfo) {
+ LOGGER.debug("${getPrefix()} Start prepareService")
+
org.onap.so.serviceinstancebeans.Service service = new org.onap.so.serviceinstancebeans.Service()
// Model Info
@@ -800,6 +843,8 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
// Resources
service.setResources(prepareResources(execution))
+ LOGGER.debug("${getPrefix()} Exit prepareService")
+
return service
}
@@ -811,6 +856,8 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
* @return RequestParameters
*/
RequestParameters prepareRequestParameters(DelegateExecution execution, ServiceInstance networkServiceInstance, ModelInfo modelInfo) {
+ LOGGER.debug("${getPrefix()} Start prepareRequestParameters")
+
def currentNSSI = execution.getVariable("currentNSSI")
RequestParameters requestParameters = new RequestParameters()
@@ -834,6 +881,10 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
userParams.add(serviceMap)
requestParameters.setUserParams(userParams)
+ requestParameters.setaLaCarte(false)
+
+ LOGGER.debug("${getPrefix()} Exit prepareRequestParameters")
+
return requestParameters
}
@@ -844,6 +895,8 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
* @return OwningEntity
*/
org.onap.so.serviceinstancebeans.OwningEntity prepareOwningEntity(DelegateExecution execution) {
+ LOGGER.debug("${getPrefix()} Start prepareOwningEntity")
+
def currentNSSI = execution.getVariable("currentNSSI")
AAIResourcesClient client = getAAIClient()
@@ -866,6 +919,8 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
}
}
+ LOGGER.debug("${getPrefix()} Exit prepareOwningEntity")
+
return owningEntity
}
@@ -876,6 +931,8 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
* @return Project
*/
org.onap.so.serviceinstancebeans.Project prepareProject(DelegateExecution execution) {
+ LOGGER.debug("${getPrefix()} Start prepareProject")
+
def currentNSSI = execution.getVariable("currentNSSI")
AAIResourcesClient client = getAAIClient()
@@ -898,6 +955,8 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
}
}
+ LOGGER.debug("${getPrefix()} Exit prepareProject")
+
return project
}
@@ -908,6 +967,8 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
* @return
*/
String prepareRequestDetails(DelegateExecution execution) {
+ LOGGER.debug("${getPrefix()} Start prepareRequestDetails")
+
String errorCode = ""
String errorMessage = ""
String response
@@ -941,9 +1002,12 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
// Project
requestDetails.setProject(prepareProject(execution))
+ Map<String, Object> requestDetailsMap = new LinkedHashMap<>()
+ requestDetailsMap.put("requestDetails", requestDetails)
+
ObjectMapper mapper = new ObjectMapper()
- response = mapper.writeValueAsString(requestDetails)
+ response = mapper.writeValueAsString(requestDetailsMap)
}
catch (any) {
String msg = "Exception in ${getPrefix()}.prepareRequestDetails. " + any.getCause()
@@ -956,6 +1020,8 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
}
+ LOGGER.debug("${getPrefix()} Exit prepareRequestDetails")
+
return response
}
@@ -990,60 +1056,145 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
/**
- * Removes Slice Profile association with NSSI
+ * Retrieves NSSI associated profiles from AAI
* @param execution
*/
- void removeSPAssociationWithNSSI(DelegateExecution execution) {
- LOGGER.trace("${getPrefix()} Start removeSPAssociationWithNSSI")
+ void getNSSIAssociatedProfiles(DelegateExecution execution) {
+ LOGGER.debug("${getPrefix()} Start getNSSIAssociatedProfiles")
+
+ List<SliceProfile> associatedProfiles = new ArrayList<>()
AAIResourcesClient client = getAAIClient()
def currentNSSI = execution.getVariable("currentNSSI")
+ ServiceInstance nssi = (ServiceInstance)currentNSSI['nssi']
+
String nssiId = currentNSSI['nssiId']
+
+ String givenSliceProfileId = currentNSSI['sliceProfileId']
+
+ // NSSI
AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId))
+ AAIResultWrapper nssiWrapper = client.get(nssiUri)
+ Optional<Relationships> nssiRelationships = nssiWrapper.getRelationships()
+
+ if (nssiRelationships.isPresent()) {
+ // Allotted Resource
+ for (AAIResourceUri allottedResourceUri : nssiRelationships.get().getRelatedUris(Types.ALLOTTED_RESOURCE)) {
+ AAIResultWrapper arWrapper = client.get(allottedResourceUri)
+ Optional<Relationships> arRelationships = arWrapper.getRelationships()
+
+ if(arRelationships.isPresent()) {
+ // Slice Profile Instance
+ for (AAIResourceUri sliceProfileInstanceUri : arRelationships.get().getRelatedUris(Types.SERVICE_INSTANCE)) {
+ Optional<ServiceInstance> sliceProfileInstanceOpt = client.get(ServiceInstance.class, sliceProfileInstanceUri)
+
+ if (sliceProfileInstanceOpt.isPresent()) {
+ ServiceInstance sliceProfileInstance = sliceProfileInstanceOpt.get()
+ if(sliceProfileInstance.getServiceRole().equals("slice-profile-instance")) { // Service instance as a Slice Profile Instance
- AAIResourceUri sliceProfileInstanceUri = (AAIResourceUri)currentNSSI['sliceProfileInstanceUri']
+ String globalSubscriberId = execution.getVariable("globalSubscriberId")
+ String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
- Optional<ServiceInstance> sliceProfileInstanceOpt = client.get(ServiceInstance.class, sliceProfileInstanceUri)
- if (sliceProfileInstanceOpt.isPresent()) {
- ServiceInstance sliceProfileInstance = sliceProfileInstanceOpt.get()
+ org.onap.aaiclient.client.generated.fluentbuilders.SliceProfiles sliceProfilesType =
+ AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(sliceProfileInstance.getServiceInstanceId()).sliceProfiles()
- List<SliceProfile> associatedProfiles = sliceProfileInstance.getSliceProfiles()?.getSliceProfile()
+ def sliceProfilesUri = AAIUriFactory.createResourceUri(sliceProfilesType)
+ LOGGER.debug("client.exists(sliceProfilesUri = " + client.exists(sliceProfilesUri))
+ if (!client.exists(sliceProfilesUri)) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Slice Profiles URI doesn't exist")
+ }
- String currentSNSSAI = currentNSSI['S-NSSAI']
+ AAIResultWrapper sliceProfilesWrapper = client.get(sliceProfilesUri)
+ Optional<SliceProfiles> sliceProfilesOpt = sliceProfilesWrapper.asBean(SliceProfiles.class)
+ if(sliceProfilesOpt.isPresent()) {
+ SliceProfiles sliceProfiles = sliceProfilesOpt.get()
- if(!(associatedProfiles == null || associatedProfiles.isEmpty())) {
- // Removes slice profile which contains given S-NSSAI and updates Slice Profile Instance
- associatedProfiles.removeIf({ associatedProfile -> (associatedProfile.getSNssai().equals(currentSNSSAI)) })
+ LOGGER.debug("getNSSIAssociatedProfiles: sliceProfiles.getSliceProfile().size() = " + sliceProfiles.getSliceProfile().size())
+ LOGGER.debug("getNSSIAssociatedProfiles: givenSliceProfileId = " + givenSliceProfileId)
+ for(SliceProfile sliceProfile: sliceProfiles.getSliceProfile()) {
+ LOGGER.debug("getNSSIAssociatedProfiles: sliceProfile.getProfileId() = " + sliceProfile.getProfileId())
+ if(sliceProfile.getProfileId().equals(givenSliceProfileId)) { // Slice profile id equals to received slice profile id
+ currentNSSI['sliceProfileInstanceUri'] = sliceProfileInstanceUri
+ }
- try {
- client.update(sliceProfileInstanceUri, sliceProfileInstance)
+ }
- currentNSSI['sliceProfileInstance'] = sliceProfileInstance
- } catch (Exception e) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile association with NSSI update call: " + e.getMessage())
+ associatedProfiles.addAll(sliceProfiles.getSliceProfile()) // Adds all slice profiles
+ }
+
+ }
+ }
+ else {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, "No Slice Profile Instance found")
+ }
+ }
+ }
+ else {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, "No relationships found for Allotted Resource")
}
- }
- else {
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, "No slice profiles found")
- }
+ }
}
else {
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, "No slice profile instance found")
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, "No relationships found for nssi id = " + nssiId)
}
- // Removes SLice Profile Instance association with NSSI
- try {
- client.disconnect(nssiUri, sliceProfileInstanceUri)
+ checkAssociatedProfiles(execution, associatedProfiles, nssi)
+
+ currentNSSI['associatedProfiles'] = associatedProfiles
+
+ LOGGER.debug("${getPrefix()} Exit getNSSIAssociatedProfiles")
+ }
+
+
+ void checkAssociatedProfiles(DelegateExecution execution, List<SliceProfile> associatedProfiles, ServiceInstance nssi) {}
+
+
+ /**
+ * Removes Slice Profile association with NSSI
+ * @param execution
+ */
+ void removeSPAssociationWithNSSI(DelegateExecution execution) {
+ LOGGER.debug("${getPrefix()} Start removeSPAssociationWithNSSI")
+
+ AAIResourcesClient client = getAAIClient()
+
+ def currentNSSI = execution.getVariable("currentNSSI")
+
+ String nssiId = currentNSSI['nssiId']
+ AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId))
+
+ String isTerminateNSSIVar = execution.getVariable("isTerminateNSSI" )
+
+ boolean isTerminateNSSI = Boolean.parseBoolean(isTerminateNSSIVar)
+
+ AAIResourceUri sliceProfileInstanceUri = null
+ if(!isTerminateNSSI) { // In case of NSSI non-termination associated Slice Profile Instance should be presented
+ def spURI = currentNSSI['sliceProfileInstanceUri']
+ if(spURI != null) {
+ sliceProfileInstanceUri = (AAIResourceUri)spURI
+ }
+ else {
+ String msg = "Slice Profile URI not found"
+ LOGGER.error(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
}
- catch (Exception e) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile Instance association with NSSI dosconnect call: " + e.getMessage())
+
+ // Removes SLice Profile Instance association with NSSI
+ if(sliceProfileInstanceUri != null) { // NSSI should not be terminated
+ try {
+ client.disconnect(nssiUri, sliceProfileInstanceUri)
+ }
+ catch (Exception e) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile Instance association with NSSI dosconnect call: " + e.getMessage())
+ }
}
- LOGGER.trace("${getPrefix()} Exit removeSPAssociationWithNSSI")
+ LOGGER.debug("${getPrefix()} Exit removeSPAssociationWithNSSI")
}
@@ -1052,21 +1203,38 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
* @param execution
*/
void deleteSliceProfileInstance(DelegateExecution execution) {
- LOGGER.trace("${getPrefix()} Start deleteSliceProfileInstance")
+ LOGGER.debug("${getPrefix()} Start deleteSliceProfileInstance")
AAIResourcesClient client = getAAIClient()
def currentNSSI = execution.getVariable("currentNSSI")
- AAIResourceUri sliceProfileInstanceURI = (AAIResourceUri)currentNSSI['sliceProfileInstanceUri']
+ String isTerminateNSSIVar = execution.getVariable("isTerminateNSSI" )
- try {
- client.delete(sliceProfileInstanceURI)
- }catch(Exception e){
- exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile Instance delete call: " + e.getMessage())
+ boolean isTerminateNSSI = Boolean.parseBoolean(isTerminateNSSIVar)
+
+ AAIResourceUri sliceProfileInstanceUri = null
+ if(!isTerminateNSSI) { // In case of NSSI non-termination associated Slice Profile Instance should be presented
+ def spURI = currentNSSI['sliceProfileInstanceUri']
+ if(spURI != null) {
+ sliceProfileInstanceUri = (AAIResourceUri)spURI
+ }
+ else {
+ String msg = "Slice Profile URI not found"
+ LOGGER.error(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
}
- LOGGER.trace("${getPrefix()} Exit deleteSliceProfileInstance")
+ if(sliceProfileInstanceUri != null) { // NSSI should not be terminated
+ try {
+ client.delete(sliceProfileInstanceUri)
+ } catch (Exception e) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile Instance delete call: " + e.getMessage())
+ }
+ }
+
+ LOGGER.debug("${getPrefix()} Exit deleteSliceProfileInstance")
}
@@ -1075,7 +1243,7 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
* @param execution
*/
void prepareUpdateResourceOperationStatus(DelegateExecution execution) {
- LOGGER.trace("${getPrefix()} Start updateServiceOperationStatus")
+ LOGGER.debug("${getPrefix()} Start updateServiceOperationStatus")
def currentNSSI = execution.getVariable("currentNSSI")
@@ -1092,7 +1260,7 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
setResourceOperationStatus(execution, "finished", "100", "Core NSSI ${getAction()} successful")
- LOGGER.trace("${getPrefix()} Exit updateServiceOperationStatus")
+ LOGGER.debug("${getPrefix()} Exit updateServiceOperationStatus")
}
@@ -1102,26 +1270,31 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
* @param operationType
*/
void setResourceOperationStatus(DelegateExecution execution, String status, String progress, String statusDesc) {
- LOGGER.trace("${getPrefix()} Start setResourceOperationStatus")
+ LOGGER.debug("${getPrefix()} Start setResourceOperationStatus")
def currentNSSI = execution.getVariable("currentNSSI")
- String serviceId = currentNSSI['nssiId']
+ String serviceId = currentNSSI['nsiId']
String jobId = execution.getVariable("jobId")
String nsiId = currentNSSI['nsiId']
String operationType = execution.getVariable("operationType")
+ String resourceInstanceId = currentNSSI['nssiId']
+
+ ServiceInstance nssi = (ServiceInstance) currentNSSI['nssi']
+ String modelUuid = nssi.getModelVersionId()
ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus()
resourceOperationStatus.setServiceId(serviceId)
resourceOperationStatus.setOperationId(jobId)
- resourceOperationStatus.setResourceTemplateUUID(nsiId)
+ resourceOperationStatus.setResourceTemplateUUID(modelUuid)
resourceOperationStatus.setOperType(operationType)
+ resourceOperationStatus.setResourceInstanceID(resourceInstanceId)
resourceOperationStatus.setStatus(status)
resourceOperationStatus.setProgress(progress)
resourceOperationStatus.setStatusDescription(statusDesc)
requestDBUtil.prepareUpdateResourceOperationStatus(execution, resourceOperationStatus)
- LOGGER.trace("${getPrefix()} Exit setResourceOperationStatus")
+ LOGGER.debug("${getPrefix()} Exit setResourceOperationStatus")
}
@@ -1130,11 +1303,11 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
* @param execution
*/
void prepareFailedOperationStatusUpdate(DelegateExecution execution) {
- LOGGER.trace("${getPrefix()} Start prepareFailedOperationStatusUpdate")
+ LOGGER.debug("${getPrefix()} Start prepareFailedOperationStatusUpdate")
setResourceOperationStatus(execution, "failed", "0", "Core NSSI ${getAction()} Failed")
- LOGGER.trace("${getPrefix()} Exit prepareFailedOperationStatusUpdate")
+ LOGGER.debug("${getPrefix()} Exit prepareFailedOperationStatusUpdate")
}
@@ -1143,42 +1316,58 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
* @param execution
*/
public void getPUTServiceInstanceProgress(DelegateExecution execution) {
- LOGGER.trace("${getPrefix()} Start getPUTServiceInstanceProgress")
+ LOGGER.debug("${getPrefix()} Start getPUTServiceInstanceProgress")
def currentNSSI = execution.getVariable("currentNSSI")
- String url = currentNSSI['putServiceInstanceURL']
+ ServiceInstance networkServiceInstance = (ServiceInstance)currentNSSI['networkServiceInstance']
+
+ String url = currentNSSI['requestSelfLink']
+
+ String msoKey = UrnPropertiesReader.getVariable("mso.msoKey", execution)
- getProgress(execution, url, "putStatus")
+ String basicAuth = UrnPropertiesReader.getVariable("mso.adapters.po.auth", execution)
- LOGGER.trace("${getPrefix()} Exit getPUTServiceInstanceProgress")
+ def authHeader = ""
+ String basicAuthValue = utils.getBasicAuth(basicAuth, msoKey)
+
+ getProgress(execution, url, basicAuthValue, "putStatus")
+
+ LOGGER.debug("${getPrefix()} Exit getPUTServiceInstanceProgress")
}
- void getProgress(DelegateExecution execution, String url, String statusVariableName) {
+ void getProgress(DelegateExecution execution, String url, String authHeader, String statusVariableName) {
+ LOGGER.debug("${getPrefix()} Start getProgress")
+
+ LOGGER.debug("getProgress: url = " + url)
+ LOGGER.debug("getProgress: authHeader = " + authHeader)
+
String msg=""
try {
- ExternalAPIUtil externalAPIUtil = getExternalAPIUtilFactory().create()
- Response response = externalAPIUtil.executeExternalAPIGetCall(execution, url)
+ HttpClient httpClient = getHttpClientFactory().newJsonClient(new URL(url), ONAPComponents.SO)
+ httpClient.addAdditionalHeader("Authorization", authHeader)
+ httpClient.addAdditionalHeader("Accept", "application/json")
+
+ Response response = httpClient.get()
int responseCode = response.getStatus()
- execution.setVariable("GetServiceOrderResponseCode", responseCode)
+ // 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)
+ String soResponse = ""
+ if(response.hasEntity()) {
+ soResponse = response.readEntity(String.class)
+ // execution.setVariable("GetServiceOrderResponse", extApiResponse)
+ LOGGER.debug("Create response body is: " + soResponse)
+ }
+
//Process Response //200 OK 201 CREATED 202 ACCEPTED
- if(responseCode == 200 || responseCode == 201 || responseCode == 202 )
- {
+ if (responseCode >= 200 && responseCode < 204) {
LOGGER.debug("Get Create ServiceOrder Received a Good Response")
- String orderState = responseObj.get("state")
- if("REJECTED".equalsIgnoreCase(orderState)) {
- prepareFailedOperationStatusUpdate(execution)
- return
- }
+ String requestState = jsonUtil.getJsonValue(soResponse, "request.requestStatus.requestState")
+ /*
JSONArray items = responseObj.getJSONArray("orderItem")
JSONObject item = items.get(0)
JSONObject service = item.get("service")
@@ -1190,21 +1379,25 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
execution.setVariable("networkServiceId", networkServiceId)
String serviceOrderState = item.get("state")
- execution.setVariable("ServiceOrderState", serviceOrderState)
+ execution.setVariable("ServiceOrderState", serviceOrderState) */
+
// Get serviceOrder State and process progress
- if("ACKNOWLEDGED".equalsIgnoreCase(serviceOrderState)) {
+ if("ACKNOWLEDGED".equalsIgnoreCase(requestState)) {
execution.setVariable(statusVariableName, "processing")
}
- else if("INPROGRESS".equalsIgnoreCase(serviceOrderState)) {
+ else if("IN_PROGRESS".equalsIgnoreCase(requestState)) {
execution.setVariable(statusVariableName, "processing")
}
- else if("COMPLETED".equalsIgnoreCase(serviceOrderState)) {
+ else if("COMPLETE".equalsIgnoreCase(requestState)) {
execution.setVariable(statusVariableName, "completed")
}
- else if("FAILED".equalsIgnoreCase(serviceOrderState)) {
+ else if("FAILED".equalsIgnoreCase(requestState)) {
msg = "ServiceOrder failed"
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
}
+ else if("REJECTED".equalsIgnoreCase(requestState)) {
+ prepareFailedOperationStatusUpdate(execution)
+ }
else {
msg = "ServiceOrder failed"
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
@@ -1219,6 +1412,7 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, e.getMessage())
}
+ LOGGER.debug("${getPrefix()} Exit getProgress")
}
@@ -1228,7 +1422,7 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
* @param execution
*/
void timeDelay(DelegateExecution execution) {
- LOGGER.trace("${getPrefix()} Start timeDelay")
+ LOGGER.debug("${getPrefix()} Start timeDelay")
try {
LOGGER.debug("${getPrefix()} timeDelay going to sleep for 5 sec")
@@ -1240,10 +1434,20 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
LOGGER.error("${getPrefix()} ::: timeDelay exception" + e)
}
- LOGGER.trace("${getPrefix()} Exit timeDelay")
+ LOGGER.debug("${getPrefix()} Exit timeDelay")
}
+ void postProcessRequest(DelegateExecution execution) {
+ LOGGER.debug("${getPrefix()} Start postProcessRequest")
+
+ execution.removeVariable("currentNSSI")
+
+ LOGGER.debug("***** ${getPrefix()} Exit postProcessRequest")
+ }
+
+
+
/**
* Returns AAI client
* @return AAI client
@@ -1258,7 +1462,16 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
}
- String getPrefix() {
+ /**
+ * Returns Catalog DB Util Factory
+ * @return ew CatalogDbUtilsFactory()
+ */
+ CatalogDbUtilsFactory getCatalogDbUtilsFactory() {
+ return new CatalogDbUtilsFactory()
+ }
+
+
+ private String getPrefix() {
return PREFIX
}