From 18463785dabe925f7e76f21f28fa7551c7d559e1 Mon Sep 17 00:00:00 2001 From: "Bancala, Ben (bb3476)" Date: Thu, 3 May 2018 11:50:13 -0400 Subject: fixed bug in createvnfinfra bpmn Change-Id: I3e27ec0d1487eb68e8c54d27508b58233bf49808 Issue-ID: SO-602 Signed-off-by: Bancala, Ben (bb3476) --- .../scripts/CreateVfModuleInfra.groovy | 21 +++++ .../infrastructure/aai/AAICreateResources.java | 14 ++++ .../resources/process/CreateVfModuleInfra.bpmn | 92 +++++++++++++--------- .../infrastructure/CreateVfModuleInfraTest.java | 5 ++ .../resources/__files/AAI/AAI_genericVnfGet.json | 9 +++ 5 files changed, 104 insertions(+), 37 deletions(-) create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/AAI/AAI_genericVnfGet.json (limited to 'bpmn/MSOInfrastructureBPMN') diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy index 3f0b8d11f1..797086b125 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy @@ -35,6 +35,8 @@ import org.openecomp.mso.bpmn.common.scripts.VidUtils; import org.openecomp.mso.bpmn.core.RollbackData import org.openecomp.mso.bpmn.core.WorkflowException import org.openecomp.mso.bpmn.core.json.JsonUtils +import org.openecomp.mso.bpmn.infrastructure.aai.AAICreateResources; +import org.onap.aai.domain.yang.v12.GenericVnf; public class CreateVfModuleInfra extends AbstractServiceTaskProcessor { @@ -287,6 +289,25 @@ public class CreateVfModuleInfra extends AbstractServiceTaskProcessor { exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in sendResponse(): ' + e.getMessage()) } } + + /** + * Query AAI for vnf orchestration status to determine if health check and config scaling should be run + */ + public void queryAAIForVnfOrchestrationStatus(DelegateExecution execution) { + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + def vnfId = execution.getVariable("CVFMI_vnfId") + execution.setVariable("runHealthCheck", false); + execution.setVariable("runConfigScaleOut", false); + AAICreateResources aaiCreateResources = new AAICreateResources(); + Optional vnf = aaiCreateResources.getVnfInstance(vnfId); + if(vnf.isPresent()){ + def vnfOrchestrationStatus = vnf.get().getOrchestrationStatus(); + if("active".equalsIgnoreCase(vnfOrchestrationStatus)){ + execution.setVariable("runHealthCheck", true); + execution.setVariable("runConfigScaleOut", true); + } + } + } /** * diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/aai/AAICreateResources.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/aai/AAICreateResources.java index 93ba0ae5a4..3d05f76b03 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/aai/AAICreateResources.java +++ b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/aai/AAICreateResources.java @@ -24,8 +24,10 @@ import java.util.HashMap; import java.util.Map; import java.util.Optional; +import org.onap.aai.domain.yang.v12.GenericVnf; import org.openecomp.mso.client.aai.AAIObjectType; import org.openecomp.mso.client.aai.AAIResourcesClient; +import org.openecomp.mso.client.aai.entities.AAIResultWrapper; import org.openecomp.mso.client.aai.entities.uri.AAIResourceUri; import org.openecomp.mso.client.aai.entities.uri.AAIUriFactory; @@ -81,4 +83,16 @@ public class AAICreateResources { aaiRC.createIfNotExists(serviceInstanceURI, Optional.empty()); } + public Optional getVnfInstance(String vnfId){ + try{ + AAIResourceUri vnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId); + AAIResourcesClient aaiRC = new AAIResourcesClient(); + AAIResultWrapper aaiResponse = aaiRC.get(vnfURI); + Optional vnf = aaiResponse.asBean(GenericVnf.class); + return vnf; + } catch (Exception ex){ + return Optional.empty(); + } + } + } diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateVfModuleInfra.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateVfModuleInfra.bpmn index 841dec96bd..794d3c636a 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateVfModuleInfra.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateVfModuleInfra.bpmn @@ -1,5 +1,5 @@ - + SequenceFlow_1 @@ -225,7 +225,7 @@ exceptionUtil.processJavaException(execution)]]> SequenceFlow_1xggje5 SequenceFlow_07llpjo - + SequenceFlow_07llpjo SequenceFlow_1vx081s @@ -274,12 +274,12 @@ exceptionUtil.processJavaException(execution)]]> - SequenceFlow_0e2ta6w + SequenceFlow_1b7348f SequenceFlow_1xggje5 SequenceFlow_1y7d5qk - + @@ -288,9 +288,17 @@ exceptionUtil.processJavaException(execution)]]> SequenceFlow_0u8zesf - + + + + SequenceFlow_0e2ta6w + SequenceFlow_1b7348f + + @@ -323,19 +331,19 @@ exceptionUtil.processJavaException(execution)]]> - + - + - + - - + + - + @@ -529,48 +537,48 @@ exceptionUtil.processJavaException(execution)]]> - + - + - + - + - + - - - - + + + + - + - - + + - + - + - + - - + + - + @@ -617,23 +625,23 @@ exceptionUtil.processJavaException(execution)]]> - + - + - - + + - + - - + + - + @@ -656,6 +664,16 @@ exceptionUtil.processJavaException(execution)]]> + + + + + + + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateVfModuleInfraTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateVfModuleInfraTest.java index de2ae771a5..27f421dcc7 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateVfModuleInfraTest.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateVfModuleInfraTest.java @@ -21,6 +21,7 @@ package org.openecomp.mso.bpmn.infrastructure; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchGenericVnf; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfsByVnfId; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchVfModuleId; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockAAIVfModule; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockSDNCAdapterVfModule; @@ -87,6 +88,7 @@ public class CreateVfModuleInfraTest extends WorkflowTest { logStart(); MockAAIVfModule(); + MockGetGenericVnfsByVnfId("skask","__files/AAI/AAI_genericVnfGet.json",200); MockPatchGenericVnf("skask"); MockPatchVfModuleId("skask", ".*"); MockSDNCAdapterVfModule(); @@ -148,6 +150,7 @@ public class CreateVfModuleInfraTest extends WorkflowTest { logStart(); MockAAIVfModule(); + MockGetGenericVnfsByVnfId("skask","__files/AAI/AAI_genericVnfGet.json",200); MockPatchGenericVnf("skask"); MockPatchVfModuleId("skask", ".*"); MockSDNCAdapterVfModule(); @@ -239,6 +242,7 @@ public class CreateVfModuleInfraTest extends WorkflowTest { MockAAIVfModule(); + MockGetGenericVnfsByVnfId("skask","__files/AAI/AAI_genericVnfGet.json",200); MockPatchGenericVnf("skask"); MockPatchVfModuleId("skask", ".*"); MockSDNCAdapterVfModule(); @@ -325,6 +329,7 @@ public class CreateVfModuleInfraTest extends WorkflowTest { logStart(); MockAAIVfModule(); + MockGetGenericVnfsByVnfId("skask","__files/AAI/AAI_genericVnfGet.json",200); MockPatchGenericVnf("skask"); MockPatchVfModuleId("skask", ".*"); MockSDNCAdapterVfModule(); diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/AAI/AAI_genericVnfGet.json b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/AAI/AAI_genericVnfGet.json new file mode 100644 index 0000000000..09d7758f04 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/AAI/AAI_genericVnfGet.json @@ -0,0 +1,9 @@ +{ + "vnf-id": "msoVnf123", + "vnf-name": "MSO-Test-VNF-123", + "vnf-type": "vnf-type", + "orchestration-status": "active", + "in-maint": false, + "is-closed-loop-disabled": false, + "resource-version": "1525360206136" +} \ No newline at end of file -- cgit 1.2.3-korg