diff options
31 files changed, 233 insertions, 154 deletions
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/StackService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/StackService.java index 6b7ceedbb8..5196ffffda 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/StackService.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/StackService.java @@ -276,7 +276,7 @@ public class StackService extends ExternalTaskUtils { networkAdapterImpl.createNetwork(req.getCloudSiteId(), req.getTenantId(), req.getNetworkType(), req.getModelCustomizationUuid(), req.getNetworkName(), physicalNetworkName, vlans, routeTargets, shared, external, req.getFailIfExists(), false, req.getSubnets(), fqdns, routeTable, req.getMsoRequest(), - networkId, neutronNetworkId, networkFqdn, subnetIdMap, networkRollback, false); + networkId, neutronNetworkId, networkFqdn, subnetIdMap, networkRollback, true); success.setTrue(); backout.setValue(req.getBackout()); canonicalStackId.value = networkRollback.value.getNetworkStackId(); diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java index 6a62a5de61..45b29244d1 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java @@ -245,7 +245,7 @@ public class HeatBridgeImpl implements HeatBridgeApi { @Override public List<org.openstack4j.model.compute.Image> extractOpenstackImagesFromServers(final List<Server> servers) { Objects.requireNonNull(osClient, ERR_MSG_NULL_OS_CLIENT); - return servers.stream().map(Server::getImage) + return servers.stream().filter(s -> s.getImage() != null).map(Server::getImage) .filter(distinctByProperty(org.openstack4j.model.compute.Image::getId)).collect(Collectors.toList()); } diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java index 531496cc8f..ebc7c3a81e 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java @@ -102,6 +102,8 @@ import org.openstack4j.model.network.Port; import org.openstack4j.model.network.Subnet; import org.openstack4j.openstack.heat.domain.HeatResource; import org.openstack4j.openstack.heat.domain.HeatResource.Resources; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.core.env.Environment; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.type.TypeReference; @@ -118,6 +120,8 @@ public class HeatBridgeImplTest { private static final String TENANT_ID = "7320ec4a5b9d4589ba7c4412ccfd290f"; private static final ObjectMapper MAPPER = new ObjectMapper(); + private static Logger logger = LoggerFactory.getLogger(HeatBridgeImplTest.class); + @Mock private OpenstackClient osClient; @@ -139,6 +143,12 @@ public class HeatBridgeImplTest { private Server server; @Mock + private Server server2; + + @Mock + private Image image; + + @Mock private AAIDSLQueryClient dSLQueryClient; @Spy @@ -626,6 +636,25 @@ public class HeatBridgeImplTest { verify(osClient, times(5)).getNetworkById(anyString()); } + + @Test + public void testExtractOpenstackImagesFromServers() throws HeatBridgeException { + // Arrange + List<Server> serverList = new ArrayList<>(); + serverList.add(server); + serverList.add(server2); + when(server.getImage()).thenReturn(null); + when(server.getImage()).thenReturn(image); + when(image.getId()).thenReturn("imageId"); + // Act + + List<Image> images = heatbridge.extractOpenstackImagesFromServers(serverList); + + + // Assert + assertEquals(1, images.size()); + } + private List<? extends Resource> extractTestStackResources() { List<HeatResource> stackResources = null; try { @@ -638,6 +667,7 @@ public class HeatBridgeImplTest { return stackResources; } + private String readTestResourceFile(String filePath) { String content = null; String pathname = Objects.requireNonNull(getClass().getClassLoader().getResource(filePath)).getFile(); diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java index 44ea2a25a2..02b1df79dd 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java @@ -978,7 +978,7 @@ public class ASDCController { String artifactContent = null; List<IArtifactInfo> serviceArtifacts = iNotif.getServiceArtifacts(); Optional<IArtifactInfo> artifactOpt = serviceArtifacts.stream() - .filter(e -> e.getArtifactType().equalsIgnoreCase("OTHER")).findFirst(); + .filter(e -> e.getArtifactType().equalsIgnoreCase("WORKFLOW")).findFirst(); if (artifactOpt.isPresent()) { IArtifactInfo artifactInfo = artifactOpt.get(); logger.debug("Ready to parse this serviceArtifactUUID: " + artifactInfo.getArtifactUUID()); diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/EtsiResourcePackageProcessor.java b/asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/EtsiResourcePackageProcessor.java index bb7197b7a4..4205de3cab 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/EtsiResourcePackageProcessor.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/EtsiResourcePackageProcessor.java @@ -44,7 +44,7 @@ import com.google.common.collect.ImmutableSet; public class EtsiResourcePackageProcessor { private final static Logger LOGGER = LoggerFactory.getLogger(EtsiResourcePackageProcessor.class); - private static final String ONBOARDED_PACKAGE_DIR_PATH = "Artifacts/Deployment/ONBOARDED_PACKAGE"; + private static final String ONBOARDED_PACKAGE_DIR_PATH = "Artifacts/Deployment/ETSI_PACKAGE"; private final SdcResourceProvider sdcResourceProvider; private final EtsiCatalogServiceProvider catalogServiceProvider; private static final int SLEEP_TIME_IN_SECONDS = 5; diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java index 49fef1d3f0..d57b305902 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java @@ -2913,15 +2913,19 @@ public class ToscaResourceInstaller { } private void createServiceArtifact(Service service, VfResourceStructure vfResourceStruct, String artifactContent) { + if (null == vfResourceStruct) { + return; + } List<ServiceArtifact> serviceArtifactList = new ArrayList<>(); ServiceArtifact serviceArtifact; List<IArtifactInfo> artifactInfoList = vfResourceStruct.getNotification().getServiceArtifacts().stream() - .filter(artifact -> artifact.getArtifactType().equalsIgnoreCase("OTHER")).collect(Collectors.toList()); + .filter(artifact -> artifact.getArtifactType().equalsIgnoreCase("WORKFLOW")) + .collect(Collectors.toList()); for (IArtifactInfo artifactInfo : artifactInfoList) { serviceArtifact = new ServiceArtifact(); serviceArtifact.setArtifactUUID(artifactInfo.getArtifactUUID()); serviceArtifact.setName(artifactInfo.getArtifactName()); - serviceArtifact.setType(artifactInfo.getArtifactType()); + serviceArtifact.setType("OTHER"); serviceArtifact.setVersion(artifactInfo.getArtifactVersion()); serviceArtifact.setDescription(artifactInfo.getArtifactDescription()); serviceArtifact.setChecksum(artifactInfo.getArtifactChecksum()); diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/SdcNotificationWithSol004PackageTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/SdcNotificationWithSol004PackageTest.java index cb5bd0f51a..2e8da35f3e 100644 --- a/asdc-controller/src/test/java/org/onap/so/asdc/client/SdcNotificationWithSol004PackageTest.java +++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/SdcNotificationWithSol004PackageTest.java @@ -345,7 +345,7 @@ public class SdcNotificationWithSol004PackageTest extends BaseTest { * Mock the AAI using wireshark. */ private void initMockAaiServer(final String serviceUuid, final String serviceInvariantUuid) { - final String modelEndpoint = "/aai/v19/service-design-and-creation/models/model/" + serviceInvariantUuid + final String modelEndpoint = "/aai/v21/service-design-and-creation/models/model/" + serviceInvariantUuid + "/model-vers/model-ver/" + serviceUuid + "?depth=0"; wireMockServer.stubFor(post(urlEqualTo(modelEndpoint)).willReturn(ok())); diff --git a/asdc-controller/src/test/resources/resource-examples/vgw/ONBOARDED_PACKAGE/VENDOR_LICENSE/vendor-license-model.xml b/asdc-controller/src/test/resources/resource-examples/vgw/ETSI_PACKAGE/VENDOR_LICENSE/vendor-license-model.xml index 6499a58fab..6499a58fab 100644 --- a/asdc-controller/src/test/resources/resource-examples/vgw/ONBOARDED_PACKAGE/VENDOR_LICENSE/vendor-license-model.xml +++ b/asdc-controller/src/test/resources/resource-examples/vgw/ETSI_PACKAGE/VENDOR_LICENSE/vendor-license-model.xml diff --git a/asdc-controller/src/test/resources/resource-examples/vgw/ONBOARDED_PACKAGE/VF_LICENSE/vf-license-model.xml b/asdc-controller/src/test/resources/resource-examples/vgw/ETSI_PACKAGE/VF_LICENSE/vf-license-model.xml index 581a3acb7f..581a3acb7f 100644 --- a/asdc-controller/src/test/resources/resource-examples/vgw/ONBOARDED_PACKAGE/VF_LICENSE/vf-license-model.xml +++ b/asdc-controller/src/test/resources/resource-examples/vgw/ETSI_PACKAGE/VF_LICENSE/vf-license-model.xml diff --git a/asdc-controller/src/test/resources/resource-examples/vgw/ONBOARDED_PACKAGE/vgw6.csar b/asdc-controller/src/test/resources/resource-examples/vgw/ETSI_PACKAGE/vgw6.csar Binary files differindex 56dbb2bce0..56dbb2bce0 100644 --- a/asdc-controller/src/test/resources/resource-examples/vgw/ONBOARDED_PACKAGE/vgw6.csar +++ b/asdc-controller/src/test/resources/resource-examples/vgw/ETSI_PACKAGE/vgw6.csar diff --git a/asdc-controller/src/test/resources/resource-examples/vgw/SDC_RESOURCE_CSAR/vgw_sdc_resource.csar b/asdc-controller/src/test/resources/resource-examples/vgw/SDC_RESOURCE_CSAR/vgw_sdc_resource.csar Binary files differindex 7ddfb6ef51..9eb240d9a7 100644 --- a/asdc-controller/src/test/resources/resource-examples/vgw/SDC_RESOURCE_CSAR/vgw_sdc_resource.csar +++ b/asdc-controller/src/test/resources/resource-examples/vgw/SDC_RESOURCE_CSAR/vgw_sdc_resource.csar diff --git a/asdc-controller/src/test/resources/resource-examples/vgw/dmaap-notification-message.json b/asdc-controller/src/test/resources/resource-examples/vgw/dmaap-notification-message.json index d936cd1144..8c42c9c3e9 100644 --- a/asdc-controller/src/test/resources/resource-examples/vgw/dmaap-notification-message.json +++ b/asdc-controller/src/test/resources/resource-examples/vgw/dmaap-notification-message.json @@ -29,8 +29,8 @@ }, { "artifactName": "vgw6.csar", - "artifactType": "ONBOARDED_PACKAGE", - "artifactURL": "/ONBOARDED_PACKAGE/vgw6.csar", + "artifactType": "ETSI_PACKAGE", + "artifactURL": "/ETSI_PACKAGE/vgw6.csar", "artifactChecksum": "NjdmNGU3ZDlkODQ0YTUzMTU5NjZmOThiYjMxNTJiNGI\u003d", "artifactDescription": "Artifact created from csar", "artifactTimeout": 120, diff --git a/asdc-controller/src/test/resources/resource-examples/vgw/service-Vgwservicev1-csar.csar b/asdc-controller/src/test/resources/resource-examples/vgw/service-Vgwservicev1-csar.csar Binary files differindex 51a9e19466..eaed092b00 100644 --- a/asdc-controller/src/test/resources/resource-examples/vgw/service-Vgwservicev1-csar.csar +++ b/asdc-controller/src/test/resources/resource-examples/vgw/service-Vgwservicev1-csar.csar diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeallocateTransportNSSI.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeallocateTransportNSSI.bpmn index 94279b7fe8..bd759caffd 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeallocateTransportNSSI.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeallocateTransportNSSI.bpmn @@ -26,7 +26,7 @@ ex.processJavaException(execution)</bpmn:script> <bpmn:incoming>Flow_0ca4l8d</bpmn:incoming> </bpmn:endEvent> <bpmn:scriptTask id="ScriptTask_1ssh2l9" name="Prepare Update Resource Oper Status((finish)" scriptFormat="groovy"> - <bpmn:incoming>SequenceFlow_0kixzdj</bpmn:incoming> + <bpmn:incoming>SequenceFlow_1jygjln</bpmn:incoming> <bpmn:outgoing>SequenceFlow_1qv8qw1</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* def runScript = new TnAllocateNssi() @@ -34,15 +34,6 @@ runScript.prepareUpdateJobStatus(execution,"finished","100","Deallocated TN NSSI </bpmn:scriptTask> <bpmn:sequenceFlow id="SequenceFlow_03s744c" sourceRef="StartEvent_1nbljfd" targetRef="ScriptTask_1tc44ge" /> <bpmn:sequenceFlow id="SequenceFlow_1qv8qw1" sourceRef="ScriptTask_1ssh2l9" targetRef="Activity_0rgeefb" /> - <bpmn:scriptTask id="ScriptTask_19uxoi8" name="Update AAI Status" scriptFormat="groovy"> - <bpmn:incoming>SequenceFlow_1jygjln</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_0kixzdj</bpmn:outgoing> - <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* -execution.setVariable("orchestrationStatus", "deallocated") -def runScript = new DoDeallocateTnNssi() -runScript.updateAAIOrchStatus(execution)</bpmn:script> - </bpmn:scriptTask> - <bpmn:sequenceFlow id="SequenceFlow_0kixzdj" sourceRef="ScriptTask_19uxoi8" targetRef="ScriptTask_1ssh2l9" /> <bpmn:scriptTask id="Activity_1tw8eyy" name="PreProcess SDNC Deallocate TN NSSI Request" scriptFormat="groovy"> <bpmn:incoming>SequenceFlow_07e12rt</bpmn:incoming> <bpmn:outgoing>Flow_0cpctye</bpmn:outgoing> @@ -91,7 +82,7 @@ def runScript = new DoDeallocateTnNssi() runScript.preProcessRequest(execution)</bpmn:script> </bpmn:scriptTask> <bpmn:sequenceFlow id="SequenceFlow_07e12rt" sourceRef="ScriptTask_1tc44ge" targetRef="Activity_1tw8eyy" /> - <bpmn:sequenceFlow id="SequenceFlow_1jygjln" sourceRef="Activity_013rjwc" targetRef="ScriptTask_19uxoi8" /> + <bpmn:sequenceFlow id="SequenceFlow_1jygjln" sourceRef="Activity_013rjwc" targetRef="ScriptTask_1ssh2l9" /> <bpmn:serviceTask id="Activity_0rgeefb" name="Update Resource Operation Status"> <bpmn:extensionElements> <camunda:connector> @@ -121,6 +112,10 @@ runScript.preProcessRequest(execution)</bpmn:script> <bpmn:error id="Error_0p2naox" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoDeallocateTransportNSSI"> + <bpmndi:BPMNEdge id="Flow_0ca4l8d_di" bpmnElement="Flow_0ca4l8d"> + <di:waypoint x="840" y="350" /> + <di:waypoint x="1022" y="350" /> + </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_1jygjln_di" bpmnElement="SequenceFlow_1jygjln"> <di:waypoint x="360" y="350" /> <di:waypoint x="520" y="350" /> @@ -132,8 +127,8 @@ runScript.preProcessRequest(execution)</bpmn:script> <bpmndi:BPMNEdge id="Flow_1jdb2oq_di" bpmnElement="SequenceFlow_1jdb2oq"> <di:waypoint x="1080" y="121" /> <di:waypoint x="1220" y="121" /> - <di:waypoint x="1220" y="210" /> - <di:waypoint x="310" y="210" /> + <di:waypoint x="1220" y="230" /> + <di:waypoint x="310" y="230" /> <di:waypoint x="310" y="310" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_0fuabjs_di" bpmnElement="Flow_0fuabjs"> @@ -144,30 +139,31 @@ runScript.preProcessRequest(execution)</bpmn:script> <di:waypoint x="630" y="121" /> <di:waypoint x="729" y="121" /> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0kixzdj_di" bpmnElement="SequenceFlow_0kixzdj"> + <bpmndi:BPMNEdge id="SequenceFlow_1qv8qw1_di" bpmnElement="SequenceFlow_1qv8qw1"> <di:waypoint x="620" y="350" /> <di:waypoint x="740" y="350" /> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1qv8qw1_di" bpmnElement="SequenceFlow_1qv8qw1"> - <di:waypoint x="840" y="350" /> - <di:waypoint x="990" y="350" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_03s744c_di" bpmnElement="SequenceFlow_03s744c"> <di:waypoint x="214" y="121" /> <di:waypoint x="285" y="121" /> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="Flow_0ca4l8d_di" bpmnElement="Flow_0ca4l8d"> - <di:waypoint x="1090" y="350" /> - <di:waypoint x="1202" y="350" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="StartEvent_1nbljfd_di" bpmnElement="StartEvent_1nbljfd"> <dc:Bounds x="178" y="103" width="36" height="36" /> <bpmndi:BPMNLabel> <dc:Bounds x="166" y="146" width="70" height="53" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1ssh2l9_di" bpmnElement="ScriptTask_1ssh2l9"> + <dc:Bounds x="520" y="310" width="100" height="80" /> + </bpmndi:BPMNShape> <bpmndi:BPMNShape id="Activity_0rgeefb_di" bpmnElement="Activity_0rgeefb"> - <dc:Bounds x="990" y="310" width="100" height="80" /> + <dc:Bounds x="740" y="310" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_05h01gx_di" bpmnElement="EndEvent_05h01gx"> + <dc:Bounds x="1022" y="332" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1030" y="375" width="20" height="14" /> + </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="SubProcess_1yv9i68_di" bpmnElement="SubProcess_1yv9i68" isExpanded="true"> <dc:Bounds x="685" y="1080" width="781" height="196" /> @@ -189,18 +185,6 @@ runScript.preProcessRequest(execution)</bpmn:script> <bpmndi:BPMNShape id="ScriptTask_1swzdpw_di" bpmnElement="ScriptTask_1swzdpw"> <dc:Bounds x="979" y="1144" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="EndEvent_05h01gx_di" bpmnElement="EndEvent_05h01gx"> - <dc:Bounds x="1202" y="332" width="36" height="36" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="1210" y="375" width="20" height="14" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ScriptTask_1ssh2l9_di" bpmnElement="ScriptTask_1ssh2l9"> - <dc:Bounds x="740" y="310" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ScriptTask_19uxoi8_di" bpmnElement="ScriptTask_19uxoi8"> - <dc:Bounds x="520" y="310" width="100" height="80" /> - </bpmndi:BPMNShape> <bpmndi:BPMNShape id="Activity_1tw8eyy_di" bpmnElement="Activity_1tw8eyy"> <dc:Bounds x="509" y="74" width="121" height="94" /> </bpmndi:BPMNShape> diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/GraphInventoryResultWrapper.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/GraphInventoryResultWrapper.java index 9e6572388b..ae32107339 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/GraphInventoryResultWrapper.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/GraphInventoryResultWrapper.java @@ -28,6 +28,7 @@ import java.util.HashMap; import java.util.Map; import java.util.Optional; import org.onap.aaiclient.client.graphinventory.GraphInventoryCommonObjectMapperProvider; +import org.onap.aaiclient.client.graphinventory.GraphInventoryObjectName; import org.onap.so.jsonpath.JsonPathUtil; import org.slf4j.Logger; import com.fasterxml.jackson.core.JsonProcessingException; @@ -63,6 +64,15 @@ public abstract class GraphInventoryResultWrapper<R extends GraphInventoryRelati } } + public boolean hasRelationshipsTo(GraphInventoryObjectName name) { + Optional<R> rOpt = this.getRelationships(); + if (rOpt.isPresent()) { + return rOpt.get().getRelatedLinks(name).size() > 0; + } else { + return false; + } + } + public Optional<R> getRelationships() { final String path = "$.relationship-list"; if (isEmpty()) { diff --git a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/AAIResultWrapperTest.java b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/AAIResultWrapperTest.java index adc2e7284e..98431759de 100644 --- a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/AAIResultWrapperTest.java +++ b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/AAIResultWrapperTest.java @@ -21,8 +21,9 @@ package org.onap.aaiclient.client.aai.entities; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; import java.io.IOException; -import java.io.Serializable; import java.nio.file.Files; import java.nio.file.Paths; import java.util.HashMap; @@ -36,6 +37,7 @@ import org.junit.runner.RunWith; import org.mockito.junit.MockitoJUnitRunner; import org.onap.aai.domain.yang.GenericVnf; import org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types; import org.springframework.util.SerializationUtils; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.type.TypeReference; @@ -107,4 +109,11 @@ public class AAIResultWrapperTest { AAIResultWrapper wrapper = new AAIResultWrapper(new GenericVnf()); assertEquals("{}", wrapper.getJson()); } + + @Test + public void hasRelationshipToTest() { + assertTrue(aaiResultWrapper.hasRelationshipsTo(Types.VCE)); + assertFalse(aaiResultWrapper.hasRelationshipsTo(Types.CLASS_OF_SERVICE)); + + } } diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/CamundaDatabaseConfiguration.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/CamundaDatabaseConfiguration.java index c803808df1..770e91c1cb 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/CamundaDatabaseConfiguration.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/CamundaDatabaseConfiguration.java @@ -22,13 +22,17 @@ package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows; import static org.slf4j.LoggerFactory.getLogger; import javax.sql.DataSource; +import org.camunda.bpm.engine.spring.SpringProcessEngineConfiguration; +import org.camunda.bpm.spring.boot.starter.util.SpringBootProcessEnginePlugin; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.data.jpa.repository.config.EnableJpaRepositories; +import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.jmx.export.MBeanExporter; +import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.annotation.EnableTransactionManagement; import com.zaxxer.hikari.HikariConfig; import com.zaxxer.hikari.HikariDataSource; @@ -39,9 +43,10 @@ import com.zaxxer.hikari.HikariDataSource; */ @Configuration @EnableTransactionManagement -@EnableJpaRepositories(entityManagerFactoryRef = "entityManagerFactory", transactionManagerRef = "transactionManager") public class CamundaDatabaseConfiguration { + private static final String CAMUNDA_TRANSACTION_MANAGER_BEAN_NAME = "camundaTransactionManager"; + private static final String CAMUNDA_DATA_SOURCE_BEAN_NAME = "camundaBpmDataSource"; private static final Logger logger = getLogger(CamundaDatabaseConfiguration.class); @@ -66,4 +71,22 @@ public class CamundaDatabaseConfiguration { return new HikariDataSource(hikariConfig); } + @Bean(name = CAMUNDA_TRANSACTION_MANAGER_BEAN_NAME) + public PlatformTransactionManager camundaTransactionManager( + @Qualifier(CAMUNDA_DATA_SOURCE_BEAN_NAME) final DataSource dataSource) { + return new DataSourceTransactionManager(dataSource); + } + + @Bean + public SpringBootProcessEnginePlugin transactionManagerProcessEnginePlugin( + @Qualifier(CAMUNDA_TRANSACTION_MANAGER_BEAN_NAME) final PlatformTransactionManager camundaTransactionManager) { + return new SpringBootProcessEnginePlugin() { + @Override + public void preInit(final SpringProcessEngineConfiguration processEngineConfiguration) { + logger.info("Setting Camunda TransactionManager ..."); + processEngineConfiguration.setTransactionManager(camundaTransactionManager); + + } + }; + } } diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/service/JobExecutorService.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/service/JobExecutorService.java index 49118494cf..14d4fa2f07 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/service/JobExecutorService.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/service/JobExecutorService.java @@ -302,7 +302,7 @@ public class JobExecutorService { } private boolean isNotImmediateTerminateRequest(final TerminateNsRequest terminateNsRequest) { - return terminateNsRequest.getTerminationTime() != null; + return terminateNsRequest != null && terminateNsRequest.getTerminationTime() != null; } private boolean isNotInstantiated(final NfvoNsInst nfvoNsInst) { diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/AbstractNetworkServiceTask.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/AbstractNetworkServiceTask.java index e94b3de81e..a785a5199b 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/AbstractNetworkServiceTask.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/AbstractNetworkServiceTask.java @@ -19,9 +19,9 @@ */ package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.tasks; -import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME; import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.JOB_ID_PARAM_NAME; import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.NS_INSTANCE_ID_PARAM_NAME; +import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME; import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.OCC_ID_PARAM_NAME; import java.time.LocalDateTime; import java.util.Optional; @@ -31,7 +31,6 @@ import org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobStatusEnum; import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoJob; import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoJobStatus; import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNsInst; -import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NsLcmOpOcc; import org.onap.so.etsi.nfvo.ns.lcm.database.beans.OperationStateEnum; import org.onap.so.etsi.nfvo.ns.lcm.database.beans.State; import org.onap.so.etsi.nfvo.ns.lcm.database.service.DatabaseServiceProvider; @@ -109,21 +108,8 @@ public abstract class AbstractNetworkServiceTask { public void updateNsLcmOpOccStatusToCompleted(final DelegateExecution execution) { logger.info("Executing updateNsLcmOpOccStatusToCompleted ..."); - final String occId = (String) execution.getVariable(OCC_ID_PARAM_NAME); - final Optional<NsLcmOpOcc> optional = databaseServiceProvider.getNsLcmOpOcc(occId); - - if (optional.isEmpty()) { - final String message = "Unable to find record for NSLcmOpOcc in database using id: " + occId; - logger.error(message); - abortOperation(execution, message); - } - - final NsLcmOpOcc nsLcmOpOcc = optional.get(); - final OperationStateEnum operationStateCompleted = OperationStateEnum.COMPLETED; - logger.info("Setting operation state to {} for id: {}", operationStateCompleted, occId); - nsLcmOpOcc.setOperationState(operationStateCompleted); - databaseServiceProvider.addNSLcmOpOcc(nsLcmOpOcc); + updateNsLcmOpOccOperationState(execution, OperationStateEnum.COMPLETED); logger.info("Finished executing updateNsLcmOpOccStatusToCompleted ..."); @@ -131,20 +117,8 @@ public abstract class AbstractNetworkServiceTask { public void updateNsLcmOpOccStatusToFailed(final DelegateExecution execution) { logger.info("Executing updateNsLcmOpOccStatusToFailed ..."); - final String occId = (String) execution.getVariable(OCC_ID_PARAM_NAME); - - final Optional<NsLcmOpOcc> optional = databaseServiceProvider.getNsLcmOpOcc(occId); - if (optional.isPresent()) { - final NsLcmOpOcc nsLcmOpOcc = optional.get(); - final OperationStateEnum operationStateFailed = OperationStateEnum.FAILED; - logger.info("Setting operation state to {} for id: {}", operationStateFailed, occId); - nsLcmOpOcc.setOperationState(operationStateFailed); - - databaseServiceProvider.addNSLcmOpOcc(nsLcmOpOcc); - } else { - logger.error("Unable to find record for NSLcmOpOcc in database using id: {}", occId); - } + updateNsLcmOpOccOperationState(execution, OperationStateEnum.FAILED); logger.info("Finished executing updateNsLcmOpOccStatusToFailed ..."); @@ -154,6 +128,19 @@ public abstract class AbstractNetworkServiceTask { abortOperation(execution, message, new InlineResponse400().detail(message)); } + private void updateNsLcmOpOccOperationState(final DelegateExecution execution, + final OperationStateEnum operationState) { + final String occId = (String) execution.getVariable(OCC_ID_PARAM_NAME); + + final boolean isSuccessful = databaseServiceProvider.updateNsLcmOpOccOperationState(occId, operationState); + if (!isSuccessful) { + final String message = + "Unable to update NsLcmOpOcc " + occId + " operationState to" + operationState + " in database"; + logger.error(message); + abortOperation(execution, message); + } + } + protected void abortOperation(final DelegateExecution execution, final String message, final InlineResponse400 problemDetails) { logger.error(message); @@ -175,10 +162,10 @@ public abstract class AbstractNetworkServiceTask { } protected void updateNsInstanceStatus(final DelegateExecution execution, final State nsStatus) { - final NfvoNsInst nfvoNsInst = getNfvoNsInst(execution); + final String nsInstId = (String) execution.getVariable(NS_INSTANCE_ID_PARAM_NAME); + logger.info("Updating NfvoNsInst Status to {} and saving to DB", nsStatus); - nfvoNsInst.setStatus(nsStatus); - databaseServiceProvider.saveNfvoNsInst(nfvoNsInst); + databaseServiceProvider.updateNsInstState(nsInstId, nsStatus); } protected NfvoNsInst getNfvoNsInst(final DelegateExecution execution) { diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/CreateInstantiateVnfTask.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/CreateInstantiateVnfTask.java index 600792acc0..0d4cbbe24f 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/CreateInstantiateVnfTask.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/CreateInstantiateVnfTask.java @@ -195,7 +195,7 @@ public class CreateInstantiateVnfTask extends AbstractNetworkServiceTask { } public void updateNfInstanceStatusToFailed(final DelegateExecution execution) { - logger.info("Executing updateNfInstanceStatusToActive"); + logger.info("Executing updateNfInstanceStatusToFailed"); updateNfInstanceStatus(execution, State.FAILED); final CreateInstantiateRequest request = @@ -203,22 +203,19 @@ public class CreateInstantiateVnfTask extends AbstractNetworkServiceTask { addJobStatus(execution, ERROR, "Failed to create and instantiate VNF: " + request.getVnfName() + " will set status to " + State.FAILED); - logger.info("Finished executing updateNfInstanceStatusToInstantiated ..."); + logger.info("Finished executing updateNfInstanceStatusToFailed ..."); } private void updateNfInstanceStatus(final DelegateExecution execution, final State vnfStatus) { final String nfInstId = (String) execution.getVariable(NF_INST_ID_PARAM_NAME); - final Optional<NfvoNfInst> optional = databaseServiceProvider.getNfvoNfInst(nfInstId); - if (optional.isEmpty()) { - final String message = "Unable to find NfvoNfInst record in database using nfInstId: " + nfInstId; + final boolean isSuccessful = databaseServiceProvider.updateNfInstState(nfInstId, vnfStatus); + if (!isSuccessful) { + final String message = + "Unable to update NfvoNfInst " + nfInstId + " status to" + vnfStatus + " in database"; logger.error(message); abortOperation(execution, message); } - - final NfvoNfInst nfvoNfInst = optional.get(); - nfvoNfInst.setStatus(vnfStatus); - databaseServiceProvider.saveNfvoNfInst(nfvoNfInst); } } diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/TerminateVnfTask.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/TerminateVnfTask.java index 049a6f38b0..f3e7eea212 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/TerminateVnfTask.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/TerminateVnfTask.java @@ -31,7 +31,6 @@ import org.onap.so.adapters.etsisol003adapter.lcm.v1.model.DeleteVnfResponse; import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.aai.AaiServiceProvider; import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.vnfm.Sol003AdapterServiceProvider; import org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobStatusEnum; -import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNfInst; import org.onap.so.etsi.nfvo.ns.lcm.database.beans.State; import org.onap.so.etsi.nfvo.ns.lcm.database.service.DatabaseServiceProvider; import org.slf4j.Logger; @@ -170,16 +169,12 @@ public class TerminateVnfTask extends AbstractNetworkServiceTask { private void updateNfInstanceStatus(final DelegateExecution execution, final State vnfStatus) { final String vnfId = (String) execution.getVariable(TERMINATE_VNF_VNFID_PARAM_NAME); - final Optional<NfvoNfInst> optional = databaseServiceProvider.getNfvoNfInst(vnfId); - if (optional.isEmpty()) { - final String message = "Unable to find NfvoNfInst record in database using vnfId: " + vnfId; + final boolean isSuccessful = databaseServiceProvider.updateNfInstState(vnfId, vnfStatus); + if (!isSuccessful) { + final String message = "Unable to update NfvoNfInst " + vnfId + " status to" + vnfStatus + " in database"; logger.error(message); abortOperation(execution, message); } - - final NfvoNfInst nfvoNfInst = optional.get(); - nfvoNfInst.setStatus(vnfStatus); - databaseServiceProvider.saveNfvoNfInst(nfvoNfInst); } } diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/BaseTest.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/BaseTest.java index b6fd9e407a..1a89f75a70 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/BaseTest.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/BaseTest.java @@ -67,7 +67,7 @@ public abstract class BaseTest { protected static final Logger logger = getLogger(BaseTest.class); - private static final long TIME_OUT_IN_SECONDS = 60; + private static final long TIME_OUT_IN_SECONDS = 120; private static final int SLEEP_TIME_IN_SECONDS = 5; @Autowired diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/workflow/engine/tasks/DeleteNsTaskTest.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/workflow/engine/tasks/DeleteNsTaskTest.java index adb8a9e69b..017bdf6b70 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/workflow/engine/tasks/DeleteNsTaskTest.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/workflow/engine/tasks/DeleteNsTaskTest.java @@ -19,7 +19,17 @@ */ package org.onap.so.etsi.nfvo.ns.workflow.engine.tasks; -import com.google.gson.Gson; +import static com.github.tomakehurst.wiremock.client.WireMock.delete; +import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.ok; +import static com.github.tomakehurst.wiremock.client.WireMock.okJson; +import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import java.time.LocalDateTime; +import java.util.Optional; +import java.util.UUID; import org.camunda.bpm.engine.history.HistoricProcessInstance; import org.junit.After; import org.junit.Before; @@ -27,24 +37,12 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.BaseTest; -import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.GsonProvider; import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.exceptions.NsRequestProcessingException; import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.service.JobExecutorService; import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoJob; import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNsInst; import org.onap.so.etsi.nfvo.ns.lcm.database.beans.State; import org.springframework.beans.factory.annotation.Autowired; -import java.time.LocalDateTime; -import java.util.Optional; -import java.util.UUID; -import static com.github.tomakehurst.wiremock.client.WireMock.delete; -import static com.github.tomakehurst.wiremock.client.WireMock.get; -import static com.github.tomakehurst.wiremock.client.WireMock.ok; -import static com.github.tomakehurst.wiremock.client.WireMock.okJson; -import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; /** * @author Andrew Lamb (andrew.a.lamb@est.tech) @@ -55,18 +53,12 @@ public class DeleteNsTaskTest extends BaseTest { @Autowired private JobExecutorService objUnderTest; - @Autowired - private GsonProvider gsonProvider; - @Rule public ExpectedException expectedException = ExpectedException.none(); - private Gson gson; - @Before public void before() { wireMockServer.resetAll(); - gson = gsonProvider.getGson(); } @After diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/workflow/engine/tasks/TerminateNsTaskTest.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/workflow/engine/tasks/TerminateNsTaskTest.java index b821c85edd..51460ec4c8 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/workflow/engine/tasks/TerminateNsTaskTest.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/workflow/engine/tasks/TerminateNsTaskTest.java @@ -19,7 +19,25 @@ */ package org.onap.so.etsi.nfvo.ns.workflow.engine.tasks; -import com.google.gson.Gson; +import static com.github.tomakehurst.wiremock.client.WireMock.delete; +import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.ok; +import static com.github.tomakehurst.wiremock.client.WireMock.okJson; +import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.vnfm.Sol003AdapterConfiguration.SOL003_ADAPTER_REST_TEMPLATE_BEAN; +import static org.springframework.test.web.client.ExpectedCount.times; +import static org.springframework.test.web.client.match.MockRestRequestMatchers.method; +import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo; +import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess; +import java.io.IOException; +import java.time.LocalDateTime; +import java.util.List; +import java.util.Optional; +import java.util.UUID; import org.camunda.bpm.engine.history.HistoricProcessInstance; import org.hamcrest.text.MatchesPattern; import org.junit.After; @@ -47,26 +65,7 @@ import org.springframework.http.MediaType; import org.springframework.http.converter.json.GsonHttpMessageConverter; import org.springframework.test.web.client.MockRestServiceServer; import org.springframework.web.client.RestTemplate; -import java.io.IOException; -import java.time.LocalDateTime; -import java.util.List; -import java.util.Optional; -import java.util.UUID; -import static com.github.tomakehurst.wiremock.client.WireMock.delete; -import static com.github.tomakehurst.wiremock.client.WireMock.get; -import static com.github.tomakehurst.wiremock.client.WireMock.ok; -import static com.github.tomakehurst.wiremock.client.WireMock.okJson; -import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching; -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.etsicatalog.EtsiCatalogServiceProviderConfiguration.ETSI_CATALOG_REST_TEMPLATE_BEAN; -import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.vnfm.Sol003AdapterConfiguration.SOL003_ADAPTER_REST_TEMPLATE_BEAN; -import static org.springframework.test.web.client.ExpectedCount.times; -import static org.springframework.test.web.client.match.MockRestRequestMatchers.method; -import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo; -import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess; +import com.google.gson.Gson; /** * @author Andrew Lamb (andrew.a.lamb@est.tech) diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/resources/application.yaml b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/resources/application.yaml index 1fabfbaac9..101e17a791 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/resources/application.yaml +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/resources/application.yaml @@ -42,7 +42,7 @@ etsi-catalog-manager: endpoint: http://modeling-etsicatalog.onap:8806/api so-etsi-ns-lcm-workflow-engine: requesttimeout: - timeoutInSeconds: 60 + timeoutInSeconds: 120 logging: level: diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NSLcmOpOccRepository.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NSLcmOpOccRepository.java index 696c7be5dd..d7f2f4cefa 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NSLcmOpOccRepository.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NSLcmOpOccRepository.java @@ -19,15 +19,24 @@ */ package org.onap.so.etsi.nfvo.ns.lcm.database.repository; -import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NsLcmOpOcc; -import org.springframework.data.repository.CrudRepository; import java.util.Optional; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NsLcmOpOcc; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.OperationStateEnum; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Modifying; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; /** * @author Waqas Ikram (waqas.ikram@est.tech) * @author mukeshsharma(mukeshsharma@est.tech) */ -public interface NSLcmOpOccRepository extends CrudRepository<NsLcmOpOcc, String> { +public interface NSLcmOpOccRepository extends JpaRepository<NsLcmOpOcc, String> { Optional<NsLcmOpOcc> findById(final String id); + + @Modifying(clearAutomatically = true) + @Query("UPDATE NsLcmOpOcc SET operationState = (:operationState) WHERE id = (:id)") + int updateNsLcmOpOccOperationState(@Param("id") final String id, + @Param("operationState") final OperationStateEnum operationState); } diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NfvoJobRepository.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NfvoJobRepository.java index 2d6d033689..220902c631 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NfvoJobRepository.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NfvoJobRepository.java @@ -21,13 +21,13 @@ package org.onap.so.etsi.nfvo.ns.lcm.database.repository; import java.util.Optional; import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoJob; -import org.springframework.data.repository.CrudRepository; +import org.springframework.data.jpa.repository.JpaRepository; /** * @author Waqas Ikram (waqas.ikram@est.tech) * */ -public interface NfvoJobRepository extends CrudRepository<NfvoJob, String>, RefreshableRepository<NfvoJob> { +public interface NfvoJobRepository extends JpaRepository<NfvoJob, String>, RefreshableRepository<NfvoJob> { Optional<NfvoJob> findByResourceId(final String resourceId); diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NfvoNfInstRepository.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NfvoNfInstRepository.java index de14d43de4..f91a85f2e6 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NfvoNfInstRepository.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NfvoNfInstRepository.java @@ -22,17 +22,29 @@ package org.onap.so.etsi.nfvo.ns.lcm.database.repository; import java.util.List; import java.util.Optional; import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNfInst; -import org.springframework.data.repository.CrudRepository; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.State; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Modifying; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; /** * @author Waqas Ikram (waqas.ikram@est.tech) * @author mukeshsharma(mukeshsharma@est.tech) */ -public interface NfvoNfInstRepository extends CrudRepository<NfvoNfInst, String> { +public interface NfvoNfInstRepository extends JpaRepository<NfvoNfInst, String> { Optional<NfvoNfInst> findByNfInstId(final String nfInstId); List<NfvoNfInst> findByNsInstNsInstId(final String nsInstId); List<NfvoNfInst> findByNsInstNsInstIdAndName(final String nsInstId, final String name); + + @Modifying(clearAutomatically = true) + @Query("UPDATE NfvoNfInst SET status = (:state) WHERE nfInstId = (:nfInstId)") + int updateNfInstState(@Param("nfInstId") final String nfInstId, @Param("state") final State state); + + @Modifying(clearAutomatically = true) + @Query("DELETE FROM NfvoNfInst WHERE nfInstId = (:nfInstId)") + void deleteNfvoNfInstUsingNfInstId(@Param("nfInstId") final String nfInstId); } diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NfvoNsInstRepository.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NfvoNsInstRepository.java index beeeacf8cf..a64cf9bdd5 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NfvoNsInstRepository.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NfvoNsInstRepository.java @@ -21,13 +21,17 @@ package org.onap.so.etsi.nfvo.ns.lcm.database.repository; import java.util.Optional; import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNsInst; -import org.springframework.data.repository.CrudRepository; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.State; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Modifying; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; /** * @author Waqas Ikram (waqas.ikram@est.tech) * */ -public interface NfvoNsInstRepository extends CrudRepository<NfvoNsInst, String> { +public interface NfvoNsInstRepository extends JpaRepository<NfvoNsInst, String> { Optional<NfvoNsInst> findByName(final String name); @@ -35,5 +39,8 @@ public interface NfvoNsInstRepository extends CrudRepository<NfvoNsInst, String> boolean existsNfvoNsInstByName(final String name); + @Modifying(clearAutomatically = true) + @Query("UPDATE NfvoNsInst SET status = (:state) WHERE nsInstId = (:nsInstId)") + int updateNsInstState(@Param("nsInstId") final String nsInstId, @Param("state") final State state); } diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/service/DatabaseServiceProvider.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/service/DatabaseServiceProvider.java index 1487b630c7..ec8777d0fa 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/service/DatabaseServiceProvider.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/service/DatabaseServiceProvider.java @@ -25,6 +25,8 @@ import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoJob; import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNfInst; import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNsInst; import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NsLcmOpOcc; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.OperationStateEnum; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.State; import org.onap.so.etsi.nfvo.ns.lcm.database.repository.NSLcmOpOccRepository; import org.onap.so.etsi.nfvo.ns.lcm.database.repository.NfvoJobRepository; import org.onap.so.etsi.nfvo.ns.lcm.database.repository.NfvoNfInstRepository; @@ -66,7 +68,7 @@ public class DatabaseServiceProvider { public boolean addJob(final NfvoJob job) { logger.info("Adding NfvoJob: {} to database", job); - return nfvoJobRepository.save(job) != null; + return nfvoJobRepository.saveAndFlush(job) != null; } public Optional<NfvoJob> getJob(final String jobId) { @@ -102,7 +104,13 @@ public class DatabaseServiceProvider { public boolean saveNfvoNsInst(final NfvoNsInst nfvoNsInst) { logger.info("Saving NfvoNsInst: {} to database", nfvoNsInst); - return nfvoNsInstRepository.save(nfvoNsInst) != null; + return nfvoNsInstRepository.saveAndFlush(nfvoNsInst) != null; + } + + @Transactional(propagation = Propagation.REQUIRES_NEW) + public boolean updateNsInstState(final String nsInstId, final State state) { + logger.info("Updating NfvoNsInst: {} State to {}", nsInstId, state); + return nfvoNsInstRepository.updateNsInstState(nsInstId, state) > 0; } public Optional<NfvoNsInst> getNfvoNsInst(final String nsInstId) { @@ -117,7 +125,13 @@ public class DatabaseServiceProvider { public boolean saveNfvoNfInst(final NfvoNfInst nfvoNfInst) { logger.info("Saving NfvoNfInst: {} to database", nfvoNfInst); - return nfvoNfInstRepository.save(nfvoNfInst) != null; + return nfvoNfInstRepository.saveAndFlush(nfvoNfInst) != null; + } + + @Transactional(propagation = Propagation.REQUIRES_NEW) + public boolean updateNfInstState(final String nfInstId, final State state) { + logger.info("Updating NfvoNfInst: {} State to {}", nfInstId, state); + return nfvoNfInstRepository.updateNfInstState(nfInstId, state) > 0; } public List<NfvoNfInst> getNfvoNfInstByNsInstId(final String nsInstId) { @@ -140,14 +154,21 @@ public class DatabaseServiceProvider { return nfvoNfInstRepository.findByNfInstId(nfInstId).isPresent(); } + @Transactional(propagation = Propagation.REQUIRES_NEW) public void deleteNfvoNfInst(final String nfInstId) { logger.info("Deleting NfvoNfInst with nfInstId: {} from database", nfInstId); - nfvoNfInstRepository.deleteById(nfInstId); + nfvoNfInstRepository.deleteNfvoNfInstUsingNfInstId(nfInstId); } public boolean addNSLcmOpOcc(final NsLcmOpOcc nsLcmOpOcc) { logger.info("Adding NSLcmOpOcc: {} to database", nsLcmOpOcc); - return nsLcmOpOccRepository.save(nsLcmOpOcc) != null; + return nsLcmOpOccRepository.saveAndFlush(nsLcmOpOcc) != null; + } + + @Transactional(propagation = Propagation.REQUIRES_NEW) + public boolean updateNsLcmOpOccOperationState(final String id, final OperationStateEnum operationState) { + logger.info("Updating NsLcmOpOcc: {} operationState to {}", id, operationState); + return nsLcmOpOccRepository.updateNsLcmOpOccOperationState(id, operationState) > 0; } public Optional<NsLcmOpOcc> getNsLcmOpOcc(final String id) { diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLifecycleManagementController.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLifecycleManagementController.java index 2390cef564..4d6f92c373 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLifecycleManagementController.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLifecycleManagementController.java @@ -145,7 +145,7 @@ public class NsLifecycleManagementController { produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}, consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) public ResponseEntity<Void> terminateNs(@PathVariable("nsInstanceId") final String nsInstanceId, - @RequestBody final TerminateNsRequest terminateNsRequest) { + @RequestBody(required = false) final TerminateNsRequest terminateNsRequest) { logger.debug("Received terminate NS request: {}\n with nsInstanceId: {}", terminateNsRequest, nsInstanceId); final URI resourceUri = nsLifeCycleManager.terminateNs(nsInstanceId, terminateNsRequest); logger.info("{} Ns Terminate started successfully. Resource Operation Occurrence uri: {}", nsInstanceId, |