summaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks
diff options
context:
space:
mode:
authorByung-Woo Jun <byung-woo.jun@est.tech>2020-09-10 12:38:11 +0000
committerGerrit Code Review <gerrit@onap.org>2020-09-10 12:38:11 +0000
commita714a448501d30fee850f878e85023db72b71f14 (patch)
tree4ccddc3c0065a17722ef5bc797c6171ebb12d957 /bpmn/so-bpmn-tasks
parentfa1aa4e2179d9f852d7025d026685bd72385ce4b (diff)
parent44ffcde54cb7d832232a32fe7a60b4849bef447a (diff)
Merge "multiple pnf fix"
Diffstat (limited to 'bpmn/so-bpmn-tasks')
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevel.java (renamed from bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelPreparable.java)25
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelConstants.java4
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelPostcheck.java2
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelPreparation.java10
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelRequestDispatcher.java22
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelUpgrade.java12
6 files changed, 55 insertions, 20 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelPreparable.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevel.java
index e26195158d..b8f5ec9674 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelPreparable.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevel.java
@@ -23,6 +23,7 @@ package org.onap.so.bpmn.infrastructure.service.level;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
+import jline.internal.Log;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.onap.so.bpmn.infrastructure.service.level.impl.ServiceLevelConstants;
import org.onap.so.client.exception.ExceptionBuilder;
@@ -35,9 +36,9 @@ import org.springframework.beans.factory.annotation.Autowired;
/**
* Parent class for Service level upgrade Execution, it should be extended for service level upgrade tasks.
*/
-public class ServiceLevelPreparable {
+public class ServiceLevel {
- protected static final Logger LOG = LoggerFactory.getLogger(ServiceLevelPreparable.class);
+ protected static final Logger LOG = LoggerFactory.getLogger(ServiceLevel.class);
@Autowired
protected ExceptionBuilder exceptionBuilder;
@@ -45,6 +46,10 @@ public class ServiceLevelPreparable {
@Autowired
protected CatalogDbClient catalogDbClient;
+ private static final String PNF_NAME_LIST = "pnfNameList";
+
+ private static final String PNF_COUNTER = "pnfCounter";
+
/**
* Fetches workflow names based on the controller scope and operation name.
*
@@ -95,4 +100,20 @@ public class ServiceLevelPreparable {
}
+ /**
+ * This method set correct value of pnf name for health check and software upgrade workflow.
+ *
+ * @param delegateExecution Delegate execution obj
+ */
+ public void pnfCounterExecution(DelegateExecution delegateExecution) {
+ LOG.debug("Running execute block for activity id: {}, name: {}", delegateExecution.getCurrentActivityId(),
+ delegateExecution.getCurrentActivityName());
+
+ final List<String> pnfNameList = (List<String>) delegateExecution.getVariable(PNF_NAME_LIST);
+ final int pnfCounter = (int) delegateExecution.getVariable(PNF_COUNTER);
+
+ delegateExecution.setVariable(ServiceLevelConstants.PNF_NAME, pnfNameList.get(pnfCounter));
+ delegateExecution.setVariable(PNF_COUNTER, pnfCounter + 1);
+ }
+
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelConstants.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelConstants.java
index 7b73fff20c..b0b12b5276 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelConstants.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelConstants.java
@@ -38,6 +38,10 @@ public class ServiceLevelConstants {
public static final String SW_UP_OPERATION = "ResourceSoftwareUpgrade";
public static final String CONTROLLER_STATUS = "ControllerStatus";
public static final int ERROR_CODE = 601;
+ public static final String PNF_COUNTER = "pnfCounter";
+ public static final int COUNT_ZERO = 0;
+ public static final String PNF_NAME_LIST = "pnfNameList";
+ public static final String PNF_SIZE = "pnfSize";
// TODO GenericVNFHealthCheck and GenericVnfSoftwareUpgrade workflow names should be updated once the workflow is
// implemented.
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelPostcheck.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelPostcheck.java
index fad28e315e..8e720c3e53 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelPostcheck.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelPostcheck.java
@@ -8,6 +8,6 @@ import org.springframework.stereotype.Component;
public class ServiceLevelPostcheck implements JavaDelegate {
@Override
public void execute(DelegateExecution delegateExecution) throws Exception {
- // TODO : Set serviceInstance to aai
+ // Write your postcheck operations here, if any
}
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelPreparation.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelPreparation.java
index 59884ecbc2..6cb3461001 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelPreparation.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelPreparation.java
@@ -26,7 +26,7 @@ import java.util.List;
import java.util.Map;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.JavaDelegate;
-import org.onap.so.bpmn.infrastructure.service.level.ServiceLevelPreparable;
+import org.onap.so.bpmn.infrastructure.service.level.ServiceLevel;
import org.springframework.stereotype.Component;
@@ -35,10 +35,10 @@ import org.springframework.stereotype.Component;
* validation.
*/
@Component("ServiceLevelPreparation")
-public class ServiceLevelPreparation extends ServiceLevelPreparable implements JavaDelegate {
+public class ServiceLevelPreparation extends ServiceLevel implements JavaDelegate {
private static final List<String> PNF_HEALTH_CHECK_PARAMS = Arrays.asList(ServiceLevelConstants.SERVICE_INSTANCE_ID,
- ServiceLevelConstants.RESOURCE_TYPE, ServiceLevelConstants.BPMN_REQUEST, ServiceLevelConstants.PNF_NAME);
+ ServiceLevelConstants.RESOURCE_TYPE, ServiceLevelConstants.BPMN_REQUEST);
// TODO Update the list with vnf health check parameters if any validation needed
private static final List<String> VNF_HEALTH_CHECK_PARAMS = Collections.emptyList();
@@ -48,6 +48,9 @@ public class ServiceLevelPreparation extends ServiceLevelPreparable implements J
@Override
public void execute(DelegateExecution execution) throws Exception {
+ LOG.debug("Running execute block for activity id: {}, name: {}", execution.getCurrentActivityId(),
+ execution.getCurrentActivityName());
+
if (execution.hasVariable(ServiceLevelConstants.RESOURCE_TYPE)
&& execution.getVariable(ServiceLevelConstants.RESOURCE_TYPE) != null) {
final String controllerScope = (String) execution.getVariable(ServiceLevelConstants.RESOURCE_TYPE);
@@ -60,6 +63,7 @@ public class ServiceLevelPreparation extends ServiceLevelPreparable implements J
LOG.info("Parameters validated successfully for {}", wflName);
execution.setVariable(ServiceLevelConstants.HEALTH_CHECK_WORKFLOW_TO_INVOKE, wflName);
execution.setVariable(ServiceLevelConstants.CONTROLLER_STATUS, ServiceLevelConstants.EMPTY_STRING);
+ execution.setVariable(ServiceLevelConstants.PNF_COUNTER, ServiceLevelConstants.COUNT_ZERO);
} else {
exceptionBuilder.buildAndThrowWorkflowException(execution, ServiceLevelConstants.ERROR_CODE,
"Invalid Controller scope to prepare resource level health check");
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelRequestDispatcher.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelRequestDispatcher.java
index 5b20a86cb7..5d9295dc95 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelRequestDispatcher.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelRequestDispatcher.java
@@ -23,6 +23,7 @@ package org.onap.so.bpmn.infrastructure.service.level.impl;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.JavaDelegate;
+import org.onap.aai.domain.yang.Relationship;
import org.onap.aai.domain.yang.ServiceInstance;
import org.onap.aaiclient.client.aai.AAIRestClientI;
import org.onap.aaiclient.client.aai.AAIRestClientImpl;
@@ -34,7 +35,11 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Optional;
+import java.util.stream.Collector;
+import java.util.stream.Collectors;
import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.*;
/**
@@ -83,21 +88,18 @@ public class ServiceLevelRequestDispatcher implements JavaDelegate {
Optional<ServiceInstance> optionalSi =
restClient.getServiceInstanceById(serviceInstanceId, serviceType, globalSubscriberId);
- if (!optionalSi.isPresent()) {
-
- }
-
optionalSi.ifPresentOrElse(serviceInstance -> {
- final String pnfName = serviceInstance.getRelationshipList().getRelationship().stream()
- .filter(x -> x.getRelatedTo().contains("pnf")).findFirst().get().getRelationshipData().stream()
- .filter(data -> data.getRelationshipKey().contains("pnf.pnf-name")).findFirst().get()
- .getRelationshipValue();
- if (pnfName == null || pnfName.isEmpty()) {
+ final List<String> pnfNameList = serviceInstance.getRelationshipList().getRelationship().stream()
+ .filter(x -> x.getRelatedTo().contains("pnf")).flatMap(x -> x.getRelationshipData().stream())
+ .filter(data -> data.getRelationshipKey().contains("pnf.pnf-name"))
+ .map(x -> x.getRelationshipValue()).collect(Collectors.toList());
+ if (pnfNameList == null || pnfNameList.size() == 0) {
logger.warn(
"Unable to find the PNF for service instance id: " + serviceInstance.getServiceInstanceId());
return;
}
- delegateExecution.setVariable(ServiceLevelConstants.PNF_NAME, pnfName);
+ delegateExecution.setVariable(ServiceLevelConstants.PNF_NAME_LIST, pnfNameList);
+ delegateExecution.setVariable(ServiceLevelConstants.PNF_SIZE, pnfNameList.size());
delegateExecution.setVariable(ServiceLevelConstants.RESOURCE_TYPE, ServiceLevelConstants.PNF);
}, () -> {
throwExceptionWithWarn(delegateExecution, "Unable to find the service instance: " + serviceInstanceId);
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelUpgrade.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelUpgrade.java
index 9d7d8efb65..a3a8f6e714 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelUpgrade.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelUpgrade.java
@@ -26,14 +26,14 @@ import java.util.List;
import java.util.Map;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.JavaDelegate;
-import org.onap.so.bpmn.infrastructure.service.level.ServiceLevelPreparable;
+import org.onap.so.bpmn.infrastructure.service.level.ServiceLevel;
import org.springframework.stereotype.Component;
@Component
-public class ServiceLevelUpgrade extends ServiceLevelPreparable implements JavaDelegate {
+public class ServiceLevelUpgrade extends ServiceLevel implements JavaDelegate {
private static final List<String> PNF_SOFTWARE_UP_PARAMS = Arrays.asList(ServiceLevelConstants.SERVICE_INSTANCE_ID,
- ServiceLevelConstants.RESOURCE_TYPE, ServiceLevelConstants.BPMN_REQUEST, ServiceLevelConstants.PNF_NAME);
+ ServiceLevelConstants.RESOURCE_TYPE, ServiceLevelConstants.BPMN_REQUEST);
// TODO Update the list with vnf software upgrade parameters if any validation needed
private static final List<String> VNF_SOFTWARE_UP_PARAMS = Collections.emptyList();
@@ -44,6 +44,9 @@ public class ServiceLevelUpgrade extends ServiceLevelPreparable implements JavaD
@Override
public void execute(DelegateExecution execution) throws Exception {
+ LOG.debug("Running execute block for activity id: {}, name: {}", execution.getCurrentActivityId(),
+ execution.getCurrentActivityName());
+
if (execution.hasVariable(ServiceLevelConstants.RESOURCE_TYPE)
&& execution.getVariable(ServiceLevelConstants.RESOURCE_TYPE) != null) {
final String controllerScope = (String) execution.getVariable(ServiceLevelConstants.RESOURCE_TYPE);
@@ -54,7 +57,8 @@ public class ServiceLevelUpgrade extends ServiceLevelPreparable implements JavaD
validateParamsWithScope(execution, controllerScope, SOFTWARE_UP_PARAMS_MAP.get(controllerScope));
LOG.info("Parameters validated successfully for {}", wflName);
execution.setVariable(ServiceLevelConstants.SOFTWARE_WORKFLOW_TO_INVOKE, wflName);
- execution.setVariable(ServiceLevelConstants.CONTROLLER_STATUS, "");
+ execution.setVariable(ServiceLevelConstants.CONTROLLER_STATUS, ServiceLevelConstants.EMPTY_STRING);
+ execution.setVariable(ServiceLevelConstants.PNF_COUNTER, ServiceLevelConstants.COUNT_ZERO);
} else {
exceptionBuilder.buildAndThrowWorkflowException(execution, ServiceLevelConstants.ERROR_CODE,
"Invalid Controller scope for resource level software upgrade");