diff options
Diffstat (limited to 'bpmn/so-bpmn-infrastructure-common/src')
4 files changed, 96 insertions, 5 deletions
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy index 80e6e758c0..1eb626101e 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy @@ -164,7 +164,8 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso //uuiRequest String incomingRequest = resourceInputObj.getRequestsInputs() String serviceParameters = jsonUtil.getJsonValue(incomingRequest, "service.parameters") - JSONObject inputParameters = new JSONObject(customizeResourceParam(serviceParameters)) + String requestInputs = JsonUtils.getJsonValue(serviceParameters, "requestInputs") + JSONObject inputParameters = new JSONObject(customizeResourceParam(requestInputs)) execution.setVariable(Prefix + "ServiceParameters", inputParameters) // CallSource is added only when ONAP SO calling 3rdONAP(External API) SO(Remote call) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy index b5d196181b..4939173d65 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy @@ -466,6 +466,19 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { msoLogger.trace("COMPLETED preInitResourcesOperStatus Process ") } + // if site location is in local Operator, create all resources in local ONAP; + // if site location is in 3rd Operator, only process sp-partner to create all resources in 3rd ONAP + public void doProcessSiteLocation(DelegateExecution execution){ + + msoLogger.trace("======== Start doProcessSiteLocation Process ======== ") + ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + String uuiRequest = execution.getVariable("uuiRequest") + ServiceDecomposition serviceDecompositionforLocal = ServicePluginFactory.getInstance().doProcessSiteLocation(serviceDecomposition, uuiRequest); + execution.setVariable("serviceDecomposition", serviceDecompositionforLocal) + + msoLogger.trace("======== COMPLETED doProcessSiteLocation Process ======== ") + } + // prepare input param for using DoCreateResources.bpmn public void preProcessForAddResource(DelegateExecution execution) { msoLogger.trace("STARTED preProcessForAddResource Process ") diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy index 6d23ae7c65..827d44726b 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy @@ -336,6 +336,11 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor { String sppartnerName = "sp-partner" + eValue jObj.put("resourceType", sppartnerName) } + else if(eKey.equals(rt + ".id")){ + jObj.put("resourceInstanceId", eValue) + String resourceName = rt + eValue; + jObj.put("resourceType", resourceName) + } } def rl_props = utils.getIdenticalChildren(node, "related-to-property") @@ -412,6 +417,8 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor { if (serviceRelationShip != null) { relationShipList = jsonSlurper.parseText(serviceRelationShip) } + + List<Resource> deleteRealResourceList = new ArrayList<Resource>(); //Set the real resource instance id to the decomosed resource list for (Resource resource: deleteResourceList) { @@ -421,13 +428,17 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor { if (relationShipList != null) { relationShipList.each { if (StringUtils.containsIgnoreCase(it.resourceType, resource.getModelInfo().getModelName())) { - resource.setResourceId(it.resourceInstanceId); + resource.setResourceId(it.resourceInstanceId) + deleteRealResourceList.add(resource) } } } } - execution.setVariable("deleteResourceList", deleteResourceList) - utils.log("DEBUG", "delete resource list : " + deleteResourceList, isDebugEnabled) + + // only delete real existing resources + execution.setVariable("deleteResourceList", deleteRealResourceList) + + utils.log("DEBUG", "delete resource list : " + deleteRealResourceList, isDebugEnabled) } catch (Exception ex) { String exceptionMessage = "Bpmn error encountered in create generic e2e service flow. processDecomposition() - " + ex.getMessage() utils.log("DEBUG", exceptionMessage, isDebugEnabled) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java index bd781756a5..7226feb552 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java @@ -20,6 +20,7 @@ package org.onap.so.bpmn.infrastructure.workflow.service; +import org.json.JSONObject; import java.io.IOException; import java.net.SocketTimeoutException; import java.util.ArrayList; @@ -27,7 +28,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; - +import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpResponse; import org.apache.http.ParseException; import org.apache.http.client.HttpClient; @@ -45,6 +46,7 @@ import org.apache.http.util.EntityUtils; import org.camunda.bpm.engine.runtime.Execution; import org.onap.so.bpmn.core.UrnPropertiesReader; import org.onap.so.bpmn.core.domain.ServiceDecomposition; +import org.onap.so.bpmn.core.domain.Resource; import org.onap.so.bpmn.core.json.JsonUtils; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; @@ -61,6 +63,8 @@ public class ServicePluginFactory { public static final String OOF_Default_EndPoint = "http://192.168.1.223:8443/oof/sotncalc"; public static final String Third_SP_Default_EndPoint = "http://192.168.1.223:8443/sp/resourcemgr/querytps"; + + public static final String Inventory_OSS_Default_EndPoint = "http://192.168.1.199:8443/oss/inventory"; private static final int DEFAULT_TIME_OUT = 60000; @@ -77,7 +81,15 @@ public class ServicePluginFactory { } return instance; } + + private ServicePluginFactory() { + + } + + private String getInventoryOSSEndPoint(){ + return UrnPropertiesReader.getVariable("mso.service-plugin.inventory-oss-endpoint", Inventory_OSS_Default_EndPoint); + } private String getThirdSPEndPoint(){ return UrnPropertiesReader.getVariable("mso.service-plugin.third-sp-endpoint", Third_SP_Default_EndPoint); } @@ -86,6 +98,60 @@ public class ServicePluginFactory { return UrnPropertiesReader.getVariable("mso.service-plugin.oof-calc-endpoint", OOF_Default_EndPoint); } + public ServiceDecomposition doProcessSiteLocation(ServiceDecomposition serviceDecomposition, String uuiRequest) { + ServiceDecomposition serviceDecompositionforLocal = serviceDecomposition; + + if (isSiteLocationLocal(serviceDecomposition, uuiRequest)) { + return serviceDecomposition; + } + + List<Resource> addResourceList = serviceDecomposition.getServiceResources(); + for (Resource resource : addResourceList) { + String resourcemodelName = resource.getModelInfo().getModelName(); + if (!StringUtils.containsIgnoreCase(resourcemodelName, "sp-partner")) { + serviceDecompositionforLocal.deleteResource(resource); + break; + } + if (!StringUtils.containsIgnoreCase(resourcemodelName, "sppartner")) { + serviceDecompositionforLocal.deleteResource(resource); + break; + } + } + + return serviceDecompositionforLocal; + } + + public boolean isSiteLocationLocal(ServiceDecomposition serviceDecomposition, String uuiRequest) { + boolean isSiteLocationLocal = true; + + String serviceModelName = serviceDecomposition.getModelInfo().getModelName(); + String serviceParameters = JsonUtils.getJsonValue(uuiRequest, "service.parameters"); + String requestInputs = JsonUtils.getJsonValue(serviceParameters, "requestInputs"); + JSONObject inputParameters = new JSONObject(requestInputs); + + if(StringUtils.containsIgnoreCase(serviceModelName, "site") && inputParameters.has("location")) + { + Object location = inputParameters.get("location"); + JSONObject locationObj = new JSONObject(location); + String locationONAP = queryLocationFromInventoryOSS(locationObj); + if(StringUtils.containsIgnoreCase(locationONAP, "remote")) { + isSiteLocationLocal = false; + } + } + + return isSiteLocationLocal; + } + + private String queryLocationFromInventoryOSS(JSONObject locationObj) { + String reqContent = getJsonString(locationObj); + String url = getInventoryOSSEndPoint(); + String responseContent = sendRequest(url, "POST", reqContent); + String locationONAP = ""; + if (null != responseContent) { + locationONAP = getJsonObject(responseContent, String.class); + } + return locationONAP; + } public String preProcessService(ServiceDecomposition serviceDecomposition, String uuiRequest) { |