summaryrefslogtreecommitdiffstats
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/DoActivateTnNssi.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy90
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyTnNssi.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy19
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy41
6 files changed, 110 insertions, 46 deletions
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssi.groovy
index 0900863a62..e5c9514fa5 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssi.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssi.groovy
@@ -158,7 +158,7 @@ public class DoActivateTnNssi extends AbstractServiceTaskProcessor {
roStatus.setProgress(progress)
roStatus.setStatus(status)
roStatus.setStatusDescription(statusDescription)
- requestDBUtil.prepareUpdateResourceOperationStatus(execution, status)
+ requestDBUtil.prepareUpdateResourceOperationStatus(execution, roStatus)
}
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy
index 0f1bf0d8b4..7beafefc28 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy
@@ -23,12 +23,10 @@ package org.onap.so.bpmn.infrastructure.scripts
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
import org.onap.aai.domain.yang.SliceProfile
-import org.onap.aaiclient.client.aai.AAIObjectType
import org.onap.aaiclient.client.aai.AAIResourcesClient
import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri
import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory
import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder
-import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types
import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.onap.so.bpmn.core.json.JsonUtils
@@ -38,6 +36,7 @@ import org.slf4j.LoggerFactory
class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor {
private static final Logger logger = LoggerFactory.getLogger(DoCreateTnNssiInstance.class);
+ final String AAI_VERSION = "v21"
JsonUtils jsonUtil = new JsonUtils()
TnNssmfUtils tnNssmfUtils = new TnNssmfUtils()
ExceptionUtil exceptionUtil = new ExceptionUtil()
@@ -67,23 +66,26 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor {
void createSliceProfile(DelegateExecution execution) {
- String sliceserviceInstanceId = execution.getVariable("sliceServiceInstanceId")
+ String ssInstanceId = execution.getVariable("sliceServiceInstanceId")
String sliceProfileStr = execution.getVariable("sliceProfile")
String sliceProfileId = UUID.randomUUID().toString()
SliceProfile sliceProfile = new SliceProfile();
sliceProfile.setProfileId(sliceProfileId)
sliceProfile.setLatency(Integer.parseInt(jsonUtil.getJsonValue(sliceProfileStr, "latency")))
sliceProfile.setResourceSharingLevel(jsonUtil.getJsonValue(sliceProfileStr, "resourceSharingLevel"))
- sliceProfile.setSNssai(tnNssmfUtils.getFirstSnssaiFromSliceProfile(sliceProfileStr)) //TODO: should be list
+ //sliceProfile.setSNssai(tnNssmfUtils.getFirstSnssaiFromSliceProfile(sliceProfileStr))
- sliceProfile.setE2ELatency(Integer.parseInt(jsonUtil.getJsonValue(sliceProfileStr, "latency")))
sliceProfile.setMaxBandwidth(Integer.parseInt(jsonUtil.getJsonValue(sliceProfileStr, "maxBandwidth")))
- //TODO: new API
- sliceProfile.setReliability(new Object())
+ //sliceProfile.setReliability(new Object())
try {
AAIResourcesClient client = getAAIClient()
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(sliceserviceInstanceId).sliceProfile(sliceProfileId))
+ AAIResourceUri uri =
+ AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business()
+ .customer(execution.getVariable("globalSubscriberId"))
+ .serviceSubscription(execution.getVariable("subscriptionServiceType"))
+ .serviceInstance(ssInstanceId)
+ .sliceProfile(sliceProfileId))
client.create(uri, sliceProfile)
} catch (BpmnError e) {
@@ -112,20 +114,25 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor {
ss.setOrchestrationStatus(serviceStatus)
String modelInvariantUuid = execution.getVariable("modelInvariantUuid")
String modelUuid = execution.getVariable("modelUuid")
- ss.setModelInvariantId(modelInvariantUuid)
- ss.setModelVersionId(modelUuid)
+ //TODO: need valid model ID from the caller, as AAI does not accept invalid IDs
+ //ss.setModelInvariantId(modelInvariantUuid)
+ //ss.setModelVersionId(modelUuid)
String serviceInstanceLocationid = tnNssmfUtils.getFirstPlmnIdFromSliceProfile(sliceProfileStr)
ss.setServiceInstanceLocationId(serviceInstanceLocationid)
String snssai = tnNssmfUtils.getFirstSnssaiFromSliceProfile(sliceProfileStr)
ss.setEnvironmentContext(snssai)
ss.setServiceRole(serviceRole)
AAIResourcesClient client = getAAIClient()
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(ssInstanceId))
+ AAIResourceUri uri =
+ AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business()
+ .customer(execution.getVariable("globalSubscriberId"))
+ .serviceSubscription(execution.getVariable("subscriptionServiceType"))
+ .serviceInstance(ssInstanceId))
client.create(uri, ss)
} catch (BpmnError e) {
throw e
} catch (Exception ex) {
- String msg = "Exception in DoCreateTnNssiInstance.createServiceInstance. " + ex.getMessage()
+ String msg = "Exception in DoCreateTnNssiInstance.createServiceInstance: " + ex.getMessage()
logger.info(msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
}
@@ -133,17 +140,19 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor {
void createAllottedResource(DelegateExecution execution) {
- String serviceInstanceId = execution.getVariable('sliceServiceInstanceId')
-
- AAIResourcesClient resourceClient = getAAIClient()
- AAIResourceUri ssServiceuri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstanceId))
+ String ssInstanceId = execution.getVariable('sliceServiceInstanceId')
try {
List<String> networkStrList = jsonUtil.StringArrayToList(execution.getVariable("transportSliceNetworks"))
for (String networkStr : networkStrList) {
String allottedResourceId = UUID.randomUUID().toString()
- AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(execution.getVariable("sliceserviceInstanceId")).allottedResource(allottedResourceId))
+ AAIResourceUri allottedResourceUri =
+ AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business()
+ .customer(execution.getVariable("globalSubscriberId"))
+ .serviceSubscription(execution.getVariable("subscriptionServiceType"))
+ .serviceInstance(execution.getVariable("sliceServiceInstanceId"))
+ .allottedResource(allottedResourceId))
execution.setVariable("allottedResourceUri", allottedResourceUri)
String modelInvariantId = execution.getVariable("modelInvariantUuid")
String modelVersionId = execution.getVariable("modelUuid")
@@ -152,27 +161,37 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor {
resource.setId(allottedResourceId)
resource.setType("TsciNetwork")
resource.setAllottedResourceName("network_" + execution.getVariable("sliceServiceInstanceName"))
- resource.setModelInvariantId(modelInvariantId)
- resource.setModelVersionId(modelVersionId)
getAAIClient().create(allottedResourceUri, resource)
- //AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceFromExistingURI(Types.SERVICE_INSTANCE, UriBuilder.fromPath(ssServiceuri).build())
- //getAAIClient().connect(allottedResourceUri,ssServiceuri)
- //execution.setVariable("aaiARPath", allottedResourceUri.build().toString());
String linkArrayStr = jsonUtil.getJsonValue(networkStr, "connectionLinks")
- createLogicalLinksForAllocatedResource(execution, linkArrayStr, serviceInstanceId, allottedResourceId)
+ createLogicalLinksForAllocatedResource(execution, linkArrayStr, ssInstanceId, allottedResourceId)
}
-
+ } catch (BpmnError e) {
+ throw e
} catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Exception in createAaiAR " + ex.getMessage())
+ String msg = "Exception in DoCreateTnNssiInstance.createAllottedResource: " + ex.getMessage()
+ logger.info(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
}
}
void createLogicalLinksForAllocatedResource(DelegateExecution execution,
- String linkArrayStr, String serviceInstanceId,
+ String linkArrayStr, String ssInstanceId,
String allottedResourceId) {
-
try {
+ AAIResourceUri allottedResourceUri =
+ AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business()
+ .customer(execution.getVariable("globalSubscriberId"))
+ .serviceSubscription(execution.getVariable("subscriptionServiceType"))
+ .serviceInstance(ssInstanceId)
+ .allottedResource(allottedResourceId))
+
+ if (!getAAIClient().exists(allottedResourceUri)) {
+ logger.info("ERROR: createLogicalLinksForAllocatedResource: allottedResource not exist: uri={}",
+ allottedResourceUri)
+ return
+ }
+
List<String> linkStrList = jsonUtil.StringArrayToList(linkArrayStr)
for (String linkStr : linkStrList) {
@@ -186,15 +205,22 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor {
resource.setLinkId(logicalLinkId)
resource.setLinkName(epA)
resource.setLinkName2(epB)
- resource.setModelInvariantId(modelInvariantId)
- resource.setModelVersionId(modelVersionId)
+ resource.setLinkType("TsciConnectionLink")
+ resource.setInMaint(false)
- AAIResourceUri logicalLinkUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().logicalLink(logicalLinkId))
+ //epA is link-name
+ AAIResourceUri logicalLinkUri =
+ AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().logicalLink(epA))
getAAIClient().create(logicalLinkUri, resource)
+
+ tnNssmfUtils.attachLogicalLinkToAllottedResource(execution, AAI_VERSION, allottedResourceUri, epA);
}
+ } catch (BpmnError e) {
+ throw e
} catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000,
- "Exception in createLogicalLinksForAllocatedResource" + ex.getMessage())
+ String msg = "Exception in DoCreateTnNssiInstance.createLogicalLinksForAllocatedResource: " + ex.getMessage()
+ logger.info(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
}
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy
index a410b93d16..baf0333a19 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy
@@ -162,7 +162,7 @@ class DoDeallocateTnNssi extends AbstractServiceTaskProcessor {
roStatus.setProgress(progress)
roStatus.setStatus(status)
roStatus.setStatusDescription(statusDescription)
- requestDBUtil.prepareUpdateResourceOperationStatus(execution, status)
+ requestDBUtil.prepareUpdateResourceOperationStatus(execution, roStatus)
}
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyTnNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyTnNssi.groovy
index 03a726c52c..4ff15a58c5 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyTnNssi.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyTnNssi.groovy
@@ -387,7 +387,7 @@ public class DoModifyTnNssi extends AbstractServiceTaskProcessor {
roStatus.setProgress(progress)
roStatus.setStatus(status)
roStatus.setStatusDescription(statusDescription)
- requestDBUtil.prepareUpdateResourceOperationStatus(execution, status)
+ requestDBUtil.prepareUpdateResourceOperationStatus(execution, roStatus)
}
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy
index 7d2e536af9..e856522fca 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy
@@ -27,11 +27,9 @@ import groovy.json.JsonSlurper
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
import org.onap.aai.domain.yang.ServiceInstance
-import org.onap.aaiclient.client.aai.AAIObjectType
import org.onap.aaiclient.client.aai.AAIResourcesClient
import org.onap.aaiclient.client.aai.entities.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.so.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.onap.so.bpmn.common.scripts.ExceptionUtil
@@ -155,7 +153,7 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor {
"modelUuid":"${modelUuid}",
"modelVersion":""
}"""
- execution.setVariable("ssServiceModelInfo", serviceModelInfo)
+ execution.setVariable("serviceModelInfo", serviceModelInfo)
logger.debug("Finish prepareDecomposeService")
}
@@ -186,13 +184,14 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor {
if (maxIndex < 1) {
String msg = "Exception in TN NSST processDecomposition. There is no NSST associated with TN NSST "
logger.info(msg)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ //exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ } else {
+ execution.setVariable("tnNsstInfoList", nsstInfoList)
+ execution.setVariable("tnModelVersion", tnModelVersion)
+ execution.setVariable("tnModelName", tnModelName)
+ execution.setVariable("currentIndex", currentIndex)
+ execution.setVariable("maxIndex", maxIndex)
}
- execution.setVariable("tnNsstInfoList", nsstInfoList)
- execution.setVariable("tnModelVersion", tnModelVersion)
- execution.setVariable("tnModelName", tnModelName)
- execution.setVariable("currentIndex", currentIndex)
- execution.setVariable("maxIndex", maxIndex)
logger.debug("End processDecomposition")
}
@@ -334,7 +333,7 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor {
roStatus.setProgress(progress)
roStatus.setStatus(status)
roStatus.setStatusDescription(statusDescription)
- requestDBUtil.prepareUpdateResourceOperationStatus(execution, status)
+ requestDBUtil.prepareUpdateResourceOperationStatus(execution, roStatus)
}
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy
index a1b883c34e..1bb0e8aca7 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy
@@ -20,8 +20,11 @@
package org.onap.so.bpmn.infrastructure.scripts
-
+import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.onap.aai.domain.yang.Relationship
+import org.onap.aaiclient.client.aai.AAIResourcesClient
+import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri
import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.onap.so.bpmn.common.scripts.MsoUtils
import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
@@ -241,4 +244,40 @@ class TnNssmfUtils {
return res
}
+
+ void createRelationShipInAAI(DelegateExecution execution, AAIResourceUri uri, Relationship relationship) {
+ logger.debug("createRelationShipInAAI Start")
+ String msg
+ AAIResourcesClient client = new AAIResourcesClient()
+ try {
+ if (!client.exists(uri)) {
+ logger.info("ERROR: createRelationShipInAAI: not exist: uri={}", uri)
+ return
+ }
+ AAIResourceUri from = ((AAIResourceUri) (uri.clone())).relationshipAPI()
+ client.create(from, relationship)
+
+ } catch (BpmnError e) {
+ throw e
+ } catch (Exception ex) {
+ msg = "Exception in createRelationShipInAAI. " + ex.getMessage()
+ logger.info(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ logger.debug("createRelationShipInAAI Exit")
+ }
+
+ void attachLogicalLinkToAllottedResource(DelegateExecution execution, String aaiVersion, AAIResourceUri arUri,
+ String logicalLinkId) {
+
+
+ String toLink = "aai/${aaiVersion}/network/logical-links/logical-link/${logicalLinkId}"
+
+ Relationship relationship = new Relationship()
+ relationship.setRelatedLink(toLink)
+ relationship.setRelatedTo("logical-link")
+ relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf")
+
+ createRelationShipInAAI(execution, arUri, relationship)
+ }
}