aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks/src/main
diff options
context:
space:
mode:
authorLukasz Muszkieta <lukasz.muszkieta@nokia.com>2020-08-04 08:12:42 +0000
committerGerrit Code Review <gerrit@onap.org>2020-08-04 08:12:42 +0000
commit039a298c38ecf33d164be72eca725ec3861bb884 (patch)
tree7f5f924a442cd04a823a0f6e9630b3b008154738 /bpmn/so-bpmn-tasks/src/main
parent4e81b212f66800fffbb06a1f6c55b5733a98c122 (diff)
parentd7ef9a5b2f6f1a7e807a100f7e69fc373dc5e71a (diff)
Merge "Ensure that model related parameters are set when re-using Inventoried PNF instance"
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/main')
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java2
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIPnfResources.java35
2 files changed, 33 insertions, 4 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java
index e3181c3e91..55edf0bb6c 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java
@@ -260,7 +260,7 @@ public class AAICreateTasks {
public void createPnf(BuildingBlockExecution execution) {
try {
Pnf pnf = extractPojosForBB.extractByKey(execution, ResourceKey.PNF);
- aaiPnfResources.checkIfPnfExistsInAaiAndCanBeUsed(pnf.getPnfName());
+ aaiPnfResources.checkIfPnfExistsInAaiAndCanBeUsed(pnf);
ServiceInstance serviceInstance =
extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
aaiPnfResources.createPnfAndConnectServiceInstance(pnf, serviceInstance);
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIPnfResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIPnfResources.java
index 3b22cd9d81..3da17194ff 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIPnfResources.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIPnfResources.java
@@ -22,6 +22,7 @@ package org.onap.so.client.orchestration;
import com.google.common.base.Strings;
import java.util.Optional;
+import org.apache.commons.lang3.StringUtils;
import org.onap.aai.domain.yang.RelatedToProperty;
import org.onap.aai.domain.yang.Relationship;
import org.onap.aai.domain.yang.RelationshipData;
@@ -68,11 +69,39 @@ public class AAIPnfResources {
injectionHelper.getAaiClient().update(pnfURI, aaiObjectMapper.mapPnf(pnfCopy));
}
- public void checkIfPnfExistsInAaiAndCanBeUsed(String pnfName) throws Exception {
- Optional<org.onap.aai.domain.yang.Pnf> pnfFromAai = injectionHelper.getAaiClient()
- .get(org.onap.aai.domain.yang.Pnf.class, AAIUriFactory.createResourceUri(AAIObjectType.PNF, pnfName));
+ public void checkIfPnfExistsInAaiAndCanBeUsed(Pnf pnf) throws Exception {
+ Optional<org.onap.aai.domain.yang.Pnf> pnfFromAai =
+ injectionHelper.getAaiClient().get(org.onap.aai.domain.yang.Pnf.class,
+ AAIUriFactory.createResourceUri(AAIObjectType.PNF, pnf.getPnfName()));
if (pnfFromAai.isPresent()) {
checkIfPnfCanBeUsed(pnfFromAai.get());
+ updatePnfInAAI(pnf, pnfFromAai.get());
+ }
+ }
+
+ private void updatePnfInAAI(Pnf pnf, org.onap.aai.domain.yang.Pnf pnfFromAai) {
+ updatePnfFields(pnf, pnfFromAai);
+ injectionHelper.getAaiClient().update(AAIUriFactory.createResourceUri(AAIObjectType.PNF, pnf.getPnfName()),
+ pnfFromAai);
+ logger.debug("updatePnfInAAI: {}", pnfFromAai);
+ }
+
+ private void updatePnfFields(Pnf pnf, org.onap.aai.domain.yang.Pnf pnfFromAai) {
+ if (pnf.getModelInfoPnf() != null
+ && StringUtils.isNotBlank(pnf.getModelInfoPnf().getModelCustomizationUuid())) {
+ pnfFromAai.setModelCustomizationId(pnf.getModelInfoPnf().getModelCustomizationUuid());
+ }
+ if (pnf.getModelInfoPnf() != null && StringUtils.isNotBlank(pnf.getModelInfoPnf().getModelInvariantUuid())) {
+ pnfFromAai.setModelInvariantId(pnf.getModelInfoPnf().getModelInvariantUuid());
+ }
+ if (pnf.getModelInfoPnf() != null && StringUtils.isNotBlank(pnf.getModelInfoPnf().getModelUuid())) {
+ pnfFromAai.setModelVersionId(pnf.getModelInfoPnf().getModelUuid());
+ }
+ if (pnf.getOrchestrationStatus() != null && StringUtils.isNotBlank(pnf.getOrchestrationStatus().toString())) {
+ pnfFromAai.setOrchestrationStatus(pnf.getOrchestrationStatus().toString());
+ }
+ if (StringUtils.isNotBlank(pnf.getRole())) {
+ pnfFromAai.setNfRole(pnf.getRole());
}
}