From: Manamohan Satapathy Date: Tue, 26 Mar 2019 09:09:52 +0000 (+0530) Subject: Config Deploy X-Git-Tag: 1.4.1~127^2 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=28f62a251d2904dc3fdf6d33d0d5d4034c90efa0;p=so.git Config Deploy SO Generic Building Block to support config deploy action. Change-Id: Ica02a1dae7ba542fad67a5258bc9b4e046d3468a Issue-ID: SO-1482 Signed-off-by: Manamohan Satapathy --- diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ConfigDeployVnfBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ConfigDeployVnfBB.bpmn new file mode 100644 index 0000000000..92ac5f9f5b --- /dev/null +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ConfigDeployVnfBB.bpmn @@ -0,0 +1,116 @@ + + + + + SequenceFlow_0pd4jka + + + SequenceFlow_1tb7fs1 + SequenceFlow_00u29dm + + + SequenceFlow_00u29dm + + + + + + + + + + + SequenceFlow_0kruy8t + SequenceFlow_03xbj4e + + + SequenceFlow_0pd4jka + SequenceFlow_0moyu92 + + + + + SequenceFlow_0moyu92 + SequenceFlow_0kruy8t + + + SequenceFlow_03xbj4e + SequenceFlow_1tb7fs1 + SequenceFlow_0o50k2d + + + #{execution.getVariable("CDSStatus").equals("Success")} + + + + SequenceFlow_0o50k2d + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 bc6770cc81..82b61c17b5 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 @@ -538,4 +538,26 @@ public class AAIUpdateTasks { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } + + public void updateOrchestrationStausConfigDeployConfigureVnf(BuildingBlockExecution execution){ + try{ + GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); + aaiVnfResources.updateOrchestrationStatusVnf(vnf, OrchestrationStatus.CONFIGURE); + + }catch(Exception ex){ + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + + } + + public void updateOrchestrationStausConfigDeployConfiguredVnf(BuildingBlockExecution execution){ + try{ + GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); + aaiVnfResources.updateOrchestrationStatusVnf(vnf, OrchestrationStatus.CONFIGURED); + + }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/ConfigDeployVnf.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnf.java new file mode 100644 index 0000000000..1bc7c0f574 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnf.java @@ -0,0 +1,130 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : SO +* ================================================================================ +* Copyright 2019 TechMahindra +*================================================================================= +* 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 java.util.UUID; + +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.infrastructure.aai.tasks.AAIUpdateTasks; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +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.cds.beans.AbstractCDSPropertiesBean; +import org.onap.so.client.cds.beans.ConfigDeployPropertiesForVnf; +import org.onap.so.client.cds.beans.ConfigDeployRequestVnf; +import org.onap.so.client.exception.ExceptionBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * + * Get vnf related data and config Deploy + * + */ +@Component +public class ConfigDeployVnf { + private static final Logger logger = LoggerFactory.getLogger(ConfigDeployVnf.class); + private final static String ORIGINATOR_ID = "SO"; + private final static String ACTION_NAME = "config-deploy"; + private final static String MODE = "async"; + + @Autowired + private ExceptionBuilder exceptionUtil; + @Autowired + private ExtractPojosForBB extractPojosForBB; + @Autowired + private AAIUpdateTasks aaiUpdateTask; + + /** + * Update vnf orch status to configure in AAI + * + * @param execution + */ + public void updateAAIConfigure(BuildingBlockExecution execution) { + aaiUpdateTask.updateOrchestrationStausConfigDeployConfigureVnf(execution); + + } + /** + * Getting the vnf object and set in execution object + * + * @param execution + * + * + */ + public void preProcessAbstractCDSProcessing(BuildingBlockExecution execution) { + + + logger.info("Start preProcessAbstractCDSProcessing"); + try { + GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); + + ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); + + ConfigDeployPropertiesForVnf configDeployPropertiesForVnf = new ConfigDeployPropertiesForVnf(); + configDeployPropertiesForVnf.setServiceInstanceId(serviceInstance.getServiceInstanceId()); + configDeployPropertiesForVnf.setServiceModelUuid(serviceInstance.getModelInfoServiceInstance().getModelUuid()); + configDeployPropertiesForVnf.setVnfCustomizationUuid(vnf.getModelInfoGenericVnf().getModelCustomizationUuid()); + configDeployPropertiesForVnf.setVnfId(vnf.getVnfId()); + configDeployPropertiesForVnf.setVnfName(vnf.getVnfName()); + + ConfigDeployRequestVnf configDeployRequestVnf = new ConfigDeployRequestVnf(); + + configDeployRequestVnf.setResolutionKey(vnf.getVnfName()); + configDeployRequestVnf.setConfigDeployPropertiesForVnf(configDeployPropertiesForVnf); + + String blueprintName = vnf.getBlueprintName(); + String blueprintVersion = vnf.getBlueprintVersion(); + AbstractCDSPropertiesBean abstractCDSPropertiesBean = new AbstractCDSPropertiesBean(); + + abstractCDSPropertiesBean.setBlueprintName(blueprintName); + abstractCDSPropertiesBean.setBlueprintVersion(blueprintVersion); + abstractCDSPropertiesBean.setRequestObject(configDeployRequestVnf.toString()); + + + GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock(); + + abstractCDSPropertiesBean.setOriginatorId( ORIGINATOR_ID); + abstractCDSPropertiesBean.setRequestId(gBBInput.getRequestContext().getMsoRequestId()); + abstractCDSPropertiesBean.setSubRequestId(UUID.randomUUID().toString()); + abstractCDSPropertiesBean.setActionName(ACTION_NAME); + abstractCDSPropertiesBean.setMode(MODE); + + execution.setVariable("executionObject", abstractCDSPropertiesBean); + + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + } + + /** + * Update vnf orch status to configured in AAI + * + * @param execution + */ + public void updateAAIConfigured(BuildingBlockExecution execution) { + aaiUpdateTask.updateOrchestrationStausConfigDeployConfiguredVnf(execution); + + } +} \ No newline at end of file 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 78d08aa1f1..05af58040a 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 @@ -655,4 +655,17 @@ public class AAIUpdateTasksTest extends BaseTaskTest{ aaiUpdateTasks.updateManagementV6AddressVnf(execution); verify(aaiVnfResources, times(0)).updateObjectVnf(genericVnf); } + + @Test + public void updateOrchestrationStatusVnfConfigureTest() throws Exception { + doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.CONFIGURE); + + aaiUpdateTasks.updateOrchestrationStausConfigDeployConfigureVnf(execution); + } + @Test + public void updateOrchestrationStatusVnfConfiguredTest() throws Exception { + doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.CONFIGURED); + + aaiUpdateTasks.updateOrchestrationStausConfigDeployConfiguredVnf(execution); + } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnfTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnfTest.java new file mode 100644 index 0000000000..e5aa702dad --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnfTest.java @@ -0,0 +1,97 @@ + +/* +* ============LICENSE_START======================================================= +* ONAP : SO +* ================================================================================ +* Copyright 2019 TechMahindra +*================================================================================= +* 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.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.when; + +import java.util.UUID; + +import org.camunda.bpm.engine.delegate.BpmnError; +import org.junit.Before; +import org.junit.Test; +import org.mockito.ArgumentMatchers; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.onap.so.bpmn.BaseTaskTest; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.infrastructure.aai.tasks.AAIUpdateTasks; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.client.exception.BBObjectNotFoundException; + +public class ConfigDeployVnfTest extends BaseTaskTest { + + @InjectMocks + private ConfigDeployVnf configDeployVnf = new ConfigDeployVnf(); + @Mock + AAIUpdateTasks aAIUpdateTasks = new AAIUpdateTasks(); + + + private GenericVnf genericVnf; + private ServiceInstance serviceInstance; + private RequestContext requestContext; + private String msoRequestId; + + @Before + public void before() throws BBObjectNotFoundException { + genericVnf = setGenericVnf(); + serviceInstance = setServiceInstance(); + msoRequestId = UUID.randomUUID().toString(); + requestContext = setRequestContext(); + requestContext.setMsoRequestId(msoRequestId); + gBBInput.setRequestContext(requestContext); + + doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class)); + when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf); + when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))).thenReturn(serviceInstance); + } + + + + @Test + public void preProcessAbstractCDSProcessingTest() throws Exception { + + configDeployVnf.preProcessAbstractCDSProcessing(execution); + + assertTrue(true); + } + + @Test + public void updateAAIConfigureTaskTest() throws Exception { + + configDeployVnf.updateAAIConfigure(execution); + assertTrue(true); + } + + @Test + public void updateAAIConfiguredTaskTest() throws Exception { + configDeployVnf.updateAAIConfigured(execution); + assertTrue(true); + } + +} diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/OrchestrationStatus.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/OrchestrationStatus.java index 6902d8f36a..0fa07cfe0f 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/OrchestrationStatus.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/OrchestrationStatus.java @@ -30,7 +30,9 @@ public enum OrchestrationStatus { PENDING_CREATE("PendingCreate", "pending.?create"), PENDING_DELETE("PendingDelete", "pending.?delete"), PRECREATED("PreCreated", "pre.?created"), - CONFIGASSIGNED("ConfigAssigned", "config.?assigned"); + CONFIGASSIGNED("ConfigAssigned", "config.?assigned"), + CONFIGURE("Configure" , "configure"), + CONFIGURED("Configured" , "configured"); private final String name; private final String fuzzyMatcher;