diff options
Diffstat (limited to 'bpmn')
62 files changed, 1651 insertions, 294 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java index 025b533dc0..750f25532c 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -154,7 +156,7 @@ public class ResourceRequestBuilder { } } - if (resourceInputStr != null || !resourceInputStr.equals("")) { + if (resourceInputStr != null && !resourceInputStr.isEmpty()) { return getResourceInput(resourceInputStr, serviceInputs); } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/homingobjects/Candidate.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/homingobjects/Candidate.java index 91cd2ad791..a727162415 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/homingobjects/Candidate.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/homingobjects/Candidate.java @@ -31,10 +31,10 @@ public class Candidate implements Serializable { private static final long serialVersionUID = -3959572501582849328L; - @JsonProperty("candidateType") - private CandidateType candidateType; - @JsonProperty("candidates") - private List<String> candidates; + @JsonProperty("identifierType") + private CandidateType identifierType; + @JsonProperty("identifiers") + private List<String> identifiers; @JsonProperty("cloudOwner") private String cloudOwner; @@ -42,32 +42,32 @@ public class Candidate implements Serializable { * list of candidates * i.e. actual serviceInstanceId, actual vnfName, actual cloudRegionId, etc. */ - public List<String> getCandidates() { - return candidates; + public List<String> getIdentifiers() { + return identifiers; } /** * list of candidates * i.e. actual serviceInstanceId, actual vnfName, actual cloudRegionId, etc. */ - public void setCandidates(List<String> candidates) { - this.candidates = candidates; + public void setIdentifiers(List<String> identifiers) { + this.identifiers = identifiers; } /** * Way to identify the type of candidate * i.e. "serviceInstanceId", "vnfName", "cloudRegionId", etc. */ - public CandidateType getCandidateType(){ - return candidateType; + public CandidateType getIdentifierType(){ + return identifierType; } /** * Way to identify the type of candidate * i.e. "serviceInstanceId", "vnfName", "cloudRegionId", etc. */ - public void setCandidateType(CandidateType candidateType){ - this.candidateType = candidateType; + public void setIdentifierType(CandidateType identifierType){ + this.identifierType = identifierType; } /** diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/homingobjects/CandidateType.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/homingobjects/CandidateType.java index f1534ab60f..6a4fa50020 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/homingobjects/CandidateType.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/homingobjects/CandidateType.java @@ -20,6 +20,8 @@ package org.onap.so.bpmn.servicedecomposition.homingobjects; +import com.fasterxml.jackson.annotation.JsonValue; + public enum CandidateType{ @@ -35,11 +37,8 @@ public enum CandidateType{ } @Override + @JsonValue public String toString() { return name; } - - public String getName(){ - return name; - } } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java index ca0a78a3f2..fbff0620a3 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java @@ -406,17 +406,16 @@ public class BBInputSetup implements JavaDelegate { if (lookupKeyMap.get(ResourceKey.VF_MODULE_ID) != null && vfModuleTemp.getVfModuleId().equalsIgnoreCase(lookupKeyMap.get(ResourceKey.VF_MODULE_ID))) { vfModule = vfModuleTemp; - String vfModuleCustId = bbInputSetupUtils.getAAIVfModule(vnf.getVnfId(), vfModule.getVfModuleId()).getModelCustomizationId(); - modelInfo.setModelCustomizationId(vfModuleCustId); - break; } + String vfModuleCustId = bbInputSetupUtils.getAAIVfModule(vnf.getVnfId(), vfModuleTemp.getVfModuleId()).getModelCustomizationId(); + ModelInfo modelInfoVfModule = new ModelInfo(); + modelInfoVfModule.setModelCustomizationId(vfModuleCustId); + mapCatalogVfModule(vfModuleTemp, modelInfoVfModule, service, vnfModelCustomizationUUID); } if (vfModule == null && bbName.equalsIgnoreCase(AssignFlows.VF_MODULE.toString())) { vfModule = createVfModule(lookupKeyMap, resourceId, instanceName, instanceParams); vnf.getVfModules().add(vfModule); - } - if(vfModule != null) { mapCatalogVfModule(vfModule, modelInfo, service, vnfModelCustomizationUUID); } } else { diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java index b210b5ed2f..ee7999f995 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java @@ -55,6 +55,7 @@ public class ExecuteBuildingBlockRainyDay { private Environment environment; protected String retryDurationPath = "mso.rainyDay.retryDurationMultiplier"; protected String defaultCode = "mso.rainyDay.defaultCode"; + protected String maxRetries = "mso.rainyDay.maxRetries"; public void setRetryTimer(DelegateExecution execution) { try { @@ -172,10 +173,17 @@ public class ExecuteBuildingBlockRainyDay { msoLogger.debug("RainyDayHandler Status Code is: " + handlingCode); execution.setVariable(HANDLING_CODE, handlingCode); } catch (Exception e) { - msoLogger.error("Failed to determine RainyDayHandler Status. Seting handlingCode = Abort", e); String code = this.environment.getProperty(defaultCode); + msoLogger.error("Failed to determine RainyDayHandler Status. Seting handlingCode = "+ code, e); execution.setVariable(HANDLING_CODE, code); } + try{ + int envMaxRetries = Integer.parseInt(this.environment.getProperty(maxRetries)); + execution.setVariable("maxRetries", envMaxRetries); + } catch (Exception ex) { + msoLogger.error("Could not read maxRetries from config file. Setting max to 5 retries"); + execution.setVariable("maxRetries", 5); + } } public void setHandlingStatusSuccess(DelegateExecution execution) { diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/dmaapproperties/GlobalDmaapPublisher.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/dmaapproperties/GlobalDmaapPublisher.java index 382852886e..17b99e2741 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/dmaapproperties/GlobalDmaapPublisher.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/dmaapproperties/GlobalDmaapPublisher.java @@ -38,22 +38,21 @@ public class GlobalDmaapPublisher extends DmaapPublisher { } @Override - public String getUserName() { + public String getAuth() { - return UrnPropertiesReader.getVariable("mso.global.dmaap.username"); + return UrnPropertiesReader.getVariable("mso.global.dmaap.auth"); } @Override - public String getPassword() { + public String getKey() { - return UrnPropertiesReader.getVariable("mso.global.dmaap.password"); + return UrnPropertiesReader.getVariable("mso.msoKey"); } @Override public String getTopic() { - return UrnPropertiesReader.getVariable("mso.global.dmaap.publisher.topic"); } diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModuleTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModuleTest.groovy index 55f68f665e..dac038fab3 100644 --- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModuleTest.groovy +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModuleTest.groovy @@ -97,7 +97,7 @@ class CreateAAIVfModuleTest extends MsoGroovyTest{ @Test void testCreateGenericVnf(){ when(mockExecution.getVariable("CAAIVfMod_vnfName")).thenReturn("vnfName") - Mockito.doNothing().when(client).create(any(AAIResourceUri.class),anyObject()) + Mockito.doNothing().when(client).create(any(AAIResourceUri.class) as AAIResourceUri,anyObject()) createAAIVfModule.createGenericVnf(mockExecution) Mockito.verify(mockExecution).setVariable("CAAIVfMod_createGenericVnfResponseCode", 201) Mockito.verify(mockExecution).setVariable("CAAIVfMod_createGenericVnfResponse","Vnf Created") @@ -112,7 +112,7 @@ class CreateAAIVfModuleTest extends MsoGroovyTest{ when(mockExecution.getVariable("CAAIVfMod_personaId")).thenReturn("model1") when(mockExecution.getVariable("CAAIVfMod_moduleName")).thenReturn("vfModuleName") - Mockito.doNothing().when(client).create(any(AAIResourceUri.class),anyObject()) + Mockito.doNothing().when(client).create(any(AAIResourceUri.class) as AAIResourceUri,anyObject()) createAAIVfModule.createVfModule(mockExecution,false) Mockito.verify(mockExecution).setVariable("CAAIVfMod_createVfModuleResponseCode", 201) Mockito.verify(mockExecution).setVariable("CAAIVfMod_createVfModuleResponse","Vf Module Created") @@ -173,7 +173,7 @@ class CreateAAIVfModuleTest extends MsoGroovyTest{ Optional<GenericVnf> genericVnf = getAAIObjectFromJson(GenericVnf.class,"__files/aai/GenericVnfVfModule.json"); when(mockExecution.getVariable("CAAIVfMod_queryGenericVnfResponse")).thenReturn(genericVnf.get()) when(mockExecution.getVariable("CAAIVfMod_moduleName")).thenReturn("vfModuleName") - Mockito.doNothing().when(client).create(any(AAIResourceUri.class),anyObject()) + Mockito.doNothing().when(client).create(any(AAIResourceUri.class) as AAIResourceUri,anyObject()) createAAIVfModule.createVfModule(mockExecution,true) Mockito.verify(mockExecution).setVariable("CAAIVfMod_createVfModuleResponseCode", 201) Mockito.verify(mockExecution).setVariable("CAAIVfMod_createVfModuleResponse","Vf Module Created") diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModuleTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModuleTest.groovy index 4b6f8aa918..2a872511e7 100644 --- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModuleTest.groovy +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModuleTest.groovy @@ -92,7 +92,7 @@ class DeleteAAIVfModuleTest extends MsoGroovyTest{ void testDeleteGenericVnf() { ExecutionEntity mockExecution = setupMock() when(mockExecution.getVariable("DAAIVfMod_vnfId")).thenReturn("vnfId1") - doNothing().when(client).delete(isA(AAIResourceUri.class)) + doNothing().when(client).delete(isA(AAIResourceUri.class) as AAIResourceUri) deleteAAIVfModule.deleteGenericVnf(mockExecution) Mockito.verify(mockExecution).setVariable(prefix + "deleteGenericVnfResponseCode", 200) } @@ -169,7 +169,7 @@ class DeleteAAIVfModuleTest extends MsoGroovyTest{ ExecutionEntity mockExecution = setupMock() when(mockExecution.getVariable("DAAIVfMod_vnfId")).thenReturn("vnfId1") try { - doThrow(new NotFoundException("Vnf Not Found")).when(client).delete(isA(AAIResourceUri.class)) + doThrow(new NotFoundException("Vnf Not Found")).when(client).delete(isA(AAIResourceUri.class) as AAIResourceUri) deleteAAIVfModule.deleteGenericVnf(mockExecution) } catch (Exception ex) { println " Test End - Handle catch-throw BpmnError()! " @@ -186,7 +186,7 @@ class DeleteAAIVfModuleTest extends MsoGroovyTest{ ExecutionEntity mockExecution = setupMock() when(mockExecution.getVariable("DAAIVfMod_vnfId")).thenReturn("vnfId1") when(mockExecution.getVariable("DAAIVfMod_vfModuleId")).thenReturn("vfModuleId1") - doNothing().when(client).delete(isA(AAIResourceUri.class)) + doNothing().when(client).delete(isA(AAIResourceUri.class) as AAIResourceUri) deleteAAIVfModule.deleteVfModule(mockExecution) Mockito.verify(mockExecution).setVariable(prefix + "deleteVfModuleResponseCode", 200) } @@ -197,7 +197,7 @@ class DeleteAAIVfModuleTest extends MsoGroovyTest{ when(mockExecution.getVariable("DAAIVfMod_vnfId")).thenReturn("vnfId1") when(mockExecution.getVariable("DAAIVfMod_vfModuleId")).thenReturn("vfModuleId1") try { - doThrow(new NotFoundException("Vnf Not Found")).when(client).delete(isA(AAIResourceUri.class)) + doThrow(new NotFoundException("Vnf Not Found")).when(client).delete(isA(AAIResourceUri.class) as AAIResourceUri) deleteAAIVfModule.deleteVfModule(mockExecution) } catch (Exception ex) { println " Test End - Handle catch-throw BpmnError()! " diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModuleTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModuleTest.groovy index 2d2f58b415..72bcfcf359 100644 --- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModuleTest.groovy +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModuleTest.groovy @@ -111,7 +111,7 @@ class UpdateAAIVfModuleTest extends MsoGroovyTest { vfModule.setVfModuleId("supercool") vfModule.setResourceVersion("12345") when(mockExecution.getVariable(prefix + "getVfModuleResponse")).thenReturn(vfModule) - doNothing().when(client).update(isA(AAIResourceUri.class), anyObject()) + doNothing().when(client).update(isA(AAIResourceUri.class) as AAIResourceUri, anyObject()) updateAAIVfModule.updateVfModule(mockExecution) verify(mockExecution).setVariable("UAAIVfMod_updateVfModuleResponseCode", 200) } @@ -126,7 +126,7 @@ class UpdateAAIVfModuleTest extends MsoGroovyTest { vfModule.setVfModuleId("supercool") vfModule.setResourceVersion("12345") when(mockExecution.getVariable(prefix + "getVfModuleResponse")).thenReturn(vfModule) - doThrow(new NotFoundException("Vf Module not found")).when(client).update(isA(AAIResourceUri.class), anyObject()) + doThrow(new NotFoundException("Vf Module not found")).when(client).update(isA(AAIResourceUri.class) as AAIResourceUri, anyObject()) thrown.expect(BpmnError.class) updateAAIVfModule.updateVfModule(mockExecution) verify(mockExecution).setVariable("UAAIVfMod_updateVfModuleResponseCode", 404) @@ -143,7 +143,7 @@ class UpdateAAIVfModuleTest extends MsoGroovyTest { vfModule.setVfModuleId("supercool") vfModule.setResourceVersion("12345") when(mockExecution.getVariable(prefix + "getVfModuleResponse")).thenReturn(vfModule) - doThrow(new IllegalStateException("Error in AAI client")).when(client).update(isA(AAIResourceUri.class), anyObject()) + doThrow(new IllegalStateException("Error in AAI client")).when(client).update(isA(AAIResourceUri.class) as AAIResourceUri, anyObject()) thrown.expect(BpmnError.class) updateAAIVfModule.updateVfModule(mockExecution) verify(mockExecution).setVariable("UAAIVfMod_updateVfModuleResponseCode", 500) diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilderTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilderTest.java index e5e13268b2..ddca319708 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilderTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilderTest.java @@ -405,4 +405,32 @@ public class ResourceRequestBuilderTest extends BaseTest { assertEquals(resourceSequence.get(0), "res1"); assertEquals(resourceSequence.get(1), "res2"); } -}
\ No newline at end of file + + @Test + public void getResourceInputWithEmptyServiceResourcesTest() throws Exception { + + stubFor(get(urlEqualTo("/ecomp/mso/catalog/v2/serviceResources?serviceModelUuid=c3954379-4efe-431c-8258-f84905b158e5")) + .willReturn(ok("{ \"serviceResources\" : {\n" + + "\t\"modelInfo\" : {\n" + + "\t\t\"modelName\" : \"demoVFWCL\",\n" + + "\t\t\"modelUuid\" : \"c3954379-4efe-431c-8258-f84905b158e5\",\n" + + "\t\t\"modelInvariantUuid\" : \"0cbff61e-3b0a-4eed-97ce-b1b4faa03493\",\n" + + "\t\t\"modelVersion\" : \"1.0\"\n" + + "\t},\n" + + "\t\"serviceType\" : \"\",\n" + + "\t\"serviceRole\" : \"\",\n" + + "\t\"environmentContext\" : null,\n" + + "\t\"workloadContext\" : \"Production\",\n" + + "\t\"serviceVnfs\": [], \n" + + "\t\"serviceNetworks\": [],\n" + + "\t\"serviceAllottedResources\": []\n" + + "\t}}"))); + + HashMap serviceInput = new HashMap(); + serviceInput.put("key1", "value"); + Map<String, Object> stringObjectMap = ResourceRequestBuilder.buildResouceRequest("c3954379-4efe-431c-8258-f84905b158e5", + "e776449e-2b10-45c5-9217-2775c88ca1a0", serviceInput); + assertEquals(0, stringObjectMap.size()); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java index 35a7005751..56875d315b 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java @@ -2551,6 +2551,12 @@ public class BBInputSetupTest { volumeGroup.setVolumeGroupId(volumeGroupId); vnf.getVolumeGroups().add(volumeGroup); serviceInstance.getVnfs().add(vnf); + VfModule vfModule1 = new VfModule(); + vfModule1.setVfModuleId("vfModuleId1"); + VfModule vfModule2 = new VfModule(); + vfModule2.setVfModuleId("vfModuleId2"); + vnf.getVfModules().add(vfModule1); + vnf.getVfModules().add(vfModule2); Map<ResourceKey, String> lookupKeyMap = new HashMap<>(); lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, vnfId); String resourceId = vfModuleId; @@ -2563,16 +2569,20 @@ public class BBInputSetupTest { vnfAAI.setModelCustomizationId("vnfModelCustId"); org.onap.aai.domain.yang.VolumeGroup volumeGroupAAI = new org.onap.aai.domain.yang.VolumeGroup(); volumeGroupAAI.setModelCustomizationId(vfModuleCustomizationId); + org.onap.aai.domain.yang.VfModule vfModuleAAI = new org.onap.aai.domain.yang.VfModule(); + vfModuleAAI.setModelCustomizationId(vfModuleCustomizationId); doReturn(vnfAAI).when(SPY_bbInputSetupUtils).getAAIGenericVnf(vnf.getVnfId()); doReturn(volumeGroupAAI).when(SPY_bbInputSetupUtils).getAAIVolumeGroup(CLOUD_OWNER, cloudConfiguration.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId()); + doReturn(vfModuleAAI).when(SPY_bbInputSetupUtils).getAAIVfModule(isA(String.class), isA(String.class)); doNothing().when(SPY_bbInputSetup).mapCatalogVnf(isA(GenericVnf.class), isA(ModelInfo.class), isA(Service.class)); doNothing().when(SPY_bbInputSetup).mapCatalogVfModule(isA(VfModule.class), isA(ModelInfo.class), isA(Service.class), isA(String.class)); SPY_bbInputSetup.populateVfModule(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, relatedInstanceList, instanceName, instanceParams, cloudConfiguration); + verify(SPY_bbInputSetup, times(3)).mapCatalogVfModule(isA(VfModule.class), isA(ModelInfo.class), isA(Service.class), isA(String.class)); assertEquals("Lookup Key Map populated with VfModule Id", vfModuleId, lookupKeyMap.get(ResourceKey.VF_MODULE_ID)); assertEquals("Lookup Key Map populated with VolumeGroup Id", volumeGroupId, lookupKeyMap.get(ResourceKey.VOLUME_GROUP_ID)); } diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java index 868aabf6a9..6344a3f1a6 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java @@ -131,6 +131,7 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution,true); assertEquals("Rollback", delegateExecution.getVariable("handlingCode")); + assertEquals(5,delegateExecution.getVariable("maxRetries")); } @Test diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/dmaapproperties/DmaapPropertiesClientTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/dmaapproperties/DmaapPropertiesClientTest.java index 95b86524a3..c50a6db178 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/dmaapproperties/DmaapPropertiesClientTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/dmaapproperties/DmaapPropertiesClientTest.java @@ -75,7 +75,7 @@ public class DmaapPropertiesClientTest extends BaseTest{ @Test public void testDmaapPublishRequest() throws JsonProcessingException, MapperException { - stubFor(post(urlEqualTo("/events/com.att.mso.asyncStatusUpdate?timeout=20000")) + stubFor(post(urlEqualTo("/events/com.att.mso.asyncStatusUpdate?timeout=60000")) .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_ACCEPTED))); dmaapPropertiesClient.dmaapPublishRequest(requestId, clientSource, correlator, serviceInstanceId, startTime, finishTime, requestScope, diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/dmaapproperties/GlobalDmaapPublisherTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/dmaapproperties/GlobalDmaapPublisherTest.java index 4d7c85efdb..fc69f812be 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/dmaapproperties/GlobalDmaapPublisherTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/dmaapproperties/GlobalDmaapPublisherTest.java @@ -35,8 +35,8 @@ public class GlobalDmaapPublisherTest extends BaseTest{ @Test public void testGetters() { - assertEquals("dmaapUsername", globalDmaapPublisher.getUserName()); - assertEquals("ZG1hYXBQYXNzd29yZA==", globalDmaapPublisher.getPassword()); + assertEquals("81B7E3533B91A6706830611FB9A8ECE529BBCCE754B1F1520FA7C8698B42F97235BEFA993A387E664D6352C63A6185D68DA7F0B1D360637CBA102CB166E3E62C11EB1F75386D3506BCECE51E54", globalDmaapPublisher.getAuth()); + assertEquals("07a7159d3bf51a0e53be7a8f89699be7", globalDmaapPublisher.getKey()); assertEquals("com.att.mso.asyncStatusUpdate", globalDmaapPublisher.getTopic()); assertEquals("http://localhost:" + wireMockPort, globalDmaapPublisher.getHost().get()); } diff --git a/bpmn/MSOCommonBPMN/src/test/resources/application-test.yaml b/bpmn/MSOCommonBPMN/src/test/resources/application-test.yaml index 945972c9e2..afdb800ffe 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/application-test.yaml +++ b/bpmn/MSOCommonBPMN/src/test/resources/application-test.yaml @@ -146,6 +146,7 @@ mso: host: http://localhost:${wiremock.server.port} publisher: topic: com.att.mso.asyncStatusUpdate + auth: 81B7E3533B91A6706830611FB9A8ECE529BBCCE754B1F1520FA7C8698B42F97235BEFA993A387E664D6352C63A6185D68DA7F0B1D360637CBA102CB166E3E62C11EB1F75386D3506BCECE51E54 oof: auth: test timeout: PT10S @@ -163,6 +164,16 @@ sdnc: auth: Basic YWRtaW46YWRtaW4= host: http://localhost:8446 path: /restconf/operations/GENERIC-RESOURCE-API +sdno: + health-check: + dmaap: + password: alRyMzJ3NUNeakxl + publisher: + topic: com.att.sdno.test-health-diagnostic-v02 + host: https://olsd004.wnsnet.attws.com:3905 + subscriber: + topic: com.att.sdno.test-health-diagnostic-v02 + auth: 81B7E3533B91A6706830611FB9A8ECE529BBCCE754B1F1520FA7C8698B42F97235BEFA993A387E664D6352C63A6185D68DA7F0B1D360637CBA102CB166E3E62C11EB1F75386D3506BCECE51E54 sniro: conductor: enabled: true @@ -178,7 +189,15 @@ sniro: headers.patchVersion: 1 headers.minorVersion: 1 headers.latestVersion: 2 - +ruby: + create-ticket-request: + dmaap: + username: m04768@mso.ecomp.att.com + password: alRyMzJ3NUNeakxl + publisher: + topic: com.att.pdas.exp.msoCMFallout-v1 + host: https://olsd004.wnsnet.attws.com:3905 + auth: 81B7E3533B91A6706830611FB9A8ECE529BBCCE754B1F1520FA7C8698B42F97235BEFA993A387E664D6352C63A6185D68DA7F0B1D360637CBA102CB166E3E62C11EB1F75386D3506BCECE51E54 spring: datasource: jdbc-url: jdbc:mariadb://localhost:3307/camundabpmn diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionTestImpl.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionTestImpl.java index 70d94052e1..4e0bf02685 100644 --- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionTestImpl.java +++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionTestImpl.java @@ -20,12 +20,10 @@ package org.onap.so.bpmn.infrastructure.pnf.delegate; -import java.io.IOException; import java.util.HashMap; import java.util.Map; import java.util.Objects; import java.util.Optional; - import org.onap.aai.domain.yang.Pnf; import org.onap.so.bpmn.infrastructure.pnf.implementation.AaiConnection; import org.springframework.context.annotation.Primary; @@ -39,9 +37,10 @@ public class AaiConnectionTestImpl implements AaiConnection { public static final String ID_WITH_ENTRY = "idWithEntryNoIp"; private Map<String, Pnf> created = new HashMap<>(); + private Map<String, String> serviceAndPnfRelationMap = new HashMap<>(); @Override - public Optional<Pnf> getEntryFor(String correlationId) throws IOException { + public Optional<Pnf> getEntryFor(String correlationId) { if (Objects.equals(correlationId, ID_WITH_ENTRY)) { return Optional.of(new Pnf()); } else { @@ -50,15 +49,25 @@ public class AaiConnectionTestImpl implements AaiConnection { } @Override - public void createEntry(String correlationId, Pnf entry) throws IOException { + public void createEntry(String correlationId, Pnf entry) { created.put(correlationId, entry); } + @Override + public void createRelation(String serviceInstanceId, String pnfName) { + serviceAndPnfRelationMap.put(serviceInstanceId, pnfName); + } + public Map<String, Pnf> getCreated() { return created; } + public Map<String, String> getServiceAndPnfRelationMap() { + return serviceAndPnfRelationMap; + } + public void reset() { created.clear(); + serviceAndPnfRelationMap.clear(); } } diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAndActivatePnfResourceTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAndActivatePnfResourceTest.java index 2d0d4b51a9..db6cbe06ae 100644 --- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAndActivatePnfResourceTest.java +++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAndActivatePnfResourceTest.java @@ -31,15 +31,19 @@ import java.util.Map; import java.util.UUID; import org.assertj.core.api.Assertions; +import org.assertj.core.data.MapEntry; import org.camunda.bpm.engine.runtime.ProcessInstance; +import org.junit.Before; import org.junit.Test; import org.onap.so.BaseIntegrationTest; import org.springframework.beans.factory.annotation.Autowired; public class CreateAndActivatePnfResourceTest extends BaseIntegrationTest { - private static final String TIMEOUT_10_S = "PT10S"; private static final String VALID_UUID = UUID.nameUUIDFromBytes("testUuid".getBytes()).toString(); + private static final String SERVICE_INSTANCE_ID = "serviceForInstance"; + + private Map<String, Object> variables; @Autowired private AaiConnectionTestImpl aaiConnection; @@ -47,14 +51,18 @@ public class CreateAndActivatePnfResourceTest extends BaseIntegrationTest { @Autowired private DmaapClientTestImpl dmaapClientTestImpl; + @Before + public void setup() { + aaiConnection.reset(); + variables = new HashMap<>(); + variables.put("serviceInstanceId", SERVICE_INSTANCE_ID); + variables.put(PNF_UUID, VALID_UUID); + } + @Test public void shouldWaitForMessageFromDmaapAndUpdateAaiEntryWhenAaiEntryExists() { // given - aaiConnection.reset(); - Map<String, Object> variables = new HashMap<>(); - variables.put("timeoutForPnfEntryNotification", TIMEOUT_10_S); variables.put(CORRELATION_ID, AaiConnectionTestImpl.ID_WITH_ENTRY); - variables.put(PNF_UUID, VALID_UUID); // when ProcessInstance instance = runtimeService .startProcessInstanceByKey("CreateAndActivatePnfResource", "businessKey", variables); @@ -70,19 +78,17 @@ public class CreateAndActivatePnfResourceTest extends BaseIntegrationTest { "AaiEntryExists", "InformDmaapClient", "WaitForDmaapPnfReadyNotification", + "CreateRelationId", "AaiEntryUpdated" ); + Assertions.assertThat(aaiConnection.getServiceAndPnfRelationMap()). + containsOnly(MapEntry.entry(SERVICE_INSTANCE_ID,AaiConnectionTestImpl.ID_WITH_ENTRY)); } @Test public void shouldCreateAaiEntryWaitForMessageFromDmaapAndUpdateAaiEntryWhenNoAaiEntryExists() { // given - aaiConnection.reset(); - - Map<String, Object> variables = new HashMap<>(); - variables.put("timeoutForPnfEntryNotification", TIMEOUT_10_S); variables.put(CORRELATION_ID, AaiConnectionTestImpl.ID_WITHOUT_ENTRY); - variables.put(PNF_UUID, VALID_UUID); // when ProcessInstance instance = runtimeService .startProcessInstanceByKey("CreateAndActivatePnfResource", "businessKey", variables); @@ -99,8 +105,11 @@ public class CreateAndActivatePnfResourceTest extends BaseIntegrationTest { "AaiEntryExists", "InformDmaapClient", "WaitForDmaapPnfReadyNotification", + "CreateRelationId", "AaiEntryUpdated" ); Assertions.assertThat(aaiConnection.getCreated()).containsOnlyKeys(AaiConnectionTestImpl.ID_WITHOUT_ENTRY); + Assertions.assertThat(aaiConnection.getServiceAndPnfRelationMap()). + containsOnly(MapEntry.entry(SERVICE_INSTANCE_ID,AaiConnectionTestImpl.ID_WITHOUT_ENTRY)); } } diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateVfModuleBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateVfModuleBB.bpmn index 08252f66b8..97fad57e7d 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateVfModuleBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateVfModuleBB.bpmn @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.7.1"> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.4.0"> <bpmn:process id="CreateVfModuleBB" name="CreateVfModuleBB" isExecutable="true"> <bpmn:startEvent id="CreateVfModuleBB_Start"> <bpmn:outgoing>SequenceFlow_1xr6chl</bpmn:outgoing> @@ -23,13 +23,17 @@ <bpmn:outgoing>SequenceFlow_1s4rpyp</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_16g4dz0" sourceRef="CreateVfModule" targetRef="VnfAdapter" /> - <bpmn:sequenceFlow id="SequenceFlow_0ecr393" sourceRef="VnfAdapter" targetRef="UpdateVfModuleHeatStackId" /> + <bpmn:sequenceFlow id="SequenceFlow_0ecr393" sourceRef="VnfAdapter" targetRef="CreateNetworkPolicies" /> <bpmn:callActivity id="VnfAdapter" name="Vnf Adapter" calledElement="VnfAdapter"> <bpmn:extensionElements> <camunda:in source="gBuildingBlockExecution" target="gBuildingBlockExecution" /> <camunda:out source="WorkflowException" target="WorkflowException" /> <camunda:in source="VNFREST_Request" target="VNFREST_Request" /> <camunda:out source="heatStackId" target="heatStackId" /> + <camunda:out source="contrailServiceInstanceFqdn" target="contrailServiceInstanceFqdn" /> + <camunda:out source="oamManagementV4Address" target="oamManagementV4Address" /> + <camunda:out source="oamManagementV6Address" target="oamManagementV6Address" /> + <camunda:out source="contrailNetworkPolicyFqdnList" target="contrailNetworkPolicyFqdnList" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_16g4dz0</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0ecr393</bpmn:outgoing> @@ -39,7 +43,7 @@ <bpmn:outgoing>SequenceFlow_1vbwdaw</bpmn:outgoing> </bpmn:serviceTask> <bpmn:serviceTask id="UpdateVfModuleHeatStackId" name=" AAI Update (vf module) " camunda:expression="${AAIUpdateTasks.updateHeatStackIdVfModule(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> - <bpmn:incoming>SequenceFlow_0ecr393</bpmn:incoming> + <bpmn:incoming>SequenceFlow_15do1tu</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0rds4rj</bpmn:outgoing> </bpmn:serviceTask> <bpmn:subProcess id="SubProcess_1getwnf" name="Error Handling " triggeredByEvent="true"> @@ -55,29 +59,49 @@ </bpmn:subProcess> <bpmn:sequenceFlow id="SequenceFlow_0rds4rj" sourceRef="UpdateVfModuleHeatStackId" targetRef="UpdateVfModuleStatus" /> <bpmn:sequenceFlow id="SequenceFlow_1vbwdaw" sourceRef="UpdateVfModuleStatus" targetRef="CreateVfModuleBB_End" /> + <bpmn:serviceTask id="CreateNetworkPolicies" name="AAI Create (network policies)" camunda:expression="${AAICreateTasks.createNetworkPolicies(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:incoming>SequenceFlow_0ecr393</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0xqhep5</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_0xqhep5" sourceRef="CreateNetworkPolicies" targetRef="UpdateVnfIpv4OamAddress" /> + <bpmn:serviceTask id="UpdateVnfIpv4OamAddress" name="AAI Update (VNF)Â " camunda:expression="${AAIUpdateTasks.updateIpv4OamAddressVnf(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:incoming>SequenceFlow_0xqhep5</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1yo6mvv</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_1yo6mvv" sourceRef="UpdateVnfIpv4OamAddress" targetRef="UpdateVnfManagementV6Address" /> + <bpmn:serviceTask id="UpdateVnfManagementV6Address" name="AAI Update (VNF)" camunda:expression="${AAIUpdateTasks.updateManagementV6AddressVnf(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:incoming>SequenceFlow_1yo6mvv</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1i03uy2</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_1i03uy2" sourceRef="UpdateVnfManagementV6Address" targetRef="UpdateVfModuleContrailServiceInstanceFqdn" /> + <bpmn:serviceTask id="UpdateVfModuleContrailServiceInstanceFqdn" name="AAI Update (vf module) " camunda:expression="${AAIUpdateTasks.updateContrailServiceInstanceFqdnVfModule(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:incoming>SequenceFlow_1i03uy2</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_15do1tu</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_15do1tu" sourceRef="UpdateVfModuleContrailServiceInstanceFqdn" targetRef="UpdateVfModuleHeatStackId" /> </bpmn:process> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="CreateVfModuleBB"> <bpmndi:BPMNShape id="StartEvent_0kxwniy_di" bpmnElement="CreateVfModuleBB_Start"> - <dc:Bounds x="100" y="88" width="36" height="36" /> + <dc:Bounds x="59" y="88" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="106" y="124" width="24" height="12" /> + <dc:Bounds x="77" y="124" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_13t22km_di" bpmnElement="QueryVfModule"> <dc:Bounds x="416" y="66" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1xr6chl_di" bpmnElement="SequenceFlow_1xr6chl"> - <di:waypoint xsi:type="dc:Point" x="136" y="106" /> + <di:waypoint xsi:type="dc:Point" x="95" y="106" /> <di:waypoint xsi:type="dc:Point" x="216" y="106" /> <bpmndi:BPMNLabel> - <dc:Bounds x="131" y="91" width="90" height="0" /> + <dc:Bounds x="156" y="91" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="EndEvent_0qdq7wj_di" bpmnElement="CreateVfModuleBB_End"> - <dc:Bounds x="1299" y="88" width="36" height="36" /> + <dc:Bounds x="1118" y="293" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1272" y="128" width="90" height="12" /> + <dc:Bounds x="1136" y="333" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_1dgenhy_di" bpmnElement="CreateVfModule"> @@ -102,61 +126,107 @@ </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_16g4dz0_di" bpmnElement="SequenceFlow_16g4dz0"> <di:waypoint xsi:type="dc:Point" x="712" y="106" /> - <di:waypoint xsi:type="dc:Point" x="777" y="106" /> + <di:waypoint xsi:type="dc:Point" x="790" y="106" /> <bpmndi:BPMNLabel> - <dc:Bounds x="700" y="85" width="90" height="12" /> + <dc:Bounds x="751" y="91" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0ecr393_di" bpmnElement="SequenceFlow_0ecr393"> - <di:waypoint xsi:type="dc:Point" x="877" y="107" /> - <di:waypoint xsi:type="dc:Point" x="931" y="107" /> + <di:waypoint xsi:type="dc:Point" x="890" y="107" /> + <di:waypoint xsi:type="dc:Point" x="994" y="107" /> + <di:waypoint xsi:type="dc:Point" x="994" y="209" /> + <di:waypoint xsi:type="dc:Point" x="73" y="209" /> + <di:waypoint xsi:type="dc:Point" x="73" y="306" /> + <di:waypoint xsi:type="dc:Point" x="142" y="306" /> <bpmndi:BPMNLabel> - <dc:Bounds x="859" y="92" width="90" height="0" /> + <dc:Bounds x="534" y="194" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="CallActivity_1i1pfzb_di" bpmnElement="VnfAdapter"> - <dc:Bounds x="777" y="66" width="100" height="80" /> + <dc:Bounds x="790" y="66" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_0fpfn71_di" bpmnElement="UpdateVfModuleStatus"> - <dc:Bounds x="1117" y="66" width="100" height="80" /> + <dc:Bounds x="942" y="271" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_04k1b85_di" bpmnElement="UpdateVfModuleHeatStackId"> - <dc:Bounds x="931" y="68" width="100" height="80" /> + <dc:Bounds x="777" y="271" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="SubProcess_1getwnf_di" bpmnElement="SubProcess_1getwnf" isExpanded="true"> - <dc:Bounds x="172" y="276" width="231" height="135" /> + <dc:Bounds x="136" y="439" width="231" height="135" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="StartEvent_1c8o652_di" bpmnElement="StartEvent_1c8o652"> - <dc:Bounds x="211" y="334" width="36" height="36" /> + <dc:Bounds x="175" y="497" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="184" y="370" width="0" height="12" /> + <dc:Bounds x="148" y="533" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="EndEvent_1emam1w_di" bpmnElement="EndEvent_1emam1w"> - <dc:Bounds x="348" y="334" width="36" height="36" /> + <dc:Bounds x="312" y="497" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="321" y="370" width="0" height="12" /> + <dc:Bounds x="285" y="533" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0gcots6_di" bpmnElement="SequenceFlow_0gcots6"> - <di:waypoint xsi:type="dc:Point" x="247" y="352" /> - <di:waypoint xsi:type="dc:Point" x="348" y="352" /> + <di:waypoint xsi:type="dc:Point" x="211" y="515" /> + <di:waypoint xsi:type="dc:Point" x="312" y="515" /> <bpmndi:BPMNLabel> - <dc:Bounds x="297.5" y="331" width="0" height="12" /> + <dc:Bounds x="262" y="494" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0rds4rj_di" bpmnElement="SequenceFlow_0rds4rj"> - <di:waypoint xsi:type="dc:Point" x="1031" y="107" /> - <di:waypoint xsi:type="dc:Point" x="1117" y="107" /> + <di:waypoint xsi:type="dc:Point" x="877" y="311" /> + <di:waypoint xsi:type="dc:Point" x="942" y="311" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1074" y="85" width="0" height="13" /> + <dc:Bounds x="910" y="296" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1vbwdaw_di" bpmnElement="SequenceFlow_1vbwdaw"> - <di:waypoint xsi:type="dc:Point" x="1217" y="106" /> - <di:waypoint xsi:type="dc:Point" x="1299" y="106" /> + <di:waypoint xsi:type="dc:Point" x="1042" y="311" /> + <di:waypoint xsi:type="dc:Point" x="1083" y="311" /> + <di:waypoint xsi:type="dc:Point" x="1083" y="311" /> + <di:waypoint xsi:type="dc:Point" x="1118" y="311" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1098" y="311" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_1v8zx4s_di" bpmnElement="CreateNetworkPolicies"> + <dc:Bounds x="142" y="271" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0xqhep5_di" bpmnElement="SequenceFlow_0xqhep5"> + <di:waypoint xsi:type="dc:Point" x="242" y="311" /> + <di:waypoint xsi:type="dc:Point" x="295" y="311" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="269" y="296" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_015ayw5_di" bpmnElement="UpdateVnfIpv4OamAddress"> + <dc:Bounds x="295" y="271" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1yo6mvv_di" bpmnElement="SequenceFlow_1yo6mvv"> + <di:waypoint xsi:type="dc:Point" x="395" y="311" /> + <di:waypoint xsi:type="dc:Point" x="464" y="311" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="430" y="296" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_0mlfsc9_di" bpmnElement="UpdateVnfManagementV6Address"> + <dc:Bounds x="464" y="271" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1i03uy2_di" bpmnElement="SequenceFlow_1i03uy2"> + <di:waypoint xsi:type="dc:Point" x="564" y="311" /> + <di:waypoint xsi:type="dc:Point" x="612" y="311" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="588" y="296" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_0wctnhw_di" bpmnElement="UpdateVfModuleContrailServiceInstanceFqdn"> + <dc:Bounds x="612" y="271" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_15do1tu_di" bpmnElement="SequenceFlow_15do1tu"> + <di:waypoint xsi:type="dc:Point" x="712" y="311" /> + <di:waypoint xsi:type="dc:Point" x="777" y="311" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1258" y="84" width="0" height="13" /> + <dc:Bounds x="745" y="286" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVfModuleBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVfModuleBB.bpmn index 5cf41b655b..804ae70c58 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVfModuleBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVfModuleBB.bpmn @@ -24,11 +24,15 @@ <camunda:in source="deleteVfModuleRequest" target="deleteVfModuleRequest" /> <camunda:in source="VNFREST_Request" target="VNFREST_Request" /> <camunda:out source="heatStackId" target="heatStackId" /> + <camunda:out source="oamManagementV4Address" target="oamManagementV4Address" /> + <camunda:out source="oamManagementV6Address" target="oamManagementV6Address" /> + <camunda:out source="contrailNetworkPolicyFqdnList" target="contrailNetworkPolicyFqdnList" /> + <camunda:out source="contrailServiceInstanceFqdn" target="contrailServiceInstanceFqdn" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_08tvhtf</bpmn:incoming> <bpmn:outgoing>SequenceFlow_02lpx87</bpmn:outgoing> </bpmn:callActivity> - <bpmn:sequenceFlow id="SequenceFlow_02lpx87" sourceRef="VnfAdapter" targetRef="UpdateVfModuleHeatStackId" /> + <bpmn:sequenceFlow id="SequenceFlow_02lpx87" sourceRef="VnfAdapter" targetRef="DeleteNetworkPolicies" /> <bpmn:subProcess id="SubProcess_11p7mrh" name="Error Handling " triggeredByEvent="true"> <bpmn:startEvent id="StartEvent_1xp6ewt"> <bpmn:outgoing>SequenceFlow_0h607z0</bpmn:outgoing> @@ -41,11 +45,31 @@ <bpmn:sequenceFlow id="SequenceFlow_0h607z0" sourceRef="StartEvent_1xp6ewt" targetRef="EndEvent_0guhjau" /> </bpmn:subProcess> <bpmn:serviceTask id="UpdateVfModuleHeatStackId" name=" AAI Update (vf module) " camunda:expression="${AAIUpdateTasks.updateHeatStackIdVfModule(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> - <bpmn:incoming>SequenceFlow_02lpx87</bpmn:incoming> + <bpmn:incoming>SequenceFlow_0yuz21z</bpmn:incoming> <bpmn:outgoing>SequenceFlow_01vfwtp</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_01vfwtp" sourceRef="UpdateVfModuleHeatStackId" targetRef="UpdateVfModuleDeleteStatus" /> <bpmn:sequenceFlow id="SequenceFlow_09l7pcg" sourceRef="UpdateVfModuleDeleteStatus" targetRef="DeleteVfModuleBB_End" /> + <bpmn:sequenceFlow id="SequenceFlow_0xyu3pk" sourceRef="DeleteNetworkPolicies" targetRef="UpdateVnfIpv4OamAddress" /> + <bpmn:serviceTask id="DeleteNetworkPolicies" name="AAI Delete (network policies)" camunda:expression="${AAIDeleteTasks.deleteNetworkPolicies(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:incoming>SequenceFlow_02lpx87</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0xyu3pk</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:serviceTask id="UpdateVnfManagementV6Address" name="AAI Update (VNF)" camunda:expression="${AAIUpdateTasks.updateManagementV6AddressVnf(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:incoming>SequenceFlow_0jtem3b</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0khqfnc</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_0jtem3b" sourceRef="UpdateVnfIpv4OamAddress" targetRef="UpdateVnfManagementV6Address" /> + <bpmn:serviceTask id="UpdateVnfIpv4OamAddress" name="AAI Update (VNF)" camunda:expression="${AAIUpdateTasks.updateIpv4OamAddressVnf(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:incoming>SequenceFlow_0xyu3pk</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0jtem3b</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_0khqfnc" sourceRef="UpdateVnfManagementV6Address" targetRef="UpdateVfModuleContrailServiceInstanceFqdn" /> + <bpmn:sequenceFlow id="SequenceFlow_0yuz21z" sourceRef="UpdateVfModuleContrailServiceInstanceFqdn" targetRef="UpdateVfModuleHeatStackId" /> + <bpmn:serviceTask id="UpdateVfModuleContrailServiceInstanceFqdn" name="AAI Update (vf module) " camunda:expression="${AAIUpdateTasks.updateContrailServiceInstanceFqdnVfModule(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:incoming>SequenceFlow_0khqfnc</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0yuz21z</bpmn:outgoing> + </bpmn:serviceTask> </bpmn:process> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DeleteVfModuleBB"> @@ -66,7 +90,7 @@ </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_0pbhsub_di" bpmnElement="UpdateVfModuleDeleteStatus"> - <dc:Bounds x="762" y="80" width="100" height="80" /> + <dc:Bounds x="758" y="243" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_08tvhtf_di" bpmnElement="SequenceFlow_08tvhtf"> <di:waypoint xsi:type="dc:Point" x="361" y="120" /> @@ -76,9 +100,9 @@ </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="EndEvent_1rn6yvh_di" bpmnElement="DeleteVfModuleBB_End"> - <dc:Bounds x="922" y="102" width="36" height="36" /> + <dc:Bounds x="918" y="265" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="940" y="142" width="0" height="0" /> + <dc:Bounds x="936" y="305" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="CallActivity_0whogn3_di" bpmnElement="VnfAdapter"> @@ -86,50 +110,94 @@ </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_02lpx87_di" bpmnElement="SequenceFlow_02lpx87"> <di:waypoint xsi:type="dc:Point" x="527" y="120" /> - <di:waypoint xsi:type="dc:Point" x="604" y="120" /> + <di:waypoint xsi:type="dc:Point" x="591" y="120" /> <bpmndi:BPMNLabel> - <dc:Bounds x="566" y="105" width="0" height="0" /> + <dc:Bounds x="559" y="105" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="SubProcess_11p7mrh_di" bpmnElement="SubProcess_11p7mrh" isExpanded="true"> - <dc:Bounds x="261" y="276" width="231" height="135" /> + <dc:Bounds x="295" y="412" width="231" height="135" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="StartEvent_1xp6ewt_di" bpmnElement="StartEvent_1xp6ewt"> - <dc:Bounds x="304" y="338" width="36" height="36" /> + <dc:Bounds x="338" y="474" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="277" y="374" width="0" height="12" /> + <dc:Bounds x="311" y="510" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="EndEvent_0guhjau_di" bpmnElement="EndEvent_0guhjau"> - <dc:Bounds x="433" y="338" width="36" height="36" /> + <dc:Bounds x="467" y="474" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="406" y="374" width="0" height="12" /> + <dc:Bounds x="440" y="510" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0h607z0_di" bpmnElement="SequenceFlow_0h607z0"> - <di:waypoint xsi:type="dc:Point" x="340" y="356" /> - <di:waypoint xsi:type="dc:Point" x="433" y="356" /> + <di:waypoint xsi:type="dc:Point" x="374" y="492" /> + <di:waypoint xsi:type="dc:Point" x="467" y="492" /> <bpmndi:BPMNLabel> - <dc:Bounds x="386.5" y="335" width="0" height="12" /> + <dc:Bounds x="421" y="471" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_0vlgqod_di" bpmnElement="UpdateVfModuleHeatStackId"> - <dc:Bounds x="604" y="80" width="100" height="80" /> + <dc:Bounds x="591" y="243" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_01vfwtp_di" bpmnElement="SequenceFlow_01vfwtp"> - <di:waypoint xsi:type="dc:Point" x="704" y="120" /> - <di:waypoint xsi:type="dc:Point" x="762" y="120" /> + <di:waypoint xsi:type="dc:Point" x="691" y="283" /> + <di:waypoint xsi:type="dc:Point" x="758" y="283" /> <bpmndi:BPMNLabel> - <dc:Bounds x="733" y="95" width="0" height="0" /> + <dc:Bounds x="725" y="268" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_09l7pcg_di" bpmnElement="SequenceFlow_09l7pcg"> - <di:waypoint xsi:type="dc:Point" x="862" y="120" /> - <di:waypoint xsi:type="dc:Point" x="922" y="120" /> + <di:waypoint xsi:type="dc:Point" x="858" y="283" /> + <di:waypoint xsi:type="dc:Point" x="918" y="283" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="888" y="258" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0xyu3pk_di" bpmnElement="SequenceFlow_0xyu3pk"> + <di:waypoint xsi:type="dc:Point" x="691" y="120" /> + <di:waypoint xsi:type="dc:Point" x="751" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="721" y="105" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_0tty0ac_di" bpmnElement="DeleteNetworkPolicies"> + <dc:Bounds x="591" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_0lrrd16_di" bpmnElement="UpdateVnfManagementV6Address"> + <dc:Bounds x="261" y="243" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0jtem3b_di" bpmnElement="SequenceFlow_0jtem3b"> + <di:waypoint xsi:type="dc:Point" x="851" y="120" /> + <di:waypoint xsi:type="dc:Point" x="941" y="120" /> + <di:waypoint xsi:type="dc:Point" x="941" y="205" /> + <di:waypoint xsi:type="dc:Point" x="182" y="205" /> + <di:waypoint xsi:type="dc:Point" x="182" y="283" /> + <di:waypoint xsi:type="dc:Point" x="261" y="283" /> <bpmndi:BPMNLabel> - <dc:Bounds x="892" y="95" width="0" height="0" /> + <dc:Bounds x="562" y="190" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_0w9805b_di" bpmnElement="UpdateVnfIpv4OamAddress"> + <dc:Bounds x="751" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0khqfnc_di" bpmnElement="SequenceFlow_0khqfnc"> + <di:waypoint xsi:type="dc:Point" x="361" y="283" /> + <di:waypoint xsi:type="dc:Point" x="427" y="283" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="394" y="268" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0yuz21z_di" bpmnElement="SequenceFlow_0yuz21z"> + <di:waypoint xsi:type="dc:Point" x="527" y="283" /> + <di:waypoint xsi:type="dc:Point" x="591" y="283" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="559" y="268" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_0v8naz9_di" bpmnElement="UpdateVfModuleContrailServiceInstanceFqdn"> + <dc:Bounds x="427" y="243" width="100" height="80" /> + </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> </bpmn:definitions> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ExecuteBuildingBlock.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ExecuteBuildingBlock.bpmn index 943ce12a8a..5189f8b48a 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ExecuteBuildingBlock.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ExecuteBuildingBlock.bpmn @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.7.1"> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.8.2"> <bpmn:process id="ExecuteBuildingBlock" name="ExecuteBuildingBlock" isExecutable="true"> <bpmn:startEvent id="Start_ExecuteBuildingBlock" name="start"> <bpmn:outgoing>SequenceFlow_0rq4c5r</bpmn:outgoing> @@ -73,7 +73,7 @@ <bpmn:sequenceFlow id="SequenceFlow_0ndt8ft" sourceRef="Task_SetRetryTimer" targetRef="IntermediateCatchEvent_RetryTimer" /> <bpmn:sequenceFlow id="SequenceFlow_07a1ytc" sourceRef="IntermediateCatchEvent_RetryTimer" targetRef="EndEvent_1sez2lh" /> <bpmn:sequenceFlow id="SequenceFlow_1wbevp0" name="yes" sourceRef="ExclusiveGateway_0ey4zpt" targetRef="Task_SetRetryTimer"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("retryCount")<5}]]></bpmn:conditionExpression> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("retryCount")<execution.getVariable("maxRetries")}]]></bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:endEvent id="EndEvent_0mvmk3i"> <bpmn:incoming>SequenceFlow_0h8v45y</bpmn:incoming> diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/CreateVfModuleBBTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/CreateVfModuleBBTest.java index 0e4bb5a194..8c44309cca 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/CreateVfModuleBBTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/CreateVfModuleBBTest.java @@ -40,6 +40,10 @@ public class CreateVfModuleBBTest extends BaseBPMNTest{ "QueryVfModule", "CreateVfModule", "VnfAdapter", + "CreateNetworkPolicies", + "UpdateVnfIpv4OamAddress", + "UpdateVnfManagementV6Address", + "UpdateVfModuleContrailServiceInstanceFqdn", "UpdateVfModuleHeatStackId", "UpdateVfModuleStatus", "CreateVfModuleBB_End"); @@ -53,7 +57,9 @@ public class CreateVfModuleBBTest extends BaseBPMNTest{ assertThat(pi).isNotNull(); assertThat(pi).isStarted() .hasPassedInOrder("CreateVfModuleBB_Start", "QueryVnf") - .hasNotPassed("QueryVfModule", "CreateVfModule", "VnfAdapter", "UpdateVfModuleHeatStackId", "UpdateVfModuleStatus", "CreateVfModuleBB_End"); + .hasNotPassed("QueryVfModule", "CreateVfModule", "VnfAdapter", "CreateNetworkPolicies", "UpdateVnfIpv4OamAddress", + "UpdateVnfManagementV6Address","UpdateVfModuleContrailServiceInstanceFqdn","UpdateVfModuleHeatStackId", + "UpdateVfModuleStatus", "CreateVfModuleBB_End"); assertThat(pi).isEnded(); } @@ -64,7 +70,8 @@ public class CreateVfModuleBBTest extends BaseBPMNTest{ assertThat(pi).isNotNull(); assertThat(pi).isStarted() .hasPassedInOrder("CreateVfModuleBB_Start", "QueryVnf", "QueryVfModule") - .hasNotPassed("CreateVfModule", "VnfAdapter", "UpdateVfModuleHeatStackId", "UpdateVfModuleStatus", "CreateVfModuleBB_End"); + .hasNotPassed("CreateVfModule", "VnfAdapter", "CreateNetworkPolicies", "UpdateVnfIpv4OamAddress", "UpdateVnfManagementV6Address", + "UpdateVfModuleContrailServiceInstanceFqdn","UpdateVfModuleHeatStackId", "UpdateVfModuleStatus", "CreateVfModuleBB_End"); assertThat(pi).isEnded(); } @@ -75,7 +82,8 @@ public class CreateVfModuleBBTest extends BaseBPMNTest{ assertThat(pi).isNotNull(); assertThat(pi).isStarted() .hasPassedInOrder("CreateVfModuleBB_Start", "QueryVnf", "QueryVfModule", "CreateVfModule") - .hasNotPassed("VnfAdapter", "UpdateVfModuleHeatStackId", "UpdateVfModuleStatus", "CreateVfModuleBB_End"); + .hasNotPassed("VnfAdapter", "CreateNetworkPolicies","UpdateVnfIpv4OamAddress", "UpdateVnfManagementV6Address", + "UpdateVfModuleContrailServiceInstanceFqdn","UpdateVfModuleHeatStackId", "UpdateVfModuleStatus", "CreateVfModuleBB_End"); assertThat(pi).isEnded(); } @@ -87,7 +95,8 @@ public class CreateVfModuleBBTest extends BaseBPMNTest{ ProcessInstance pi = runtimeService.startProcessInstanceByKey("CreateVfModuleBB", variables); assertThat(pi).isNotNull(); assertThat(pi).isStarted() - .hasPassedInOrder("CreateVfModuleBB_Start", "QueryVnf", "QueryVfModule", "CreateVfModule", "VnfAdapter", "UpdateVfModuleHeatStackId") + .hasPassedInOrder("CreateVfModuleBB_Start", "QueryVnf", "QueryVfModule", "CreateVfModule", "VnfAdapter", "CreateNetworkPolicies", + "UpdateVnfIpv4OamAddress", "UpdateVnfManagementV6Address", "UpdateVfModuleContrailServiceInstanceFqdn","UpdateVfModuleHeatStackId") .hasNotPassed("UpdateVfModuleStatus", "CreateVfModuleBB_End"); assertThat(pi).isEnded(); @@ -100,7 +109,9 @@ public class CreateVfModuleBBTest extends BaseBPMNTest{ ProcessInstance pi = runtimeService.startProcessInstanceByKey("CreateVfModuleBB", variables); assertThat(pi).isNotNull(); assertThat(pi).isStarted() - .hasPassedInOrder("CreateVfModuleBB_Start", "QueryVnf", "QueryVfModule", "CreateVfModule", "VnfAdapter", "UpdateVfModuleHeatStackId", "UpdateVfModuleStatus") + .hasPassedInOrder("CreateVfModuleBB_Start", "QueryVnf", "QueryVfModule", "CreateVfModule", "VnfAdapter", "CreateNetworkPolicies", + "UpdateVnfIpv4OamAddress", "UpdateVnfManagementV6Address", "UpdateVfModuleContrailServiceInstanceFqdn","UpdateVfModuleHeatStackId", + "UpdateVfModuleStatus") .hasNotPassed("CreateVfModuleBB_End"); assertThat(pi).isEnded(); } diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/DeleteVfModuleBBTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/DeleteVfModuleBBTest.java index d9190b5e12..cedffb77d4 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/DeleteVfModuleBBTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/DeleteVfModuleBBTest.java @@ -38,6 +38,8 @@ public class DeleteVfModuleBBTest extends BaseBPMNTest{ ProcessInstance pi = runtimeService.startProcessInstanceByKey("DeleteVfModuleBB", variables); assertThat(pi).isNotNull(); assertThat(pi).isStarted().hasPassedInOrder("DeleteVfModuleBB_Start", "DeleteVfModuleVnfAdapter", "VnfAdapter", + "DeleteNetworkPolicies", "UpdateVnfIpv4OamAddress", "UpdateVnfManagementV6Address", + "UpdateVfModuleContrailServiceInstanceFqdn", "UpdateVfModuleHeatStackId", "UpdateVfModuleDeleteStatus", "DeleteVfModuleBB_End"); assertThat(pi).isEnded(); } @@ -49,7 +51,9 @@ public class DeleteVfModuleBBTest extends BaseBPMNTest{ assertThat(pi).isNotNull(); assertThat(pi).isStarted() .hasPassedInOrder("DeleteVfModuleBB_Start", "DeleteVfModuleVnfAdapter") - .hasNotPassed("VnfAdapter", "UpdateVfModuleHeatStackId", "UpdateVfModuleDeleteStatus", "DeleteVfModuleBB_End"); + .hasNotPassed("VnfAdapter", "DeleteNetworkPolicies", "UpdateVnfIpv4OamAddress", "UpdateVnfManagementV6Address", + "UpdateVfModuleContrailServiceInstanceFqdn","UpdateVfModuleHeatStackId", "UpdateVfModuleDeleteStatus", + "DeleteVfModuleBB_End"); assertThat(pi).isEnded(); } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/aai/AaiConnectionImpl.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/aai/AaiConnectionImpl.java index d57e48781d..1bf2a290cb 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/aai/AaiConnectionImpl.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/aai/AaiConnectionImpl.java @@ -23,7 +23,11 @@ package org.onap.so.bpmn.infrastructure.pnf.aai; import java.util.Optional; import org.onap.aai.domain.yang.Pnf; import org.onap.so.bpmn.infrastructure.pnf.implementation.AaiConnection; +import org.onap.so.client.aai.AAIObjectType; +import org.onap.so.client.aai.AAIResourcesClient; import org.onap.so.client.aai.AAIRestClientImpl; +import org.onap.so.client.aai.entities.uri.AAIResourceUri; +import org.onap.so.client.aai.entities.uri.AAIUriFactory; import org.springframework.stereotype.Component; @Component @@ -40,4 +44,12 @@ public class AaiConnectionImpl implements AaiConnection { AAIRestClientImpl restClient = new AAIRestClientImpl(); restClient.createPnf(correlationId, entry); } + + @Override + public void createRelation(String serviceInstanceId, String pnfName) { + AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, + serviceInstanceId); + AAIResourceUri pnfUri = AAIUriFactory.createResourceUri(AAIObjectType.PNF, pnfName); + new AAIResourcesClient().connect(serviceInstanceURI, pnfUri); + } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateRelation.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateRelation.java new file mode 100644 index 0000000000..21d43964f8 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateRelation.java @@ -0,0 +1,58 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2019 Nokia. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.pnf.delegate; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.onap.so.bpmn.common.scripts.ExceptionUtil; +import org.onap.so.bpmn.infrastructure.pnf.implementation.AaiConnection; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class CreateRelation implements JavaDelegate { + + private static final Logger logger = LoggerFactory.getLogger(CreateRelation.class); + + private AaiConnection aaiConnectionImpl; + + @Autowired + public CreateRelation(AaiConnection aaiConnectionImpl) { + this.aaiConnectionImpl = aaiConnectionImpl; + } + + @Override + public void execute(DelegateExecution delegateExecution) { + String serviceInstanceId = (String) delegateExecution.getVariable("serviceInstanceId"); + String pnfName = (String) delegateExecution.getVariable("correlationId"); + try { + aaiConnectionImpl.createRelation(serviceInstanceId, pnfName); + } catch (Exception e) { + new ExceptionUtil().buildAndThrowWorkflowException(delegateExecution, 9999, + "An exception occurred when making service and pnf relation. Exception: " + e.getMessage()); + } + logger.debug("The relation has been made between service with id: {} and pnf with name: {}", + serviceInstanceId, pnfName); + } + +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/implementation/AaiConnection.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/implementation/AaiConnection.java index 5165912653..eaabb2bfbb 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/implementation/AaiConnection.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/implementation/AaiConnection.java @@ -29,4 +29,6 @@ public interface AaiConnection { Optional<Pnf> getEntryFor(String correlationId) throws IOException; void createEntry(String correlationId, Pnf entry) throws IOException; + + void createRelation(String serviceInstanceId, String pnfName) throws IOException; } diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionTestImpl.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionTestImpl.java index 201e791a24..76b62a9cea 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionTestImpl.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionTestImpl.java @@ -37,7 +37,7 @@ public class AaiConnectionTestImpl implements AaiConnection { private Map<String, Pnf> created = new HashMap<>(); @Override - public Optional<Pnf> getEntryFor(String correlationId) throws IOException { + public Optional<Pnf> getEntryFor(String correlationId) { if (Objects.equals(correlationId, ID_WITH_ENTRY)) { return Optional.of(new Pnf()); } else { @@ -50,6 +50,10 @@ public class AaiConnectionTestImpl implements AaiConnection { created.put(correlationId, entry); } + @Override + public void createRelation(String serviceInstanceId, String pnfName) { + } + public Map<String, Pnf> getCreated() { return created; } diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionThrowingException.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionThrowingException.java index 7df6757817..300d1e4c9b 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionThrowingException.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionThrowingException.java @@ -36,4 +36,10 @@ public class AaiConnectionThrowingException implements AaiConnection { public void createEntry(String correlationId, Pnf entry) throws IOException { throw new IOException(); } + + @Override + public void createRelation(String serviceInstanceId, String pnfName) throws IOException { + throw new IOException(); + } + } diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateRelationTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateRelationTest.java new file mode 100644 index 0000000000..2dd3e23828 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateRelationTest.java @@ -0,0 +1,67 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2019 Nokia. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.pnf.delegate; + +import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; + +import java.io.IOException; +import org.camunda.bpm.engine.delegate.BpmnError; +import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake; +import org.junit.Before; +import org.junit.Test; +import org.onap.so.bpmn.infrastructure.pnf.aai.AaiConnectionImpl; +import org.onap.so.bpmn.infrastructure.pnf.implementation.AaiConnection; + +public class CreateRelationTest { + + private static final String SERVICE_INSTANCE_ID = "serviceTest"; + private static final String PNF_NAME = "pnfNameTest"; + + private DelegateExecutionFake executionFake; + + @Before + public void setUp() { + executionFake = new DelegateExecutionFake(); + executionFake.setVariable("serviceInstanceId", SERVICE_INSTANCE_ID); + executionFake.setVariable("correlationId", PNF_NAME); + } + + @Test + public void createRelationSuccessful() throws IOException { + // given + AaiConnection aaiConnectionMock = mock(AaiConnectionImpl.class); + CreateRelation testedObject = new CreateRelation(aaiConnectionMock); + // when + testedObject.execute(executionFake); + // then + verify(aaiConnectionMock).createRelation(SERVICE_INSTANCE_ID, PNF_NAME); + } + + @Test + public void shouldThrowBpmnErrorWhenExceptionOccurred() { + CreateRelation testedObject = new CreateRelation(new AaiConnectionThrowingException()); + executionFake.setVariable("testProcessKey", "testProcessKeyValue"); + + assertThatThrownBy(() -> testedObject.execute(executionFake)).isInstanceOf(BpmnError.class); + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateAndActivatePnfResource.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateAndActivatePnfResource.bpmn index d8079174c1..5defe2121b 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateAndActivatePnfResource.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateAndActivatePnfResource.bpmn @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="2.0.3"> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.11.3"> <bpmn:collaboration id="Collaboration_1d0w8lf"> <bpmn:participant id="Participant_1egg397" name="SO Create and Activate Pnf Resource" processRef="CreateAndActivatePnfResource" /> <bpmn:participant id="Participant_0atuyq0" name="AAI" /> @@ -17,7 +17,7 @@ <bpmn:sequenceFlow id="SequenceFlow_0v5ffpe" name="No" sourceRef="DoesAaiContainInfoAboutPnf" targetRef="CreatePnfEntryInAai"> <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{!aaiContainsInfoAboutPnf}</bpmn:conditionExpression> </bpmn:sequenceFlow> - <bpmn:sequenceFlow id="SequenceFlow_0p09qgm" sourceRef="WaitForDmaapPnfReadyNotification" targetRef="AaiEntryUpdated" /> + <bpmn:sequenceFlow id="SequenceFlow_0p09qgm" sourceRef="WaitForDmaapPnfReadyNotification" targetRef="CreateRelationId" /> <bpmn:sequenceFlow id="SequenceFlow_17s9025" sourceRef="AaiEntryExists" targetRef="InformDmaapClient" /> <bpmn:sequenceFlow id="SequenceFlow_1qr6cmf" sourceRef="CreatePnfEntryInAai" targetRef="AaiEntryExists" /> <bpmn:sequenceFlow id="SequenceFlow_1j4r3zt" sourceRef="CheckAiiForCorrelationId" targetRef="DoesAaiContainInfoAboutPnf" /> @@ -59,9 +59,6 @@ <bpmn:incoming>SequenceFlow_1miyzfe</bpmn:incoming> <bpmn:errorEventDefinition errorRef="Error_1" /> </bpmn:endEvent> - <bpmn:endEvent id="AaiEntryUpdated" name="AAI entry updated"> - <bpmn:incoming>SequenceFlow_0p09qgm</bpmn:incoming> - </bpmn:endEvent> <bpmn:receiveTask id="WaitForDmaapPnfReadyNotification" name="Wait for DMAAP pnf-ready notification" messageRef="Message_13h1tlo"> <bpmn:incoming>SequenceFlow_1o8od8e</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0p09qgm</bpmn:outgoing> @@ -77,13 +74,20 @@ <bpmn:incoming>SequenceFlow_1qr6cmf</bpmn:incoming> <bpmn:outgoing>SequenceFlow_17s9025</bpmn:outgoing> </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="SequenceFlow_0o6zhjk" sourceRef="CreateRelationId" targetRef="AaiEntryUpdated" /> + <bpmn:endEvent id="AaiEntryUpdated" name="AAI entry updated"> + <bpmn:incoming>SequenceFlow_0o6zhjk</bpmn:incoming> + </bpmn:endEvent> + <bpmn:serviceTask id="CreateRelationId" name="Create Relation" camunda:delegateExpression="${CreateRelation}"> + <bpmn:incoming>SequenceFlow_0p09qgm</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0o6zhjk</bpmn:outgoing> + </bpmn:serviceTask> <bpmn:association id="Association_0d7oxnz" sourceRef="CreateAndActivatePnf_StartEvent" targetRef="TextAnnotation_1eyzes8" /> <bpmn:textAnnotation id="TextAnnotation_1eyzes8"> - <bpmn:text>Inputs: + <bpmn:text><![CDATA[Inputs: Â -Â timeoutForPnfEntryNotification - String - correlationId - String - - uuid - String -</bpmn:text> + - uuid - String]]></bpmn:text> </bpmn:textAnnotation> </bpmn:process> <bpmn:error id="Error_1" name="MSO Workflow Exception" errorCode="MSOWorkflowException" /> @@ -100,9 +104,9 @@ </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="EndEvent_0k52gr7_di" bpmnElement="AaiEntryUpdated"> - <dc:Bounds x="1312" y="189" width="36" height="36" /> + <dc:Bounds x="1364" y="189" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1287" y="230" width="88" height="14" /> + <dc:Bounds x="1339" y="230" width="89" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="StartEvent_0j5ok9h_di" bpmnElement="CreateAndActivatePnf_StartEvent"> @@ -118,38 +122,38 @@ <dc:Bounds x="511" y="167" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1j4r3zt_di" bpmnElement="SequenceFlow_1j4r3zt"> - <di:waypoint x="319" y="207" /> - <di:waypoint x="390" y="207" /> + <di:waypoint xsi:type="dc:Point" x="319" y="207" /> + <di:waypoint xsi:type="dc:Point" x="390" y="207" /> <bpmndi:BPMNLabel> <dc:Bounds x="309.5" y="187" width="90" height="10" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1l1t6ak_di" bpmnElement="SequenceFlow_1l1t6ak"> - <di:waypoint x="415" y="182" /> - <di:waypoint x="415" y="66" /> - <di:waypoint x="711" y="66" /> - <di:waypoint x="711" y="182" /> + <di:waypoint xsi:type="dc:Point" x="415" y="182" /> + <di:waypoint xsi:type="dc:Point" x="415" y="66" /> + <di:waypoint xsi:type="dc:Point" x="711" y="66" /> + <di:waypoint xsi:type="dc:Point" x="711" y="182" /> <bpmndi:BPMNLabel> <dc:Bounds x="430" y="159" width="19" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0v5ffpe_di" bpmnElement="SequenceFlow_0v5ffpe"> - <di:waypoint x="440" y="207" /> - <di:waypoint x="511" y="207" /> + <di:waypoint xsi:type="dc:Point" x="440" y="207" /> + <di:waypoint xsi:type="dc:Point" x="511" y="207" /> <bpmndi:BPMNLabel> <dc:Bounds x="448" y="210" width="14" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1qr6cmf_di" bpmnElement="SequenceFlow_1qr6cmf"> - <di:waypoint x="611" y="207" /> - <di:waypoint x="686" y="207" /> + <di:waypoint xsi:type="dc:Point" x="611" y="207" /> + <di:waypoint xsi:type="dc:Point" x="686" y="207" /> <bpmndi:BPMNLabel> <dc:Bounds x="605" y="187" width="90" height="10" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0j5ksz1_di" bpmnElement="SequenceFlow_0j5ksz1"> - <di:waypoint x="-18" y="207" /> - <di:waypoint x="48" y="207" /> + <di:waypoint xsi:type="dc:Point" x="-18" y="207" /> + <di:waypoint xsi:type="dc:Point" x="48" y="207" /> <bpmndi:BPMNLabel> <dc:Bounds x="-30" y="187" width="90" height="10" /> </bpmndi:BPMNLabel> @@ -158,22 +162,22 @@ <dc:Bounds x="123" y="523" width="502" height="60" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="MessageFlow_1h3xu88_di" bpmnElement="MessageFlow_1h3xu88"> - <di:waypoint x="561" y="247" /> - <di:waypoint x="561" y="523" /> + <di:waypoint xsi:type="dc:Point" x="561" y="247" /> + <di:waypoint xsi:type="dc:Point" x="561" y="523" /> <bpmndi:BPMNLabel> <dc:Bounds x="531" y="380" width="90" height="10" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="MessageFlow_09ibv5a_di" bpmnElement="MessageFlow_09ibv5a"> - <di:waypoint x="250" y="247" /> - <di:waypoint x="250" y="523" /> + <di:waypoint xsi:type="dc:Point" x="250" y="247" /> + <di:waypoint xsi:type="dc:Point" x="250" y="523" /> <bpmndi:BPMNLabel> <dc:Bounds x="220" y="380" width="90" height="10" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="MessageFlow_0vjul4t_di" bpmnElement="MessageFlow_0vjul4t"> - <di:waypoint x="289" y="523" /> - <di:waypoint x="289" y="247" /> + <di:waypoint xsi:type="dc:Point" x="289" y="523" /> + <di:waypoint xsi:type="dc:Point" x="289" y="247" /> <bpmndi:BPMNLabel> <dc:Bounds x="259" y="380" width="90" height="10" /> </bpmndi:BPMNLabel> @@ -191,19 +195,19 @@ <dc:Bounds x="-37" y="70" width="243" height="82" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="Association_0d7oxnz_di" bpmnElement="Association_0d7oxnz"> - <di:waypoint x="-36" y="189" /> - <di:waypoint x="-36" y="152" /> + <di:waypoint xsi:type="dc:Point" x="-36" y="189" /> + <di:waypoint xsi:type="dc:Point" x="-36" y="152" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="MessageFlow_1vrcp2d_di" bpmnElement="MessageFlow_1vrcp2d"> - <di:waypoint x="1060" y="523" /> - <di:waypoint x="1060" y="247" /> + <di:waypoint xsi:type="dc:Point" x="1060" y="523" /> + <di:waypoint xsi:type="dc:Point" x="1060" y="247" /> <bpmndi:BPMNLabel> <dc:Bounds x="996" y="380" width="90" height="10" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_17s9025_di" bpmnElement="SequenceFlow_17s9025"> - <di:waypoint x="736" y="207" /> - <di:waypoint x="803" y="207" /> + <di:waypoint xsi:type="dc:Point" x="736" y="207" /> + <di:waypoint xsi:type="dc:Point" x="803" y="207" /> <bpmndi:BPMNLabel> <dc:Bounds x="719" y="187" width="90" height="10" /> </bpmndi:BPMNLabel> @@ -215,9 +219,9 @@ </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1kc34bc_di" bpmnElement="SequenceFlow_1kc34bc"> - <di:waypoint x="1092" y="265" /> - <di:waypoint x="1092" y="363" /> - <di:waypoint x="1145" y="363" /> + <di:waypoint xsi:type="dc:Point" x="1092" y="265" /> + <di:waypoint xsi:type="dc:Point" x="1092" y="363" /> + <di:waypoint xsi:type="dc:Point" x="1145" y="363" /> <bpmndi:BPMNLabel> <dc:Bounds x="1028" y="309" width="90" height="10" /> </bpmndi:BPMNLabel> @@ -226,22 +230,22 @@ <dc:Bounds x="1008" y="167" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0p09qgm_di" bpmnElement="SequenceFlow_0p09qgm"> - <di:waypoint x="1108" y="207" /> - <di:waypoint x="1312" y="207" /> + <di:waypoint xsi:type="dc:Point" x="1108" y="207" /> + <di:waypoint xsi:type="dc:Point" x="1195" y="207" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1148" y="187" width="90" height="10" /> + <dc:Bounds x="1106.5" y="187" width="90" height="10" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1o8od8e_di" bpmnElement="SequenceFlow_1o8od8e"> - <di:waypoint x="903" y="207" /> - <di:waypoint x="1008" y="207" /> + <di:waypoint xsi:type="dc:Point" x="903" y="207" /> + <di:waypoint xsi:type="dc:Point" x="1008" y="207" /> <bpmndi:BPMNLabel> <dc:Bounds x="893.5" y="187" width="90" height="10" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="MessageFlow_0tg4hw9_di" bpmnElement="MessageFlow_0tg4hw9"> - <di:waypoint x="853" y="247" /> - <di:waypoint x="853" y="523" /> + <di:waypoint xsi:type="dc:Point" x="853" y="247" /> + <di:waypoint xsi:type="dc:Point" x="853" y="523" /> <bpmndi:BPMNLabel> <dc:Bounds x="823" y="380" width="90" height="10" /> </bpmndi:BPMNLabel> @@ -250,15 +254,15 @@ <dc:Bounds x="803" y="167" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1miyzfe_di" bpmnElement="SequenceFlow_1miyzfe"> - <di:waypoint x="1245" y="363" /> - <di:waypoint x="1312" y="363" /> + <di:waypoint xsi:type="dc:Point" x="1245" y="363" /> + <di:waypoint xsi:type="dc:Point" x="1312" y="363" /> <bpmndi:BPMNLabel> <dc:Bounds x="1233.5" y="343" width="90" height="10" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="MessageFlow_1py54jr_di" bpmnElement="MessageFlow_1py54jr"> - <di:waypoint x="1195" y="403" /> - <di:waypoint x="1195" y="523" /> + <di:waypoint xsi:type="dc:Point" x="1195" y="403" /> + <di:waypoint xsi:type="dc:Point" x="1195" y="523" /> <bpmndi:BPMNLabel> <dc:Bounds x="1165" y="458" width="90" height="10" /> </bpmndi:BPMNLabel> @@ -267,8 +271,8 @@ <dc:Bounds x="1145" y="323" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0967g8p_di" bpmnElement="SequenceFlow_0967g8p"> - <di:waypoint x="148" y="207" /> - <di:waypoint x="219" y="207" /> + <di:waypoint xsi:type="dc:Point" x="148" y="207" /> + <di:waypoint xsi:type="dc:Point" x="219" y="207" /> <bpmndi:BPMNLabel> <dc:Bounds x="183.5" y="187" width="0" height="10" /> </bpmndi:BPMNLabel> @@ -282,6 +286,16 @@ <dc:Bounds x="672" y="242" width="77" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0o6zhjk_di" bpmnElement="SequenceFlow_0o6zhjk"> + <di:waypoint xsi:type="dc:Point" x="1295" y="207" /> + <di:waypoint xsi:type="dc:Point" x="1364" y="207" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1329.5" y="186" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_0xn3ug6_di" bpmnElement="CreateRelationId"> + <dc:Bounds x="1195" y="167" width="100" height="80" /> + </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> </bpmn:definitions> diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/SniroHomingV2.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/SniroHomingV2.java index e83c27c400..cb893ce950 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/SniroHomingV2.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/SniroHomingV2.java @@ -403,10 +403,8 @@ public class SniroHomingV2 { List<org.onap.so.client.sniro.beans.Candidate> cans = new ArrayList<org.onap.so.client.sniro.beans.Candidate>(); for(Candidate c:required){ org.onap.so.client.sniro.beans.Candidate can = new org.onap.so.client.sniro.beans.Candidate(); - org.onap.so.client.sniro.beans.CandidateType type = new org.onap.so.client.sniro.beans.CandidateType(); - type.setName(c.getCandidateType().getName()); - can.setCandidateType(type); - can.setCandidates(c.getCandidates()); + can.setIdentifierType(c.getIdentifierType()); + can.setIdentifiers(c.getIdentifiers()); can.setCloudOwner(c.getCloudOwner()); cans.add(can); } @@ -416,10 +414,8 @@ public class SniroHomingV2 { List<org.onap.so.client.sniro.beans.Candidate> cans = new ArrayList<org.onap.so.client.sniro.beans.Candidate>(); for(Candidate c:excluded){ org.onap.so.client.sniro.beans.Candidate can = new org.onap.so.client.sniro.beans.Candidate(); - org.onap.so.client.sniro.beans.CandidateType type = new org.onap.so.client.sniro.beans.CandidateType(); - type.setName(c.getCandidateType().getName()); - can.setCandidateType(type); - can.setCandidates(c.getCandidates()); + can.setIdentifierType(c.getIdentifierType()); + can.setIdentifiers(c.getIdentifiers()); can.setCloudOwner(c.getCloudOwner()); cans.add(can); } 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 4a3cb01b74..f47781082d 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 @@ -22,11 +22,13 @@ package org.onap.so.bpmn.infrastructure.aai.tasks; import java.util.Arrays; import java.util.List; +import java.util.Optional; +import java.util.TreeSet; +import java.util.UUID; import java.util.stream.Collectors; import org.camunda.bpm.engine.delegate.BpmnError; import org.onap.so.bpmn.common.BuildingBlockExecution; -import org.onap.so.bpmn.core.UrnPropertiesReader; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; @@ -35,6 +37,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; import org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness; +import org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy; import org.onap.so.bpmn.servicedecomposition.bbobjects.OwningEntity; import org.onap.so.bpmn.servicedecomposition.bbobjects.Platform; import org.onap.so.bpmn.servicedecomposition.bbobjects.Project; @@ -44,6 +47,9 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; +import org.onap.so.client.aai.AAIObjectPlurals; +import org.onap.so.client.aai.entities.uri.AAIResourceUri; +import org.onap.so.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.exception.BBObjectNotFoundException; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.client.orchestration.AAIConfigurationResources; @@ -53,9 +59,10 @@ import org.onap.so.client.orchestration.AAIVfModuleResources; import org.onap.so.client.orchestration.AAIVnfResources; import org.onap.so.client.orchestration.AAIVolumeGroupResources; import org.onap.so.client.orchestration.AAIVpnBindingResources; -import org.onap.so.db.catalog.beans.OrchestrationStatus; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; @@ -64,8 +71,13 @@ import org.springframework.stereotype.Component; public class AAICreateTasks { private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, AAICreateTasks.class); + private static final Logger logger = LoggerFactory.getLogger(AAICreateTasks.class.getName()); + private static final String networkTypeProvider = "PROVIDER"; private static String NETWORK_COLLECTION_NAME = "networkCollectionName"; + private static String CONTRAIL_NETWORK_POLICY_FQDN_LIST = "contrailNetworkPolicyFqdnList"; + private static String HEAT_STACK_ID = "heatStackId"; + private static String NETWORK_POLICY_FQDN_PARAM = "network-policy-fqdn"; @Autowired private AAIServiceInstanceResources aaiSIResources; @Autowired @@ -233,6 +245,11 @@ public class AAICreateTasks { try { GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID)); VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID, execution.getLookupMap().get(ResourceKey.VF_MODULE_ID)); + int moduleIndex = 0; + if (vfModule.getModelInfoVfModule() != null && !Boolean.TRUE.equals(vfModule.getModelInfoVfModule().getIsBaseBoolean())) { + moduleIndex = this.getLowestUnusedVfModuleIndexFromAAIVnfResponse(vnf, vfModule); + } + vfModule.setModuleIndex(moduleIndex); aaiVfModuleResources.createVfModule(vfModule, vnf); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); @@ -432,4 +449,95 @@ public class AAICreateTasks { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } + + public void createNetworkPolicies(BuildingBlockExecution execution) { + try{ + String fqdns = execution.getVariable(CONTRAIL_NETWORK_POLICY_FQDN_LIST); + if (fqdns != null && !fqdns.isEmpty()) { + String fqdnList[] = fqdns.split(","); + int fqdnCount = fqdnList.length; + if (fqdnCount > 0) { + for (int i=0; i < fqdnCount; i++) { + String fqdn = fqdnList[i]; + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY); + uri.queryParam(NETWORK_POLICY_FQDN_PARAM, fqdn); + Optional<org.onap.aai.domain.yang.NetworkPolicy> oNetPolicy = aaiNetworkResources.getNetworkPolicy(uri); + if(!oNetPolicy.isPresent()) { + msoLogger.debug("This network policy FQDN is not in AAI yet: " + fqdn); + String networkPolicyId = UUID.randomUUID().toString(); + msoLogger.debug("Adding network-policy with network-policy-id " + networkPolicyId); + NetworkPolicy networkPolicy = new NetworkPolicy(); + networkPolicy.setNetworkPolicyId(networkPolicyId); + networkPolicy.setNetworkPolicyFqdn(fqdn); + networkPolicy.setHeatStackId(execution.getVariable(HEAT_STACK_ID)); + + aaiNetworkResources.createNetworkPolicy(networkPolicy); + } + } + } + } + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + } + + /** + * Groups existing vf modules by the model uuid of our new vf module and returns the lowest unused index + * + * if we have a module type A, and there are 3 instances of those, + * and then module type B has 2 instances, if we are adding a new module type A, + * the vf-module-index should be 3 assuming contiguous indices (not 5, or 2) + * + */ + protected int getLowestUnusedVfModuleIndexFromAAIVnfResponse(GenericVnf genericVnf, VfModule newVfModule) { + + String newVfModuleModelInvariantUUID = null; + if (newVfModule.getModelInfoVfModule() != null) { + newVfModuleModelInvariantUUID = newVfModule.getModelInfoVfModule().getModelInvariantUUID(); + } + + + if (genericVnf != null && genericVnf.getVfModules() != null && !genericVnf.getVfModules().isEmpty()) { + List<VfModule> modules = genericVnf.getVfModules().stream().filter(item -> !item.getVfModuleId().equals(newVfModule.getVfModuleId())).collect(Collectors.toList()); + TreeSet<Integer> moduleIndices = new TreeSet<>(); + int nullIndexFound = 0; + for (VfModule vfModule : modules) { + if (vfModule.getModelInfoVfModule() != null) { + if (vfModule.getModelInfoVfModule().getModelInvariantUUID().equals(newVfModuleModelInvariantUUID)) { + if (vfModule.getModuleIndex() != null) { + moduleIndices.add(vfModule.getModuleIndex()); + } else { + nullIndexFound++; + logger.warn("Found null index for vf-module-id {} and model-invariant-uuid {}", vfModule.getVfModuleId(), vfModule.getModelInfoVfModule().getModelInvariantUUID()); + } + } + } + } + + return calculateUnusedIndex(moduleIndices, nullIndexFound); + } else { + return 0; + } + } + + protected int calculateUnusedIndex(TreeSet<Integer> moduleIndices, int nullIndexFound) { + //pad array with nulls + Integer[] temp = new Integer[moduleIndices.size() + nullIndexFound]; + Integer[] array = moduleIndices.toArray(temp); + int result = 0; + //when a null is found skip that potential value + //effectively creates something like, [0,1,3,null,null] -> [0,1,null(2),3,null(4)] + for (int i=0; i < array.length; i++, result++) { + if (Integer.valueOf(result) != array[i]) { + if (nullIndexFound > 0) { + nullIndexFound--; + i--; + } else { + break; + } + } + } + + return result; + } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasks.java index a00806a19c..8f0334e462 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasks.java @@ -21,16 +21,23 @@ package org.onap.so.bpmn.infrastructure.aai.tasks; +import java.util.Optional; +import java.util.UUID; + import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; +import org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; +import org.onap.so.client.aai.AAIObjectPlurals; +import org.onap.so.client.aai.entities.uri.AAIResourceUri; +import org.onap.so.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.client.orchestration.AAIConfigurationResources; import org.onap.so.client.orchestration.AAINetworkResources; @@ -38,11 +45,16 @@ import org.onap.so.client.orchestration.AAIServiceInstanceResources; import org.onap.so.client.orchestration.AAIVfModuleResources; import org.onap.so.client.orchestration.AAIVnfResources; import org.onap.so.client.orchestration.AAIVolumeGroupResources; +import org.onap.so.logger.MsoLogger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component public class AAIDeleteTasks { + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, AAIDeleteTasks.class); + + private static String CONTRAIL_NETWORK_POLICY_FQDN_LIST = "contrailNetworkPolicyFqdnList"; + private static String NETWORK_POLICY_FQDN_PARAM = "network-policy-fqdn"; @Autowired private ExceptionBuilder exceptionUtil; @@ -145,4 +157,30 @@ public class AAIDeleteTasks { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } + + public void deleteNetworkPolicies(BuildingBlockExecution execution) { + try{ + String fqdns = execution.getVariable(CONTRAIL_NETWORK_POLICY_FQDN_LIST); + if (fqdns != null && !fqdns.isEmpty()) { + String fqdnList[] = fqdns.split(","); + int fqdnCount = fqdnList.length; + if (fqdnCount > 0) { + for (int i=0; i < fqdnCount; i++) { + String fqdn = fqdnList[i]; + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY); + uri.queryParam(NETWORK_POLICY_FQDN_PARAM, fqdn); + Optional<org.onap.aai.domain.yang.NetworkPolicy> oNetPolicy = aaiNetworkResources.getNetworkPolicy(uri); + if(oNetPolicy.isPresent()) { + String networkPolicyId = oNetPolicy.get().getNetworkPolicyId(); + msoLogger.debug("Deleting network-policy with network-policy-id " + networkPolicyId); + + aaiNetworkResources.deleteNetworkPolicy(networkPolicyId); + } + } + } + } + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java index ed6379a6a4..5176bee0d6 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java @@ -449,4 +449,53 @@ public class AAIUpdateTasks { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } + + public void updateIpv4OamAddressVnf(BuildingBlockExecution execution) { + try { + String ipv4OamAddress = execution.getVariable("oamManagementV4Address"); + if (ipv4OamAddress != null) { + GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID)); + GenericVnf copiedGenericVnf = genericVnf.shallowCopyId(); + + genericVnf.setIpv4OamAddress(ipv4OamAddress); + copiedGenericVnf.setIpv4OamAddress(ipv4OamAddress); + + aaiVnfResources.updateObjectVnf(copiedGenericVnf); + } + } catch(Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + } + + public void updateManagementV6AddressVnf(BuildingBlockExecution execution) { + try { + String managementV6Address = execution.getVariable("oamManagementV6Address"); + if (managementV6Address != null) { + GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID)); + GenericVnf copiedGenericVnf = genericVnf.shallowCopyId(); + + genericVnf.setManagementV6Address(managementV6Address); + copiedGenericVnf.setManagementV6Address(managementV6Address); + + aaiVnfResources.updateObjectVnf(copiedGenericVnf); + } + } catch(Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + } + + public void updateContrailServiceInstanceFqdnVfModule(BuildingBlockExecution execution) { + try { + String contrailServiceInstanceFqdn = execution.getVariable("contrailServiceInstanceFqdn"); + if (contrailServiceInstanceFqdn != null) { + VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID, execution.getLookupMap().get(ResourceKey.VF_MODULE_ID)); + GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID)); + vfModule.setContrailServiceInstanceFqdn(contrailServiceInstanceFqdn); + aaiVfModuleResources.updateContrailServiceInstanceFqdnVfModule(vfModule, vnf); + } + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + } + }
\ No newline at end of file diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1.java index d919c53c9c..fec7e8456f 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1.java @@ -1,3 +1,23 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + package org.onap.so.bpmn.infrastructure.adapter.network.tasks; import java.io.StringReader; @@ -15,6 +35,9 @@ import org.onap.so.adapters.nwrest.CreateNetworkResponse; import org.onap.so.adapters.nwrest.DeleteNetworkError; import org.onap.so.adapters.nwrest.DeleteNetworkRequest; import org.onap.so.adapters.nwrest.DeleteNetworkResponse; +import org.onap.so.adapters.nwrest.UpdateNetworkError; +import org.onap.so.adapters.nwrest.UpdateNetworkRequest; +import org.onap.so.adapters.nwrest.UpdateNetworkResponse; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.client.orchestration.NetworkAdapterResources; import org.slf4j.Logger; @@ -95,6 +118,14 @@ public class NetworkAdapterRestV1 { DeleteNetworkResponse deleteNetworkResponse = (DeleteNetworkResponse) unmarshalXml(callback, DeleteNetworkResponse.class); execution.setVariable("deleteNetworkResponse", deleteNetworkResponse); } + } else if (networkAdapterRequest instanceof UpdateNetworkRequest) { + if (callback.contains("updateNetworkError")) { + UpdateNetworkError updateNetworkError = (UpdateNetworkError) unmarshalXml(callback, UpdateNetworkError.class); + throw new Exception(updateNetworkError.getMessage()); + } else { + UpdateNetworkResponse updateNetworkResponse = (UpdateNetworkResponse) unmarshalXml(callback, UpdateNetworkResponse.class); + execution.setVariable("updateNetworkResponse", updateNetworkResponse); + } } } } catch (Exception e) { diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImpl.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImpl.java index f1a9e955b6..0851dc9d95 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImpl.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImpl.java @@ -26,6 +26,7 @@ import org.onap.so.adapters.vnfrest.CreateVolumeGroupResponse; import org.onap.so.adapters.vnfrest.DeleteVfModuleResponse; import org.onap.so.adapters.vnfrest.DeleteVolumeGroupResponse; import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; @@ -47,10 +48,18 @@ import javax.xml.bind.Unmarshaller; import javax.xml.parsers.SAXParserFactory; import javax.xml.transform.sax.SAXSource; import java.io.StringReader; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; @Component public class VnfAdapterImpl { - private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, VnfAdapterCreateTasks.class); + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, VnfAdapterImpl.class); + private static final String CONTRAIL_SERVICE_INSTANCE_FQDN = "contrailServiceInstanceFqdn"; + private static final String OAM_MANAGEMENT_V4_ADDRESS = "oamManagementV4Address"; + private static final String OAM_MANAGEMENT_V6_ADDRESS = "oamManagementV6Address"; + private static final String CONTRAIL_NETWORK_POLICY_FQDN_LIST = "contrailNetworkPolicyFqdnList"; @Autowired private ExtractPojosForBB extractPojosForBB; @@ -65,6 +74,10 @@ public class VnfAdapterImpl { execution.setVariable("mso-request-id", gBBInput.getRequestContext().getMsoRequestId()); execution.setVariable("mso-service-instance-id", serviceInstance.getServiceInstanceId()); execution.setVariable("heatStackId", null); + execution.setVariable(CONTRAIL_SERVICE_INSTANCE_FQDN, null); + execution.setVariable(OAM_MANAGEMENT_V4_ADDRESS, null); + execution.setVariable(OAM_MANAGEMENT_V6_ADDRESS, null); + execution.setVariable(CONTRAIL_NETWORK_POLICY_FQDN_LIST, null); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } @@ -79,15 +92,36 @@ public class VnfAdapterImpl { VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID, execution.getLookupMap().get(ResourceKey.VF_MODULE_ID)); String heatStackId = ((CreateVfModuleResponse) vnfRestResponse).getVfModuleStackId(); if(!StringUtils.isEmpty(heatStackId)) { - vfModule.setHeatStackId(heatStackId); + vfModule.setHeatStackId(heatStackId); execution.setVariable("heatStackId", heatStackId); } + Map<String,String> vfModuleOutputs = ((CreateVfModuleResponse) vnfRestResponse).getVfModuleOutputs(); + if (vfModuleOutputs != null) { + processVfModuleOutputs(execution, vfModuleOutputs); + } } else if(vnfRestResponse instanceof DeleteVfModuleResponse) { VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID, execution.getLookupMap().get(ResourceKey.VF_MODULE_ID)); + GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID)); Boolean vfModuleDelete = ((DeleteVfModuleResponse) vnfRestResponse).getVfModuleDeleted(); if(null!= vfModuleDelete && vfModuleDelete) { vfModule.setHeatStackId(null); execution.setVariable("heatStackId", null); + Map<String,String> vfModuleOutputs = ((DeleteVfModuleResponse) vnfRestResponse).getVfModuleOutputs(); + if (vfModuleOutputs != null) { + processVfModuleOutputs(execution, vfModuleOutputs); + if (execution.getVariable(OAM_MANAGEMENT_V4_ADDRESS) != null) { + genericVnf.setIpv4OamAddress(""); + execution.setVariable(OAM_MANAGEMENT_V4_ADDRESS, ""); + } + if (execution.getVariable(OAM_MANAGEMENT_V6_ADDRESS) != null) { + genericVnf.setManagementV6Address(""); + execution.setVariable(OAM_MANAGEMENT_V6_ADDRESS, ""); + } + if (execution.getVariable(CONTRAIL_SERVICE_INSTANCE_FQDN) != null) { + vfModule.setContrailServiceInstanceFqdn(""); + execution.setVariable(CONTRAIL_SERVICE_INSTANCE_FQDN, ""); + } + } } } else if(vnfRestResponse instanceof CreateVolumeGroupResponse) { VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID, execution.getLookupMap().get(ResourceKey.VOLUME_GROUP_ID)); @@ -108,7 +142,7 @@ public class VnfAdapterImpl { } } } catch (Exception ex) { - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } @@ -133,4 +167,49 @@ public class VnfAdapterImpl { throw new MarshallerException("Error parsing VNF Adapter response. " + e.getMessage(), MsoLogger.ErrorCode.SchemaError.getValue(), e); } } + + private void processVfModuleOutputs(BuildingBlockExecution execution, Map<String,String> vfModuleOutputs) { + if (vfModuleOutputs == null) { + return; + } + try { + VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID, execution.getLookupMap().get(ResourceKey.VF_MODULE_ID)); + GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID)); + List<String> contrailNetworkPolicyFqdnList = new ArrayList<String>(); + Iterator<String> keys = vfModuleOutputs.keySet().iterator(); + while (keys.hasNext()) { + String key = keys.next(); + if (key.equals("contrail-service-instance-fqdn")) { + String contrailServiceInstanceFqdn = vfModuleOutputs.get(key); + msoLogger.debug("Obtained contrailServiceInstanceFqdn: " + contrailServiceInstanceFqdn); + vfModule.setContrailServiceInstanceFqdn(contrailServiceInstanceFqdn); + execution.setVariable(CONTRAIL_SERVICE_INSTANCE_FQDN, contrailServiceInstanceFqdn); + } + else if (key.endsWith("contrail_network_policy_fqdn")) { + String contrailNetworkPolicyFqdn = vfModuleOutputs.get(key); + msoLogger.debug("Obtained contrailNetworkPolicyFqdn: " + contrailNetworkPolicyFqdn); + contrailNetworkPolicyFqdnList.add(contrailNetworkPolicyFqdn); + } + else if (key.equals("oam_management_v4_address")) { + String oamManagementV4Address = vfModuleOutputs.get(key); + msoLogger.debug("Obtained oamManagementV4Address: " + oamManagementV4Address); + genericVnf.setIpv4OamAddress(oamManagementV4Address); + execution.setVariable(OAM_MANAGEMENT_V4_ADDRESS, oamManagementV4Address); + } + else if (key.equals("oam_management_v6_address")) { + String oamManagementV6Address = vfModuleOutputs.get(key); + msoLogger.debug("Obtained oamManagementV6Address: " + oamManagementV6Address); + genericVnf.setManagementV6Address(oamManagementV6Address); + execution.setVariable(OAM_MANAGEMENT_V6_ADDRESS, oamManagementV6Address); + } + + if (!contrailNetworkPolicyFqdnList.isEmpty()) { + execution.setVariable(CONTRAIL_NETWORK_POLICY_FQDN_LIST, String.join(",", contrailNetworkPolicyFqdnList)); + } + } + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + + } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ActivateVfModule.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ActivateVfModule.java index 32c852b0e1..f2fb37e182 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ActivateVfModule.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ActivateVfModule.java @@ -1,3 +1,23 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + package org.onap.so.bpmn.infrastructure.flowspecific.tasks; import org.onap.so.bpmn.common.BuildingBlockExecution; 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 0c0e1464b2..99bda80e4f 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 @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -48,7 +50,6 @@ import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; 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.entities.AAIResultWrapper; import org.onap.so.client.aai.entities.Relationships; @@ -58,16 +59,16 @@ import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization; import org.onap.so.db.catalog.beans.CollectionResourceCustomization; import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization; import org.onap.so.db.catalog.beans.CvnfcCustomization; -import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization; import org.onap.so.db.catalog.beans.VfModuleCustomization; import org.onap.so.db.catalog.beans.VnfVfmoduleCvnfcConfigurationCustomization; import org.onap.so.db.catalog.beans.macro.NorthBoundRequest; import org.onap.so.db.catalog.beans.macro.OrchestrationFlow; import org.onap.so.db.catalog.client.CatalogDbClient; -import org.onap.so.logger.MsoLogger; import org.onap.so.serviceinstancebeans.ModelInfo; import org.onap.so.serviceinstancebeans.ModelType; import org.onap.so.serviceinstancebeans.Networks; +import org.onap.so.serviceinstancebeans.RelatedInstance; +import org.onap.so.serviceinstancebeans.RelatedInstanceList; import org.onap.so.serviceinstancebeans.RequestDetails; import org.onap.so.serviceinstancebeans.Service; import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; @@ -198,7 +199,7 @@ public class WorkflowAction { if (orchFlows == null || orchFlows.isEmpty()) { orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, aLaCarte, cloudOwner, serviceType); } - orchFlows = filterOrchFlows(orchFlows, resourceType, execution); + orchFlows = filterOrchFlows(sIRequest, orchFlows, resourceType, execution); String key = ""; ModelInfo modelInfo = sIRequest.getRequestDetails().getModelInfo(); if(modelInfo.getModelType().equals(ModelType.service)) { @@ -437,8 +438,7 @@ public class WorkflowAction { CollectionResourceCustomization networkCollection = null; int count = 0; for(CollectionResourceCustomization collectionCust : service.getCollectionResourceCustomizations()){ - if(catalogDbClient.getNetworkCollectionResourceCustomizationByID(collectionCust.getModelCustomizationUUID()) - instanceof NetworkCollectionResourceCustomization) { + if(catalogDbClient.getNetworkCollectionResourceCustomizationByID(collectionCust.getModelCustomizationUUID()) != null) { networkCollection = collectionCust; count++; } @@ -1103,10 +1103,22 @@ public class WorkflowAction { return listToExecute; } - protected List<OrchestrationFlow> filterOrchFlows(List<OrchestrationFlow> orchFlows, WorkflowType resourceType, DelegateExecution execution) { + protected List<OrchestrationFlow> filterOrchFlows(ServiceInstancesRequest sIRequest, List<OrchestrationFlow> orchFlows, WorkflowType resourceType, DelegateExecution execution) { List<OrchestrationFlow> result = new ArrayList<>(orchFlows); + String vnfCustomizationUUID = ""; + String vfModuleCustomizationUUID = sIRequest.getRequestDetails().getModelInfo().getModelCustomizationUuid(); + RelatedInstanceList[] relatedInstanceList = sIRequest.getRequestDetails().getRelatedInstanceList(); + if (relatedInstanceList != null) { + for (RelatedInstanceList relatedInstList : relatedInstanceList) { + RelatedInstance relatedInstance = relatedInstList.getRelatedInstance(); + if (relatedInstance.getModelInfo().getModelType().equals(ModelType.vnf)) { + vnfCustomizationUUID = relatedInstance.getModelInfo().getModelCustomizationUuid(); + } + } + } + if (resourceType.equals(WorkflowType.VFMODULE)) { - List<String> fabricCustomizations = traverseCatalogDbForConfiguration((String)execution.getVariable("vnfId"), (String)execution.getVariable("vfModuleId")); + List<String> fabricCustomizations = traverseCatalogDbForConfiguration(vnfCustomizationUUID, vfModuleCustomizationUUID); if (fabricCustomizations.isEmpty()) { result = orchFlows.stream().filter(item -> !item.getFlowName().contains(FABRIC_CONFIGURATION)).collect(Collectors.toList()); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java index 78a84b1772..f6c9597de8 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java @@ -41,6 +41,7 @@ import org.onap.so.serviceinstancebeans.ServiceInstancesResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; import com.fasterxml.jackson.core.JsonProcessingException; @@ -54,6 +55,7 @@ public class WorkflowActionBBTasks { private static final String G_ALACARTE = "aLaCarte"; private static final String G_ACTION = "requestAction"; private static final String RETRY_COUNT = "retryCount"; + protected String maxRetries = "mso.rainyDay.maxRetries"; private static final Logger logger = LoggerFactory.getLogger(WorkflowActionBBTasks.class); @Autowired @@ -62,6 +64,8 @@ public class WorkflowActionBBTasks { private WorkflowAction workflowAction; @Autowired private WorkflowActionBBFailure workflowActionBBFailure; + @Autowired + private Environment environment; public void selectBB(DelegateExecution execution) { List<ExecuteBuildingBlock> flowsToExecute = (List<ExecuteBuildingBlock>) execution @@ -215,17 +219,24 @@ public class WorkflowActionBBTasks { String requestId = (String) execution.getVariable(G_REQUEST_ID); String retryDuration = (String) execution.getVariable("RetryDuration"); int retryCount = (int) execution.getVariable(RETRY_COUNT); + int envMaxRetries; + try{ + envMaxRetries = Integer.parseInt(this.environment.getProperty(maxRetries)); + } catch (Exception ex) { + logger.error("Could not read maxRetries from config file. Setting max to 5 retries"); + envMaxRetries = 5; + } int nextCount = retryCount +1; if (handlingCode.equals("Retry")){ workflowActionBBFailure.updateRequestErrorStatusMessage(execution); try{ InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId); - request.setRetryStatusMessage("Retry " + nextCount + "/5 will be started in " + retryDuration); + request.setRetryStatusMessage("Retry " + nextCount + "/" + envMaxRetries + " will be started in " + retryDuration); requestDbclient.updateInfraActiveRequests(request); } catch(Exception ex){ logger.warn("Failed to update Request Db Infra Active Requests with Retry Status",ex); } - if(retryCount<5){ + if(retryCount<envMaxRetries){ int currSequence = (int) execution.getVariable("gCurrentSequence"); execution.setVariable("gCurrentSequence", currSequence-1); execution.setVariable(RETRY_COUNT, nextCount); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java index c895566ca5..c8eeaa7a2b 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java @@ -302,4 +302,8 @@ public class AAIObjectMapper { public org.onap.aai.domain.yang.Subnet mapSubnet (Subnet subnet){ return modelMapper.map(subnet,org.onap.aai.domain.yang.Subnet.class); } + + public org.onap.aai.domain.yang.NetworkPolicy mapNetworkPolicy (NetworkPolicy networkPolicy){ + return modelMapper.map(networkPolicy,org.onap.aai.domain.yang.NetworkPolicy.class); + } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java index d2bf95a28e..4ca3f2a78d 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java @@ -45,6 +45,7 @@ import org.springframework.stereotype.Component; @Component public class AAINetworkResources { + @Autowired private InjectionHelper injectionHelper; @@ -171,6 +172,16 @@ public class AAINetworkResources { AAIResourceUri instanceGroupURI = AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId()); injectionHelper.getAaiClient().delete(instanceGroupURI); } - - + + public void createNetworkPolicy(org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy networkPolicy) { + NetworkPolicy aaiNetworkPolicy = aaiObjectMapper.mapNetworkPolicy(networkPolicy); + String networkPolicyId = networkPolicy.getNetworkPolicyId(); + AAIResourceUri netUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, networkPolicyId); + injectionHelper.getAaiClient().create(netUri, aaiNetworkPolicy); + } + + public void deleteNetworkPolicy(String networkPolicyId) { + AAIResourceUri networkPolicyURI = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, networkPolicyId); + injectionHelper.getAaiClient().delete(networkPolicyURI); + } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVfModuleResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVfModuleResources.java index a641d43ba3..ef61319eee 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVfModuleResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVfModuleResources.java @@ -76,6 +76,15 @@ public class AAIVfModuleResources { injectionHelper.getAaiClient().update(vfModuleURI, aaiVfModule); } + public void updateContrailServiceInstanceFqdnVfModule(VfModule vfModule, GenericVnf vnf) { + AAIResourceUri vfModuleURI = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnf.getVnfId(), vfModule.getVfModuleId()); + VfModule copiedVfModule = vfModule.shallowCopyId(); + + copiedVfModule.setContrailServiceInstanceFqdn(vfModule.getContrailServiceInstanceFqdn()); + org.onap.aai.domain.yang.VfModule aaiVfModule = aaiObjectMapper.mapVfModule(copiedVfModule); + injectionHelper.getAaiClient().update(vfModuleURI, aaiVfModule); + } + public void changeAssignVfModule(VfModule vfModule, GenericVnf vnf) { AAIResourceUri vfModuleURI = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnf.getVnfId(), vfModule.getVfModuleId()); org.onap.aai.domain.yang.VfModule AAIVfModule = aaiObjectMapper.mapVfModule(vfModule); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/Candidate.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/Candidate.java index b42636b078..3b7e509752 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/Candidate.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/Candidate.java @@ -23,34 +23,36 @@ package org.onap.so.client.sniro.beans; import java.io.Serializable; import java.util.List; +import org.onap.so.bpmn.servicedecomposition.homingobjects.CandidateType; + import com.fasterxml.jackson.annotation.JsonProperty; public class Candidate implements Serializable{ private static final long serialVersionUID = -5474502255533410907L; - @JsonProperty("candidateType") - private CandidateType candidateType; - @JsonProperty("candidates") - private List<String> candidates; + @JsonProperty("identifierType") + private CandidateType identifierType; + @JsonProperty("identifiers") + private List<String> identifiers; @JsonProperty("cloudOwner") private String cloudOwner; - public CandidateType getCandidateType(){ - return candidateType; + public CandidateType getIdentifierType(){ + return identifierType; } - public void setCandidateType(CandidateType candidateType){ - this.candidateType = candidateType; + public void setIdentifierType(CandidateType identifierType){ + this.identifierType = identifierType; } - public List<String> getCandidates(){ - return candidates; + public List<String> getIdentifiers(){ + return identifiers; } - public void setCandidates(List<String> candidates){ - this.candidates = candidates; + public void setIdentifiers(List<String> identifiers){ + this.identifiers = identifiers; } public String getCloudOwner(){ diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/CandidateType.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/CandidateType.java deleted file mode 100644 index d8984c0b83..0000000000 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/CandidateType.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.client.sniro.beans; - -import java.io.Serializable; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class CandidateType implements Serializable{ - - private static final long serialVersionUID = 2273215496314532173L; - - @JsonProperty("name") - private String name; - - - public String getName(){ - return name; - } - - public void setName(String name){ - this.name = name; - } - -} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java index df1f0adcea..d8c7ebaff7 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java @@ -45,6 +45,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; import org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness; +import org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy; import org.onap.so.bpmn.servicedecomposition.bbobjects.OwningEntity; import org.onap.so.bpmn.servicedecomposition.bbobjects.Platform; import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf; @@ -516,7 +517,7 @@ public class TestDataSetup{ VfModule vfModule = new VfModule(); vfModule.setVfModuleId("testVfModuleId" + vfModuleCounter); vfModule.setVfModuleName("testVfModuleName" + vfModuleCounter); - + vfModule.setModuleIndex(0); ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule(); modelInfoVfModule.setModelInvariantUUID("testModelInvariantUUID" + vfModuleCounter); modelInfoVfModule.setModelVersion("testModelVersion" + vfModuleCounter); @@ -529,6 +530,10 @@ public class TestDataSetup{ } public VfModule setVfModule() { + return setVfModule(true); + } + + public VfModule setVfModule(boolean addToGenericVnf) { VfModule vfModule = buildVfModule(); GenericVnf genericVnf = null; @@ -539,7 +544,9 @@ public class TestDataSetup{ genericVnf = setGenericVnf(); } - genericVnf.getVfModules().add(vfModule); + if (addToGenericVnf) { + genericVnf.getVfModules().add(vfModule); + } lookupKeyMap.put(ResourceKey.VF_MODULE_ID, vfModule.getVfModuleId()); return vfModule; @@ -702,4 +709,12 @@ public class TestDataSetup{ subnet.setNeutronSubnetId("testNeutronSubnetId"); return subnet; } + + public NetworkPolicy buildNetworkPolicy() { + NetworkPolicy networkPolicy = new NetworkPolicy(); + networkPolicy.setNetworkPolicyId("testNetworkPolicyId"); + networkPolicy.setNetworkPolicyFqdn("testNetworkPolicyFqdn"); + networkPolicy.setHeatStackId("testHeatStackId"); + return networkPolicy; + } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java index da7e727488..c48019af83 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java @@ -19,6 +19,7 @@ */ package org.onap.so.bpmn.infrastructure.aai.tasks; +import static org.junit.Assert.assertEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doNothing; @@ -29,12 +30,18 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import java.util.Arrays; +import java.util.Optional; +import java.util.TreeSet; + import org.camunda.bpm.engine.delegate.BpmnError; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; +import org.mockito.ArgumentCaptor; import org.mockito.ArgumentMatchers; +import org.mockito.Captor; import org.mockito.InjectMocks; import org.onap.so.bpmn.BaseTaskTest; import org.onap.so.bpmn.common.BuildingBlockExecution; @@ -43,12 +50,16 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; +import org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule; import org.onap.so.client.exception.BBObjectNotFoundException; import org.onap.so.db.catalog.beans.OrchestrationStatus; +import org.onap.so.client.aai.entities.uri.AAIResourceUri; public class AAICreateTasksTest extends BaseTaskTest{ @@ -65,6 +76,9 @@ public class AAICreateTasksTest extends BaseTaskTest{ private Customer customer; private Configuration configuration; + @Captor + ArgumentCaptor<NetworkPolicy> networkPolicyCaptor; + @Rule public final ExpectedException exception = ExpectedException.none(); @@ -268,9 +282,17 @@ public class AAICreateTasksTest extends BaseTaskTest{ @Test public void createVfModuleTest() throws Exception { - doNothing().when(aaiVfModuleResources).createVfModule(vfModule, genericVnf); + + VfModule newVfModule = setVfModule(false); + newVfModule.setModuleIndex(null); + newVfModule.getModelInfoVfModule().setModelInvariantUUID("testModelInvariantUUID1"); + doNothing().when(aaiVfModuleResources).createVfModule(newVfModule, genericVnf); + when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID), any())).thenReturn(newVfModule); + + assertEquals(null, newVfModule.getModuleIndex()); aaiCreateTasks.createVfModule(execution); - verify(aaiVfModuleResources, times(1)).createVfModule(vfModule, genericVnf); + assertEquals(1, newVfModule.getModuleIndex().intValue()); + verify(aaiVfModuleResources, times(1)).createVfModule(newVfModule, genericVnf); } @Test @@ -445,4 +467,138 @@ public class AAICreateTasksTest extends BaseTaskTest{ aaiCreateTasks.connectVnfToTenant(execution); verify(aaiVnfResources, times(1)).connectVnfToTenant(genericVnf, gBBInput.getCloudRegion()); } + @Test + public void createNetworkPolicyNeedToCreateAllTest() throws Exception { + execution.setVariable("heatStackId", "testHeatStackId"); + execution.setVariable("contrailNetworkPolicyFqdnList", "ABC123,ED456"); + Optional<NetworkPolicy> networkPolicy = Optional.empty(); + doReturn(networkPolicy).when(aaiNetworkResources).getNetworkPolicy(any(AAIResourceUri.class)); + doNothing().when(aaiNetworkResources).createNetworkPolicy(any(NetworkPolicy.class)); + aaiCreateTasks.createNetworkPolicies(execution); + verify(aaiNetworkResources, times(2)).createNetworkPolicy(networkPolicyCaptor.capture()); + assertEquals("ABC123", networkPolicyCaptor.getAllValues().get(0).getNetworkPolicyFqdn()); + assertEquals("ED456", networkPolicyCaptor.getAllValues().get(1).getNetworkPolicyFqdn()); + assertEquals("testHeatStackId", networkPolicyCaptor.getAllValues().get(0).getHeatStackId()); + assertEquals("testHeatStackId", networkPolicyCaptor.getAllValues().get(1).getHeatStackId()); + } + + @Test + public void createNetworkPolicyNeedToCreateNoneTest() throws Exception { + execution.setVariable("heatStackId", "testHeatStackId"); + execution.setVariable("contrailNetworkPolicyFqdnList", "ABC123"); + NetworkPolicy networkPolicy = new NetworkPolicy(); + doReturn(Optional.of(networkPolicy)).when(aaiNetworkResources).getNetworkPolicy(any(AAIResourceUri.class)); + doNothing().when(aaiNetworkResources).createNetworkPolicy(any(NetworkPolicy.class)); + aaiCreateTasks.createNetworkPolicies(execution); + verify(aaiNetworkResources, times(0)).createNetworkPolicy(any(NetworkPolicy.class)); + } + + @Test + public void createNetworkPolicyNoNetworkPoliciesTest() throws Exception { + execution.setVariable("heatStackId", "testHeatStackId"); + aaiCreateTasks.createNetworkPolicies(execution); + verify(aaiNetworkResources, times(0)).createNetworkPolicy(any(NetworkPolicy.class)); + } + + @Test + public void createVfModuleGetLowestIndexTest() throws Exception { + GenericVnf vnf = new GenericVnf(); + ModelInfoGenericVnf vnfInfo = new ModelInfoGenericVnf(); + vnf.setModelInfoGenericVnf(vnfInfo); + vnfInfo.setModelInvariantUuid("my-uuid"); + + ModelInfoVfModule infoA = new ModelInfoVfModule(); + infoA.setIsBaseBoolean(false); + infoA.setModelInvariantUUID("A"); + + ModelInfoVfModule infoB = new ModelInfoVfModule(); + infoB.setIsBaseBoolean(false); + infoB.setModelInvariantUUID("B"); + + ModelInfoVfModule infoC = new ModelInfoVfModule(); + infoC.setIsBaseBoolean(false); + infoC.setModelInvariantUUID("C"); + + VfModule newVfModuleA = new VfModule(); + newVfModuleA.setVfModuleId("a"); + VfModule newVfModuleB = new VfModule(); + newVfModuleB.setVfModuleId("b"); + VfModule newVfModuleC = new VfModule(); + newVfModuleC.setVfModuleId("c"); + + VfModule vfModule = new VfModule(); + vnf.getVfModules().add(vfModule); + vfModule.setVfModuleId("1"); + + VfModule vfModule2 = new VfModule(); + vnf.getVfModules().add(vfModule2); + vfModule2.setVfModuleId("2"); + + VfModule vfModule3 = new VfModule(); + vnf.getVfModules().add(vfModule3); + vfModule3.setVfModuleId("3"); + + VfModule vfModule4 = new VfModule(); + vnf.getVfModules().add(vfModule4); + vfModule4.setVfModuleId("4"); + + VfModule vfModule5 = new VfModule(); + vnf.getVfModules().add(vfModule5); + vfModule5.setVfModuleId("5"); + + //modules are included in the vnf already + vnf.getVfModules().add(newVfModuleA); + vnf.getVfModules().add(newVfModuleB); + vnf.getVfModules().add(newVfModuleC); + + //A + newVfModuleA.setModelInfoVfModule(infoA); + vfModule.setModelInfoVfModule(infoA); + vfModule2.setModelInfoVfModule(infoA); + vfModule3.setModelInfoVfModule(infoA); + + //B + + newVfModuleB.setModelInfoVfModule(infoB); + vfModule4.setModelInfoVfModule(infoB); + vfModule5.setModelInfoVfModule(infoB); + + //C + newVfModuleC.setModelInfoVfModule(infoC); + + + //A + vfModule.setModuleIndex(2); + vfModule2.setModuleIndex(0); + vfModule3.setModuleIndex(3); + + //B + vfModule4.setModuleIndex(null); + vfModule5.setModuleIndex(1); + + assertEquals(1, aaiCreateTasks.getLowestUnusedVfModuleIndexFromAAIVnfResponse(vnf, newVfModuleA)); + + assertEquals(2, aaiCreateTasks.getLowestUnusedVfModuleIndexFromAAIVnfResponse(vnf, newVfModuleB)); + + assertEquals(0, aaiCreateTasks.getLowestUnusedVfModuleIndexFromAAIVnfResponse(vnf, newVfModuleC)); + + } + + @Test + public void calculateUnusedIndexTest() { + + TreeSet<Integer> a = new TreeSet<>(Arrays.asList(0,1,3)); + TreeSet<Integer> b = new TreeSet<>(Arrays.asList(0,1,8)); + TreeSet<Integer> c = new TreeSet<>(Arrays.asList(0,2,4)); + assertEquals(2, aaiCreateTasks.calculateUnusedIndex(a, 0)); + assertEquals(5, aaiCreateTasks.calculateUnusedIndex(a, 2)); + + assertEquals(4, aaiCreateTasks.calculateUnusedIndex(b, 2)); + assertEquals(3, aaiCreateTasks.calculateUnusedIndex(b, 1)); + + assertEquals(5, aaiCreateTasks.calculateUnusedIndex(c, 2)); + assertEquals(9, aaiCreateTasks.calculateUnusedIndex(c, 6)); + assertEquals(1, aaiCreateTasks.calculateUnusedIndex(c, 0)); + + } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasksTest.java index 67f5d197de..5cb775180e 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasksTest.java @@ -20,22 +20,26 @@ package org.onap.so.bpmn.infrastructure.aai.tasks; +import static org.junit.Assert.assertEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import java.util.ArrayList; -import java.util.List; +import java.util.Optional; import org.camunda.bpm.engine.delegate.BpmnError; import org.junit.Before; import org.junit.Test; +import org.mockito.ArgumentCaptor; import org.mockito.ArgumentMatchers; +import org.mockito.Captor; import org.mockito.InjectMocks; +import org.onap.aai.domain.yang.NetworkPolicy; import org.onap.so.bpmn.BaseTaskTest; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; @@ -46,6 +50,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.so.client.exception.BBObjectNotFoundException; @@ -62,6 +67,9 @@ public class AAIDeleteTasksTest extends BaseTaskTest { private CloudRegion cloudRegion; private Configuration configuration; + @Captor + ArgumentCaptor<String> stringCaptor; + @Before public void before() throws BBObjectNotFoundException { serviceInstance = setServiceInstance(); @@ -179,4 +187,34 @@ public class AAIDeleteTasksTest extends BaseTaskTest { aaiDeleteTasks.deleteConfiguration(execution); verify(aaiConfigurationResources, times(1)).deleteConfiguration(configuration); } + + @Test + public void deleteNetworkPolicyNeedToDeleteAllTest() throws Exception { + execution.setVariable("contrailNetworkPolicyFqdnList", "ABC123,DEF456"); + NetworkPolicy networkPolicy0 = new NetworkPolicy(); + networkPolicy0.setNetworkPolicyId("testNetworkPolicyId0"); + NetworkPolicy networkPolicy1 = new NetworkPolicy(); + networkPolicy1.setNetworkPolicyId("testNetworkPolicyId1"); + doReturn(Optional.of(networkPolicy0),Optional.of(networkPolicy1)).when(aaiNetworkResources).getNetworkPolicy(any(AAIResourceUri.class)); + doNothing().when(aaiNetworkResources).deleteNetworkPolicy(any(String.class)); + aaiDeleteTasks.deleteNetworkPolicies(execution); + verify(aaiNetworkResources, times(2)).deleteNetworkPolicy(stringCaptor.capture()); + assertEquals("testNetworkPolicyId0", stringCaptor.getAllValues().get(0)); + assertEquals("testNetworkPolicyId1", stringCaptor.getAllValues().get(1)); + } + + @Test + public void deleteNetworkPolicyNeedToDeleteNoneTest() throws Exception { + execution.setVariable("contrailNetworkPolicyFqdnList", "ABC123"); + Optional<NetworkPolicy> networkPolicy = Optional.empty(); + doReturn(networkPolicy).when(aaiNetworkResources).getNetworkPolicy(any(AAIResourceUri.class)); + aaiDeleteTasks.deleteNetworkPolicies(execution); + verify(aaiNetworkResources, times(0)).deleteNetworkPolicy(any(String.class)); + } + + @Test + public void deleteNetworkPolicyNoNetworkPoliciesTest() throws Exception { + aaiDeleteTasks.deleteNetworkPolicies(execution); + verify(aaiNetworkResources, times(0)).deleteNetworkPolicy(any(String.class)); + } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java index f97b137fb3..73d7257632 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java @@ -586,4 +586,49 @@ public class AAIUpdateTasksTest extends BaseTaskTest{ verify(aaiConfigurationResources, times(1)).updateOrchestrationStatusConfiguration(configuration, OrchestrationStatus.ACTIVE); } + @Test + public void updateContrailServiceInstanceFqdnVfModuleTest() throws Exception { + execution.setVariable("contrailServiceInstanceFqdn", "newContrailServiceInstanceFqdn"); + doNothing().when(aaiVfModuleResources).updateContrailServiceInstanceFqdnVfModule(vfModule, genericVnf); + + aaiUpdateTasks.updateContrailServiceInstanceFqdnVfModule(execution); + + verify(aaiVfModuleResources, times(1)).updateContrailServiceInstanceFqdnVfModule(vfModule, genericVnf); + assertEquals("newContrailServiceInstanceFqdn", vfModule.getContrailServiceInstanceFqdn()); + } + @Test + public void updateContrailServiceInstanceFqdnVfModuleNoUpdateTest() throws Exception { + aaiUpdateTasks.updateContrailServiceInstanceFqdnVfModule(execution); + verify(aaiVfModuleResources, times(0)).updateContrailServiceInstanceFqdnVfModule(vfModule, genericVnf); + } + @Test + public void updateIpv4OamAddressVnfTest() throws Exception { + execution.setVariable("oamManagementV4Address", "newIpv4OamAddress"); + doNothing().when(aaiVnfResources).updateObjectVnf(genericVnf); + + aaiUpdateTasks.updateIpv4OamAddressVnf(execution); + + verify(aaiVnfResources, times(1)).updateObjectVnf(genericVnf); + assertEquals("newIpv4OamAddress", genericVnf.getIpv4OamAddress()); + } + @Test + public void updateIpv4OamAddressVnfNoUpdateTest() throws Exception { + aaiUpdateTasks.updateIpv4OamAddressVnf(execution); + verify(aaiVnfResources, times(0)).updateObjectVnf(genericVnf); + } + @Test + public void updateManagementV6AddressVnfTest() throws Exception { + execution.setVariable("oamManagementV6Address", "newManagementV6Address"); + doNothing().when(aaiVnfResources).updateObjectVnf(genericVnf); + + aaiUpdateTasks.updateManagementV6AddressVnf(execution); + + verify(aaiVnfResources, times(1)).updateObjectVnf(genericVnf); + assertEquals("newManagementV6Address", genericVnf.getManagementV6Address()); + } + @Test + public void updateManagementV6AddressVnfNoUpdateTest() throws Exception { + aaiUpdateTasks.updateManagementV6AddressVnf(execution); + verify(aaiVnfResources, times(0)).updateObjectVnf(genericVnf); + } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java index 2ba8cb4b57..516c9480ad 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java @@ -1,11 +1,37 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + package org.onap.so.bpmn.infrastructure.adapter.network.tasks; +import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; +import static org.junit.Assert.assertThat; + import java.io.IOException; +import java.util.HashMap; +import java.util.Map; import javax.xml.bind.JAXBException; import org.junit.Test; import org.onap.so.adapters.nwrest.CreateNetworkResponse; +import org.onap.so.adapters.nwrest.UpdateNetworkResponse; public class NetworkAdapterRestV1Test { @@ -16,4 +42,17 @@ public class NetworkAdapterRestV1Test { String returnedXml = response.toXmlString(); System.out.println(returnedXml); } + + @Test + public void testUnmarshalXmlUpdate() throws IOException, JAXBException { + UpdateNetworkResponse expectedResponse = new UpdateNetworkResponse(); + expectedResponse.setMessageId("ec100bcc-2659-4aa4-b4d8-3255715c2a51"); + expectedResponse.setNetworkId("80de31e3-cc78-4111-a9d3-5b92bf0a39eb"); + Map<String,String>subnetMap = new HashMap<String,String>(); + subnetMap.put("95cd8437-25f1-4238-8720-cbfe7fa81476", "d8d16606-5d01-4822-b160-9a0d257303e0"); + expectedResponse.setSubnetMap(subnetMap); + String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><updateNetworkResponse><messageId>ec100bcc-2659-4aa4-b4d8-3255715c2a51</messageId><networkId>80de31e3-cc78-4111-a9d3-5b92bf0a39eb</networkId><subnetMap><entry><key>95cd8437-25f1-4238-8720-cbfe7fa81476</key><value>d8d16606-5d01-4822-b160-9a0d257303e0</value></entry></subnetMap></updateNetworkResponse>"; + UpdateNetworkResponse response = (UpdateNetworkResponse) new NetworkAdapterRestV1().unmarshalXml(xml, UpdateNetworkResponse.class); + assertThat(expectedResponse, sameBeanAs(response)); + } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImplTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImplTest.java index 4158f9cfae..33d0dbe130 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImplTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImplTest.java @@ -21,6 +21,7 @@ package org.onap.so.bpmn.infrastructure.adapter.vnf.tasks; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNull; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; @@ -35,6 +36,7 @@ import org.mockito.InjectMocks; import org.onap.so.FileUtil; import org.onap.so.bpmn.BaseTaskTest; import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; @@ -50,6 +52,7 @@ public class VnfAdapterImplTest extends BaseTaskTest { private RequestContext requestContext; private ServiceInstance serviceInstance; + private GenericVnf genericVnf; private VfModule vfModule; private VolumeGroup volumeGroup; @@ -58,12 +61,17 @@ public class VnfAdapterImplTest extends BaseTaskTest { private static final String VNF_ADAPTER_VOLUME_CREATE_RESPONSE = FileUtil.readResourceFile("__files/VfModularity/CreateVfModuleVolumeCallbackResponse.xml"); private static final String VNF_ADAPTER_VOLUME_DELETE_RESPONSE = FileUtil.readResourceFile("__files/VfModularity/DeleteVfModuleVolumeCallbackResponse.xml"); private static final String TEST_VFMODULE_HEATSTACK_ID = "slowburn"; - private static final String TEST_VOLUME_HEATSTACK_ID = "testHeatStackId1"; + private static final String TEST_VOLUME_HEATSTACK_ID = "testHeatStackId1"; + private static final String TEST_CONTRAIL_SERVICE_INSTANCE_FQDN = "default-domain:MSOTest:MsoNW-RA"; + private static final String TEST_OAM_MANAGEMENT_V4_ADDRESS = "127.0.0.1"; + private static final String TEST_OAM_MANAGEMENT_V6_ADDRESS = "2000:abc:bce:1111"; + private static final String TEST_CONTRAIL_NETWORK_POLICY_FQDNS = "MSOTest:DefaultPolicyFQDN2,MSOTest:DefaultPolicyFQDN1"; @Before public void before() throws BBObjectNotFoundException { requestContext = setRequestContext(); serviceInstance = setServiceInstance(); + genericVnf = setGenericVnf(); vfModule = setVfModule(); volumeGroup = setVolumeGroup(); vfModule.setHeatStackId(null); @@ -72,6 +80,7 @@ public class VnfAdapterImplTest extends BaseTaskTest { doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class)); when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID), any())).thenReturn(serviceInstance); when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID), any())).thenReturn(volumeGroup); + when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID), any())).thenReturn(genericVnf); when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID), any())).thenReturn(vfModule); } @@ -86,8 +95,15 @@ public class VnfAdapterImplTest extends BaseTaskTest { @Test public void postProcessVnfAdapter_CreateResponseTest() { execution.setVariable("vnfAdapterRestV1Response", VNF_ADAPTER_REST_CREATE_RESPONSE); - vnfAdapterImpl.postProcessVnfAdapter(execution); + vnfAdapterImpl.postProcessVnfAdapter(execution); assertEquals(TEST_VFMODULE_HEATSTACK_ID, vfModule.getHeatStackId()); + assertEquals(TEST_CONTRAIL_SERVICE_INSTANCE_FQDN, vfModule.getContrailServiceInstanceFqdn()); + assertEquals(TEST_CONTRAIL_SERVICE_INSTANCE_FQDN, execution.getVariable("contrailServiceInstanceFqdn")); + assertEquals(TEST_OAM_MANAGEMENT_V4_ADDRESS, genericVnf.getIpv4OamAddress()); + assertEquals(TEST_OAM_MANAGEMENT_V4_ADDRESS, execution.getVariable("oamManagementV4Address")); + assertEquals(TEST_OAM_MANAGEMENT_V6_ADDRESS, genericVnf.getManagementV6Address()); + assertEquals(TEST_OAM_MANAGEMENT_V6_ADDRESS, execution.getVariable("oamManagementV6Address")); + assertEquals(TEST_CONTRAIL_NETWORK_POLICY_FQDNS, execution.getVariable("contrailNetworkPolicyFqdnList")); } @@ -111,6 +127,20 @@ public class VnfAdapterImplTest extends BaseTaskTest { vnfAdapterImpl.postProcessVnfAdapter(execution); assertNull(vfModule.getHeatStackId()); } + + @Test + public void postProcessVnfAdapter_CreateResponseTest_EmptyVfModuleOutputs() { + execution.setVariable("vnfAdapterRestV1Response", "<createVfModuleResponse><vfModuleOutputs></vfModuleOutputs></createVfModuleResponse>"); + vnfAdapterImpl.postProcessVnfAdapter(execution); + assertNull(vfModule.getHeatStackId()); + assertNull(vfModule.getContrailServiceInstanceFqdn()); + assertNull(execution.getVariable("contrailServiceInstanceFqdn")); + assertNotEquals(TEST_OAM_MANAGEMENT_V4_ADDRESS, genericVnf.getIpv4OamAddress()); + assertNull(execution.getVariable("oamManagementV4Address")); + assertNull(genericVnf.getManagementV6Address()); + assertNull(execution.getVariable("oamManagementV6Address")); + assertNull(execution.getVariable("contrailNetworkPolicyFqdnList")); + } @Test public void postProcessVnfAdapter_DeleteResponseTest() { @@ -118,6 +148,25 @@ public class VnfAdapterImplTest extends BaseTaskTest { execution.setVariable("vnfAdapterRestV1Response", VNF_ADAPTER_REST_DELETE_RESPONSE); vnfAdapterImpl.postProcessVnfAdapter(execution); assertNull(vfModule.getHeatStackId()); + assertEquals(vfModule.getContrailServiceInstanceFqdn(), ""); + assertEquals(execution.getVariable("contrailServiceInstanceFqdn"), ""); + assertEquals(genericVnf.getIpv4OamAddress(), ""); + assertEquals(execution.getVariable("oamManagementV4Address"), ""); + assertEquals(genericVnf.getManagementV6Address(), ""); + assertEquals(execution.getVariable("oamManagementV6Address"), ""); + assertEquals(TEST_CONTRAIL_NETWORK_POLICY_FQDNS, execution.getVariable("contrailNetworkPolicyFqdnList")); + } + + @Test + public void postProcessVnfAdapter_DeleteResponseTest_EmptyVfModuleOutputs() { + execution.setVariable("vnfAdapterRestV1Response", "<createVfModuleResponse><vfModuleOutputs></vfModuleOutputs></createVfModuleResponse>"); + vnfAdapterImpl.postProcessVnfAdapter(execution); + assertNull(vfModule.getHeatStackId()); + assertNull(vfModule.getContrailServiceInstanceFqdn()); + assertNull(execution.getVariable("contrailServiceInstanceFqdn")); + assertNull(execution.getVariable("oamManagementV4Address")); + assertNull(execution.getVariable("oamManagementV6Address")); + assertNull(execution.getVariable("contrailNetworkPolicyFqdnList")); } @Test diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ActivateVfModuleTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ActivateVfModuleTest.java index 57e463c0f8..d1d167e561 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ActivateVfModuleTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ActivateVfModuleTest.java @@ -1,3 +1,23 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + package org.onap.so.bpmn.infrastructure.flowspecific.tasks; import static org.junit.Assert.*; diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/SniroHomingV2IT.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/SniroHomingV2IT.java index f0bb6a369c..59fad5cdd6 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/SniroHomingV2IT.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/SniroHomingV2IT.java @@ -84,7 +84,7 @@ public class SniroHomingV2IT extends BaseIntegrationTest{ requestContext.setMsoRequestId("testRequestId"); RequestParameters params = new RequestParameters(); params.setaLaCarte(false); - params.setSubscriptionServiceType("iptollfree"); + params.setSubscriptionServiceType("testSubscriptionServiceType"); requestContext.setRequestParameters(params); } @@ -94,10 +94,10 @@ public class SniroHomingV2IT extends BaseIntegrationTest{ bondingLink.getServiceProxies().add(setServiceProxy("1", "transport")); ServiceProxy sp2 = setServiceProxy("2", "infrastructure"); Candidate requiredCandidate = new Candidate(); - requiredCandidate.setCandidateType(CandidateType.VNF_ID); + requiredCandidate.setIdentifierType(CandidateType.VNF_ID); List<String> c = new ArrayList<String>(); c.add("testVnfId"); - requiredCandidate.setCandidates(c); + requiredCandidate.setIdentifiers(c); sp2.addRequiredCandidates(requiredCandidate); bondingLink.getServiceProxies().add(sp2); serviceInstance.getVpnBondingLinks().add(bondingLink); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorUnitTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorUnitTest.java index 4ace2727be..03b39f57e5 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorUnitTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorUnitTest.java @@ -1,3 +1,23 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + package org.onap.so.bpmn.infrastructure.workflow.tasks; import static org.hamcrest.CoreMatchers.equalTo; diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java index f3b094f645..2fc62978fb 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java @@ -31,6 +31,7 @@ import static org.mockito.Mockito.when; import java.util.ArrayList; import java.util.List; +import org.camunda.bpm.engine.delegate.BpmnError; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake; import org.junit.Before; @@ -46,6 +47,7 @@ import org.onap.so.bpmn.core.WorkflowException; import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.db.request.beans.InfraActiveRequests; +import org.springframework.core.env.Environment; public class WorkflowActionBBTasksTest extends BaseTaskTest { @@ -64,6 +66,9 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { private DelegateExecution execution; + @Mock + protected Environment environment; + @Rule public ExpectedException thrown = ExpectedException.none(); @@ -287,6 +292,7 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { String reqId = "reqId123"; execution.setVariable("mso-request-id", reqId); doNothing().when(workflowActionBBFailure).updateRequestErrorStatusMessage(isA(DelegateExecution.class)); + doReturn("6").when(environment).getProperty("mso.rainyDay.maxRetries"); execution.setVariable("handlingCode","Retry"); execution.setVariable("retryCount", 1); execution.setVariable("gCurrentSequence",1); @@ -297,6 +303,25 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { } @Test + public void checkRetryStatusTestExceededMaxRetries(){ + String reqId = "reqId123"; + execution.setVariable("mso-request-id", reqId); + doNothing().when(workflowActionBBFailure).updateRequestErrorStatusMessage(isA(DelegateExecution.class)); + doReturn("6").when(environment).getProperty("mso.rainyDay.maxRetries"); + execution.setVariable("handlingCode","Retry"); + execution.setVariable("retryCount", 6); + execution.setVariable("gCurrentSequence",1); + InfraActiveRequests req = new InfraActiveRequests(); + doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId(reqId); + try{ + workflowActionBBTasks.checkRetryStatus(execution); + } catch (BpmnError e) { + WorkflowException exception = (WorkflowException) execution.getVariable("WorkflowException"); + assertEquals("Exceeded maximum retries. Ending flow with status Abort",exception.getErrorMessage()); + } + } + + @Test public void checkRetryStatusNoRetryTest(){ String reqId = "reqId123"; execution.setVariable("mso-request-id", reqId); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java index 7b348c8cb3..c74f590e6b 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -23,6 +25,7 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.equalTo; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertThat; import static org.mockito.ArgumentMatchers.anyObject; @@ -31,16 +34,18 @@ import static org.mockito.Matchers.isA; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.when; +import com.fasterxml.jackson.databind.ObjectMapper; import java.io.IOException; import java.net.MalformedURLException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashSet; import java.util.List; import java.util.Optional; +import java.util.Set; import java.util.UUID; - import org.camunda.bpm.engine.delegate.BpmnError; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake; @@ -70,6 +75,8 @@ import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization; import org.onap.so.db.catalog.beans.CollectionResource; import org.onap.so.db.catalog.beans.CollectionResourceCustomization; import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization; +import org.onap.so.db.catalog.beans.ConfigurationResource; +import org.onap.so.db.catalog.beans.CvnfcCustomization; import org.onap.so.db.catalog.beans.HeatEnvironment; import org.onap.so.db.catalog.beans.HeatTemplate; import org.onap.so.db.catalog.beans.InstanceGroup; @@ -77,6 +84,7 @@ import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization; import org.onap.so.db.catalog.beans.NetworkResourceCustomization; import org.onap.so.db.catalog.beans.Service; import org.onap.so.db.catalog.beans.VfModuleCustomization; +import org.onap.so.db.catalog.beans.VnfVfmoduleCvnfcConfigurationCustomization; import org.onap.so.db.catalog.beans.macro.NorthBoundRequest; import org.onap.so.db.catalog.beans.macro.OrchestrationFlow; import org.onap.so.serviceinstancebeans.RequestDetails; @@ -85,8 +93,6 @@ import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; import org.onap.so.serviceinstancebeans.SubscriberInfo; import org.springframework.core.env.Environment; -import com.fasterxml.jackson.databind.ObjectMapper; - public class WorkflowActionTest extends BaseTaskTest { @@ -854,6 +860,63 @@ public class WorkflowActionTest extends BaseTaskTest { ,"DeleteNetworkCollectionBB"); } + @Test + public void selectExecutionListALaCarteVfModuleNoFabricCreateTest() throws Exception{ + String gAction = "createInstance"; + String resource = "VfModule"; + execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); + execution.setVariable("requestAction", gAction); + String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); + execution.setVariable("bpmnRequest", bpmnRequest); + execution.setVariable("aLaCarte", true); + execution.setVariable("apiVersion", "7"); + execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules"); + + + NorthBoundRequest northBoundRequest = new NorthBoundRequest(); + List<OrchestrationFlow> orchFlows = createFlowList("AssignVfModuleBB","CreateVfModuleBB","ActivateVfModuleBB","AssignFabricConfigurationBB","ActivateFabricConfigurationBB"); + northBoundRequest.setOrchestrationFlowList(orchFlows); + + when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,true,"my-custom-cloud-owner")).thenReturn(northBoundRequest); + workflowAction.selectExecutionList(execution); + List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute"); + assertEqualsBulkFlowName(ebbs,"AssignVfModuleBB","CreateVfModuleBB","ActivateVfModuleBB"); + } + + @Test + public void selectExecutionListALaCarteVfModuleFabricCreateTest() throws Exception{ + String gAction = "createInstance"; + String resource = "VfModule"; + execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); + execution.setVariable("requestAction", gAction); + String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); + execution.setVariable("bpmnRequest", bpmnRequest); + execution.setVariable("aLaCarte", true); + execution.setVariable("apiVersion", "7"); + execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules"); + + NorthBoundRequest northBoundRequest = new NorthBoundRequest(); + List<OrchestrationFlow> orchFlows = createFlowList("AssignVfModuleBB","CreateVfModuleBB","ActivateVfModuleBB","AssignFabricConfigurationBB","ActivateFabricConfigurationBB"); + northBoundRequest.setOrchestrationFlowList(orchFlows); + + List<CvnfcCustomization> cvnfcCustomizations = new ArrayList<CvnfcCustomization>(); + CvnfcCustomization cvnfcCustomization = new CvnfcCustomization(); + VnfVfmoduleCvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization = new VnfVfmoduleCvnfcConfigurationCustomization(); + ConfigurationResource configurationResource = new ConfigurationResource(); + configurationResource.setToscaNodeType("FabricConfiguration"); + vnfVfmoduleCvnfcConfigurationCustomization.setConfigurationResource(configurationResource); + Set<VnfVfmoduleCvnfcConfigurationCustomization> custSet = new HashSet<VnfVfmoduleCvnfcConfigurationCustomization>(); + custSet.add(vnfVfmoduleCvnfcConfigurationCustomization); + cvnfcCustomization.setVnfVfmoduleCvnfcConfigurationCustomization(custSet); + cvnfcCustomizations.add(cvnfcCustomization); + + when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,true,"my-custom-cloud-owner")).thenReturn(northBoundRequest); + when(catalogDbClient.getCvnfcCustomizationByVnfCustomizationUUIDAndVfModuleCustomizationUUID("fc25201d-36d6-43a3-8d39-fdae88e526ae", "9a6d01fd-19a7-490a-9800-460830a12e0b")).thenReturn(cvnfcCustomizations); + workflowAction.selectExecutionList(execution); + List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute"); + assertEqualsBulkFlowName(ebbs,"AssignVfModuleBB","CreateVfModuleBB","ActivateVfModuleBB","AssignFabricConfigurationBB","ActivateFabricConfigurationBB"); + } + /** * WorkflowActionBB Tests */ @@ -1228,7 +1291,44 @@ public class WorkflowActionTest extends BaseTaskTest { assertEquals("222",result.get(1).getResourceId()); assertEquals("111",result.get(2).getResourceId()); } - + + @Test + public void findCatalogNetworkCollectionTest() { + Service service = new Service(); + NetworkCollectionResourceCustomization networkCustomization = new NetworkCollectionResourceCustomization(); + networkCustomization.setModelCustomizationUUID("123"); + service.getCollectionResourceCustomizations().add(networkCustomization); + doReturn(networkCustomization).when(catalogDbClient).getNetworkCollectionResourceCustomizationByID("123"); + CollectionResourceCustomization customization = workflowAction.findCatalogNetworkCollection(execution, service); + assertNotNull(customization); + } + + @Test + public void findCatalogNetworkCollectionEmptyTest() { + Service service = new Service(); + NetworkCollectionResourceCustomization networkCustomization = new NetworkCollectionResourceCustomization(); + networkCustomization.setModelCustomizationUUID("123"); + service.getCollectionResourceCustomizations().add(networkCustomization); + CollectionResourceCustomization customization = workflowAction.findCatalogNetworkCollection(execution, service); + assertNull(customization); + } + + @Test + public void findCatalogNetworkCollectionMoreThanOneTest() { + Service service = new Service(); + NetworkCollectionResourceCustomization networkCustomization1 = new NetworkCollectionResourceCustomization(); + networkCustomization1.setModelCustomizationUUID("123"); + NetworkCollectionResourceCustomization networkCustomization2 = new NetworkCollectionResourceCustomization(); + networkCustomization2.setModelCustomizationUUID("321"); + service.getCollectionResourceCustomizations().add(networkCustomization1); + service.getCollectionResourceCustomizations().add(networkCustomization2); + doReturn(networkCustomization1).when(catalogDbClient).getNetworkCollectionResourceCustomizationByID("123"); + doReturn(networkCustomization2).when(catalogDbClient).getNetworkCollectionResourceCustomizationByID("321"); + workflowAction.findCatalogNetworkCollection(execution, service); + assertEquals("Found multiple Network Collections in the Service model, only one per Service is supported.", + execution.getVariable("WorkflowActionErrorMessage")); + } + private List<OrchestrationFlow> createFlowList (String... flowNames){ List<OrchestrationFlow> result = new ArrayList<>(); for(String flowName : flowNames){ diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionUnitTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionUnitTest.java index 297d75a104..2dd4033aa2 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionUnitTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionUnitTest.java @@ -57,6 +57,10 @@ import org.onap.so.db.catalog.beans.CvnfcCustomization; import org.onap.so.db.catalog.beans.VnfVfmoduleCvnfcConfigurationCustomization; import org.onap.so.db.catalog.beans.macro.OrchestrationFlow; import org.onap.so.db.catalog.client.CatalogDbClient; +import org.onap.so.serviceinstancebeans.ModelInfo; +import org.onap.so.serviceinstancebeans.RelatedInstance; +import org.onap.so.serviceinstancebeans.RequestDetails; +import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; @RunWith(MockitoJUnitRunner.class) public class WorkflowActionUnitTest { @@ -87,9 +91,16 @@ public class WorkflowActionUnitTest { "flow y", "ActivateFabricConfigurationBB", "flow z"); - doReturn(Arrays.asList("yes", "yes")).when(workflowAction).traverseCatalogDbForConfiguration(ArgumentMatchers.isNull(), ArgumentMatchers.isNull()); + doReturn(Arrays.asList("yes", "yes")).when(workflowAction).traverseCatalogDbForConfiguration(ArgumentMatchers.any(String.class), ArgumentMatchers.isNull()); - List<OrchestrationFlow> result = workflowAction.filterOrchFlows(flows, WorkflowType.VFMODULE, mock(DelegateExecution.class)); + ServiceInstancesRequest sIRequest = new ServiceInstancesRequest(); + RequestDetails requestDetails = new RequestDetails(); + ModelInfo modelInfo = new ModelInfo(); + requestDetails.setModelInfo(modelInfo); + RelatedInstance relatedInstance = new RelatedInstance(); + sIRequest.setRequestDetails(requestDetails); + + List<OrchestrationFlow> result = workflowAction.filterOrchFlows(sIRequest, flows, WorkflowType.VFMODULE, mock(DelegateExecution.class)); assertThat(result, is(flows)); } @@ -103,7 +114,14 @@ public class WorkflowActionUnitTest { "ActivateFabricConfigurationBB", "flow z"); - List<OrchestrationFlow> result = workflowAction.filterOrchFlows(flows, WorkflowType.VFMODULE, mock(DelegateExecution.class)); + ServiceInstancesRequest sIRequest = new ServiceInstancesRequest(); + RequestDetails requestDetails = new RequestDetails(); + ModelInfo modelInfo = new ModelInfo(); + modelInfo.setModelCustomizationUuid(""); + requestDetails.setModelInfo(modelInfo); + sIRequest.setRequestDetails(requestDetails); + + List<OrchestrationFlow> result = workflowAction.filterOrchFlows(sIRequest, flows, WorkflowType.VFMODULE, mock(DelegateExecution.class)); List<OrchestrationFlow> expected = createFlowList( "flow x", "flow y", @@ -147,7 +165,7 @@ public class WorkflowActionUnitTest { doReturn(Arrays.asList(flow)).when(workflowAction).queryNorthBoundRequestCatalogDb(any(), any(), any(), anyBoolean(), any(), any()); workflowAction.selectExecutionList(execution); - verify(workflowAction, times(1)).filterOrchFlows(eq(flows), any(), any()); + verify(workflowAction, times(1)).filterOrchFlows(any(), eq(flows), any(), any()); flow = new OrchestrationFlow(); flow.setFlowName("flow y"); @@ -155,7 +173,7 @@ public class WorkflowActionUnitTest { when(execution.getVariable(eq("aLaCarte"))).thenReturn(false); workflowAction.selectExecutionList(execution); - verify(workflowAction, never()).filterOrchFlows(eq(flows), any(), any()); + verify(workflowAction, never()).filterOrchFlows(any(), eq(flows), any(), any()); } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java index db01399b82..a8e9a7e57e 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java @@ -41,6 +41,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.HostRoute; import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; +import org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy; import org.onap.so.bpmn.servicedecomposition.bbobjects.OwningEntity; import org.onap.so.bpmn.servicedecomposition.bbobjects.Project; import org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTarget; @@ -672,4 +673,21 @@ public class AAIObjectMapperTest { assertThat(actualSubnet, sameBeanAs(expectedSubnet)); } + + @Test + public void mapNetworkPolicyTest() { + NetworkPolicy networkPolicy = new NetworkPolicy(); + networkPolicy.setNetworkPolicyId("testNetworkPolicyId"); + networkPolicy.setNetworkPolicyFqdn("testNetworkPolicyFqdn"); + networkPolicy.setHeatStackId("testHeatStackId"); + + org.onap.aai.domain.yang.NetworkPolicy expectedNetworkPolicy = new org.onap.aai.domain.yang.NetworkPolicy(); + expectedNetworkPolicy.setNetworkPolicyId("testNetworkPolicyId"); + expectedNetworkPolicy.setNetworkPolicyFqdn("testNetworkPolicyFqdn"); + expectedNetworkPolicy.setHeatStackId("testHeatStackId"); + + org.onap.aai.domain.yang.NetworkPolicy actualNetworkPolicy = aaiObjectMapper.mapNetworkPolicy(networkPolicy); + + assertThat(actualNetworkPolicy, sameBeanAs(expectedNetworkPolicy)); + } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAINetworkResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAINetworkResourcesTest.java index 82ffdf9559..2e2cc5d974 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAINetworkResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAINetworkResourcesTest.java @@ -45,7 +45,6 @@ import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; -import org.onap.aai.domain.yang.NetworkPolicy; import org.onap.aai.domain.yang.RouteTableReference; import org.onap.aai.domain.yang.VpnBinding; import org.onap.so.bpmn.common.InjectionHelper; @@ -54,6 +53,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection; import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; +import org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet; import org.onap.so.client.aai.AAIObjectType; @@ -77,6 +77,7 @@ public class AAINetworkResourcesTest extends TestDataSetup{ private ServiceInstance serviceInstance; private CloudRegion cloudRegion; private Subnet subnet; + private NetworkPolicy networkPolicy; @Mock protected AAIResourcesClient MOCK_aaiResourcesClient; @@ -107,6 +108,8 @@ public class AAINetworkResourcesTest extends TestDataSetup{ subnet = buildSubnet(); + networkPolicy = buildNetworkPolicy(); + doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient(); } @@ -175,16 +178,15 @@ public class AAINetworkResourcesTest extends TestDataSetup{ public void getNetworkPolicyTest() throws Exception { final String content = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "queryAaiNetworkPolicy.json"))); AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(content); - Optional<NetworkPolicy> oNetPolicy = Optional.empty(); + Optional<org.onap.aai.domain.yang.NetworkPolicy> oNetPolicy = Optional.empty(); AAIResourceUri netPolicyUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, "ModelInvariantUUID"); doReturn(aaiResultWrapper).when(MOCK_aaiResourcesClient).get(isA(AAIResourceUri.class)); oNetPolicy = aaiNetworkResources.getNetworkPolicy(netPolicyUri); - verify(MOCK_aaiResourcesClient, times(1)).get(any(AAIResourceUri.class)); - + verify(MOCK_aaiResourcesClient, times(1)).get(any(AAIResourceUri.class)); if (oNetPolicy.isPresent()) { - NetworkPolicy networkPolicy = oNetPolicy.get(); - assertThat(aaiResultWrapper.asBean(NetworkPolicy.class).get(), sameBeanAs(networkPolicy)); + org.onap.aai.domain.yang.NetworkPolicy networkPolicy = oNetPolicy.get(); + assertThat(aaiResultWrapper.asBean(org.onap.aai.domain.yang.NetworkPolicy.class).get(), sameBeanAs(networkPolicy)); } } @@ -357,4 +359,20 @@ public class AAINetworkResourcesTest extends TestDataSetup{ assertThat(aaiResultWrapper.asBean(org.onap.aai.domain.yang.Subnet.class).get(), sameBeanAs(subnet)); } } + + @Test + public void createNetworkPolicyTest() throws Exception { + doNothing().when(MOCK_aaiResourcesClient).create(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.NetworkPolicy.class)); + doReturn(new org.onap.aai.domain.yang.NetworkPolicy()).when(MOCK_aaiObjectMapper).mapNetworkPolicy(networkPolicy); + aaiNetworkResources.createNetworkPolicy(networkPolicy); + verify(MOCK_aaiResourcesClient, times(1)).create(any(AAIResourceUri.class), isA(org.onap.aai.domain.yang.NetworkPolicy.class)); + } + + @Test + public void deleteNetworkPolicyTest() throws Exception { + doNothing().when(MOCK_aaiResourcesClient).delete(isA(AAIResourceUri.class)); + aaiNetworkResources.deleteNetworkPolicy(networkPolicy.getNetworkPolicyId()); + verify(MOCK_aaiResourcesClient, times(1)).delete(any(AAIResourceUri.class)); + } + } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVfModuleResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVfModuleResourcesTest.java index 0a8e7ce349..a8200caf79 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVfModuleResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVfModuleResourcesTest.java @@ -138,4 +138,17 @@ public class AAIVfModuleResourcesTest extends TestDataSetup{ assertEquals("testHeatStackId", vfModule.getHeatStackId()); } + + @Test + public void updateContrailServiceInstanceFqdnVfModuleTest() throws Exception { + vfModule.setContrailServiceInstanceFqdn("testContrailServiceInstanceFqdn"); + + doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.VfModule.class)); + + aaiVfModuleResources.updateContrailServiceInstanceFqdnVfModule(vfModule, vnf); + + verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class),ArgumentMatchers.isNull()); + + assertEquals("testContrailServiceInstanceFqdn", vfModule.getContrailServiceInstanceFqdn()); + } } diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest1Vpn.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest1Vpn.json index b65203b24d..6713f80ad9 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest1Vpn.json +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest1Vpn.json @@ -42,13 +42,11 @@ "modelInvariantId" : "testProxyModelInvariantUuid2" }, "requiredCandidates" : [ { - "candidateType" : { - "name" : "vnfId" - }, - "candidates" : [ "testVnfId" ] + "identifierType" : "vnfId", + "identifiers" : [ "testVnfId" ] } ] } ], - "requestParameters" : {"subscriptionServiceType":"iptollfree","aLaCarte":false} + "requestParameters" : {"subscriptionServiceType":"testSubscriptionServiceType","aLaCarte":false} }, "licenseInfo" : { "licenseDemands" : [ ] diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3AR.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3AR.json index ac460c328a..740a05d1be 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3AR.json +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3AR.json @@ -51,7 +51,7 @@ "modelInvariantId" : "testAllottedModelInvariantUuid3" } } ], - "requestParameters" : {"subscriptionServiceType":"iptollfree","aLaCarte":false} + "requestParameters" : {"subscriptionServiceType":"testSubscriptionServiceType","aLaCarte":false} }, "licenseInfo" : { "licenseDemands" : [ ] diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3Vpn.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3Vpn.json index 6db2153691..14a89c90fc 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3Vpn.json +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3Vpn.json @@ -42,10 +42,8 @@ "modelInvariantId" : "testProxyModelInvariantUuid2" }, "requiredCandidates" : [ { - "candidateType" : { - "name" : "vnfId" - }, - "candidates" : [ "testVnfId" ] + "identifierType" : "vnfId", + "identifiers" : [ "testVnfId" ] } ] }, { "serviceResourceId" : "testProxyId1", @@ -66,10 +64,8 @@ "modelInvariantId" : "testProxyModelInvariantUuid2" }, "requiredCandidates" : [ { - "candidateType" : { - "name" : "vnfId" - }, - "candidates" : [ "testVnfId" ] + "identifierType" : "vnfId", + "identifiers" : [ "testVnfId" ] } ] }, { "serviceResourceId" : "testProxyId1", @@ -90,13 +86,11 @@ "modelInvariantId" : "testProxyModelInvariantUuid2" }, "requiredCandidates" : [ { - "candidateType" : { - "name" : "vnfId" - }, - "candidates" : [ "testVnfId" ] + "identifierType" : "vnfId", + "identifiers" : [ "testVnfId" ] } ] } ], - "requestParameters" : {"subscriptionServiceType":"iptollfree","aLaCarte":false} + "requestParameters" : {"subscriptionServiceType":"testSubscriptionServiceType","aLaCarte":false} }, "licenseInfo" : { "licenseDemands" : [ ] diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/VfModuleCreateWithFabric.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/VfModuleCreateWithFabric.json new file mode 100644 index 0000000000..332ad4500c --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/VfModuleCreateWithFabric.json @@ -0,0 +1,65 @@ +{ + "requestDetails": { + "modelInfo": { + "modelCustomizationName": "model-cust-name", + "modelInvariantId": "db86e4a6-c027-452e-a559-3a23b3128367", + "modelType": "vfModule", + "modelName": "test-model-name", + "modelVersion": "1", + "modelCustomizationUuid": "9a6d01fd-19a7-490a-9800-460830a12e0b", + "modelVersionId": "14c8f313-fb0f-4cf6-8caf-c7cce8137b60", + "modelCustomizationId": "9a6d01fd-19a7-490a-9800-460830a12e0b", + "modelUuid": "14c8f313-fb0f-4cf6-8caf-c7cce8137b60", + "modelInvariantUuid": "db86e4a6-c027-452e-a559-3a23b3128367", + "modelInstanceName": "test-model-instance-name" + }, + "requestInfo": { + "source": "VID", + "instanceName": "instanceName", + "suppressRollback": false, + "requestorId": "user" + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "f647e3ef-6d2e-4cd3-bff4-8df4634208de", + "modelInfo": { + "modelInvariantId": "86adb376-5303-441a-b50e-96c0cd643b0f", + "modelType": "service", + "modelName": "model-name", + "modelVersion": "1.0", + "modelVersionId": "599e21ed-803d-4d1f-83df-20005339b83f", + "modelUuid": "599e21ed-803d-4d1f-83df-20005339b83f", + "modelInvariantUuid": "86adb376-5303-441a-b50e-96c0cd643b0f" + } + } + }, + { + "relatedInstance": { + "instanceId": "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d", + "modelInfo": { + "modelCustomizationName": "modle-cust-name", + "modelInvariantId": "5cca9285-4ed4-4e11-a609-921ed3344811", + "modelType": "vnf", + "modelName": "modle-name", + "modelVersion": "1.0", + "modelCustomizationUuid": "fc25201d-36d6-43a3-8d39-fdae88e526ae", + "modelVersionId": "7cae703a-b20d-481a-863a-b862236c00f7", + "modelCustomizationId": "fc25201d-36d6-43a3-8d39-fdae88e526ae", + "modelUuid": "7cae703a-b20d-481a-863a-b862236c00f7", + "modelInvariantUuid": "5cca9285-4ed4-4e11-a609-921ed3344811", + "modelInstanceName": "model-inst-name" + } + } + } + ], + "cloudConfiguration": { + "tenantId": "872f331350c54e59991a8de2cbffb40c", + "cloudOwner": "my-custom-cloud-owner", + "lcpCloudRegionId": "cloud-region" + }, + "requestParameters": { + "usePreload": true + } + } +}
\ No newline at end of file |