aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-infrastructure-common/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/so-bpmn-infrastructure-common/src/main')
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy80
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy36
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy7
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java234
4 files changed, 243 insertions, 114 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 044f0b462b..8bb48a203b 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
@@ -22,6 +22,7 @@
package org.onap.so.bpmn.infrastructure.scripts
+import com.google.gson.JsonObject
import org.json.JSONArray
import org.json.JSONObject
import org.json.XML
@@ -93,11 +94,12 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
// set local resourceInput
execution.setVariable(Prefix + "ResourceInput", resourceInputObj)
+ String spPartnerModelName = UrnPropertiesReader.getVariable("sp-partner.modelName")
boolean is3rdONAPExist = false
- if(inputParameters.has("sppartner_url"))
+ if(inputParameters.has(spPartnerModelName + "_url"))
{
- String sppartnerUrl = inputParameters.get("sppartner_url")
+ String sppartnerUrl = inputParameters.get(spPartnerModelName + "_url")
if(!isBlank(sppartnerUrl)) {
execution.setVariable(Prefix + "SppartnerUrl", sppartnerUrl)
is3rdONAPExist = true
@@ -108,9 +110,9 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
logger.debug(msg)
}
}
- if(inputParameters.has("sppartner_providingServiceUuid"))
+ if(inputParameters.has(spPartnerModelName + "_providingServiceUuid"))
{
- String sppartnerUUID= inputParameters.get("sppartner_providingServiceUuid")
+ String sppartnerUUID= inputParameters.get(spPartnerModelName + "_providingServiceUuid")
execution.setVariable(Prefix + "SppartnerUUID", sppartnerUUID)
is3rdONAPExist = true
}
@@ -119,9 +121,9 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
String msg = "sppartner providingServiceUuid is blank."
logger.debug(msg)
}
- if(inputParameters.has("sppartner_providingServiceInvariantUuid"))
+ if(inputParameters.has(spPartnerModelName + "_providingServiceInvariantUuid"))
{
- String sppartnerInvarianteUUID = inputParameters.get("sppartner_providingServiceInvariantUuid")
+ String sppartnerInvarianteUUID = inputParameters.get(spPartnerModelName + "_providingServiceInvariantUuid")
execution.setVariable(Prefix + "SppartnerInvarianteUUID", sppartnerInvarianteUUID)
is3rdONAPExist = true
}
@@ -131,9 +133,9 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
logger.debug(msg)
}
- if(inputParameters.has("sppartner_handoverMode"))
+ if(inputParameters.has(spPartnerModelName + "_handoverMode"))
{
- String handoverMode = inputParameters.get("sppartner_handoverMode")
+ String handoverMode = inputParameters.get(spPartnerModelName + "_handoverMode")
execution.setVariable(Prefix + "HandoverMode", handoverMode)
is3rdONAPExist = true
}
@@ -167,7 +169,7 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
String serviceParameters = JsonUtils.getJsonValue(incomingRequest, "service.parameters")
String requestInputs = JsonUtils.getJsonValue(serviceParameters, "requestInputs")
JSONObject inputParameters = new JSONObject(requestInputs)
- execution.setVariable(Prefix + "ServiceParameters", inputParameters)
+ execution.setVariable(Prefix + "ServiceParameters", inputParameters.toString())
// CallSource is added only when ONAP SO calling 3rdONAP(External API) SO(Remote call)
boolean isLocalCall = true
@@ -182,7 +184,7 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
}
}
execution.setVariable(Prefix + "CallSource", callSource)
- logger.debug("callSource is: " + callSource )
+ logger.info("callSource is: " + callSource )
execution.setVariable("IsLocalCall", isLocalCall)
@@ -308,39 +310,39 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
String handoverMode = execution.getVariable(Prefix + "HandoverMode")
if("SOTN".equalsIgnoreCase(handoverMode)) {
// Put TP Link info into serviceParameters
- JSONObject inputParameters = execution.getVariable(Prefix + "ServiceParameters")
+ JSONObject inputParameters = new JSONObject(execution.getVariable(Prefix + "ServiceParameters"))
if(inputParameters.has("remote-access-provider-id")) {
Map<String, Object> crossTPs = new HashMap<String, Object>();
- crossTPs.put("local-access-provider-id", inputParameters.get("remote-access-provider-id"));
- crossTPs.put("local-access-client-id", inputParameters.get("remote-access-client-id"));
- crossTPs.put("local-access-topology-id", inputParameters.get("remote-access-topology-id"));
- crossTPs.put("local-access-node-id", inputParameters.get("remote-access-node-id"));
- crossTPs.put("local-access-ltp-id", inputParameters.get("remote-access-ltp-id"));
- crossTPs.put("remote-access-provider-id", inputParameters.get("local-access-provider-id"));
- crossTPs.put("remote-access-client-id", inputParameters.get("local-access-client-id"));
- crossTPs.put("remote-access-topology-id", inputParameters.get("local-access-topology-id"));
- crossTPs.put("remote-access-node-id", inputParameters.get("local-access-node-id"));
- crossTPs.put("remote-access-ltp-id", inputParameters.get("local-access-ltp-id"));
-
- inputParameters.put("local-access-provider-id", crossTPs.get("local-access-provider-id"));
- inputParameters.put("local-access-client-id", crossTPs.get("local-access-client-id"));
- inputParameters.put("local-access-topology-id", crossTPs.get("local-access-topology-id"));
- inputParameters.put("local-access-node-id", crossTPs.get("local-access-node-id"));
- inputParameters.put("local-access-ltp-id", crossTPs.get("local-access-ltp-id"));
- inputParameters.put("remote-access-provider-id", crossTPs.get("remote-access-provider-id"));
- inputParameters.put("remote-access-client-id", crossTPs.get("remote-access-client-id"));
- inputParameters.put("remote-access-topology-id", crossTPs.get("remote-access-topology-id"));
- inputParameters.put("remote-access-node-id", crossTPs.get("remote-access-node-id"));
- inputParameters.put("remote-access-ltp-id", crossTPs.get("remote-access-ltp-id"));
-
- execution.setVariable(Prefix + "ServiceParameters", inputParameters)
+ crossTPs.put("local-access-provider-id", inputParameters.get("remote-access-provider-id"))
+ crossTPs.put("local-access-client-id", inputParameters.get("remote-access-client-id"))
+ crossTPs.put("local-access-topology-id", inputParameters.get("remote-access-topology-id"))
+ crossTPs.put("local-access-node-id", inputParameters.get("remote-access-node-id"))
+ crossTPs.put("local-access-ltp-id", inputParameters.get("remote-access-ltp-id"))
+ crossTPs.put("remote-access-provider-id", inputParameters.get("local-access-provider-id"))
+ crossTPs.put("remote-access-client-id", inputParameters.get("local-access-client-id"))
+ crossTPs.put("remote-access-topology-id", inputParameters.get("local-access-topology-id"))
+ crossTPs.put("remote-access-node-id", inputParameters.get("local-access-node-id"))
+ crossTPs.put("remote-access-ltp-id", inputParameters.get("local-access-ltp-id"))
+
+ inputParameters.put("local-access-provider-id", crossTPs.get("local-access-provider-id"))
+ inputParameters.put("local-access-client-id", crossTPs.get("local-access-client-id"))
+ inputParameters.put("local-access-topology-id", crossTPs.get("local-access-topology-id"))
+ inputParameters.put("local-access-node-id", crossTPs.get("local-access-node-id"))
+ inputParameters.put("local-access-ltp-id", crossTPs.get("local-access-ltp-id"))
+ inputParameters.put("remote-access-provider-id", crossTPs.get("remote-access-provider-id"))
+ inputParameters.put("remote-access-client-id", crossTPs.get("remote-access-client-id"))
+ inputParameters.put("remote-access-topology-id", crossTPs.get("remote-access-topology-id"))
+ inputParameters.put("remote-access-node-id", crossTPs.get("remote-access-node-id"))
+ inputParameters.put("remote-access-ltp-id", crossTPs.get("remote-access-ltp-id"))
+
+ execution.setVariable(Prefix + "ServiceParameters", inputParameters.toString())
}
else {
logger.error("No allocated CrossONAPResource found in ServiceParameters")
}
}
- logger.info("Exit " + allocateCrossONAPResource)
+ logger.info("Exit allocateCrossONAPResource")
}
public void prepare3rdONAPRequest(DelegateExecution execution) {
@@ -409,7 +411,7 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
_requestInputs_ += ",\n" + externalAPIUtil.setTemplate(ExternalAPIUtil.RequestInputsTemplate, requestInputsMap)
// Transfer all uuiRequest incomeParameters to ExternalAPI format
- JSONObject inputParameters = execution.getVariable(Prefix + "ServiceParameters")
+ JSONObject inputParameters = new JSONObject(execution.getVariable(Prefix + "ServiceParameters"))
for(String key : inputParameters.keySet()) {
String inputName = key
String inputValue = inputParameters.opt(key)
@@ -506,7 +508,7 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
}
JSONArray items = responseObj.getJSONArray("orderItem")
- JSONObject item = items[0]
+ JSONObject item = items.get(0)
JSONObject service = item.get("service")
String sppartnerServiceId = service.get("id")
if(sppartnerServiceId == null || sppartnerServiceId.equals("null")) {
@@ -572,7 +574,9 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
*/
public void timeDelay(DelegateExecution execution) {
try {
+ logger.debug("going to sleep for 5 sec")
Thread.sleep(5000)
+ logger.debug("wakeup after 5 sec")
} catch(InterruptedException e) {
logger.error("Time Delay exception" + e)
}
@@ -601,6 +605,8 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
AAIResourcesClient client = new AAIResourcesClient()
AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SP_PARTNER, sppartnerId)
+ logger.info("sending request to create sp-partner: " + uri.toString())
+ logger.info("requestbody: " + partner)
client.create(uri, partner)
AAIResourceUri siUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, serviceType, serviceInstanceId)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy
index b0419be7cb..bcd33530b1 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy
@@ -276,9 +276,10 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor {
case ~/[\w\s\W]*sdwanvpnattachment[\w\s\W]*/ :
case ~/[\w\s\W]*sotnvpnattachment[\w\s\W]*/ :
+ case ~/[\w\s\W]*SOTN-Attachment[\w\s\W]*/ :
// fill attachment TP in networkInputParamJson
- def vpnName = StringUtils.containsIgnoreCase(modelName, "sotnvpnattachment") ? "sotnvpnattachmentvf_sotncondition_sotnVpnName" : "sdwanvpnattachmentvf_sdwancondition_sdwanVpnName"
- fillAttachmentTPInfo(resourceInputObj, modelName, execution, vpnName)
+ def vpnName = StringUtils.containsIgnoreCase(modelName, "sotnvpnattachment") ? "sotnvpnattachmentvf_sotncondition_sotnVpnName" : (StringUtils.containsIgnoreCase(modelName, "SOTN-Attachment") ? "elinesotnattachmentvf0_elinesotnattachmentvfc0_sotnVpnName" : "sdwanvpnattachmentvf_sdwancondition_sdwanVpnName")
+ fillAttachmentTPInfo(resourceInputObj, execution, vpnName)
break
default:
@@ -286,27 +287,36 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor {
// in case name is different as expected
if ("ALLOTTED_RESOURCE".equals(resourceInputObj.getResourceModelInfo().getModelType())) {
def vpnName = modelName + "_sotnVpnName"
- fillAttachmentTPInfo(resourceInputObj, modelName, execution, vpnName)
+ fillAttachmentTPInfo(resourceInputObj, execution, vpnName)
}
break
}
return resourceInputObj
}
- private void fillAttachmentTPInfo(ResourceInput resourceInputObj, String modelName, DelegateExecution execution, String vpnName) {
- String customer = resourceInputObj.getGlobalSubscriberId()
- String serviceType = resourceInputObj.getServiceType()
+ private void fillAttachmentTPInfo(ResourceInput resourceInputObj, DelegateExecution execution, String vpnName) {
String parentServiceName = jsonUtil.getJsonValueForKey(resourceInputObj.getRequestsInputs(), vpnName)
AAIResourcesClient client = new AAIResourcesClient()
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.SERVICE_INSTANCE, customer, serviceType).queryParam("service-instance-name", parentServiceName)
- ServiceInstances sis = client.get(uri).asBean(ServiceInstances.class).get()
- logger.debug("Fetched AAI ServiceInstances for the vpnName:" + vpnName + " is " + sis.getServiceInstance().toString())
- ServiceInstance si = sis.getServiceInstance().get(0)
-
- def parentServiceInstanceId = si.getServiceInstanceId()
- execution.setVariable("parentServiceInstanceId", parentServiceInstanceId)
+ logger.info("sending request to resolve vpn-name:" + vpnName)
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(new AAIObjectPlurals("/nodes", "/service-instances", "queryByName")).queryParam("service-instance-name", parentServiceName)
+ Optional<ServiceInstances> serviceInstancesOpt = client.get(ServiceInstances.class, uri)
+
+ if(serviceInstancesOpt.isPresent()) {
+ List<ServiceInstance> serviceInstanceList = serviceInstancesOpt.get().getServiceInstance()
+ logger.info("response from aai:" + serviceInstanceList.toString())
+ if (serviceInstanceList.size() > 0) {
+ ServiceInstance si = serviceInstanceList.get(0)
+ String parentServiceInstanceId = si.getServiceInstanceId()
+ execution.setVariable("parentServiceInstanceId", parentServiceInstanceId)
+ logger.info("setting parentService id:" + parentServiceInstanceId)
+ } else {
+ logger.error("No service instance found for given name.")
+ }
+ } else {
+ logger.error("No nodes found with this name" + vpnName)
+ }
}
/**
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 d9f9299616..0191439dac 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
@@ -584,6 +584,13 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor {
List<Resource> addResourceList = serviceDecomposition.getServiceResources()
execution.setVariable("addResourceList", addResourceList)
+ boolean isCreateResourceListValid = true
+ if (addResourceList == null || addResourceList.isEmpty()) {
+ isCreateResourceListValid = false
+ }
+
+ execution.setVariable("isCreateResourceListValid", isCreateResourceListValid)
+
logger.trace("COMPLETED preProcessForAddResource Process ")
}
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 9319353e5a..95be6ba7fc 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
@@ -29,6 +29,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.SocketTimeoutException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -56,6 +57,8 @@ import org.camunda.bpm.engine.runtime.Execution;
import org.onap.aai.domain.yang.LogicalLink;
import org.onap.aai.domain.yang.LogicalLinks;
import org.onap.aai.domain.yang.PInterface;
+import org.onap.aai.domain.yang.Pnf;
+import org.onap.aai.domain.yang.Relationship;
import org.onap.so.bpmn.core.UrnPropertiesReader;
import org.onap.so.bpmn.core.domain.Resource;
import org.onap.so.bpmn.core.domain.ServiceDecomposition;
@@ -166,8 +169,7 @@ public class ServicePluginFactory {
}
private boolean isNeedProcessSite(String uuiRequest) {
- return uuiRequest.toLowerCase().contains("site_address")
- && uuiRequest.toLowerCase().contains("sotncondition_clientsignal");
+ return uuiRequest.toLowerCase().contains("address") && uuiRequest.toLowerCase().contains("clientsignal");
}
@SuppressWarnings("unchecked")
@@ -178,6 +180,7 @@ public class ServicePluginFactory {
return true;
}
String host = (String) tpInfoMap.get("host");
+ logger.info("host string from tpinfo:" + host);
// host is empty means TP is in local, not empty means TP is in remote ONAP
if (!host.isEmpty()) {
return false;
@@ -191,17 +194,33 @@ public class ServicePluginFactory {
accessTPInfo.put("access-ltp-id", tpInfoMap.get("access-ltp-id"));
// change resources
+ boolean flgResourceFound = false;
String resourceName = (String) tpInfoMap.get("resourceName");
for (Object curResource : resources) {
Map<String, Object> resource = (Map<String, Object>) curResource;
String curResourceName = (String) resource.get("resourceName");
curResourceName = curResourceName.replaceAll(" ", "");
if (resourceName.equalsIgnoreCase(curResourceName)) {
+ flgResourceFound = true;
+ logger.info("found match to add site tp info using uui template resource name");
putResourceRequestInputs(resource, accessTPInfo);
break;
}
}
+ if (!flgResourceFound) {
+ String attacmentResName = UrnPropertiesReader.getVariable("sp-partner.attachment-resource-name");
+ for (Object curResource : resources) {
+ Map<String, Object> resource = (Map<String, Object>) curResource;
+ String curResourceName = (String) resource.get("resourceName");
+
+ if (attacmentResName.equals(curResourceName)) {
+ logger.info("found match to add site tp info using customized resource name");
+ putResourceRequestInputs(resource, accessTPInfo);
+ }
+ }
+ }
+
return true;
}
@@ -215,10 +234,10 @@ public class ServicePluginFactory {
// logic for R2 uuiRequest params in service level
for (Entry<String, Object> entry : serviceRequestInputs.entrySet()) {
String key = entry.getKey();
- if (key.toLowerCase().contains("site_address")) {
+ if (key.toLowerCase().contains("address")) {
location = entry.getValue();
}
- if (key.toLowerCase().contains("sotncondition_clientsignal")) {
+ if (key.toLowerCase().contains("clientsignal")) {
clientSignal = entry.getValue();
vpnAttachmentResourceName = key.substring(0, key.indexOf("_"));
}
@@ -242,10 +261,12 @@ public class ServicePluginFactory {
tpInfoMap = tpJson;
// add resourceName
tpInfoMap.put("resourceName", vpnAttachmentResourceName);
+ logger.info("*** we will try to find resourcename(" + vpnAttachmentResourceName
+ + ") to add resource input ***");
break;
}
}
- logger.debug("Get Terminal TP from InventoryOSS");
+ logger.info("Get Terminal TP from InventoryOSS: " + tpInfoMap);
return tpInfoMap;
}
@@ -330,10 +351,40 @@ public class ServicePluginFactory {
return false;
}
+ public static String CUSTOM_RESOURCE_TP = "custom-resource-tp";
+ public static String VS_MONITORED = "VS_assured";
+ public static String VS_UNMONITORED = "VS_besteffort";
+ public static String TS_MONITORED = "TS1";
+ public static String TS_UNMONITORED = "TS2";
+ public static String CUSTOM_TP_LIST[] = new String[] {VS_MONITORED, VS_UNMONITORED, TS_MONITORED, TS_UNMONITORED};
+
+ private void customizeTP(Map<String, Object> crossTps, String svcName, DelegateExecution execution) {
+ Optional<String> customType = Arrays.stream(CUSTOM_TP_LIST).filter(svcName::contains).findFirst();
+ if (customType.isPresent()) {
+ logger.info("customizing TP");
+ String localTPs = UrnPropertiesReader.getVariable(CUSTOM_RESOURCE_TP + "." + customType.get() + ".local");
+ String remoteTPs = UrnPropertiesReader.getVariable(CUSTOM_RESOURCE_TP + "." + customType.get() + ".remote");
+
+ String localTP = (String) crossTps.get("local-access-ltp-id");
+ String remoteTP = (String) crossTps.get("remote-access-ltp-id");
+
+ if (localTPs.contains(localTP) && remoteTPs.contains(remoteTP)) {
+ logger.info("using same tp returned from AAI");
+ return;
+ }
+
+ crossTps.put("local-access-ltp-id", localTPs.split(",")[0]);
+ crossTps.put("remote-access-ltp-id", remoteTPs.split(",")[0]);
+ }
+ logger.info("cross TP info:" + crossTps);
+ }
+
@SuppressWarnings("unchecked")
private void allocateCrossTPResources(DelegateExecution execution, Map<String, Object> serviceRequestInputs) {
- Map<String, Object> crossTPs = this.getTPsfromAAI();
+ String serviceName = (String) execution.getVariable("serviceInstanceName");
+ Map<String, Object> crossTPs = this.getTPsfromAAI(serviceName);
+ // customizeTP(crossTPs, serviceName, execution);
if (crossTPs == null || crossTPs.isEmpty()) {
serviceRequestInputs.put("local-access-provider-id", "");
@@ -353,17 +404,45 @@ public class ServicePluginFactory {
serviceRequestInputs.put("local-access-node-id", crossTPs.get("local-access-node-id"));
serviceRequestInputs.put("local-access-ltp-id", crossTPs.get("local-access-ltp-id"));
serviceRequestInputs.put("remote-access-provider-id", crossTPs.get("remote-access-provider-id"));
- serviceRequestInputs.put("remote-access-client-id", crossTPs.get("remote-client-id"));
- serviceRequestInputs.put("remote-access-topology-id", crossTPs.get("remote-topology-id"));
- serviceRequestInputs.put("remote-access-node-id", crossTPs.get("remote-node-id"));
- serviceRequestInputs.put("remote-access-ltp-id", crossTPs.get("remote-ltp-id"));
+ serviceRequestInputs.put("remote-access-client-id", crossTPs.get("remote-access-client-id"));
+ serviceRequestInputs.put("remote-access-topology-id", crossTPs.get("remote-access-topology-id"));
+ serviceRequestInputs.put("remote-access-node-id", crossTPs.get("remote-access-node-id"));
+ serviceRequestInputs.put("remote-access-ltp-id", crossTPs.get("remote-access-ltp-id"));
}
return;
}
+ private LogicalLink selectLogicalLink(List<LogicalLink> logicalLinks, String svcName) {
+ Optional<String> customType = Arrays.stream(CUSTOM_TP_LIST).filter(svcName::contains).findFirst();
+ if (customType.isPresent()) {
+
+ String[] allowedList =
+ UrnPropertiesReader.getVariable(CUSTOM_RESOURCE_TP + "." + customType.get() + ".local").split(",");
+
+ for (String localTp : allowedList) {
+ for (LogicalLink link : logicalLinks) {
+ for (Relationship relationship : link.getRelationshipList().getRelationship()) {
+ if (relationship.getRelatedTo().equals("p-interface")
+ && relationship.getRelatedLink().contains("-ltpId-" + localTp)
+ && link.getOperationalStatus().equalsIgnoreCase("up")) {
+ logger.info("linkname:" + link.getLinkName() + " is matching with allowed list");
+ return link;
+ }
+ }
+ }
+ }
+
+ logger.error("There is no matching logical link for allowed list :" + allowedList.toString());
+ return null;
+ } else {
+ logger.info("link customization is not required");
+ return logicalLinks.get(0);
+ }
+ }
+
// This method returns Local and remote TPs information from AAI
- public Map getTPsfromAAI() {
+ public Map getTPsfromAAI(String serviceName) {
Map<String, Object> tpInfo = new HashMap<>();
AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.LOGICAL_LINK);
@@ -372,11 +451,11 @@ public class ServicePluginFactory {
if (result.isPresent()) {
LogicalLinks links = result.get();
- boolean isRemoteLink = false;
+ LogicalLink link = selectLogicalLink(links.getLogicalLink(), serviceName);
- links.getLogicalLink();
-
- for (LogicalLink link : links.getLogicalLink()) {
+ if (link != null) {
+ boolean isRemoteLink = false;
+ logger.info("processing link :" + link.getLinkName());
AAIResultWrapper wrapper = new AAIResultWrapper(link);
Optional<Relationships> optRelationships = wrapper.getRelationships();
List<AAIResourceUri> pInterfaces = new ArrayList<>();
@@ -386,57 +465,85 @@ public class ServicePluginFactory {
isRemoteLink = true;
}
pInterfaces.addAll(relationships.getRelatedAAIUris(AAIObjectType.P_INTERFACE));
- }
-
- if (isRemoteLink) {
- // find remote p interface
- AAIResourceUri localTP = null;
- AAIResourceUri remoteTP = null;
-
- AAIResourceUri pInterface0 = pInterfaces.get(0);
-
- if (isRemotePInterface(client, pInterface0)) {
- remoteTP = pInterfaces.get(0);
- localTP = pInterfaces.get(1);
- } else {
- localTP = pInterfaces.get(0);
- remoteTP = pInterfaces.get(1);
- }
-
- if (localTP != null && remoteTP != null) {
- // give local tp
- String tpUrl = localTP.build().toString();
- PInterface intfLocal = client.get(PInterface.class, localTP).get();
- tpInfo.put("local-access-node-id", tpUrl.split("/")[6]);
-
- String[] networkRef = intfLocal.getNetworkRef().split("/");
- if (networkRef.length == 6) {
- tpInfo.put("local-access-provider-id", networkRef[1]);
- tpInfo.put("local-access-client-id", networkRef[3]);
- tpInfo.put("local-access-topology-id", networkRef[5]);
- }
- String ltpIdStr = tpUrl.substring(tpUrl.lastIndexOf("/") + 1);
- if (ltpIdStr.contains("-")) {
- tpInfo.put("local-access-ltp-id", ltpIdStr.substring(ltpIdStr.lastIndexOf("-") + 1));
+ if (isRemoteLink) {
+ // find remote p interface
+ AAIResourceUri localTP = null;
+ AAIResourceUri remoteTP = null;
+
+ AAIResourceUri pInterface0 = pInterfaces.get(0);
+
+ if (isRemotePInterface(client, pInterface0)) {
+ remoteTP = pInterfaces.get(0);
+ localTP = pInterfaces.get(1);
+ } else {
+ localTP = pInterfaces.get(0);
+ remoteTP = pInterfaces.get(1);
}
- // give remote tp
- tpUrl = remoteTP.build().toString();
- PInterface intfRemote = client.get(PInterface.class, remoteTP).get();
- tpInfo.put("remote-access-node-id", tpUrl.split("/")[6]);
-
- String[] networkRefRemote = intfRemote.getNetworkRef().split("/");
-
- if (networkRefRemote.length == 6) {
- tpInfo.put("remote-access-provider-id", networkRefRemote[1]);
- tpInfo.put("remote-access-client-id", networkRefRemote[3]);
- tpInfo.put("remote-access-topology-id", networkRefRemote[5]);
+ if (localTP != null && remoteTP != null) {
+ // give local tp
+ String tpUrl = localTP.build().toString();
+ String localNodeId = tpUrl.split("/")[4];
+ tpInfo.put("local-access-node-id", localNodeId);
+
+ logger.info("Get info for local TP :" + localNodeId);
+ Optional<Pnf> optLocalPnf = client.get(Pnf.class,
+ AAIUriFactory.createResourceUri(AAIObjectType.PNF, localNodeId));
+
+ if (optLocalPnf.isPresent()) {
+ Pnf localPnf = optLocalPnf.get();
+
+ for (Relationship rel : localPnf.getRelationshipList().getRelationship()) {
+ if (rel.getRelatedTo().equalsIgnoreCase("network-resource")) {
+ String[] networkRef = rel.getRelatedLink()
+ .substring(rel.getRelatedLink().lastIndexOf("/") + 1).split("-");
+ if (networkRef.length == 6) {
+ tpInfo.put("local-access-provider-id", networkRef[1]);
+ tpInfo.put("local-access-client-id", networkRef[3]);
+ tpInfo.put("local-access-topology-id", networkRef[5]);
+ }
+ }
+ }
+ }
+ String ltpIdStr = tpUrl.substring(tpUrl.lastIndexOf("/") + 1);
+ if (ltpIdStr.contains("-")) {
+ tpInfo.put("local-access-ltp-id", ltpIdStr.substring(ltpIdStr.lastIndexOf("-") + 1));
+ }
+
+ // give remote tp
+ tpUrl = remoteTP.build().toString();
+ PInterface intfRemote = client.get(PInterface.class, remoteTP).get();
+
+ String remoteNodeId = tpUrl.split("/")[4];
+ tpInfo.put("remote-access-node-id", remoteNodeId);
+
+ logger.info("Get info for remote TP:" + remoteNodeId);
+
+ String[] networkRefRemote = intfRemote.getNetworkRef().split("-");
+ Optional<Pnf> optRemotePnf = client.get(Pnf.class,
+ AAIUriFactory.createResourceUri(AAIObjectType.PNF, remoteNodeId));
+
+ if (optRemotePnf.isPresent()) {
+ Pnf remotePnf = optRemotePnf.get();
+
+ for (Relationship rel : remotePnf.getRelationshipList().getRelationship()) {
+ if (rel.getRelatedTo().equalsIgnoreCase("network-resource")) {
+ String[] networkRef = rel.getRelatedLink()
+ .substring(rel.getRelatedLink().lastIndexOf("/") + 1).split("-");
+ if (networkRef.length == 6) {
+ tpInfo.put("remote-access-provider-id", networkRefRemote[1]);
+ tpInfo.put("remote-access-client-id", networkRefRemote[3]);
+ tpInfo.put("remote-access-topology-id", networkRefRemote[5]);
+ }
+ }
+ }
+ }
+
+ String ltpIdStrR = tpUrl.substring(tpUrl.lastIndexOf("/") + 1);
+ if (ltpIdStrR.contains("-")) {
+ tpInfo.put("remote-access-ltp-id", ltpIdStrR.substring(ltpIdStr.lastIndexOf("-") + 1));
+ }
}
- String ltpIdStrR = tpUrl.substring(tpUrl.lastIndexOf("/") + 1);
- if (ltpIdStrR.contains("-")) {
- tpInfo.put("remote-access-ltp-id", ltpIdStrR.substring(ltpIdStr.lastIndexOf("-") + 1));
- }
- return tpInfo;
}
}
}
@@ -811,5 +918,4 @@ public class ServicePluginFactory {
}
}
}
-
}