From fe7a17f308f23ea8963d0948b5dc5388d626c1f9 Mon Sep 17 00:00:00 2001 From: Sunil Date: Sat, 25 Apr 2020 13:48:21 +0530 Subject: [PATCH] Adding Generic VNF information in ControllerExeuctionBB flow Solving BlueprintName and BlueprintVersion issue Changing vf-module to vfmodule Updating AAI with Orchestration status Issue-ID: SO-2806 Signed-off-by: sunilb Change-Id: I91aa653b946bae3940000f724710de87af3ce7df --- .../main/resources/db/migration/R__MacroData.sql | 6 ++-- .../org/onap/so/client/cds/PayloadConstants.java | 4 ++- .../so/client/cds/VfModuleCDSRequestProvider.java | 6 ++-- .../onap/so/client/cds/VnfCDSRequestProvider.java | 6 ++-- .../so/client/cds/GeneratePayloadForCdsTest.java | 4 ++- .../BuildingBlock/ControllerExecutionBB.bpmn | 34 ++++--------------- .../infrastructure/aai/tasks/AAIUpdateTasks.java | 16 +++++++++ .../flowspecific/tasks/ControllerExecution.java | 6 ++-- .../flowspecific/tasks/GenericCDSProcessingBB.java | 9 +++-- .../workflow/tasks/WorkflowAction.java | 15 ++++++--- .../aai/tasks/AAIUpdateTasksTest.java | 38 ++++++++++++++++++++++ .../tasks/ControllerExecutionTest.java | 4 +-- .../so/db/catalog/beans/OrchestrationStatus.java | 3 ++ 13 files changed, 102 insertions(+), 49 deletions(-) diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql index 33293afa10..2537fbd139 100644 --- a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql @@ -817,7 +817,8 @@ VALUES ('CONFIGURATION', 'PENDING CREATE', 'DEACTIVATE', 'FAIL'), ('CONFIGURATION', 'PENDING DELETE', 'DEACTIVATE', 'FAIL'), ('CONFIGURATION', 'PENDING ACTIVATION', 'DEACTIVATE', 'FAIL'), -('CONFIGURATION', 'PENDING', 'DEACTIVATE', 'FAIL'); +('CONFIGURATION', 'PENDING', 'DEACTIVATE', 'FAIL'), +('VNF','CONFIGDEPLOYED','ACTIVATE','CONTINUE'); UPDATE orchestration_flow_reference SET SEQ_NO = SEQ_NO + 2 WHERE COMPOSITE_ACTION = 'Service-Macro-Create' AND SEQ_NO > 12; @@ -886,7 +887,8 @@ UPDATE northbound_request_ref_lookup SET SERVICE_TYPE = '*' WHERE SERVICE_TYPE I INSERT INTO building_block_detail(BUILDING_BLOCK_NAME, RESOURCE_TYPE, TARGET_ACTION) VALUES ('ConfigAssignVnfBB', 'NO_VALIDATE', 'CUSTOM'), -('ConfigDeployVnfBB', 'NO_VALIDATE', 'CUSTOM'); +('ConfigDeployVnfBB', 'NO_VALIDATE', 'CUSTOM'), +('ControllerExecutionBB', 'NO_VALIDATE', 'CUSTOM'); UPDATE rainy_day_handler_macro SET reg_ex_error_message = '*' WHERE reg_ex_error_message IS null; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/PayloadConstants.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/PayloadConstants.java index 808d427d65..2812de799d 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/PayloadConstants.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/PayloadConstants.java @@ -6,6 +6,8 @@ * ================================================================================ * Modifications Copyright (C) 2020 Nordix * ================================================================================ + * Modifications Copyright (c) 2020 Tech Mahindra + * ================================================================================ * 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 @@ -36,7 +38,7 @@ public final class PayloadConstants { public static final String SEPARATOR = "-"; public static final String PNF_SCOPE = "pnf"; public static final String VNF_SCOPE = "vnf"; - public static final String VF_MODULE_SCOPE = "vfModule"; + public static final String VF_MODULE_SCOPE = "vfmodule"; public static final String SERVICE_SCOPE = "service"; public static final String RESOLUTION_KEY = "resolution-key"; public static final String CDS_ACTOR = "cds"; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/VfModuleCDSRequestProvider.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/VfModuleCDSRequestProvider.java index 065ba36a03..c2874fe23d 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/VfModuleCDSRequestProvider.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/VfModuleCDSRequestProvider.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2019 Bell Canada * ================================================================================ + * Modifications Copyright (c) 2020 Tech Mahindra + * ================================================================================ * 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 @@ -80,8 +82,8 @@ public class VfModuleCDSRequestProvider implements CDSRequestProvider { final String modelCustomizationUuidForVnf = genericVnf.getModelInfoGenericVnf().getModelCustomizationUuid(); - blueprintName = genericVnf.getBlueprintName(); - blueprintVersion = genericVnf.getBlueprintVersion(); + blueprintName = genericVnf.getModelInfoGenericVnf().getBlueprintName(); + blueprintVersion = genericVnf.getModelInfoGenericVnf().getBlueprintVersion(); VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID); vfModuleName = vfModule.getVfModuleName(); diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/VnfCDSRequestProvider.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/VnfCDSRequestProvider.java index d33976d229..7425d09721 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/VnfCDSRequestProvider.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/VnfCDSRequestProvider.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2019 Bell Canada * ================================================================================ + * Modifications Copyright (c) 2020 Tech Mahindra + * ================================================================================ * 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 @@ -79,8 +81,8 @@ public class VnfCDSRequestProvider implements CDSRequestProvider { final String modelCustomizationUuid = genericVnf.getModelInfoGenericVnf().getModelCustomizationUuid(); resolutionKey = genericVnf.getVnfName(); - blueprintName = genericVnf.getBlueprintName(); - blueprintVersion = genericVnf.getBlueprintVersion(); + blueprintName = genericVnf.getModelInfoGenericVnf().getBlueprintName(); + blueprintVersion = genericVnf.getModelInfoGenericVnf().getBlueprintVersion(); vnfObject.addProperty("service-instance-id", serviceInstance.getServiceInstanceId()); vnfObject.addProperty("service-model-uuid", serviceInstance.getModelInfoServiceInstance().getModelUuid()); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/GeneratePayloadForCdsTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/GeneratePayloadForCdsTest.java index 998976589c..20bd765338 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/GeneratePayloadForCdsTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/GeneratePayloadForCdsTest.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2019 Bell Canada. * ================================================================================ + * Modifications Copyright (c) 2020 Tech Mahindra + * ================================================================================ * 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 @@ -52,7 +54,7 @@ public class GeneratePayloadForCdsTest { private static final String VNF_SCOPE = "vnf"; private static final String SERVICE_SCOPE = "service"; private static final String SERVICE_ACTION = "create"; - private static final String VF_SCOPE = "vfModule"; + private static final String VF_SCOPE = "vfmodule"; private static final String ASSIGN_ACTION = "configAssign"; private static final String DEPLOY_ACTION = "configDeploy"; private static final String DOWNLOAD_ACTION = "downloadNESw"; diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ControllerExecutionBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ControllerExecutionBB.bpmn index f12a3d241f..1e67ea33ec 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ControllerExecutionBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ControllerExecutionBB.bpmn @@ -10,30 +10,20 @@ SequenceFlow_0no1qag - - - - - - - SequenceFlow_05qembo - SequenceFlow_0cvsnuu - - + SequenceFlow_07tqu82 SequenceFlow_1mkhog2 - - + + SequenceFlow_0vzx2yr SequenceFlow_05qembo - SequenceFlow_0cvsnuu + SequenceFlow_05qembo SequenceFlow_07tqu82 SequenceFlow_15gxql1 - #{execution.getVariable("ControllerStatus").equals("Success")} @@ -81,7 +71,7 @@ - ${execution.getVariable("controller_actor") == "CDS"} + ${execution.getVariable("actor") == "CDS"} @@ -114,17 +104,14 @@ - - - - + - + @@ -136,13 +123,6 @@ - - - - - - - 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 0190e693be..cc630232c2 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 @@ -7,6 +7,7 @@ * Modifications Copyright (c) 2019 Samsung * Modifications Copyright (c) 2019 Bell Canada. * Modifications Copyright (c) 2020 Nokia + * Modifications Copyright (c) 2020 Tech Mahindra * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -568,6 +569,21 @@ public class AAIUpdateTasks { updateOrchestrationStatusForVnf(execution, OrchestrationStatus.CONFIGURED); } + /** + * BPMN access method to update status of Vnf/vfmodule to configAssigned/ConfigDeployed in AAI + */ + public void updateOrchestrationStatus(BuildingBlockExecution execution, String scope, String action) { + if (scope.equalsIgnoreCase("vnf") && action.equalsIgnoreCase("config-assign")) { + updateOrchestrationStatusForVnf(execution, OrchestrationStatus.CONFIGASSIGNED); + } else if (scope.equalsIgnoreCase("vnf") && action.equalsIgnoreCase("config-deploy")) { + updateOrchestrationStatusForVnf(execution, OrchestrationStatus.CONFIGDEPLOYED); + } else if (scope.equalsIgnoreCase("vfModule") && action.equalsIgnoreCase("config-assign")) { + updateOrchestrationStatusForVfModule(execution, OrchestrationStatus.CONFIGASSIGNED); + } else if (scope.equalsIgnoreCase("vfModule") && action.equalsIgnoreCase("config-deploy")) { + updateOrchestrationStatusForVfModule(execution, OrchestrationStatus.CONFIGDEPLOYED); + } + } + private void updateOrchestrationStatusForService(BuildingBlockExecution execution, OrchestrationStatus status) { try { ServiceInstance serviceInstance = diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ControllerExecution.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ControllerExecution.java index 86d56005f6..754c377914 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ControllerExecution.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ControllerExecution.java @@ -39,7 +39,7 @@ import org.springframework.stereotype.Component; @Component public class ControllerExecution { private static final Logger logger = LoggerFactory.getLogger(ControllerExecution.class); - private static final String CONTROLLER_ACTOR = "controllerActor"; + private static final String CONTROLLER_ACTOR = "actor"; private static final String BUILDING_BLOCK = "buildingBlock"; private static final String SCOPE = "scope"; private static final String ACTION = "action"; @@ -59,9 +59,9 @@ public class ControllerExecution { public void setControllerActorScopeAction(BuildingBlockExecution execution) { try { GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); - String modleUuid = genericVnf.getModelInfoGenericVnf().getModelCustomizationUuid(); + String modelUuid = genericVnf.getModelInfoGenericVnf().getModelCustomizationUuid(); VnfResourceCustomization vnfResourceCustomization = - catalogDbClient.getVnfResourceCustomizationByModelCustomizationUUID(modleUuid); + catalogDbClient.getVnfResourceCustomizationByModelCustomizationUUID(modelUuid); // Fetching Controller Actor at VNF level if null then Controller Actor is set as "APPC" String controllerActor = Optional.ofNullable(vnfResourceCustomization.getControllerActor()).orElse("APPC"); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericCDSProcessingBB.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericCDSProcessingBB.java index f568026aa5..854678a6a6 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericCDSProcessingBB.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericCDSProcessingBB.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2019 Bell Canada * ================================================================================ + * Modifications Copyright (c) 2020 Tech Mahindra + * ================================================================================ * 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 @@ -34,7 +36,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; /** - * For Vnf/Vf-Module/Service BuildingBlockExecution is being used. + * This class is used in context of Building Block flow for configuration of vnf/vfmodule/service. * * @param - BuildingBlockExecution */ @@ -44,14 +46,11 @@ public class GenericCDSProcessingBB implements ControllerRunnable vfModuleResourcesSorted = null; if (requestAction.equals(CREATEINSTANCE) || requestAction.equals(ASSIGNINSTANCE) || requestAction.equals("activateInstance")) { 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 e5b003a437..a7dfe7f7a4 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 @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (c) 2020 Tech Mahindra + * ================================================================================ * 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 @@ -753,4 +755,40 @@ public class AAIUpdateTasksTest extends BaseTaskTest { when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.PNF))).thenReturn(pnf); return pnf; } + + @Test + public void updateOrchestrationStatusVnfConfigAssignedTest() throws Exception { + doNothing().when(aaiVnfResources).updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.CONFIGASSIGNED); + + aaiUpdateTasks.updateOrchestrationStatus(execution, "vnf", "config-assign"); + + verify(aaiVnfResources, times(1)).updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.CONFIGASSIGNED); + } + + @Test + public void updateOrchestrationStatusVnfConfigDeployedTest() throws Exception { + doNothing().when(aaiVnfResources).updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.CONFIGDEPLOYED); + + aaiUpdateTasks.updateOrchestrationStatus(execution, "vnf", "config-deploy"); + + verify(aaiVnfResources, times(1)).updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.CONFIGDEPLOYED); + } + + @Test + public void updateOrchestrationStatusVfModuleConfigDeployedTest() throws Exception { + doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, + OrchestrationStatus.CONFIGDEPLOYED); + aaiUpdateTasks.updateOrchestrationStatus(execution, "vfmodule", "config-deploy"); + verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf, + OrchestrationStatus.CONFIGDEPLOYED); + } + + @Test + public void updateOrchestrationStatusVfModuleConfigAssignedTest() throws Exception { + doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, + OrchestrationStatus.CONFIGASSIGNED); + aaiUpdateTasks.updateOrchestrationStatus(execution, "vfmodule", "config-assign"); + verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf, + OrchestrationStatus.CONFIGASSIGNED); + } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ControllerExecutionTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ControllerExecutionTest.java index 72a987c395..f35939ec39 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ControllerExecutionTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ControllerExecutionTest.java @@ -99,7 +99,7 @@ public class ControllerExecutionTest extends BaseTaskTest { controllerExecution.setControllerActorScopeAction(execution); assertEquals(TEST_SCOPE, execution.getVariable("scope")); assertEquals(TEST_ACTION, execution.getVariable("action")); - assertEquals(TEST_CONTROLLER_ACTOR, execution.getVariable("controllerActor")); + assertEquals(TEST_CONTROLLER_ACTOR, execution.getVariable("actor")); } @@ -114,7 +114,7 @@ public class ControllerExecutionTest extends BaseTaskTest { bbNameSelectionReference.setScope(TEST_SCOPE); doReturn(bbNameSelectionReference).when(catalogDbClient).getBBNameSelectionReference(TEST_CONTROLLER_ACTOR, TEST_SCOPE, TEST_ACTION); - execution.setVariable("controllerActor", TEST_CONTROLLER_ACTOR); + execution.setVariable("actor", TEST_CONTROLLER_ACTOR); execution.setVariable("scope", TEST_SCOPE); execution.setVariable("action", TEST_ACTION); 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 435c3a71ab..651d31b7bf 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 @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (c) 2020 Tech Mahindra + * ================================================================================ * 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 @@ -32,6 +34,7 @@ public enum OrchestrationStatus { PENDING_DELETE("PendingDelete", "pending.?delete"), PRECREATED("PreCreated", "pre.?created"), CONFIGASSIGNED("ConfigAssigned", "config.?assigned"), + CONFIGDEPLOYED("ConfigDeployed", "config.?deployed"), CONFIGURE("Configure", "configure"), CONFIGURED("Configured", "configured"), REGISTER("Register", "register"), -- 2.16.6