From ef5da81589fb49b5a7cafcb8972077007ea230e0 Mon Sep 17 00:00:00 2001 From: Lathish Date: Fri, 5 Apr 2019 12:21:52 +0000 Subject: Added Node status monitoring Issue-ID: SO-1626 Change-Id: I0447549ca1024cd768b2bead2fe351895e314567 Signed-off-by: Lathish --- .../subprocess/BuildingBlock/EtsiVnfDeleteBB.bpmn | 26 ++-- .../BuildingBlock/EtsiVnfInstantiateBB.bpmn | 22 +++- .../BuildingBlock/MonitorVnfmCreateNodeStatus.bpmn | 138 +++++++++++++++++++++ .../BuildingBlock/MonitorVnfmDeleteJob.bpmn | 2 +- .../BuildingBlock/MonitorVnfmDeleteNodeStatus.bpmn | 138 +++++++++++++++++++++ .../adapter/vnfm/tasks/Constants.java | 4 + .../adapter/vnfm/tasks/MonitorVnfmNodeTask.java | 85 +++++++++++++ .../adapter/vnfm/tasks/MonitorVnfmNodeJobTest.java | 111 +++++++++++++++++ 8 files changed, 510 insertions(+), 16 deletions(-) create mode 100644 bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/MonitorVnfmCreateNodeStatus.bpmn create mode 100644 bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/MonitorVnfmDeleteNodeStatus.bpmn create mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmNodeTask.java create mode 100644 bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmNodeJobTest.java (limited to 'bpmn') diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/EtsiVnfDeleteBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/EtsiVnfDeleteBB.bpmn index cfb376c961..2d247365d0 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/EtsiVnfDeleteBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/EtsiVnfDeleteBB.bpmn @@ -9,21 +9,20 @@ SequenceFlow_1064iul - SequenceFlow_0qt5cvg + SequenceFlow_0503le2 - - - - - - SequenceFlow_1064iul SequenceFlow_0qt5cvg - + + + SequenceFlow_0qt5cvg + SequenceFlow_0503le2 + + @@ -34,7 +33,7 @@ - + @@ -49,7 +48,14 @@ - + + + + + + + + diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/EtsiVnfInstantiateBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/EtsiVnfInstantiateBB.bpmn index b248ea1f6a..13bd107fdb 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/EtsiVnfInstantiateBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/EtsiVnfInstantiateBB.bpmn @@ -1,5 +1,5 @@ - + SequenceFlow_18fsqzd @@ -10,7 +10,7 @@ - SequenceFlow_1owx4yu + SequenceFlow_0n57z81 @@ -33,7 +33,12 @@ SequenceFlow_0hp0ka1 SequenceFlow_1owx4yu - + + + SequenceFlow_1owx4yu + SequenceFlow_0n57z81 + + @@ -48,7 +53,7 @@ - + @@ -73,7 +78,14 @@ - + + + + + + + + diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/MonitorVnfmCreateNodeStatus.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/MonitorVnfmCreateNodeStatus.bpmn new file mode 100644 index 0000000000..6d54262dc5 --- /dev/null +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/MonitorVnfmCreateNodeStatus.bpmn @@ -0,0 +1,138 @@ + + + + + SequenceFlow_1miob62 + + + SequenceFlow_1miob62 + + SequenceFlow_1moaz0q + + + SequenceFlow_0qvy3sn + SequenceFlow_1rxbeqi + SequenceFlow_1luu31f + + + SequenceFlow_1luu31f + SequenceFlow_09t51ao + + PT15S + + + + SequenceFlow_1rxbeqi + + + SequenceFlow_1moaz0q + SequenceFlow_09t51ao + SequenceFlow_0qvy3sn + + + ${execution.getVariable("createVnfNodeStatus")} + + + + + + + + SequenceFlow_0uiqnl8 + + + + SequenceFlow_0qcc5x4 + SequenceFlow_0uiqnl8 + + + SequenceFlow_0qcc5x4 + + PT3H + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/MonitorVnfmDeleteJob.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/MonitorVnfmDeleteJob.bpmn index acd55e4fc2..a35ff47c6d 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/MonitorVnfmDeleteJob.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/MonitorVnfmDeleteJob.bpmn @@ -37,7 +37,7 @@ - ${MonitorVnfmCreateJobTask.hasOperationFinished(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))} + ${MonitorVnfmDeleteJobTask.hasOperationFinished(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))} diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/MonitorVnfmDeleteNodeStatus.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/MonitorVnfmDeleteNodeStatus.bpmn new file mode 100644 index 0000000000..8fababaffe --- /dev/null +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/MonitorVnfmDeleteNodeStatus.bpmn @@ -0,0 +1,138 @@ + + + + + SequenceFlow_0spr34x + + + SequenceFlow_0spr34x + + SequenceFlow_17vvpzi + + + SequenceFlow_1unicf9 + SequenceFlow_03pp1ee + SequenceFlow_0zlblru + + + SequenceFlow_0zlblru + SequenceFlow_11rfobu + + PT15S + + + + SequenceFlow_03pp1ee + + + ${execution.getVariable("deleteVnfNodeStatus")} + + + + SequenceFlow_17vvpzi + SequenceFlow_11rfobu + SequenceFlow_1unicf9 + + + + + + + SequenceFlow_1o7p21a + + + + SequenceFlow_1suioy7 + SequenceFlow_1o7p21a + + + SequenceFlow_1suioy7 + + PT3H + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/Constants.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/Constants.java index 59f8be50c8..976b1bc8df 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/Constants.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/Constants.java @@ -34,6 +34,10 @@ public class Constants { public static final String CREATE_VNF_RESPONSE_PARAM_NAME = "createVnfResponse"; public static final String INPUT_PARAMETER = "inputParameter"; public static final String DELETE_VNF_RESPONSE_PARAM_NAME = "deleteVnfResponse"; + public static final String DELETE_VNF_NODE_STATUS = "deleteVnfNodeStatus"; + public static final String CREATE_VNF_NODE_STATUS = "createVnfNodeStatus"; + public static final String VNF_ASSIGNED = "Assigned"; + public static final String VNF_CREATED = "Created"; public static final String DOT = "."; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmNodeTask.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmNodeTask.java new file mode 100644 index 0000000000..22a5d28e52 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmNodeTask.java @@ -0,0 +1,85 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Ericsson. 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks; + +import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.CREATE_VNF_NODE_STATUS; +import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.DELETE_VNF_NODE_STATUS; +import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.VNF_ASSIGNED; +import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.VNF_CREATED; +import static org.onap.so.bpmn.servicedecomposition.entities.ResourceKey.GENERIC_VNF_ID; +import org.onap.aai.domain.yang.GenericVnf; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; +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; + + +/** + * + * @author Lathishbabu Ganesan (lathishbabu.ganesan@est.tech) + * + */ +@Component +public class MonitorVnfmNodeTask { + + private static final Logger LOGGER = LoggerFactory.getLogger(MonitorVnfmNodeTask.class); + + private final ExtractPojosForBB extractPojosForBB; + private final ExceptionBuilder exceptionUtil; + + @Autowired + public MonitorVnfmNodeTask(final ExtractPojosForBB extractPojosForBB, final ExceptionBuilder exceptionUtil) { + this.exceptionUtil = exceptionUtil; + this.extractPojosForBB = extractPojosForBB; + } + + /** + * Check the final status of vnf in A&AI + * + * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl} + */ + public void getNodeStatus(final BuildingBlockExecution execution) { + try { + LOGGER.debug("Executing getNodeStatus ..."); + final GenericVnf vnf = extractPojosForBB.extractByKey(execution, GENERIC_VNF_ID); + String orchestrationStatus = vnf.getOrchestrationStatus(); + LOGGER.debug("Orchestration Status in AAI {}", orchestrationStatus); + execution.setVariable(CREATE_VNF_NODE_STATUS, VNF_CREATED.equalsIgnoreCase(orchestrationStatus)); + execution.setVariable(DELETE_VNF_NODE_STATUS, VNF_ASSIGNED.equalsIgnoreCase(orchestrationStatus)); + } catch (final Exception exception) { + LOGGER.error("Unable to get vnf from AAI", exception); + exceptionUtil.buildAndThrowWorkflowException(execution, 1220, exception); + } + } + + /** + * Log and throw exception on timeout for job status + * + * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl} + */ + public void timeOutLogFailue(final BuildingBlockExecution execution) { + final String message = "Node operation time out"; + LOGGER.error(message); + exceptionUtil.buildAndThrowWorkflowException(execution, 1221, message); + } +} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmNodeJobTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmNodeJobTest.java new file mode 100644 index 0000000000..aa3ab113a0 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmNodeJobTest.java @@ -0,0 +1,111 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks; + +import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.CREATE_VNF_NODE_STATUS; +import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.DELETE_VNF_NODE_STATUS; +import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.VNF_CREATED; +import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.VNF_ASSIGNED; +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.Mockito.verify; +import static org.mockito.Mockito.when; +import java.util.UUID; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.onap.aai.domain.yang.GenericVnf; +import org.onap.so.bpmn.BaseTaskTest; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; + +/** + * + * @author Lathishbabu Ganesan (lathishbabu.ganesan@est.tech) + * + */ +public class MonitorVnfmNodeJobTest extends BaseTaskTest { + + private static final String VNF_ID = UUID.randomUUID().toString(); + + private static final String VNF_NAME = "VNF_NAME"; + + private MonitorVnfmNodeTask objUnderTest; + + @Mock + private VnfmAdapterServiceProvider mockedVnfmAdapterServiceProvider; + + private final BuildingBlockExecution stubbedxecution = new StubbedBuildingBlockExecution(); + + @Before + public void setUp() { + objUnderTest = getEtsiVnfMonitorNodeJobTask(); + } + + @Test + public void testGetNodeStatusCreate() throws Exception { + GenericVnf vnf = getGenericVnf(); + vnf.setOrchestrationStatus(VNF_CREATED); + when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(vnf); + objUnderTest.getNodeStatus(stubbedxecution); + assertTrue(stubbedxecution.getVariable(CREATE_VNF_NODE_STATUS)); + } + + @Test + public void testGetNodeStatusDelete() throws Exception { + GenericVnf vnf = getGenericVnf(); + vnf.setOrchestrationStatus(VNF_ASSIGNED); + when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(vnf); + objUnderTest.getNodeStatus(stubbedxecution); + assertTrue(stubbedxecution.getVariable(DELETE_VNF_NODE_STATUS)); + } + + @Test + public void testGetNodeStatusException() throws Exception { + when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenThrow(RuntimeException.class); + objUnderTest.getNodeStatus(stubbedxecution); + assertNull(stubbedxecution.getVariable(CREATE_VNF_NODE_STATUS)); + assertNull(stubbedxecution.getVariable(DELETE_VNF_NODE_STATUS)); + verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1220), + any(Exception.class)); + } + + @Test + public void testTimeOutLogFailue() throws Exception { + objUnderTest.timeOutLogFailue(stubbedxecution); + verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1221), + eq("Node operation time out")); + } + + private GenericVnf getGenericVnf() { + final GenericVnf genericVnf = new GenericVnf(); + genericVnf.setVnfId(VNF_ID); + genericVnf.setVnfName(VNF_NAME); + return genericVnf; + } + + private MonitorVnfmNodeTask getEtsiVnfMonitorNodeJobTask() { + return new MonitorVnfmNodeTask(extractPojosForBB, exceptionUtil); + } + +} -- cgit 1.2.3-korg