aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks/src/main
diff options
context:
space:
mode:
authorRob Daugherty <rd472p@att.com>2018-12-10 15:40:49 +0000
committerGerrit Code Review <gerrit@onap.org>2018-12-10 15:40:49 +0000
commitba49400b548acc433908e7a68846686cffebadca (patch)
tree5f9ec1e27307b1a57a684a3f531a13af1eaffcae /bpmn/so-bpmn-tasks/src/main
parent189bc2d2a5038e95286315df6a60748a4accf718 (diff)
parent264e0c009955ed10a656ba4d4e7f7bbf00dadbb5 (diff)
Merge "VNF Recreate"
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/main')
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java72
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionExtractResourcesAAI.java38
2 files changed, 109 insertions, 1 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java
index 294fd56cfd..4eb4ffec2f 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java
@@ -50,6 +50,10 @@ import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds;
import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetup;
import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils;
import org.onap.so.bpmn.infrastructure.workflow.tasks.Resource;
+import org.onap.so.client.aai.AAICommonObjectMapperProvider;
+import org.onap.so.client.aai.AAIObjectType;
+import org.onap.so.client.aai.entities.AAIResultWrapper;
+import org.onap.so.client.aai.entities.Relationships;
import org.onap.so.client.exception.ExceptionBuilder;
import org.onap.so.client.orchestration.AAIConfigurationResources;
import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization;
@@ -121,7 +125,10 @@ public class WorkflowAction {
@Autowired
private AAIConfigurationResources aaiConfigurationResources;
@Autowired
- private Environment environment;
+ private WorkflowActionExtractResourcesAAI workflowActionUtils;
+
+ @Autowired
+ private Environment environment;
private String defaultCloudOwner = "org.onap.so.cloud-owner";
public void setBbInputSetupUtils(BBInputSetupUtils bbInputSetupUtils) {
@@ -249,6 +256,8 @@ public class WorkflowAction {
} else if (resourceType == WorkflowType.SERVICE
&& requestAction.equalsIgnoreCase("deactivateInstance")) {
resourceCounter.add(new Resource(WorkflowType.SERVICE,"",false));
+ } else if (resourceType == WorkflowType.VNF && (requestAction.equalsIgnoreCase("replaceInstance") || (requestAction.equalsIgnoreCase("recreateInstance")))) {
+ traverseAAIVnf(execution, resourceCounter, workflowResourceIds.getServiceInstanceId(), workflowResourceIds.getVnfId(), aaiResourceIds);
} else {
buildAndThrowException(execution, "Current Macro Request is not supported");
}
@@ -550,6 +559,67 @@ public class WorkflowAction {
}
}
+ private void traverseAAIVnf(DelegateExecution execution, List<Resource> resourceCounter, String serviceId, String vnfId,
+ List<Pair<WorkflowType, String>> aaiResourceIds) {
+ try{
+ ServiceInstance serviceInstanceAAI = bbInputSetupUtils.getAAIServiceInstanceById(serviceId);
+ org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO = bbInputSetup
+ .getExistingServiceInstance(serviceInstanceAAI);
+ resourceCounter.add(new Resource(WorkflowType.SERVICE,serviceInstanceMSO.getServiceInstanceId(),false));
+ if (serviceInstanceMSO.getVnfs() != null) {
+ for (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf : serviceInstanceMSO
+ .getVnfs()) {
+ if(vnf.getVnfId().equals(vnfId)){
+ aaiResourceIds.add(new Pair<WorkflowType, String>(WorkflowType.VNF, vnf.getVnfId()));
+ resourceCounter.add(new Resource(WorkflowType.VNF,vnf.getVnfId(),false));
+ if (vnf.getVfModules() != null) {
+ for (VfModule vfModule : vnf.getVfModules()) {
+ aaiResourceIds.add(new Pair<WorkflowType, String>(WorkflowType.VFMODULE, vfModule.getVfModuleId()));
+ resourceCounter.add(new Resource(WorkflowType.VFMODULE,vfModule.getVfModuleId(),false));
+ findConfigurationsInsideVfModule(execution, vnf.getVnfId(), vfModule.getVfModuleId(), resourceCounter, aaiResourceIds);
+ }
+ }
+ if (vnf.getVolumeGroups() != null) {
+ for (org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup volumeGroup : vnf
+ .getVolumeGroups()) {
+ aaiResourceIds.add(new Pair<WorkflowType, String>(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId()));
+ resourceCounter.add(new Resource(WorkflowType.VOLUMEGROUP,volumeGroup.getVolumeGroupId(),false));
+ }
+ }
+ break;
+ }
+ }
+ }
+ } catch (Exception ex) {
+ buildAndThrowException(execution,
+ "Could not find existing Vnf or related Instances to execute the request on.");
+ }
+ }
+
+ private void findConfigurationsInsideVfModule(DelegateExecution execution, String vnfId, String vfModuleId, List<Resource> resourceCounter,
+ List<Pair<WorkflowType, String>> aaiResourceIds) {
+ try{
+ org.onap.aai.domain.yang.VfModule aaiVfModule = bbInputSetupUtils.getAAIVfModule(vnfId, vfModuleId);
+ AAIResultWrapper vfModuleWrapper = new AAIResultWrapper(
+ new AAICommonObjectMapperProvider().getMapper().writeValueAsString(aaiVfModule));
+ Optional<Relationships> relationshipsOp;
+ relationshipsOp = vfModuleWrapper.getRelationships();
+ if(relationshipsOp.isPresent()) {
+ relationshipsOp = workflowActionUtils.extractRelationshipsVnfc(relationshipsOp.get());
+ if(relationshipsOp.isPresent()){
+ Optional<Configuration> config = workflowActionUtils.extractRelationshipsConfiguration(relationshipsOp.get());
+ if(config.isPresent()){
+ aaiResourceIds.add(new Pair<WorkflowType, String>(WorkflowType.CONFIGURATION, config.get().getConfigurationId()));
+ resourceCounter.add(new Resource(WorkflowType.CONFIGURATION, config.get().getConfigurationId(), false));
+ }
+ }
+ }
+ }catch (Exception ex){
+ buildAndThrowException(execution,
+ "Failed to find Configuration object from the vfModule.");
+ }
+ }
+
protected boolean traverseUserParamsService(DelegateExecution execution, List<Resource> resourceCounter,
ServiceInstancesRequest sIRequest, String requestAction)
throws IOException {
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionExtractResourcesAAI.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionExtractResourcesAAI.java
new file mode 100644
index 0000000000..81609d1ddd
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionExtractResourcesAAI.java
@@ -0,0 +1,38 @@
+package org.onap.so.bpmn.infrastructure.workflow.tasks;
+
+import java.util.List;
+import java.util.Optional;
+
+import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
+import org.onap.so.client.aai.AAIObjectType;
+import org.onap.so.client.aai.entities.AAIResultWrapper;
+import org.onap.so.client.aai.entities.Relationships;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+
+@Component
+public class WorkflowActionExtractResourcesAAI {
+ private static final Logger logger = LoggerFactory.getLogger(WorkflowActionExtractResourcesAAI.class);
+
+ public Optional<Configuration> extractRelationshipsConfiguration(Relationships relationships) {
+ List<AAIResultWrapper> configurations = relationships.getByType(AAIObjectType.CONFIGURATION);
+ for(AAIResultWrapper configWrapper : configurations) {
+ Optional<Configuration> config = configWrapper.asBean(Configuration.class);
+ if(config.isPresent()){
+ return config;
+ }
+ }
+ return Optional.empty();
+ }
+
+ public Optional<Relationships> extractRelationshipsVnfc(Relationships relationships) {
+ List<AAIResultWrapper> vnfcs = relationships.getByType(AAIObjectType.VNFC);
+ for(AAIResultWrapper vnfcWrapper : vnfcs){
+ if(vnfcWrapper.getRelationships().isPresent()){
+ return vnfcWrapper.getRelationships();
+ }
+ }
+ return Optional.empty();
+ }
+}