From 46a0eda4be2662ed48cce9fd25d623b1cc212381 Mon Sep 17 00:00:00 2001 From: Lukasz Muszkieta Date: Thu, 18 Mar 2021 21:03:32 +0100 Subject: helm orchestration artifact type handling Issue-ID: SO-3484 Signed-off-by: Lukasz Muszkieta Change-Id: Ic1def62bd27554d7c97ebc607d2facefc40fb446 --- .../bpmn/servicedecomposition/tasks/BBInputSetup.java | 19 +++++++++++++------ .../servicedecomposition/tasks/BBInputSetupUtils.java | 6 ++++++ .../servicedecomposition/tasks/BBInputSetupTest.java | 9 +++++++++ .../tasks/BBInputSetupUtilsTest.java | 12 ++++++++++++ 4 files changed, 40 insertions(+), 6 deletions(-) (limited to 'bpmn') 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 4cd1d7dcb0..5670807ddd 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 @@ -83,6 +83,7 @@ import org.onap.so.db.catalog.beans.ConfigurationResourceCustomization; import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization; import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization; import org.onap.so.db.catalog.beans.NetworkResourceCustomization; +import org.onap.so.db.catalog.beans.OrchTemplateArtifactType; import org.onap.so.db.catalog.beans.OrchestrationStatus; import org.onap.so.db.catalog.beans.Service; import org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization; @@ -640,9 +641,9 @@ public class BBInputSetup implements JavaDelegate { parameter.getServiceModel().getCurrentService(), vnfModelCustomizationUUID); } } - if (vfModule.getModelInfoVfModule() != null && vfModule.getModelInfoVfModule().getModelName() != null - && vfModule.getModelInfoVfModule().getModelName().contains("helm")) { - parameter.setIsHelm(true); + if (vfModule != null && vfModule.getModelInfoVfModule() != null + && vfModule.getModelInfoVfModule().getModelUUID() != null) { + parameter.setIsHelm(isVfModuleHelm(vfModule.getModelInfoVfModule().getModelUUID())); } } else { logger.debug("Related VNF instance Id not found: {}", @@ -1479,9 +1480,9 @@ public class BBInputSetup implements JavaDelegate { } } if (vfModule.getModelInfoVfModule() != null - && vfModule.getModelInfoVfModule().getModelName() != null - && vfModule.getModelInfoVfModule().getModelName().contains("helm")) { - gBB.getRequestContext().setIsHelm(true); + && vfModule.getModelInfoVfModule().getModelUUID() != null) { + gBB.getRequestContext() + .setIsHelm(isVfModuleHelm(vfModule.getModelInfoVfModule().getModelUUID())); } break; } @@ -2163,4 +2164,10 @@ public class BBInputSetup implements JavaDelegate { } return customer; } + + private boolean isVfModuleHelm(String vfModuleId) { + org.onap.so.db.catalog.beans.VfModule vfModuleFromDatabase = + bbInputSetupUtils.getVfModuleByModelUUID(vfModuleId); + return OrchTemplateArtifactType.HELM.equals(vfModuleFromDatabase.getOrchTemplateArtifactType()); + } } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java index afd7f6433c..9acb050da7 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java @@ -6,6 +6,8 @@ * ================================================================================ * Modifications Copyright (c) 2019 Samsung * ================================================================================ + * Modifications Copyright (C) 2021 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 @@ -553,4 +555,8 @@ public class BBInputSetupUtils { .relatedTo(Types.CONFIGURATIONS.getFragment()).queryParam("configuration-name", configurationName); return injectionHelper.getAaiClient().getOne(Configurations.class, Configuration.class, uri); } + + public org.onap.so.db.catalog.beans.VfModule getVfModuleByModelUUID(String modelUUID) { + return catalogDbClient.getVfModuleByModelUUID(modelUUID); + } } 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 127253a72e..19a69ded8a 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 @@ -29,6 +29,7 @@ import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.isA; @@ -110,6 +111,7 @@ import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization; import org.onap.so.db.catalog.beans.InstanceGroupType; import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization; import org.onap.so.db.catalog.beans.NetworkResourceCustomization; +import org.onap.so.db.catalog.beans.OrchTemplateArtifactType; import org.onap.so.db.catalog.beans.OrchestrationStatus; import org.onap.so.db.catalog.beans.Service; import org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization; @@ -3278,6 +3280,9 @@ public class BBInputSetupTest { serviceInstance.getVnfs().add(vnf); VfModule vfModule1 = new VfModule(); vfModule1.setVfModuleId("vfModuleId1"); + ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule(); + modelInfoVfModule.setModelUUID("uuidTest"); + vfModule1.setModelInfoVfModule(modelInfoVfModule); VfModule vfModule2 = new VfModule(); vfModule2.setVfModuleId("vfModuleId2"); vnf.getVfModules().add(vfModule1); @@ -3309,6 +3314,9 @@ public class BBInputSetupTest { org.onap.aai.domain.yang.VfModule vfModuleAAI = new org.onap.aai.domain.yang.VfModule(); vfModuleAAI.setModelCustomizationId(vfModuleCustomizationId); + org.onap.so.db.catalog.beans.VfModule vfModuleFromDatabase = new org.onap.so.db.catalog.beans.VfModule(); + vfModuleFromDatabase.setOrchTemplateArtifactType(OrchTemplateArtifactType.HELM); + doReturn(vfModuleFromDatabase).when(SPY_bbInputSetupUtils).getVfModuleByModelUUID("uuidTest"); doReturn(vnfAAI).when(SPY_bbInputSetupUtils).getAAIGenericVnf(vnf.getVnfId()); doReturn(volumeGroupAAI).when(SPY_bbInputSetupUtils).getAAIVolumeGroup(CLOUD_OWNER, cloudConfiguration.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId()); @@ -3333,6 +3341,7 @@ public class BBInputSetupTest { lookupKeyMap.get(ResourceKey.VF_MODULE_ID)); assertEquals("Lookup Key Map populated with VolumeGroup Id", volumeGroupId, lookupKeyMap.get(ResourceKey.VOLUME_GROUP_ID)); + assertTrue(parameter.getIsHelm()); } @Test diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java index 85774ec23c..6d24dcc996 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java @@ -79,7 +79,9 @@ import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.MultipleObjectsFoundException; import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.NoServiceInstanceFoundException; import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization; +import org.onap.so.db.catalog.beans.OrchTemplateArtifactType; import org.onap.so.db.catalog.beans.Service; +import org.onap.so.db.catalog.beans.VfModule; import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization; import org.onap.so.db.catalog.client.CatalogDbClient; import org.onap.so.db.request.beans.InfraActiveRequests; @@ -830,6 +832,16 @@ public class BBInputSetupUtilsTest { assertNull(actualGenericVnfs); } + @Test + public void getVfModuleByModelUUID_success() { + org.onap.so.db.catalog.beans.VfModule vfModuleFromDatabase = new VfModule(); + vfModuleFromDatabase.setOrchTemplateArtifactType(OrchTemplateArtifactType.HELM); + doReturn(vfModuleFromDatabase).when(MOCK_catalogDbClient).getVfModuleByModelUUID("modelUuidTest"); + org.onap.so.db.catalog.beans.VfModule vfModuleFromDatabaseResult = + bbInputSetupUtils.getVfModuleByModelUUID("modelUuidTest"); + assertEquals(OrchTemplateArtifactType.HELM, vfModuleFromDatabaseResult.getOrchTemplateArtifactType()); + } + private InfraActiveRequests loadExpectedInfraActiveRequest() throws IOException { return mapper.readValue(new File(RESOURCE_PATH + "InfraActiveRequestExpected.json"), InfraActiveRequests.class); } -- cgit 1.2.3-korg