From: Lukasz Rajewski Date: Fri, 5 Aug 2022 12:19:19 +0000 (+0200) Subject: Merge branch 'recursive-orch' X-Git-Tag: 1.11.0~11 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=b0f785e99096f230281d17e0fa89c21aca00fbac;hp=2ef42cd813c85015322da874de668b79e790c5eb;p=so.git Merge branch 'recursive-orch' Issue-ID: SO-3980 Signed-off-by: Lukasz Rajewski Change-Id: Ie0cd0f973800196d5cb1e038db4a49208a6c4a3b --- diff --git a/INFO.yaml b/INFO.yaml index bc297f931b..b0acad1916 100644 --- a/INFO.yaml +++ b/INFO.yaml @@ -1,29 +1,66 @@ - - - name: 'Chuanyu Chen' - email: 'chenchuanyu@huawei.com' - company: 'Huawei' - id: 'boychuanyu' - timezone: 'Asia/Shanghai' +--- +project: 'so' +project_creation_date: '2017-06-15' +lifecycle_state: 'Mature' +project_category: '' +project_lead: &onap_releng_ptl + name: 'Seshu Kumar M' + email: 'seshu.kumar.m@huawei.com' + id: 'seshukm' + company: 'Huawei Technologies India Pvt Ltd' + timezone: 'India/Bangalore' +primary_contact: *onap_releng_ptl +issue_tracking: + type: 'jira' + url: 'https://jira.onap.org/projects/SO' + key: 'SO' +mailing_list: + type: 'groups.io' + url: 'lists.onap.org' + tag: '<[sub-project_name]>' +realtime_discussion: '' +meetings: + - type: 'zoom' + agenda: 'https://wiki.onap.org/display/DW/Service+Orchestrator+Project' + url: 'https://wiki.onap.org/display/DW/Service+Orchestrator+Project' + server: 'n/a' + channel: 'n/a' + repeats: 'weekly' + time: '12:30 UTC' +repositories: + - 'so' +committers: + - <<: *onap_releng_ptl - name: 'Byung-Woo Jun' email: 'byung-woo.jun@ericsson.com' company: 'Ericsson' id: 'byungwoojun' timezone: 'America/New_York' - - name: 'Steve Smokowski' - email: 'ss835w@att.com' - company: 'ATT' - id: 'stevesmokowski' - timezone: 'America/New_York' - - name: 'Lukasz Muszkieta' - email: 'lukasz.muszkieta@nokia.com' - company: 'Nokia' - id: 'lukaszM' - timezone: 'Europe/Warsaw' - - name: 'Ramesh Parthasarathy' - email: 'ramesh.parthasarathy@att.com' - company: 'ATT' - id: 'parthasram' - timezone: 'PST' + - name: 'Waqas Ikram' + email: 'waqas.ikram@est.tech' + company: 'Ericsson' + id: 'waqas.ikram' + timezone: 'Ireland/Dublin' + - name: 'Lukasz Rajewski' + email: 'lukasz.rajewski@orange.com' + company: 'Orange' + id: 'rajewluk' + timezone: 'Poland/Warsaw' + - name: 'Shashikanth VH' + email: 'shashikanth.vh@huawei.com' + company: 'Huawei Technologies India Pvt Ltd' + id: 'shashikanth.vh' + timezone: 'India/Bangalore' + - name: 'Jozsef Csongvai' + email: 'jozsef.csongvai@bell.ca' + company: 'Bell Canada' + id: 'jozsef' + timezone: 'Canada/Ontario' + - name: 'Md Irshad Sheikh' + email: 'md.irshad.sheikh@huawei.com' + company: 'Huawei Technologies India Pvt Ltd' + id: 'irshad97' + timezone: 'India/Bangalore' tsc: approval: 'https://lists.onap.org/pipermail/onap-tsc' changes: @@ -77,7 +114,7 @@ tsc: link: 'https://lists.onap.org/g/onap-tsc/message/4320' - type: 'removal' name: 'Rob Daugherty' - link: 'https://lists.onap.org/g/onap-tsc/message/4320' + link: 'https://lists.onap.org/g/onap-tsc/message/4320' - type: 'addition' name: 'Max Benjamin' link: 'https://lists.onap.org/g/onap-tsc/message/4320' @@ -102,3 +139,6 @@ tsc: - type: 'removal' name: 'Max Benjamin' link: 'https://wiki.onap.org/display/DW/2021+TSC+Decisions' + - type: 'removal' + name: 'Steve' + link: 'https://wiki.onap.org/display/Meetings/TSC+2022-03-03' diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/authentication/AuthenticationMethodTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/authentication/AuthenticationMethodTest.java index 41aac0084c..78b5c8ede9 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/authentication/AuthenticationMethodTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/authentication/AuthenticationMethodTest.java @@ -3,6 +3,7 @@ * ONAP - SO * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2022 Samsung Electronics. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +23,7 @@ package org.onap.so.cloud.authentication; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertEquals; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; @@ -61,7 +62,7 @@ public class AuthenticationMethodTest { ci.setMsoId("test"); Authentication auth = authenticationMethodFactory.getAuthenticationFor(ci); - assertTrue(RackspaceAuthentication.class.equals(auth.getClass())); + assertEquals(RackspaceAuthentication.class, auth.getClass()); } @@ -73,7 +74,7 @@ public class AuthenticationMethodTest { ci.setMsoId("someuser"); Authentication auth = authenticationMethodFactory.getAuthenticationFor(ci); - assertTrue(UsernamePassword.class.equals(auth.getClass())); + assertEquals(UsernamePassword.class, auth.getClass()); } @@ -85,7 +86,7 @@ public class AuthenticationMethodTest { ci.setMsoId("test"); Authentication auth = authenticationMethodFactory.getAuthenticationFor(ci); - assertTrue(RackspaceAuthentication.class.equals(auth.getClass())); + assertEquals(RackspaceAuthentication.class, auth.getClass()); } @Test @@ -96,7 +97,7 @@ public class AuthenticationMethodTest { ci.setMsoId("someuser"); Authentication auth = authenticationMethodFactory.getAuthenticationFor(ci); - assertTrue(UsernamePassword.class.equals(auth.getClass())); + assertEquals(UsernamePassword.class, auth.getClass()); } diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoCommonUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoCommonUtilsTest.java index 622ad4f94f..160201f442 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoCommonUtilsTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoCommonUtilsTest.java @@ -3,6 +3,7 @@ * ONAP - SO * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2022 - Samsung Electronics. 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. @@ -100,19 +101,19 @@ public class MsoCommonUtilsTest extends BaseTest { MsoException me = commonUtils.keystoneErrorToMsoException(openStackConnectException, "ContextError"); assertTrue(me instanceof MsoIOException); - assertTrue("connect".equals(me.getMessage())); + assertEquals("connect", me.getMessage()); MsoException me2 = commonUtils.keystoneErrorToMsoException(openStackResponseException, "ContextError"); assertTrue(me2 instanceof MsoOpenstackException); - assertTrue("ContextError".equals(me2.getContext())); - assertTrue(MsoExceptionCategory.OPENSTACK.equals(me2.getCategory())); + assertEquals("ContextError", me2.getContext()); + assertEquals(MsoExceptionCategory.OPENSTACK, me2.getCategory()); OpenStackResponse openStackResponse = Mockito.mock(OpenStackResponse.class); Error error = mapper.readValue(new File(RESOURCE_PATH + "Error.json"), Error.class); - doReturn(error).when(openStackResponse).getErrorEntity(eq(Error.class)); + doReturn(error).when(openStackResponse).getErrorEntity(Error.class); openStackResponseException = new OpenStackResponseException("response", 501, openStackResponse); @@ -131,19 +132,19 @@ public class MsoCommonUtilsTest extends BaseTest { MsoException me = commonUtils.heatExceptionToMsoException(openStackConnectException, "ContextError"); assertTrue(me instanceof MsoIOException); - assertTrue("connect".equals(me.getMessage())); + assertEquals("connect", me.getMessage()); MsoException me2 = commonUtils.heatExceptionToMsoException(openStackResponseException, "ContextError"); assertTrue(me2 instanceof MsoOpenstackException); - assertTrue("ContextError".equals(me2.getContext())); - assertTrue(MsoExceptionCategory.OPENSTACK.equals(me2.getCategory())); + assertEquals("ContextError", me2.getContext()); + assertEquals(MsoExceptionCategory.OPENSTACK, me2.getCategory()); OpenStackResponse openStackResponse = Mockito.mock(OpenStackResponse.class); Explanation explanation = mapper.readValue(new File(RESOURCE_PATH + "Explanation.json"), Explanation.class); - doReturn(explanation).when(openStackResponse).getErrorEntity(eq(Explanation.class)); + doReturn(explanation).when(openStackResponse).getErrorEntity(Explanation.class); openStackResponseException = new OpenStackResponseException("response", 501, openStackResponse); @@ -163,18 +164,18 @@ public class MsoCommonUtilsTest extends BaseTest { MsoException me = commonUtils.neutronExceptionToMsoException(openStackConnectException, "ContextError"); assertTrue(me instanceof MsoIOException); - assertTrue("connect".equals(me.getMessage())); + assertEquals("connect", me.getMessage()); MsoException me2 = commonUtils.neutronExceptionToMsoException(openStackResponseException, "ContextError"); assertTrue(me2 instanceof MsoOpenstackException); - assertTrue("ContextError".equals(me2.getContext())); - assertTrue(MsoExceptionCategory.OPENSTACK.equals(me2.getCategory())); + assertEquals("ContextError", me2.getContext()); + assertEquals(MsoExceptionCategory.OPENSTACK, me2.getCategory()); OpenStackResponse openStackResponse = Mockito.mock(OpenStackResponse.class); NeutronError explanation = mapper.readValue(new File(RESOURCE_PATH + "NeutronError.json"), NeutronError.class); - doReturn(explanation).when(openStackResponse).getErrorEntity(eq(NeutronError.class)); + doReturn(explanation).when(openStackResponse).getErrorEntity(NeutronError.class); openStackResponseException = new OpenStackResponseException("response", 501, openStackResponse); @@ -190,8 +191,8 @@ public class MsoCommonUtilsTest extends BaseTest { MsoException me = commonUtils.runtimeExceptionToMsoException(re, "ContextError"); assertTrue(me instanceof MsoAdapterException); - assertTrue("ContextError".equals(me.getContext())); - assertTrue(MsoExceptionCategory.INTERNAL.equals(me.getCategory())); + assertEquals("ContextError", me.getContext()); + assertEquals(MsoExceptionCategory.INTERNAL, me.getCategory()); } @Test @@ -202,6 +203,7 @@ public class MsoCommonUtilsTest extends BaseTest { assertTrue(msoException instanceof MsoAdapterException); assertEquals("ContextError", msoException.getContext()); - assertTrue(MsoExceptionCategory.INTERNAL.equals(msoException.getCategory())); + assertEquals(MsoExceptionCategory.INTERNAL, msoException.getCategory()); } } + diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatEnvironmentResourceTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatEnvironmentResourceTest.java index 2c67dfd009..18372bb8ea 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatEnvironmentResourceTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatEnvironmentResourceTest.java @@ -16,8 +16,7 @@ package org.onap.so.openstack.utils; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertNotEquals; import org.junit.Test; public class MsoHeatEnvironmentResourceTest { @@ -36,8 +35,8 @@ public class MsoHeatEnvironmentResourceTest { assertEquals("maeValue", mae.getValue()); assertEquals("\"msoHERName\": msoHERValue", msoHER.toString()); assertEquals("\"name\": maeValue", mae.toString()); - assertFalse(mae.equals(op)); - assertTrue(mae.equals(mre)); + assertNotEquals(mae, op); + assertEquals(mae, mre); assertEquals("name".hashCode(), mae.hashCode()); } } diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java index 5ee4987e38..85219c3b5c 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java @@ -447,7 +447,7 @@ public class MsoHeatUtilsTest extends MsoHeatUtils { heatUtils.createStack(createStackParam, cloudSiteId, tenantId); Mockito.verify(stackResource, times(1)).create(createStackParam); - Mockito.verify(heatUtils, times(1)).saveStackRequest(eq(createStackParam), eq(requestId), eq("stackName")); + Mockito.verify(heatUtils, times(1)).saveStackRequest(createStackParam, requestId, "stackName"); Mockito.verify(heatClient, times(1)).getStacks(); Mockito.verify(stackResource, times(1)).create(createStackParam); } diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoMulticloudUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoMulticloudUtilsTest.java index 7adfe091d3..d197550937 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoMulticloudUtilsTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoMulticloudUtilsTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP - SO * ================================================================================ - * Copyright (C) 2019 Samsung Intellectual Property. All rights reserved. + * Copyright (C) 2022 Samsung 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. @@ -28,7 +28,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertSame; import static org.junit.Assert.fail; import static org.mockito.Mockito.when; import static org.onap.so.openstack.utils.MsoMulticloudUtils.MULTICLOUD_QUERY_BODY_NULL; @@ -113,13 +113,13 @@ public class MsoMulticloudUtilsTest extends BaseTest { StackInfo result = multicloudUtils.deleteStack("MTN14", "CloudOwner", "TEST-tenant", "TEST-stack/TEST-workload"); assertNotNull(result); - assertTrue(HeatStatus.NOTFOUND == result.getStatus()); + assertSame(HeatStatus.NOTFOUND, result.getStatus()); } @Test public void queryStack() throws MsoException { StackInfo result = multicloudUtils.queryStack("MTN13", "CloudOwner", "TEST-tenant", "instanceId"); - assertTrue(HeatStatus.NOTFOUND == result.getStatus()); + assertSame(HeatStatus.NOTFOUND, result.getStatus()); } @Test @@ -129,7 +129,7 @@ public class MsoMulticloudUtilsTest extends BaseTest { .withStatus(HttpStatus.SC_OK))); StackInfo result = multicloudUtils.queryStack("MTN13", "CloudOwner", "TEST-tenant", "instanceName/instanceId"); - assertTrue(HeatStatus.FAILED == result.getStatus()); + assertSame(HeatStatus.FAILED, result.getStatus()); assertEquals(MULTICLOUD_QUERY_BODY_NULL, result.getStatusMessage()); } @@ -143,7 +143,7 @@ public class MsoMulticloudUtilsTest extends BaseTest { CloudInfo cloudInfo = new CloudInfo("cloudSiteId", "cloudOwner", "tenantId", "tenantName"); VduInstance vduInstance = multicloudUtils.deleteVdu(cloudInfo, "instanceId", 3); assertNotNull(vduInstance); - assertTrue(VduStateType.DELETED == vduInstance.getStatus().getState()); + assertSame(VduStateType.DELETED, vduInstance.getStatus().getState()); } @Ignore 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 9b21dcd2d2..c1a67a5990 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 @@ -26,7 +26,7 @@ INSERT INTO northbound_request_ref_lookup(MACRO_ACTION, ACTION, REQUEST_SCOPE, I ('VNF-Create', 'createInstance', 'Vnf', true,true, '7', '7', 'DEFAULT', '*'), ('VNF-Delete', 'deleteInstance', 'Vnf', true,true, '7', '7', 'DEFAULT', '*'), ('VNF-Macro-Delete', 'deleteInstance', 'Vnf', false,true, '7', '7', 'DEFAULT', '*'), -('VNF-Macro-Modify', 'updateInstance', 'Vnf', false,true, '7', '7','k8scloudowner4', '*'), +('VNF-Macro-Modify', 'updateInstance', 'Vnf', false,true, '7', '7','DEFAULT', '*'), ('VNF-Macro-HealthCheck', 'healthCheck', 'Vnf', false,true, '7', '7','DEFAULT', '*'), ('VolumeGroup-Create', 'createInstance', 'VolumeGroup', true,true, '7','7', 'DEFAULT', '*'), ('VolumeGroup-Delete', 'deleteInstance', 'VolumeGroup', true,true, '7','7', 'DEFAULT', '*'), @@ -39,7 +39,8 @@ INSERT INTO northbound_request_ref_lookup(MACRO_ACTION, ACTION, REQUEST_SCOPE, I ('NetworkCollection-Macro-Delete', 'deleteInstance', 'NetworkCollection', false,true, '7','7', 'DEFAULT', '*'), ('VFModule-ScaleOut', 'scaleOut', 'VfModule', true, true, '7','7', 'DEFAULT', '*'), ('VNF-InPlaceUpdate', 'inPlaceSoftwareUpdate', 'Vnf', true, true, '7','7', 'DEFAULT', '*'), -('VNF-Config-Update', 'applyUpdatedConfig', 'Vnf', true, true, '7','7', 'DEFAULT', '*'); +('VNF-Config-Update', 'applyUpdatedConfig', 'Vnf', true, true, '7','7', 'DEFAULT', '*'), +('CNF-Macro-Upgrade', 'upgradeCnf', 'Vnf', false,true, '7', '7','DEFAULT', '*'); INSERT INTO orchestration_flow_reference(COMPOSITE_ACTION, SEQ_NO, FLOW_NAME, SCOPE, ACTION, FLOW_VERSION, NB_REQ_REF_LOOKUP_ID) VALUES @@ -255,9 +256,22 @@ INSERT INTO orchestration_flow_reference(COMPOSITE_ACTION, SEQ_NO, FLOW_NAME, SC ('VNF-Config-Update', '7', 'VNFHealthCheckActivity', NULL, NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Config-Update' and CLOUD_OWNER = 'DEFAULT')), ('VNF-Config-Update', '8', 'VNFUnsetInMaintFlagActivity', NULL, NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Config-Update' and CLOUD_OWNER = 'DEFAULT')), ('VNF-Config-Update', '9', 'VNFUnsetClosedLoopDisabledFlagActivity', NULL, NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Config-Update' and CLOUD_OWNER = 'DEFAULT')), -('VNF-Macro-Modify', '1', 'ControllerExecutionBB', 'vnf', 'config-assign', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Macro-Modify' and CLOUD_OWNER = 'k8scloudowner4')), -('VNF-Macro-Modify', '2', 'ControllerExecutionBB', 'vnf', 'config-deploy', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Macro-Modify' and CLOUD_OWNER = 'k8scloudowner4')), -('VNF-Macro-HealthCheck', '1', 'HealthCheckBB', 'vnf', 'status-check', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Macro-HealthCheck' and CLOUD_OWNER = 'DEFAULT')); +('VNF-Macro-Modify', '1', 'ControllerExecutionBB', 'vnf', 'config-assign', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Macro-Modify' and CLOUD_OWNER = 'DEFAULT')), +('VNF-Macro-Modify', '2', 'ControllerExecutionBB', 'vnf', 'config-deploy', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Macro-Modify' and CLOUD_OWNER = 'DEFAULT')), +('VNF-Macro-HealthCheck', '1', 'HealthCheckBB', 'vnf', 'status-check', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Macro-HealthCheck' and CLOUD_OWNER = 'DEFAULT')), +('VNF-Macro-HealthCheck', '2', 'HealthCheckBB', 'vnf', 'health-check', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Macro-HealthCheck' and CLOUD_OWNER = 'DEFAULT')), +('CNF-Macro-Upgrade', '1', 'AAICheckVnfInMaintBB', NULL, NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'CNF-Macro-Upgrade' and CLOUD_OWNER = 'DEFAULT')), +('CNF-Macro-Upgrade', '2', 'AAISetVnfInMaintBB', NULL, NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'CNF-Macro-Upgrade' and CLOUD_OWNER = 'DEFAULT')), +('CNF-Macro-Upgrade', '3', 'DeactivateVfModuleBB', NULL, NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'CNF-Macro-Upgrade' and CLOUD_OWNER = 'DEFAULT')), +('CNF-Macro-Upgrade', '4', 'DeactivateVnfBB', NULL, NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'CNF-Macro-Upgrade' and CLOUD_OWNER = 'DEFAULT')), +('CNF-Macro-Upgrade', '5', 'ChangeModelVfModuleBB', NULL, NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'CNF-Macro-Upgrade' and CLOUD_OWNER = 'DEFAULT')), +('CNF-Macro-Upgrade', '6', 'ControllerExecutionBB', 'vnf', 'config-upgrade-assign', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'CNF-Macro-Upgrade' and CLOUD_OWNER = 'DEFAULT')), +('CNF-Macro-Upgrade', '7', 'UpgradeVfModuleBB', NULL , NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'CNF-Macro-Upgrade' and CLOUD_OWNER = 'DEFAULT')), +('CNF-Macro-Upgrade', '8', 'ControllerExecutionBB', 'vnf', 'config-upgrade-deploy', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'CNF-Macro-Upgrade' and CLOUD_OWNER = 'DEFAULT')), +('CNF-Macro-Upgrade', '9', 'ActivateVfModuleBB', NULL, NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'CNF-Macro-Upgrade' and CLOUD_OWNER = 'DEFAULT')), +('CNF-Macro-Upgrade', '10', 'ChangeModelVnfBB', NULL, NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'CNF-Macro-Upgrade' and CLOUD_OWNER = 'DEFAULT')), +('CNF-Macro-Upgrade', '11', 'ActivateVnfBB', NULL, NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'CNF-Macro-Upgrade' and CLOUD_OWNER = 'DEFAULT')), +('CNF-Macro-Upgrade', '12', 'AAIUnsetVnfInMaintBB', NULL, NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'CNF-Macro-Upgrade' and CLOUD_OWNER = 'DEFAULT')); INSERT INTO rainy_day_handler_macro (FLOW_NAME, SERVICE_TYPE, VNF_TYPE, ERROR_CODE, WORK_STEP, POLICY, SECONDARY_POLICY, REG_EX_ERROR_MESSAGE, SERVICE_ROLE) VALUES @@ -416,7 +430,11 @@ VALUES ('VNFConfigModifyActivity', 'NO_VALIDATE', 'CUSTOM'), ('ConfigAssignVnfBB', 'NO_VALIDATE', 'CUSTOM'), ('ConfigDeployVnfBB', 'NO_VALIDATE', 'CUSTOM'), -('ControllerExecutionBB', 'NO_VALIDATE', 'CUSTOM'); +('ControllerExecutionBB', 'NO_VALIDATE', 'CUSTOM'), +('StatusCheckBB', 'NO_VALIDATE', 'CUSTOM'), +('HealthCheckBB', 'NO_VALIDATE', 'CUSTOM'), +('UpgradeVfModuleBB', 'NO_VALIDATE', 'CUSTOM'); + INSERT INTO orchestration_status_state_transition_directive (resource_type, orchestration_status, target_action, flow_directive) VALUES @@ -866,3 +884,28 @@ DELETE FROM service_recipe where ACTION = 'upgradeInstance'; INSERT INTO service_recipe (ACTION, VERSION_STR, DESCRIPTION, ORCHESTRATION_URI, RECIPE_TIMEOUT, SERVICE_MODEL_UUID) VALUES ('upgradeInstance', '1.0', 'Gr api recipe to upgrade service-instance', '/mso/async/services/WorkflowActionBB', 180, 'd88da85c-d9e8-4f73-b837-3a72a431622b'); + +INSERT INTO building_block_rollback(BUILDING_BLOCK_NAME,ACTION,ROLLBACK_BUILDING_BLOCK_NAME,ROLLBACK_ACTION) +VALUES +('ActivateNetworkBB',NULL,'DeactivateNetworkBB',NULL), +('ActivatePnfBB',NULL,'DeactivatePnfBB',NULL), +('ActivateServiceInstanceBB',NULL,'DeactivateServiceInstanceBB',NULL), +('ActivateVfModuleBB',NULL,'DeactivateVfModuleBB',NULL), +('ActivateVnfBB',NULL,'DeactivateVnfBB',NULL), +('ActivateVolumeGroupBB',NULL,'DeactivateVolumeGroupBB',NULL), +('AssignNetworkBB',NULL,'UnassignNetworkBB',NULL), +('AssignServiceInstanceBB',NULL,'UnassignServiceInstanceBB',NULL), +('AssignVfModuleBB',NULL,'UnassignVfModuleBB',NULL), +('AssignVnfBB',NULL,'UnassignVnfBB',NULL), +('AssignVolumeGroupBB',NULL,'UnassignVolumeGroupBB',NULL), +('CreateNetworkBB',NULL,'DeleteNetworkBB',NULL), +('CreateNetworkCollectionBB',NULL,'DeleteNetworkCollectionBB',NULL), +('CreateVfModuleBB',NULL,'DeleteVfModuleBB',NULL), +('CreateVolumeGroupBB',NULL,'DeleteVolumeGroupBB',NULL), +('VNFSetInMaintFlagActivity',NULL,'VNFUnsetInMaintFlagActivity',NULL), +('VNFSetClosedLoopDisabledFlagActivity',NULL,'VNFUnsetClosedLoopDisabledFlagActivity',NULL), +('VNFLockActivity',NULL,'VNFUnlockActivity',NULL), +('VNFStopActivity',NULL,'VNFStartActivity',NULL), +('VNFQuiesceTrafficActivity',NULL,'VNFResumeTrafficActivity',NULL), +('EtsiVnfInstantiateBB',NULL,'EtsiVnfDeleteBB',NULL), +('AddFabricConfigurationBB',NULL,'DeleteFabricConfigurationBB',NULL); diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V1.1__Initial_Recipe_Setup.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V1.1__Initial_Recipe_Setup.sql index e4a2d6648f..6dfc863e0b 100644 --- a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V1.1__Initial_Recipe_Setup.sql +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V1.1__Initial_Recipe_Setup.sql @@ -35,6 +35,7 @@ INSERT INTO `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORC INSERT INTO `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORCHESTRATION_URI`, `SERVICE_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TIMEOUT_INTERIM`, `CREATION_TIMESTAMP`, `SERVICE_MODEL_UUID`) VALUES (4,'deleteInstance','1','DEFAULT recipe to delete service-instance if no custom BPMN flow is found','/mso/async/services/DeleteGenericALaCarteServiceInstance',NULL,180,NULL,'2017-10-05 18:52:03','48cc3acd-a9fe-11e7-8b4b-0242ac120002'); insert into `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORCHESTRATION_URI`, `SERVICE_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TIMEOUT_INTERIM`, `CREATION_TIMESTAMP`, `SERVICE_MODEL_UUID`) values (500,'updateInstance','1.0','Gr api recipe to update service-instance', '/mso/async/services/WorkflowActionBB', NULL, 180, NULL, '2017-10-05 18:52:03', 'd88da85c-d9e8-4f73-b837-3a72a431622b'); insert into `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORCHESTRATION_URI`, `SERVICE_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TIMEOUT_INTERIM`, `CREATION_TIMESTAMP`, `SERVICE_MODEL_UUID`) values (501,'healthCheck','1.0','Gr api recipe to do CNF health check', '/mso/async/services/WorkflowActionBB', NULL, 180, NULL, '2021-08-20 18:52:03', 'd88da85c-d9e8-4f73-b837-3a72a431622b'); +insert into `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORCHESTRATION_URI`, `SERVICE_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TIMEOUT_INTERIM`, `CREATION_TIMESTAMP`, `SERVICE_MODEL_UUID`) values (525,'upgradeCnf','1.0','Gr api recipe to do CNF upgrade', '/mso/async/services/WorkflowActionBB', NULL, 180, NULL, '2022-01-20 18:52:03', 'd88da85c-d9e8-4f73-b837-3a72a431622b'); -- -- Custom Reciepe for the VoLTE service added temporarily @@ -106,4 +107,6 @@ INSERT INTO `vnf_recipe` (`id`, `VF_MODULE_ID`, `ACTION`, `SERVICE_TYPE`, `VERSI INSERT INTO `vnf_recipe` (`id`, `VF_MODULE_ID`, `ACTION`, `SERVICE_TYPE`, `VERSION_STR`, `VNF_TYPE`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (12,NULL,'deleteInstance',NULL,'1','NS_DEFAULT','default custom E2E recipe to delete NS if no custom BPMN flow is found','/mso/async/services/DeleteVFCNSResource',NULL,180,'2018-04-18 18:52:03'); INSERT INTO `vnf_recipe` (`id`, `VF_MODULE_ID`, `ACTION`, `SERVICE_TYPE`, `VERSION_STR`, `VNF_TYPE`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (13,NULL,'inPlaceSoftwareUpdate',NULL,'1','VID_DEFAULT','VID_DEFAULT recipe to update VNF software if no custom BPMN flow is found','/mso/async/services/VnfInPlaceUpdate',NULL,180,'2018-05-23 11:00:00'); INSERT INTO `vnf_recipe` (`id`, `VF_MODULE_ID`, `ACTION`, `SERVICE_TYPE`, `VERSION_STR`, `VNF_TYPE`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (14,NULL,'applyUpdatedConfig',NULL,'1','VID_DEFAULT','VID_DEFAULT recipe to apply updated VNF config if no custom BPMN flow is found','/mso/async/services/VnfConfigUpdate',NULL,180,'2018-05-23 11:00:00'); -SET FOREIGN_KEY_CHECKS=1; +INSERT INTO `vnf_recipe` (`id`, `VF_MODULE_ID`, `ACTION`, `SERVICE_TYPE`, `VERSION_STR`, `VNF_TYPE`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (10030,NULL,'upgradeCnf',NULL,'1','GR-API-DEFAULT','Gr api recipe to do CNF-Upgrade','/mso/async/services/WorkflowActionBB',NULL,180,'2022-01-23 10:00:00'); +INSERT INTO `vnf_recipe` (`id`, `VF_MODULE_ID`, `ACTION`, `SERVICE_TYPE`, `VERSION_STR`, `VNF_TYPE`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (10032,NULL,'healthCheck',NULL,'1','GR-API-DEFAULT','Gr api recipe to do CNF health check','/mso/async/services/WorkflowActionBB',NULL,180,'2022-01-05 18:52:03'); +SET FOREIGN_KEY_CHECKS=1; \ No newline at end of file diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java index 48ef1329b0..74ea27cc06 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java @@ -3,6 +3,7 @@ * ONAP - SO * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2022 Samsung Electronics 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. @@ -813,7 +814,7 @@ public class CatalogDBRestTest extends CatalogDbAdapterBaseTest { restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class); assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); - JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false); + JSONAssert.assertEquals(badQueryParamResponse, response.getBody(), false); } @Test @@ -850,10 +851,10 @@ public class CatalogDBRestTest extends CatalogDbAdapterBaseTest { ObjectMapper mapper = new ObjectMapper(); ProcessingFlags processingFlagsResponse = mapper.readValue(response.getBody(), ProcessingFlags.class); - assertEquals(processingFlagsResponse.getFlag(), "TESTFLAG"); - assertEquals(processingFlagsResponse.getValue(), "NO"); - assertEquals(processingFlagsResponse.getEndpoint(), "TESTENDPOINT"); - assertEquals(processingFlagsResponse.getDescription(), "TEST FLAG"); + assertEquals("TESTFLAG", processingFlagsResponse.getFlag()); + assertEquals("NO", processingFlagsResponse.getValue()); + assertEquals("TESTENDPOINT", processingFlagsResponse.getEndpoint()); + assertEquals("TEST FLAG", processingFlagsResponse.getDescription()); } @Test @@ -876,8 +877,8 @@ public class CatalogDBRestTest extends CatalogDbAdapterBaseTest { boolean testFlagFound = false; for (int i = 0; i < processingFlagsResponse.size(); i++) { if (processingFlagsResponse.get(i).getFlag().equals("TESTFLAG")) { - assertEquals(processingFlagsResponse.get(i).getEndpoint(), "TESTENDPOINT"); - assertEquals(processingFlagsResponse.get(i).getDescription(), "TEST FLAG"); + assertEquals("TESTENDPOINT", processingFlagsResponse.get(i).getEndpoint()); + assertEquals("TEST FLAG", processingFlagsResponse.get(i).getDescription()); testFlagFound = true; } } diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceArtifactTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceArtifactTest.java index 2266eafa12..d7852cfdfe 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceArtifactTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceArtifactTest.java @@ -3,6 +3,7 @@ * ONAP - SO * ================================================================================ * Copyright (c) 2019, CMCC Technologies Co., Ltd. + * Copyright (c) 2022, Samsung Electronics. 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. @@ -35,7 +36,7 @@ public class QueryServiceArtifactTest { QueryServiceArtifact queryServiceArtifact = new QueryServiceArtifact(createList()); String jsonResult = queryServiceArtifact.JSON2(true, false); Assertions.assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.serviceArtifact[0].name").get()) - .isEqualTo("eMBB.zip"); + .contains("eMBB.zip"); } private List createList() { diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceInfoTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceInfoTest.java index e948141b89..37fd4641a1 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceInfoTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceInfoTest.java @@ -3,6 +3,7 @@ * ONAP - SO * ================================================================================ * Copyright (c) 2019, CMCC Technologies Co., Ltd. + * Copyright (c) 2022, Samsung Electronics. 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. @@ -35,7 +36,7 @@ public class QueryServiceInfoTest { QueryServiceInfo queryServiceInfo = new QueryServiceInfo(createList()); String jsonResult = queryServiceInfo.JSON2(true, false); String serviceInfo = jsonResult.substring(jsonResult.indexOf("{"), jsonResult.length()); - Assertions.assertThat(JsonPathUtil.getInstance().locateResult(serviceInfo, "$.id").get()).isEqualTo("1"); + Assertions.assertThat(JsonPathUtil.getInstance().locateResult(serviceInfo, "$.id").get()).contains("1"); } private List createList() { diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java index 8ce4051b24..4e273d5a8e 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java @@ -34,6 +34,7 @@ import org.junit.Test; import org.onap.so.adapters.catalogdb.CatalogDbAdapterBaseTest; import org.onap.so.db.catalog.beans.AuthenticationType; import org.onap.so.db.catalog.beans.BBNameSelectionReference; +import org.onap.so.db.catalog.beans.BuildingBlockRollback; import org.onap.so.db.catalog.beans.CloudIdentity; import org.onap.so.db.catalog.beans.CloudSite; import org.onap.so.db.catalog.beans.CloudifyManager; @@ -780,5 +781,11 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest { assertEquals(processingFlags.getEndpoint(), "TESTENDPOINT"); } + @Test + public void testGetBuildingBlocksList() { + List rollbackEntries = client.getBuildingBlockRollbackEntries(); + assertTrue(rollbackEntries.size() > 1); + } + } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/utils/HeatBridgeUtils.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/utils/HeatBridgeUtils.java index c281dbd9e5..17fd99482c 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/utils/HeatBridgeUtils.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/utils/HeatBridgeUtils.java @@ -35,6 +35,7 @@ package org.onap.so.heatbridge.utils; import com.google.common.base.Preconditions; import com.google.common.base.Strings; +import java.util.Collections; import java.util.List; import java.util.Optional; import java.util.stream.Collectors; @@ -71,6 +72,9 @@ public final class HeatBridgeUtils { } public static List extractPciIdsFromVServer(Vserver vserver) { + if (vserver.getLInterfaces() == null) { + return Collections.emptyList(); + } return vserver.getLInterfaces().getLInterface().stream() .filter(lInterface -> lInterface.getSriovVfs() != null && CollectionUtils.isNotEmpty(lInterface.getSriovVfs().getSriovVf())) diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestsDbClientTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestsDbClientTest.java index 33805f9faa..59919c67f2 100644 --- a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestsDbClientTest.java +++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestsDbClientTest.java @@ -3,6 +3,7 @@ * ONAP - SO * ================================================================================ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (c) 2022, Samsung Electronics. 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. @@ -26,7 +27,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; import java.sql.Timestamp; import java.time.Instant; import java.time.temporal.ChronoUnit; @@ -339,7 +339,8 @@ public class RequestsDbClientTest extends RequestsAdapterBase { requestsDbClient.getRequestProcessingDataBySoRequestIdAndNameAndTagOrderByCreateTimeDesc( "00032ab7-na18-42e5-965d-8ea592502018", "requestAction", "pincFabricConfigRequest"); assertNotNull(requestProcessingData); - assertTrue(requestProcessingData.size() == 1); + assertEquals(1, requestProcessingData.size()); assertEquals("assign", requestProcessingData.get(0).getValue()); } } + diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbExceptionBeanTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbExceptionBeanTest.java index 77821bfefd..3cf9314a8b 100644 --- a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbExceptionBeanTest.java +++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbExceptionBeanTest.java @@ -3,6 +3,7 @@ * ONAP - SO * ================================================================================ * Copyright (C) 2018 TechMahindra + * Copyright (c) 2022, Samsung Electronics. 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. @@ -37,7 +38,8 @@ public class MsoRequestsDbExceptionBeanTest { public void testGetMessage() { soRequestsDbExceptionBean.setMessage("message"); Assert.assertNotNull(soRequestsDbExceptionBean.getMessage()); - Assert.assertEquals(soRequestsDbExceptionBean.getMessage(), "message"); + Assert.assertEquals("message", soRequestsDbExceptionBean.getMessage()); } } + diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbExceptionTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbExceptionTest.java index 04f597f9b2..94c6d267e4 100644 --- a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbExceptionTest.java +++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbExceptionTest.java @@ -3,6 +3,7 @@ * ONAP - SO * ================================================================================ * Copyright (C) 2018 TechMahindra + * Copyright (c) 2022, Samsung Electronics. 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. @@ -27,7 +28,7 @@ public class MsoRequestsDbExceptionTest { public void testConstructorWithMessaqge() throws Exception { String message = "testing message"; MsoRequestsDbException msoRequestsDbException = new MsoRequestsDbException(message); - Assert.assertTrue(msoRequestsDbException.getCause() == null); + Assert.assertNull(msoRequestsDbException.getCause()); Assert.assertEquals(message, msoRequestsDbException.getLocalizedMessage()); Assert.assertEquals(message, msoRequestsDbException.getMessage()); } @@ -64,3 +65,4 @@ public class MsoRequestsDbExceptionTest { } } + diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/sdncrest/BPRestCallbackTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/sdncrest/BPRestCallbackTest.java index c1bbb9ae9a..557a67b7cb 100644 --- a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/sdncrest/BPRestCallbackTest.java +++ b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/sdncrest/BPRestCallbackTest.java @@ -24,6 +24,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; import static com.github.tomakehurst.wiremock.client.WireMock.post; import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertNotNull; import org.apache.http.HttpStatus; import org.junit.Test; @@ -48,7 +49,6 @@ public class BPRestCallbackTest extends BaseTest { .withBody(response).withStatus(HttpStatus.SC_MULTIPLE_CHOICES))); boolean responseCommon = bpRestCallback.send("http://localhost:" + wireMockPort + "/sdnc", "Test"); - assertNotNull(responseCommon); - assertEquals(true, responseCommon); + assertTrue(responseCommon); } } 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 a38eb8c3a7..b29b95a3b1 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 @@ -1252,7 +1252,7 @@ public class BBInputSetup implements JavaDelegate { || requestAction.equalsIgnoreCase("activateFabricConfiguration") || requestAction.equalsIgnoreCase("recreateInstance") || requestAction.equalsIgnoreCase("replaceInstance") - || requestAction.equalsIgnoreCase("upgradeInstance")) { + || requestAction.equalsIgnoreCase("upgradeInstance") || requestAction.equalsIgnoreCase("healthCheck")) { return getGBBMacroExistingService(executeBB, lookupKeyMap, bbName, requestAction, requestDetails.getCloudConfiguration()); } @@ -1566,6 +1566,9 @@ public class BBInputSetup implements JavaDelegate { break; } } + } else if (bbName.equals("HealthCheckBB") + && (VNF).equalsIgnoreCase(executeBB.getBuildingBlock().getBpmnScope())) { + this.setisHelmforHealthCheckBB(service, serviceInstance, gBB); } if (executeBB.getWorkflowResourceIds() != null) { parameter.setResourceId(executeBB.getWorkflowResourceIds().getNetworkCollectionId()); @@ -1586,9 +1589,10 @@ public class BBInputSetup implements JavaDelegate { Vnfs vnfs = null; VfModules vfModules = null; Networks networks = null; + CloudConfiguration cloudConfiguration = requestDetails.getCloudConfiguration(); - CloudRegion cloudRegion = getCloudRegionFromMacroRequest(cloudConfiguration, resources); - gBB.setCloudRegion(cloudRegion); + CloudRegion cloudRegion = setCloudConfiguration(gBB, cloudConfiguration); + BBInputSetupParameter parameter = new BBInputSetupParameter.Builder().setRequestId(executeBB.getRequestId()).setService(service) .setBbName(bbName).setServiceInstance(serviceInstance).setLookupKeyMap(lookupKeyMap).build(); @@ -1601,6 +1605,11 @@ public class BBInputSetup implements JavaDelegate { vnfs = findVnfsByKey(key, resources); } + // Vnf level cloud configuration takes precedence over service level cloud configuration. + if (vnfs.getCloudConfiguration() != null) { + setCloudConfiguration(gBB, vnfs.getCloudConfiguration()); + } + String vnfId = lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID); // This stores the vnf id in request db to be retrieved later when // working on a vf module or volume group @@ -1637,6 +1646,21 @@ public class BBInputSetup implements JavaDelegate { vfModules = getVfModulesByKey(key, resources); } + String vfModulesName = vfModules.getInstanceName(); + String vfModulesModelCustId = vfModules.getModelInfo().getModelCustomizationId(); + // Get the Vnf associated with vfModule + Optional parentVnf = resources.getVnfs().stream() + .filter(aVnf -> aVnf.getCloudConfiguration() != null) + .filter(aVnf -> aVnf.getVfModules().stream() + .anyMatch(aVfModules -> aVfModules.getInstanceName().equals(vfModulesName) && aVfModules + .getModelInfo().getModelCustomizationId().equals(vfModulesModelCustId))) + .findAny(); + + // Get the cloud configuration from this Vnf + if (parentVnf.isPresent()) { + cloudRegion = setCloudConfiguration(gBB, parentVnf.get().getCloudConfiguration()); + } + lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, getVnfId(executeBB, lookupKeyMap)); parameter.setModelInfo(vfModules.getModelInfo()); @@ -1667,6 +1691,16 @@ public class BBInputSetup implements JavaDelegate { networks = findNetworksByKey(key, resources); String networkId = lookupKeyMap.get(ResourceKey.NETWORK_ID); if (networks != null) { + // If service level cloud configuration is not provided then get it from networks. + if (cloudConfiguration == null) { + Optional netWithCloudConfig = resources.getNetworks() + .stream().filter(aNetwork -> aNetwork.getCloudConfiguration() != null).findAny(); + if (netWithCloudConfig.isPresent()) { + setCloudConfiguration(gBB, netWithCloudConfig.get().getCloudConfiguration()); + } else { + logger.debug("Could not find any cloud configuration for this request."); + } + } parameter.setInstanceName(networks.getInstanceName()); parameter.setModelInfo(networks.getModelInfo()); parameter.setInstanceParams(networks.getInstanceParams()); @@ -1692,6 +1726,24 @@ public class BBInputSetup implements JavaDelegate { return gBB; } + /** + * setCloudConfiguration - set cloud info on a building block. + * + * @param gBB + * @param cloudConfiguration + * @return CloudRegion + * @throws Exception + */ + private CloudRegion setCloudConfiguration(GeneralBuildingBlock gBB, CloudConfiguration cloudConfiguration) + throws Exception { + org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = bbInputSetupUtils.getCloudRegion(cloudConfiguration); + Tenant tenant = getTenant(cloudConfiguration, aaiCloudRegion); + gBB.setTenant(tenant); + CloudRegion cloudRegion = mapperLayer.mapCloudRegion(cloudConfiguration, aaiCloudRegion); + gBB.setCloudRegion(cloudRegion); + return cloudRegion; + } + protected Networks findNetworksByKey(String key, Resources resources) { for (Networks networks : resources.getNetworks()) { if (networks.getModelInfo().getModelCustomizationId().equalsIgnoreCase(key)) { @@ -1742,39 +1794,6 @@ public class BBInputSetup implements JavaDelegate { throw new ResourceNotFoundException("Could not find vnf with key: " + key + " in userparams"); } - protected CloudRegion getCloudRegionFromMacroRequest(CloudConfiguration cloudConfiguration, Resources resources) { - if (cloudConfiguration == null) { - for (Vnfs vnfs : resources.getVnfs()) { - if (cloudConfiguration == null) { - cloudConfiguration = vnfs.getCloudConfiguration(); - } else { - break; - } - for (VfModules vfModules : vnfs.getVfModules()) { - if (cloudConfiguration == null) { - cloudConfiguration = vfModules.getCloudConfiguration(); - } else { - break; - } - } - } - for (Networks networks : resources.getNetworks()) { - if (cloudConfiguration == null) { - cloudConfiguration = networks.getCloudConfiguration(); - } else { - break; - } - } - } - if (cloudConfiguration != null) { - org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = bbInputSetupUtils.getCloudRegion(cloudConfiguration); - return mapperLayer.mapCloudRegion(cloudConfiguration, aaiCloudRegion); - } else { - logger.debug("Could not find any cloud configuration for this request."); - return null; - } - } - protected String getVnfId(ExecuteBuildingBlock executeBB, Map lookupKeyMap) { String vnfId = lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID); if (vnfId == null) { @@ -2114,6 +2133,28 @@ public class BBInputSetup implements JavaDelegate { return collection; } + private void setisHelmforHealthCheckBB(Service service, ServiceInstance serviceInstance, GeneralBuildingBlock gBB) { + for (GenericVnf vnf : serviceInstance.getVnfs()) { + for (VfModule vfModule : vnf.getVfModules()) { + String vnfModelCustomizationUUID = + this.bbInputSetupUtils.getAAIGenericVnf(vnf.getVnfId()).getModelCustomizationId(); + ModelInfo vnfModelInfo = new ModelInfo(); + vnfModelInfo.setModelCustomizationUuid(vnfModelCustomizationUUID); + this.mapCatalogVnf(vnf, vnfModelInfo, service); + String vfModuleCustomizationUUID = this.bbInputSetupUtils + .getAAIVfModule(vnf.getVnfId(), vfModule.getVfModuleId()).getModelCustomizationId(); + ModelInfo vfModuleModelInfo = new ModelInfo(); + vfModuleModelInfo.setModelCustomizationId(vfModuleCustomizationUUID); + this.mapCatalogVfModule(vfModule, vfModuleModelInfo, service, vnfModelCustomizationUUID); + if (vfModule.getModelInfoVfModule() != null && vfModule.getModelInfoVfModule().getModelName() != null + && vfModule.getModelInfoVfModule().getModelName().contains("helm")) { + gBB.getRequestContext().setIsHelm(true); + break; + } + } + } + } + protected void mapL3Networks(List list, List l3Networks) { for (AAIResourceUri aaiResourceUri : list) { l3Networks.add(this.mapL3Network(aaiResourceUri)); diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsForService.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsForService.java index e8c88e00d7..4148a60433 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsForService.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsForService.java @@ -20,7 +20,7 @@ package org.onap.so.client.cds; -import static org.onap.so.client.cds.ConfigureInstanceParamsUtil.applyParamsToObject; +import static org.onap.so.client.cds.ConfigureInstanceParamsUtil.applyJsonParamsToObject; import com.google.gson.JsonObject; import java.util.List; import java.util.Map; @@ -49,7 +49,7 @@ public class ConfigureInstanceParamsForService { Optional service = extractServiceFromUserParameters.getServiceFromRequestUserParams(userParamsFromRequest); - service.map(Service::getInstanceParams).ifPresent(p -> applyParamsToObject(p, jsonObject)); + service.map(Service::getInstanceParams).ifPresent(p -> applyJsonParamsToObject(p, jsonObject)); } catch (Exception e) { throw new PayloadGenerationException("Failed to resolve instance parameters", e); } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsUtil.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsUtil.java index 117fd74498..7e9c885496 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsUtil.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsUtil.java @@ -20,15 +20,23 @@ package org.onap.so.client.cds; +import com.google.gson.Gson; import com.google.gson.JsonObject; import java.util.List; import java.util.Map; public final class ConfigureInstanceParamsUtil { + private static final Gson gson = new Gson(); + public static void applyParamsToObject(List> instanceParamsList, JsonObject jsonObject) { instanceParamsList.stream().flatMap(instanceParamsMap -> instanceParamsMap.entrySet().stream()) .forEachOrdered(entry -> jsonObject.addProperty(entry.getKey(), entry.getValue())); } + public static void applyJsonParamsToObject(List> instanceParamsList, JsonObject jsonObject) { + instanceParamsList.stream().flatMap(instanceParamsMap -> instanceParamsMap.entrySet().stream()) + .forEachOrdered(entry -> jsonObject.add(entry.getKey(), gson.toJsonTree(entry.getValue()))); + } + } 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 61a920ead8..7f066af080 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 @@ -2287,45 +2287,6 @@ public class BBInputSetupTest { assertThat(actual, sameBeanAs(expected)); } - @Test - public void testgetGBBMacroCloudConfiguration() throws Exception { - org.onap.so.serviceinstancebeans.Service serviceMacro = mapper.readValue( - new File(RESOURCE_PATH + "ServiceMacroVfModules.json"), org.onap.so.serviceinstancebeans.Service.class); - CloudConfiguration cloudConfig = null; - org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = new org.onap.aai.domain.yang.CloudRegion(); - aaiCloudRegion.setCloudOwner("test-owner-name"); - Resources resources = serviceMacro.getResources(); - doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(any(CloudConfiguration.class)); - CloudRegion expected = new CloudRegion(); - expected.setLcpCloudRegionId("mdt1"); - expected.setCloudOwner("test-owner-name"); - expected.setTenantId("88a6ca3ee0394ade9403f075db23167e"); - - CloudRegion actual = SPY_bbInputSetup.getCloudRegionFromMacroRequest(cloudConfig, resources); - assertThat(actual, sameBeanAs(expected)); - - serviceMacro = mapper.readValue(new File(RESOURCE_PATH + "ServiceMacroVnfs.json"), - org.onap.so.serviceinstancebeans.Service.class); - resources = serviceMacro.getResources(); - - actual = SPY_bbInputSetup.getCloudRegionFromMacroRequest(cloudConfig, resources); - assertThat(actual, sameBeanAs(expected)); - - serviceMacro = mapper.readValue(new File(RESOURCE_PATH + "ServiceMacroNetworks.json"), - org.onap.so.serviceinstancebeans.Service.class); - resources = serviceMacro.getResources(); - - actual = SPY_bbInputSetup.getCloudRegionFromMacroRequest(cloudConfig, resources); - assertThat(actual, sameBeanAs(expected)); - - serviceMacro = mapper.readValue(new File(RESOURCE_PATH + "ServiceMacroNoCloudConfig.json"), - org.onap.so.serviceinstancebeans.Service.class); - resources = serviceMacro.getResources(); - - actual = SPY_bbInputSetup.getCloudRegionFromMacroRequest(cloudConfig, resources); - assertNull(actual); - } - @Test public void testgetGBBMacroWithEmptyUserParams() throws Exception { String resourceId = "123"; diff --git a/bpmn/pom.xml b/bpmn/pom.xml index 6a61ed1df3..806dc1cd83 100644 --- a/bpmn/pom.xml +++ b/bpmn/pom.xml @@ -20,6 +20,7 @@ UTF-8 UTF-8 1.5.2 + 1.2.10 MSOCoreBPMN diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/HealthCheckBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/HealthCheckBB.bpmn index 8272bd3750..fad2e5506c 100755 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/HealthCheckBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/HealthCheckBB.bpmn @@ -1,30 +1,29 @@ - + - - Flow_0gd6hy6 + + Flow_0udh4cd - - Flow_0xiyno7 + + Flow_0n17e0q + Flow_131rwms - - - - Flow_05rbrsm - + + + Flow_03ogqmx + - - Flow_05rbrsm - + + Flow_03ogqmx + - + - - Flow_0gd6hy6 - Flow_1aqdd5k + + Flow_0jxw1lb + Flow_0uoe9ga - - + @@ -35,67 +34,100 @@ - Flow_1aqdd5k - Flow_1jeui7e + Flow_0uoe9ga + Flow_0t6f6l8 - - Flow_1jeui7e - Flow_0xiyno7 + + Flow_0t6f6l8 + Flow_0n17e0q - - + + Flow_0udh4cd + Flow_131rwms + Flow_0jxw1lb + + + + + + ${execution.getVariable("isHelm")} + + + - - - + + + - - - + + + + - - - + + + + + + + + + + + + + + - - - + + + - - + + + + + + - + - - + + - + - - + + + + + - - + + - - + + + + + - - + + - - - + + + - - + + - - + + diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/UpgradeVfModuleBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/UpgradeVfModuleBB.bpmn new file mode 100644 index 0000000000..59bb404936 --- /dev/null +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/UpgradeVfModuleBB.bpmn @@ -0,0 +1,215 @@ + + + + + SequenceFlow_1xr6chl + + + SequenceFlow_1s4rpyp + Flow_0gbxjjk + + + SequenceFlow_1vbwdaw + + + SequenceFlow_1xr6chl + SequenceFlow_1s4rpyp + + + SequenceFlow_0rds4rj + SequenceFlow_1vbwdaw + + + SequenceFlow_15do1tu + SequenceFlow_0rds4rj + + + Flow_1c9ox62 + SequenceFlow_0xqhep5 + + + SequenceFlow_0xqhep5 + SequenceFlow_1yo6mvv + + + SequenceFlow_1yo6mvv + SequenceFlow_1i03uy2 + + + SequenceFlow_1i03uy2 + SequenceFlow_15do1tu + + + Flow_0gbxjjk + Flow_1il4743 + + + + Flow_03q6ty9 + + + Flow_1sqy91r + Flow_03q6ty9 + + + + + Flow_1sqy91r + + + + + + + + + + + Flow_1il4743 + Flow_0piytnn + + + + + + + + + + + + Flow_0piytnn + + + + + + Flow_1c9ox62 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-common/pom.xml b/bpmn/so-bpmn-infrastructure-common/pom.xml index 846af27b96..b287594a12 100644 --- a/bpmn/so-bpmn-infrastructure-common/pom.xml +++ b/bpmn/so-bpmn-infrastructure-common/pom.xml @@ -229,6 +229,7 @@ ch.qos.logback logback-core + ${logback-core.version} org.slf4j diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AnNssmfutils.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AnNssmfutils.groovy index f17bfc2938..eb7e89ce54 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AnNssmfutils.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AnNssmfutils.groovy @@ -254,7 +254,7 @@ else{ //TNFH slice profile instance creation TNFH_sliceProfileInstance.setServiceInstanceId(TNFH_sliceProfileInstanceId) - sliceInstanceName = "sliceprofile _ "+TNFH_sliceProfileId + sliceInstanceName = "sliceprofile_"+TNFH_sliceProfileId TNFH_sliceProfileInstance.setServiceInstanceName(sliceInstanceName) serviceType = jsonUtil.getJsonValue(execution.getVariable("tnFhSliceProfile"), "sST") TNFH_sliceProfileInstance.setServiceType(serviceType) @@ -271,7 +271,7 @@ else{ //TNMH slice profile instance creation TNMH_sliceProfileInstance.setServiceInstanceId(TNMH_sliceProfileInstanceId) - sliceInstanceName = "sliceprofile _ "+TNMH_sliceProfileId + sliceInstanceName = "sliceprofile_"+TNMH_sliceProfileId TNMH_sliceProfileInstance.setServiceInstanceName(sliceInstanceName) serviceType = jsonUtil.getJsonValue(execution.getVariable("tnMhSliceProfile"), "sST") TNMH_sliceProfileInstance.setServiceType(serviceType) @@ -327,7 +327,7 @@ private SliceProfile createSliceProfile(String domainType, DelegateExecution exe result.setExpDataRateDL(profile.get("expDataRateDL")) result.setExpDataRateUL(profile.get("expDataRateUL")) result.setSurvivalTime(profile.get("survivalTime")) - result.setMaxNumberOfPDUSession(profile.get("maxNumberOfPDUSession")) + result.setMaxNumberOfPDUSession(profile.get("maxNumberofPDUSession")) result.setAreaTrafficCapDL(profile.get("areaTrafficCapDL")) result.setAreaTrafficCapUL(profile.get("areaTrafficCapUL")) result.setOverallUserDensity(profile.get("overallUserDensity")) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateSliceService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateSliceService.groovy index d0fe1e9469..e54193470d 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateSliceService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateSliceService.groovy @@ -20,6 +20,7 @@ package org.onap.so.bpmn.infrastructure.scripts +import static org.apache.commons.lang3.StringUtils.isBlank import com.fasterxml.jackson.databind.ObjectMapper import com.google.gson.Gson import com.google.gson.reflect.TypeToken @@ -27,6 +28,15 @@ import org.apache.commons.lang3.StringUtils import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.logging.filter.base.ErrorCode +import javax.ws.rs.NotFoundException +import org.onap.aai.domain.yang.Relationship +import org.onap.aai.domain.yang.ServiceInstance +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types import org.onap.so.beans.nsmf.* import org.onap.so.beans.nsmf.oof.SubnetType import org.onap.so.bpmn.common.scripts.* @@ -160,8 +170,10 @@ class DoActivateSliceService extends AbstractServiceTaskProcessor { actDeActNssi.setNssiId(nssInstance.nssiId) actDeActNssi.setSnssaiList(Arrays.asList(customerInfo.snssai)) + String sliceProfileId = getRelatedSliceProfileId(execution, customerInfo.globalSubscriberId, customerInfo.subscriptionServiceType, nssInstance.nssiId, customerInfo.snssai, "slice-profile") + actDeActNssi.setSliceProfileId(sliceProfileId) - nbiRequest.setEsrInfo(esrInfo) + nbiRequest.setEsrInfo(esrInfo) nbiRequest.setServiceInfo(serviceInfo) nbiRequest.setActDeActNssi(actDeActNssi) execution.setVariable("nbiRequest", nbiRequest) @@ -176,6 +188,48 @@ class DoActivateSliceService extends AbstractServiceTaskProcessor { logger.debug("***** Exit processDecomposition *****") } + private String getRelatedSliceProfileId(DelegateExecution execution, String globalSubscriberId, String subscriptionServiceType, String instanceId, String snssai, String role) { + logger.debug("${Prefix} - Get Related Slice Profile") + if( isBlank(role) || isBlank(instanceId)) { + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Role and instanceId are mandatory") + } + + String nssiId; + AAIResourcesClient client = getAAIClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(instanceId)) + if (!client.exists(uri)) { + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai : ${instanceId}") + } + AAIResultWrapper wrapper = client.get(uri, NotFoundException.class) + Optional si = wrapper.asBean(ServiceInstance.class) + if(si.isPresent()) { + List relationshipList = si.get().getRelationshipList().getRelationship() + for (Relationship relationship : relationshipList) { + String relatedTo = relationship.getRelatedTo() + if (relatedTo.toLowerCase() == "service-instance") { + String relatioshipurl = relationship.getRelatedLink() + String serviceInstanceId = + relatioshipurl.substring(relatioshipurl.lastIndexOf("/") + 1, relatioshipurl.length()) + uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(serviceInstanceId)) + if (!client.exists(uri)) { + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, + "Service Instance was not found in aai: ${serviceInstanceId} related to ${instanceId}") + } + AAIResultWrapper wrapper01 = client.get(uri, NotFoundException.class) + Optional serviceInstance = wrapper01.asBean(ServiceInstance.class) + if (serviceInstance.isPresent()) { + ServiceInstance instance = serviceInstance.get() + if (role.equalsIgnoreCase(instance.getServiceRole()) && snssai.equalsIgnoreCase(instance.getEnvironmentContext())) { + nssiId = instance.getServiceInstanceId() + } + } + } + } + } + return nssiId + logger.debug("${Prefix} - Exit Get Related Slice Profile instances") + } + /** * send Create Request NSSMF * @param execution diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateAccessNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateAccessNSSI.groovy index ed1c2b24d5..54fa2abdd1 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateAccessNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateAccessNSSI.groovy @@ -369,7 +369,6 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { modifySliceParams.addProperty("snssaiList", snssaiList) modifySliceParams.addProperty("sliceProfileId", sliceProfileId) modifySliceParams.addProperty("nsiInfo", nsiInfo) - modifySliceParams.addProperty("scriptName", scriptName) execution.setVariable("modifySliceParams", modifySliceParams.toString()) //create operation status in request db @@ -576,7 +575,11 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { ANServiceInstance.setServiceRole(serviceRole) List snssaiList = execution.getVariable("snssaiList") String snssai = snssaiList.get(0) - //ANServiceInstance.setEnvironmentContext(snssai) + //ANServiceInstance.setEnvironmentContext(snssai) + String modelInvariantUuid = execution.getVariable("modelInvariantUuid") + String modelUuid = execution.getVariable("modelUuid") as String + ANServiceInstance.setModelInvariantId(modelInvariantUuid) + ANServiceInstance.setModelVersionId(modelUuid) ANServiceInstance.setEnvironmentContext(execution.getVariable("networkType")) //Network Type ANServiceInstance.setWorkloadContext("AN") //domain Type @@ -639,22 +642,23 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { ANServiceInstance.setServiceType(execution.getVariable("sst") as String) ANServiceInstance.setOrchestrationStatus(serviceStatus) String serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "pLMNIdList") as String - ANServiceInstance.setServiceInstanceLocationId(serviceInstanceLocationid) + ANServiceInstance.setServiceInstanceLocationId(jsonUtil.StringArrayToList(serviceInstanceLocationid).get(0)) ANServiceInstance.setServiceRole(serviceRole) List snssaiList = jsonUtil.StringArrayToList(execution.getVariable("snssaiList") as String) String snssai = snssaiList.get(0) - ANServiceInstance.setEnvironmentContext(snssai) String modelInvariantUuid = execution.getVariable("modelInvariantUuid") String modelUuid = execution.getVariable("modelUuid") as String ANServiceInstance.setModelInvariantId(modelInvariantUuid) ANServiceInstance.setModelVersionId(modelUuid) + ANServiceInstance.setEnvironmentContext(execution.getVariable("networkType")) //Network Type ANServiceInstance.setWorkloadContext("AN") String serviceFunctionAn = jsonUtil.getJsonValue(execution.getVariable("sliceProfile") as String, "resourceSharingLevel") ANServiceInstance.setServiceFunction(serviceFunctionAn) logger.debug("completed AN service instance build " + ANServiceInstance.toString()) //create RAN NF NSSI ANNFServiceInstance.setServiceInstanceId(execution.getVariable("RANNFServiceInstanceId") as String) - sliceInstanceName = "nssi_"+execution.getVariable("ANNF_modelName") + String ANNF_nssiInstanceId = UUID.randomUUID().toString() + sliceInstanceName = "nssi_an_nf_" + ANNF_nssiInstanceId ANNFServiceInstance.setServiceInstanceName(sliceInstanceName) ANNFServiceInstance.setServiceType(execution.getVariable("sst") as String) ANNFServiceInstance.setOrchestrationStatus(serviceStatus) @@ -663,7 +667,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { ANNFServiceInstance.setServiceRole(serviceRole) snssaiList = jsonUtil.StringArrayToList(execution.getVariable("snssaiList") as String) snssai = snssaiList.get(0) - ANNFServiceInstance.setEnvironmentContext(snssai) + ANNFServiceInstance.setEnvironmentContext(execution.getVariable("networkType") as String) ANNFServiceInstance.setModelInvariantId(execution.getVariable("ANNF_modelInvariantUuid")) ANNFServiceInstance.setModelVersionId(execution.getVariable("ANNF_modelUuid")) ANNFServiceInstance.setWorkloadContext("AN_NF") @@ -1032,7 +1036,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { RU_ep.setType(type) RU_ep.setIpAddress("192.168.100.4") RU_ep.setLogicalInterfaceId("1234") - RU_ep.setNextHop("Host1") + RU_ep.setNextHop("networkId-providerId-10-clientId-0-topologyId-2-nodeId-10.1.1.1-ltpId-512") RU_ep.setPrefixLength(prefixLength) RU_ep.setAddressFamily(addressFamily) //DU Ingress @@ -1046,7 +1050,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { DU_ep.setType(type) DU_ep.setIpAddress("192.168.100.5") DU_ep.setLogicalInterfaceId("1234") - DU_ep.setNextHop("Host2") + DU_ep.setNextHop("networkId-providerId-20-clientId-0-topologyId-2-nodeId-10.2.1.2-ltpId-512") DU_ep.setPrefixLength(prefixLength) DU_ep.setAddressFamily(addressFamily) //MH RAN end point update @@ -1062,7 +1066,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { DUEG_ep.setLogicalInterfaceId("1234") DUEG_ep.setPrefixLength(prefixLength) DUEG_ep.setAddressFamily(addressFamily) - DUEG_ep.setNextHop("Host3") + DUEG_ep.setNextHop("networkId-providerId-10-clientId-0-topologyId-2-nodeId-10.1.1.1-ltpId-512") //CUIN String CUIN_routeId = UUID.randomUUID().toString() execution.setVariable("tranportEp_ID_CUIN", CUIN_routeId) @@ -1073,7 +1077,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { CUIN_ep.setType(type) CUIN_ep.setIpAddress("192.168.100.6") CUIN_ep.setLogicalInterfaceId("1234") - CUIN_ep.setNextHop("Host4") + CUIN_ep.setNextHop("networkId-providerId-20-clientId-0-topologyId-2-nodeId-10.2.1.2-ltpId-512") CUIN_ep.setPrefixLength(prefixLength) CUIN_ep.setAddressFamily(addressFamily) try { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy index bc155c5943..a22819f2e9 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy @@ -444,6 +444,7 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ .sST(sliceTaskInfo.getSliceProfile().getSST() ?: sliceParams.getServiceProfile().get("sST") as String) .nssiName(sliceTaskInfo.getSuggestNssiId() ? sliceTaskInfo.getNSSTInfo().getName() : allocateAnNssi.getNssiName()) .nssiId(sliceTaskInfo.getSuggestNssiId()) + .resourceSharingLevel(sliceParams.serviceProfile.get("resourceSharingLevel") as String) .build() nbiRequest.setServiceInfo(serviceInfo) @@ -590,6 +591,7 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ serviceInfo.nssiId = sliceTaskInfo.suggestNssiId //if shared serviceInfo.sST = sliceTaskInfo.sliceProfile.sST ?: sliceParams.serviceProfile.get("sST") serviceInfo.nssiName = allocateCnNssi.nssiName + serviceInfo.resourceSharingLevel = sliceParams.serviceProfile.get("resourceSharingLevel") nbiRequest.setServiceInfo(serviceInfo) nbiRequest.setEsrInfo(esrInfo) @@ -727,6 +729,7 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ serviceInfo.nssiId = sliceTaskInfo.suggestNssiId serviceInfo.sST = sliceTaskInfo.sliceProfile.sST ?: sliceParams.serviceProfile.get("sST") serviceInfo.nssiName = "nssi_tn" + execution.getVariable("sliceServiceInstanceName") + serviceInfo.resourceSharingLevel = sliceParams.serviceProfile.get("resourceSharingLevel") nbiRequest.setServiceInfo(serviceInfo) nbiRequest.setEsrInfo(esrInfo) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy index a784cbee6e..6981d94324 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy @@ -110,6 +110,7 @@ class DoAllocateNSSI extends AbstractServiceTaskProcessor { execution.setVariable("nssiAllocateStatus", jobStatusResponse) if (jobStatusResponse.getResponseDescriptor().getProgress() == 100) { + nssiAllocateResult.setNssiId(jobStatusResponse.getResponseDescriptor().getNssiId()) execution.setVariable("jobFinished", true) } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCloudLeasedLineCreate.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCloudLeasedLineCreate.groovy index 2e0f3cfd66..4681713fd7 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCloudLeasedLineCreate.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCloudLeasedLineCreate.groovy @@ -38,6 +38,7 @@ import org.slf4j.LoggerFactory import org.springframework.web.util.UriUtils import static org.apache.commons.lang3.StringUtils.isBlank +import static org.apache.commons.lang3.StringUtils.isNotBlank class DoCloudLeasedLineCreate extends AbstractServiceTaskProcessor { @@ -333,6 +334,7 @@ class DoCloudLeasedLineCreate extends AbstractServiceTaskProcessor { String epA = jsonUtil.getJsonValue(linkStr, "transportEndpointA") String epB = jsonUtil.getJsonValue(linkStr, "transportEndpointB") + String epBProtect = jsonUtil.getJsonValue(linkStr, "transportEndpointBProtection") String modelInvariantId = execution.getVariable("modelInvariantUuid") String modelVersionId = execution.getVariable("modelUuid") @@ -340,6 +342,9 @@ class DoCloudLeasedLineCreate extends AbstractServiceTaskProcessor { resource.setLinkId(linkId) resource.setLinkName(epA) resource.setLinkName2(epB) + if (isNotBlank(epBProtect)) { + resource.setSegmentId(epBProtect) + } resource.setLinkType("TsciConnectionLink") resource.setInMaint(false) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCloudLeasedLineModify.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCloudLeasedLineModify.groovy index 5c9877840d..bfd5ac81d3 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCloudLeasedLineModify.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCloudLeasedLineModify.groovy @@ -109,6 +109,14 @@ public class DoCloudLeasedLineModify extends AbstractServiceTaskProcessor { "transportNetworks", "transportNetworks", true) logger.debug("transportNetworks: " + execution.getVariable("transportNetworks")) + serviceIntentUtils.setExecVarFromJsonIfExists(execution, additionalPropJsonStr, + "modifyAction", "modifyAction"); + if (isNotBlank(execution.getVariable("modifyAction"))) { + logger.debug("modifyAction: " + execution.getVariable("modifyAction")) + } else { + logger.debug("modifyAction is not set") + } + if (isBlank(serviceIntentUtils.setExecVarFromJsonIfExists(execution, additionalPropJsonStr, "enableSdnc", "enableSdnc"))) { serviceIntentUtils.setEnableSdncConfig(execution) @@ -266,12 +274,16 @@ public class DoCloudLeasedLineModify extends AbstractServiceTaskProcessor { void updateTsciNetworks(DelegateExecution execution) { try { + if (modifyBandwidthGlobal(execution)) { + String netStr = jsonUtil.StringArrayToList(execution.getVariable("transportNetworks")).get(0) + int maxBw = getMaxBwFromNetworkJsonStr(execution, netStr) + updateNetworkPolicyGlobal(execution, maxBw) + return + } List networkStrList = jsonUtil.StringArrayToList(execution.getVariable("transportNetworks")) for (String networkStr : networkStrList) { - updateLogicalLinksInNetwork(execution, networkStr) - updateNetworkPolicy(execution, networkStr) + updateTsciNetwork(execution, networkStr) } - } catch (BpmnError e) { throw e } catch (Exception ex) { @@ -280,6 +292,20 @@ public class DoCloudLeasedLineModify extends AbstractServiceTaskProcessor { } } + boolean modifyBandwidthGlobal(DelegateExecution execution) { + String modifyAction = execution.getVariable("modifyAction") + if (isNotBlank(modifyAction) && modifyAction.equals("bandwidth")) { + return true + } + + return false + } + + void updateTsciNetwork(DelegateExecution execution, String networkStr) { + updateLogicalLinksInNetwork(execution, networkStr) + updateNetworkPolicy(execution, networkStr) + } + int getMaxBwFromNetworkJsonStr(DelegateExecution execution, String networkJsonStr) { int maxBw = 0 try { @@ -327,6 +353,28 @@ public class DoCloudLeasedLineModify extends AbstractServiceTaskProcessor { } } + void updateNetworkPolicyGlobal(DelegateExecution execution, int maxBw) { + try { + List arIdList = execution.getVariable("arIdList") + for (String arId : arIdList) { + Map policyMap = execution.getVariable("arPolicyMap") + String policyId = policyMap.get(arId) + if (isBlank(policyId)) { + String msg = String.format("ERROR: updateNetworkPolicy: policyId not found. arId=%s", arId) + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + updatePolicyMaxBandwidthInAAI(execution, policyId, maxBw) + } + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + String msg = String.format("ERROR: updateNetworkPolicy: exception: %s", ex.getMessage()) + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg); + } + } + void updateNetworkPolicy(DelegateExecution execution, String networkJsonStr) { try { int maxBw = getMaxBwFromNetworkJsonStr(execution, networkJsonStr) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSI.groovy index b07f5c965d..a28dbbf9b1 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSI.groovy @@ -742,7 +742,11 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor { Map instanceParamsMap = new HashMap<>() // Supported S-NSSAI - List snssais = (List) currentNSSI['S-NSSAIs'] + def snssaisList = currentNSSI['S-NSSAIs'] + List snssais = new ArrayList<>() + if(snssaisList != null) { + snssais = new ArrayList((List)snssaisList) + } LOGGER.debug("prepareInstanceParams: snssais size = " + snssais.size()) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy index 2588d07e50..7571f07081 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy @@ -21,6 +21,7 @@ package org.onap.so.bpmn.infrastructure.scripts import com.fasterxml.jackson.databind.ObjectMapper +import com.fasterxml.jackson.core.type.TypeReference import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.ServiceInstance import org.onap.so.beans.nsmf.EsrInfo @@ -271,24 +272,22 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ * @return */ private SubnetType convertServiceCategory(String serviceCategory){ - if("CN NSST".equals(serviceCategory)){ + if(serviceCategory ==~ /CN.*/){ return SubnetType.CN } - if ("AN NF NSST".equals(serviceCategory)){ - return SubnetType.AN_NF - } - if ("AN NSST".equals(serviceCategory)){ + if (serviceCategory ==~ /AN.*/){ return SubnetType.AN } - if ("TN BH NSST".equals(serviceCategory)){ + if (serviceCategory ==~ /TN.*BH.*/){ return SubnetType.TN_BH } - if("TN MH NSST".equals(serviceCategory)){ + if(serviceCategory ==~ /TN.*MH.*/){ return SubnetType.TN_MH } - if("TN FH NSST".equals(serviceCategory)){ + if(serviceCategory ==~ /TN.*FH.*/){ return SubnetType.TN_FH } + return null } @@ -475,7 +474,10 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ */ void getNSSISelectionCap4AN(DelegateExecution execution) { - def vendor = execution.getVariable("vendor") as String + SliceTaskParamsAdapter sliceParams = + execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter + + def vendor = sliceParams.anSliceTaskInfo.vendor String strRequest = buildNSSISelectionReq(vendor, NetworkType.ACCESS) @@ -497,7 +499,10 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ */ void getNSSISelectionCap4TN(DelegateExecution execution) { - def vendor = execution.getVariable("vendor") as String + SliceTaskParamsAdapter sliceParams = + execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter + + def vendor = sliceParams.tnBHSliceTaskInfo.vendor String strRequest = buildNSSISelectionReq(vendor, NetworkType.TRANSPORT) @@ -518,7 +523,10 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ */ void getNSSISelectionCap4CN(DelegateExecution execution) { - def vendor = execution.getVariable("vendor") as String + SliceTaskParamsAdapter sliceParams = + execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter + + def vendor = sliceParams.cnSliceTaskInfo.vendor String strRequest = buildNSSISelectionReq(vendor, NetworkType.CORE) @@ -626,8 +634,10 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ Map nssiNeedHandlerInfo = nssiNeedHandlerInfos.get(currNssiIndex) as Map TemplateInfo nsstInfo = nssiNeedHandlerInfo.get("nsstInfo") as TemplateInfo - Map profileInfo = nssiNeedHandlerInfo.get("sliceProfile") as Map - //profileInfo.remove("profileId") + SliceProfileAdapter sliceProfileInfo = nssiNeedHandlerInfo.get("sliceProfile") as SliceProfileAdapter + + Map profileInfo = objectMapper.convertValue(sliceProfileInfo, new TypeReference>() {}); + while (profileInfo.values().remove(null)); String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution) logger.debug( "get NSI option OOF Url: " + urlString) @@ -641,8 +651,8 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution) execution.setVariable("nssiSelection_timeout", timeout) - String oofRequest = oofUtils.buildSelectNSSIRequest(requestId, nsstInfo, messageType, - profileInfo, 600) + String oofRequest = oofUtils.buildSelectNSSIRequest(requestId, messageType, nsstInfo.UUID, + nsstInfo.invariantUUID, nsstInfo.name, profileInfo) execution.setVariable("nssiSelection_oofRequest", oofRequest) logger.debug("Sending request to OOF: " + oofRequest) @@ -672,13 +682,10 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ Map resMap = objectMapper.readValue(OOFResponse, Map.class) List> nsiSolutions = (List>) resMap.get("solutions") - Map solution = nsiSolutions.get(0) - - String resourceSharingLevel = execution.getVariable("resourceSharingLevel") - Boolean isSharable = resourceSharingLevel == "shared" //todo - if (isSharable && solution != null) { - processNssiResult(sliceTaskParams, subnetType, solution) + if(nsiSolutions.size()>=1) { + Map solution = nsiSolutions.get(0) as Map + processNssiResult(sliceTaskParams, subnetType, solution) } execution.setVariable("sliceTaskParams", sliceTaskParams) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy index dd168519e5..d2ba28256f 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy @@ -146,6 +146,11 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { ss.setWorkloadContext(domainTypeStr) } + String resourceSharingLevel = jsonUtil.getJsonValue(sliceProfileStr, "resourceSharingLevel") + if (isNotBlank(resourceSharingLevel)) { + ss.setServiceFunction(resourceSharingLevel) + } + AAIResourcesClient client = getAAIClient() AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeAllocateAccessNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeAllocateAccessNSSI.groovy index 6fd8080ef0..74a2d980f7 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeAllocateAccessNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeAllocateAccessNSSI.groovy @@ -40,6 +40,7 @@ import org.onap.so.beans.nsmf.DeAllocateNssi import org.onap.so.beans.nsmf.EsrInfo import org.onap.so.beans.nsmf.NetworkType import org.onap.so.beans.nsmf.ServiceInfo +import org.onap.so.beans.nsmf.oof.SubnetType import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.NssmfAdapterUtils @@ -333,9 +334,9 @@ class DoDeAllocateAccessNSSI extends AbstractServiceTaskProcessor { logger.debug("Generated new job for Service Instance serviceId:" + serviceId + " operationId:" + modificationJobId) ResourceOperationStatus initStatus = new ResourceOperationStatus() - initStatus.setServiceId(serviceId) + initStatus.setServiceId(nsiId) initStatus.setOperationId(modificationJobId) - initStatus.setResourceTemplateUUID(nsiId) + initStatus.setResourceTemplateUUID(serviceId) initStatus.setOperType("Modify-Deallocate") requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus) @@ -347,13 +348,18 @@ class DoDeAllocateAccessNSSI extends AbstractServiceTaskProcessor { String responseId = "1" String globalSubscriberId = execution.getVariable("globalSubscriberId") String subscriptionServiceType = execution.getVariable("subscriptionServiceType") + String anNssiId = execution.getVariable("anNssiId") JsonObject esrInfo = new JsonObject() esrInfo.addProperty("networkType", networkType) esrInfo.addProperty("vendor", "ONAP_internal") JsonObject serviceInfo = new JsonObject() - serviceInfo.addProperty("nsiId", execution.getVariable("nsiId")) + if (networkType.equals(SubnetType.AN.getSubnetType())) { + serviceInfo.addProperty("nsiId", execution.getVariable("nsiId")) + } else { + serviceInfo.addProperty("nsiId", anNssiId) + } serviceInfo.addProperty("nssiId", instanceId) serviceInfo.addProperty("globalSubscriberId", globalSubscriberId) serviceInfo.addProperty("subscriptionServiceType", subscriptionServiceType) @@ -526,7 +532,7 @@ class DoDeAllocateAccessNSSI extends AbstractServiceTaskProcessor { Map relatedSPs = execution.getVariable("relatedSPs") DeAllocateNssi deallocateNssi = new DeAllocateNssi() - deallocateNssi.setNsiId(execution.getVariable("nsiId")) + deallocateNssi.setNsiId(anNssiId) ServiceInstance tnNssi = relatedNssis.get(serviceFunction) String nssiId = tnNssi.getServiceInstanceId() diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSI.groovy index 11058748fd..e563471d2a 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSI.groovy @@ -21,13 +21,13 @@ package org.onap.so.bpmn.infrastructure.scripts import com.fasterxml.jackson.databind.ObjectMapper -import com.google.gson.JsonObject +import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution -import org.onap.aai.domain.yang.v19.AllottedResource -import org.onap.aai.domain.yang.v19.GenericVnf +import org.json.JSONArray +import org.json.JSONObject +import org.onap.aai.domain.yang.v19.ModelVer import org.onap.aai.domain.yang.v19.ServiceInstance import org.onap.aai.domain.yang.v19.SliceProfile -import org.onap.aai.domain.yang.v19.SliceProfiles import org.onap.aaiclient.client.aai.AAIResourcesClient import org.onap.aaiclient.client.aai.entities.AAIResultWrapper import org.onap.aaiclient.client.aai.entities.Relationships @@ -37,22 +37,19 @@ import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types import org.onap.logging.filter.base.ONAPComponents import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.ExternalAPIUtil +import org.onap.so.bpmn.common.scripts.ExternalAPIUtilFactory import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.common.scripts.OofUtils import org.onap.so.bpmn.common.scripts.RequestDBUtil import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.client.HttpClient -import org.onap.so.client.HttpClientFactory -import org.onap.so.client.oof.adapter.beans.payload.OofRequest import org.slf4j.Logger import org.slf4j.LoggerFactory import javax.ws.rs.core.Response -import static org.apache.commons.lang3.StringUtils.isBlank -import static org.apache.commons.lang3.StringUtils.isBlank -import static org.onap.so.bpmn.common.scripts.GenericUtils.isBlank import static org.onap.so.bpmn.common.scripts.GenericUtils.isBlank class DoDeallocateCoreNSSI extends DoCommonCoreNSSI { @@ -88,7 +85,6 @@ class DoDeallocateCoreNSSI extends DoCommonCoreNSSI { LOGGER.debug("${PREFIX} Start executeTerminateNSSIQuery") String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution) - // String urlString = UrnPropertiesReader.getVariable("mso.adapters.oof.endpoint", execution) //API Path String apiPath = "/api/oof/terminate/nxi/v1" @@ -102,20 +98,6 @@ class DoDeallocateCoreNSSI extends DoCommonCoreNSSI { String msokey = UrnPropertiesReader.getVariable("mso.msoKey", execution) String basicAuthValue = utils.encrypt(basicAuth, msokey) - /* if (basicAuthValue != null) { - LOGGER.debug( "Obtained BasicAuth username and password for OOF Adapter: " + basicAuthValue) - try { - authHeader = utils.getBasicAuth(basicAuthValue, msokey) - execution.setVariable("BasicAuthHeaderValue", authHeader) - } catch (Exception ex) { - LOGGER.error( "Unable to encode username and password string: " + ex) - exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - Unable to encode username and password string") - } - } else { - LOGGER.error( "Unable to obtain BasicAuth - BasicAuth value null") - exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - BasicAuth value null") - } */ - try { authHeader = utils.getBasicAuth(basicAuthValue, msokey) @@ -177,7 +159,6 @@ class DoDeallocateCoreNSSI extends DoCommonCoreNSSI { " \"errorCode\": \"${errorCode}\",\n" + " \"errorMessage\": \"${errorMessage}\"\n" + "}" - //exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from OOF.") } if (httpResponse.hasEntity()) { @@ -282,71 +263,124 @@ class DoDeallocateCoreNSSI extends DoCommonCoreNSSI { } - /** - * Invokes deleteServiceOrder external API + * Prepares ServiceOrderRequest * @param execution */ - void deleteServiceOrder(DelegateExecution execution) { - LOGGER.debug("${PREFIX} Start deleteServiceOrder") + private void prepareServiceOrderRequest(DelegateExecution execution) { + LOGGER.debug("${PREFIX} Start prepareServiceOrderRequest") def currentNSSI = execution.getVariable("currentNSSI") - try { - //url:/nbi/api/v4/serviceOrder/" - def nsmfЕndPoint = UrnPropertiesReader.getVariable("mso.infra.endpoint.url", execution) - - ServiceInstance networkServiceInstance = (ServiceInstance)currentNSSI['networkServiceInstance'] - - //String url = String.format("${nbiEndpointUrl}/api/v4/serviceOrder/%s", networkServiceInstance.getServiceInstanceId()) - - GenericVnf constituteVnf = (GenericVnf)currentNSSI['constituteVnf'] - - // http://so.onap:8080/onap/so/infra/serviceInstantiation/v7/serviceInstances/de6a0aa2-19f2-41fe-b313-a5a9f159acd7/vnfs/3abbb373-8d33-4977-aa4b-2bfee496b6d5 - String url = String.format("${nsmfЕndPoint}/serviceInstantiation/v7/serviceInstances/%s/vnfs/%s", networkServiceInstance.getServiceInstanceId(), constituteVnf.getVnfId()) + //extAPI path hardcoded for testing purposes, will be updated in next patch + String extAPIPath = "https://nbi.onap:8443/nbi/api/v4" + "/serviceOrder" + execution.setVariable("ExternalAPIURL", extAPIPath) + ObjectMapper objectMapper = new ObjectMapper(); + Map serviceOrder = new LinkedHashMap() + //ExternalId + serviceOrder.put("externalId", "ONAP001") + + //Requested Start Date + String requestedStartDate = utils.generateCurrentTimeInUtc() + String requestedCompletionDate = utils.generateCurrentTimeInUtc() + serviceOrder.put("requestedStartDate", requestedStartDate) + serviceOrder.put("requestedCompletionDate", requestedCompletionDate) + + //RelatedParty Fields + String relatedPartyId = execution.getVariable("globalSubscriberId") + String relatedPartyRole = "ONAPcustomer" + Map relatedParty = new LinkedHashMap() + relatedParty.put("id", relatedPartyId) + relatedParty.put("role", relatedPartyRole) + List> relatedPartyList = new ArrayList() + relatedPartyList.add(relatedParty) + serviceOrder.put("relatedParty", relatedPartyList) + + Map orderItem = new LinkedHashMap() + //orderItem id + String orderItemId = "1" + orderItem.put("id", orderItemId) + + //order item action will always be delete as we are triggering request for deletion + String orderItemAction = "delete" + orderItem.put("action", orderItemAction) + + // service Details + AAIResourcesClient client = getAAIClient() + ServiceInstance networkServiceInstance = (ServiceInstance)currentNSSI['networkServiceInstance'] //(ServiceInstance) currentNSSI['nssi'] + AAIResourceUri modelVerUrl = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.serviceDesignAndCreation().model(networkServiceInstance.getModelInvariantId()).modelVer(networkServiceInstance.getModelVersionId())) + + Map service = new LinkedHashMap() + // Service id + service.put("id", networkServiceInstance.getServiceInstanceId()) + + //ServiceName + String serviceName = networkServiceInstance.getServiceInstanceName() + service.put("name", serviceName) + + // Service Type + service.put("serviceType", networkServiceInstance.getServiceType()) + //Service State + service.put("serviceState", "active") + + Map serviceSpecification = new LinkedHashMap() + String modelUuid = networkServiceInstance.getModelVersionId() + serviceSpecification.put("id", modelUuid) + service.put("serviceSpecification", serviceSpecification) + + orderItem.put("service", service) + List> orderItemList = new ArrayList() + orderItemList.add(orderItem) + serviceOrder.put("orderItem", orderItemList) + String jsonServiceOrder = objectMapper.writeValueAsString(serviceOrder) + LOGGER.debug("******* ServiceOrder :: "+jsonServiceOrder) + execution.setVariable("serviceOrderRequest", jsonServiceOrder) + + LOGGER.debug("${PREFIX} End prepareServiceOrderRequest") + } - LOGGER.debug("url = " + url) - currentNSSI['deleteServiceOrderURL'] = url - String msoKey = UrnPropertiesReader.getVariable("mso.msoKey", execution) - String basicAuth = UrnPropertiesReader.getVariable("mso.adapters.po.auth", execution) + /** + * Invokes deleteServiceOrder external API + * @param execution + */ + void deleteServiceOrder(DelegateExecution execution) { + LOGGER.debug("${PREFIX} Start deleteServiceOrder") - def authHeader = utils.getBasicAuth(basicAuth, msoKey) + def currentNSSI = execution.getVariable("currentNSSI") - def requestDetails = "" + prepareServiceOrderRequest(execution) - String prepareRequestDetailsResponse = prepareRequestDetails(execution) - LOGGER.debug("deleteServiceOrder: prepareRequestDetailsResponse=" + prepareRequestDetailsResponse) + try { + String extAPIPath = execution.getVariable("ExternalAPIURL") + String payload = execution.getVariable("serviceOrderRequest") + LOGGER.debug("externalAPIURL is: " + extAPIPath) + LOGGER.debug("ServiceOrder payload is: " + payload) - String errorCode = jsonUtil.getJsonValue(prepareRequestDetailsResponse, "errorCode") - LOGGER.debug("deleteServiceOrder: errorCode=" + errorCode) - if(errorCode == null || errorCode.isEmpty()) { // No error - requestDetails = prepareRequestDetailsResponse - } - else { - exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(errorCode), jsonUtil.getJsonValue(prepareRequestDetailsResponse, "errorMessage")) - } + execution.setVariable("ServiceOrderId", "") - String callDeleteServiceOrderResponse = callDeleteServiceOrder(url, authHeader, requestDetails) - errorCode = jsonUtil.getJsonValue(callDeleteServiceOrderResponse, "errorCode") + String callDeleteServiceOrderResponse = callDeleteServiceOrder(execution, extAPIPath, payload) + String errorCode = jsonUtil.getJsonValue(callDeleteServiceOrderResponse, "errorCode") if(errorCode == null || errorCode.isEmpty()) { // No error - String macroOperationId = jsonUtil.getJsonValue(callDeleteServiceOrderResponse, "requestReferences.requestId") - String requestSelfLink = jsonUtil.getJsonValue(callDeleteServiceOrderResponse, "requestReferences.requestSelfLink") + JSONObject responseObj = new JSONObject(callDeleteServiceOrderResponse) - execution.setVariable("macroOperationId", macroOperationId) - execution.setVariable("requestSelfLink", requestSelfLink) + String serviceOrderId = responseObj.get("id") - currentNSSI['requestSelfLink'] = requestSelfLink + execution.setVariable("ServiceOrderId", serviceOrderId) + LOGGER.info("Delete ServiceOrderid is: " + serviceOrderId) } else { LOGGER.error(jsonUtil.getJsonValue(callDeleteServiceOrderResponse, "errorMessage")) exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(errorCode), jsonUtil.getJsonValue(callDeleteServiceOrderResponse, "errorMessage")) } - } catch (any) { - String msg = "Exception in DoDeallocateCoreNSSI.deleteServiceOrder. " + any.getCause() - LOGGER.error(msg) + + }catch (BpmnError e) { + throw e; + } catch (Exception ex) { + String msg = "Exception in ServiceOrder ExtAPI" + ex.getMessage() + LOGGER.debug(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } @@ -354,33 +388,38 @@ class DoDeallocateCoreNSSI extends DoCommonCoreNSSI { } - String callDeleteServiceOrder(String url, String authHeader, String requestDetailsStr) { + String callDeleteServiceOrder(DelegateExecution execution, String extAPIPath, String payload) { LOGGER.debug("${PREFIX} Start callDeleteServiceOrder") String errorCode = "" String errorMessage = "" String response = "" - LOGGER.debug("callDeleteServiceOrder: url = " + url) - LOGGER.debug("callDeleteServiceOrder: authHeader = " + authHeader) + LOGGER.debug("callDeleteServiceOrder: url = " + extAPIPath) try { - HttpClient httpClient = getHttpClientFactory().newJsonClient(new URL(url), ONAPComponents.SO) - httpClient.addAdditionalHeader("Authorization", authHeader) - httpClient.addAdditionalHeader("Accept", "application/json") - Response httpResponse = httpClient.delete(requestDetailsStr) + ExternalAPIUtil externalAPIUtil = getExternalAPIUtil() + Response httpResponse = externalAPIUtil.executeExternalAPIPostCall(execution, extAPIPath, payload) - int soResponseCode = httpResponse.getStatus() - LOGGER.debug("callDeleteServiceOrder: soResponseCode = " + soResponseCode) + int responseCode = httpResponse.getStatus() + execution.setVariable("ServiceOrderResponseCode", responseCode) + LOGGER.debug("Delete ServiceOrder response code is: " + responseCode) + + //Process Response + if(responseCode == 200 || responseCode == 201 || responseCode == 202 ) { + //200 OK 201 CREATED 202 ACCEPTED + LOGGER.debug("Delete ServiceOrder Received a Good Response") - if (soResponseCode >= 200 && soResponseCode < 204 && httpResponse.hasEntity()) { response = httpResponse.readEntity(String.class) LOGGER.debug("callDeleteServiceInstance: response = " + response) + + execution.setVariable("DeleteServiceOrderResponse", response) + } else { errorCode = 500 - errorMessage = "Response code is " + soResponseCode + errorMessage = "Response code is " + responseCode response = "{\n" + " \"errorCode\": \"${errorCode}\",\n" + @@ -503,18 +542,64 @@ class DoDeallocateCoreNSSI extends DoCommonCoreNSSI { void getDeleteServiceOrderProgress(DelegateExecution execution) { LOGGER.debug("${getPrefix()} Start getDeleteServiceOrderProgress") - def currentNSSI = execution.getVariable("currentNSSI") - - String url = currentNSSI['requestSelfLink'] - - String msoKey = UrnPropertiesReader.getVariable("mso.msoKey", execution) - - String basicAuth = UrnPropertiesReader.getVariable("mso.adapters.po.auth", execution) - - def authHeader = "" - String basicAuthValue = utils.getBasicAuth(basicAuth, msoKey) + String msg + try { + String extAPIPath = execution.getVariable("ExternalAPIURL") + extAPIPath += "/" + execution.getVariable("ServiceOrderId") + LOGGER.debug("externalAPIURL is: " + extAPIPath) + + ExternalAPIUtil externalAPIUtil = getExternalAPIUtil() + Response response = externalAPIUtil.executeExternalAPIGetCall(execution, extAPIPath) + int responseCode = response.getStatus() + execution.setVariable("GetServiceOrderResponseCode", responseCode) + LOGGER.debug("Get ServiceOrder response code is: " + responseCode) + String extApiResponse = response.readEntity(String.class) + JSONObject responseObj = new JSONObject(extApiResponse) + execution.setVariable("GetServiceOrderResponse", extApiResponse) + LOGGER.debug("Get response body is: " + extApiResponse) + //Process Response //200 OK 201 CREATED 202 ACCEPTED + if(responseCode == 200 || responseCode == 201 || responseCode == 202 ) + { + LOGGER.debug("Get Delete ServiceOrder Received a Good Response") + String orderState = responseObj.get("state") + if("REJECTED".equalsIgnoreCase(orderState)) { + prepareFailedOperationStatusUpdate(execution) + return + } + JSONArray items = responseObj.getJSONArray("orderItem") + JSONObject item = items.get(0) as JSONObject + JSONObject service = item.get("service") as JSONObject + String networkServiceId = service.get("id") + + execution.setVariable("networkServiceId", networkServiceId) + String serviceOrderState = item.get("state") + execution.setVariable("ServiceOrderState", serviceOrderState) + // Get serviceOrder State and process progress + if("ACKNOWLEDGED".equalsIgnoreCase(serviceOrderState) || "INPROGRESS".equalsIgnoreCase(serviceOrderState) || "IN_PROGRESS".equalsIgnoreCase(serviceOrderState)) { + execution.setVariable("deleteStatus", "processing") + } + else if("COMPLETED".equalsIgnoreCase(serviceOrderState)) { + execution.setVariable("deleteStatus", "completed") + } + else if("FAILED".equalsIgnoreCase(serviceOrderState)) { + msg = "ServiceOrder failed" + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + else { + msg = "ServiceOrder failed" + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + LOGGER.debug("NBI serviceOrder state: "+serviceOrderState) + } + else{ + msg = "Get ServiceOrder Received a Bad Response Code. Response Code is: " + responseCode + prepareFailedOperationStatusUpdate(execution) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } - getProgress(execution, url, basicAuthValue, "deleteStatus") + }catch(Exception e){ + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, e.getMessage()) + } LOGGER.debug("${getPrefix()} Exit getDeleteServiceOrderProgress") } @@ -574,4 +659,8 @@ class DoDeallocateCoreNSSI extends DoCommonCoreNSSI { String getAction() { return ACTION } + + ExternalAPIUtil getExternalAPIUtil() { + return new ExternalAPIUtilFactory().create() + } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy index b09161d5cd..ea4c29b202 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy @@ -34,6 +34,13 @@ import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.RequestDBUtil import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.common.scripts.OofUtils +import org.onap.so.client.HttpClient +import org.onap.so.client.HttpClientFactory +import org.onap.so.client.oof.adapter.beans.payload.OofRequest +import javax.ws.rs.core.Response +import org.onap.logging.filter.base.ONAPComponents import org.onap.so.db.request.beans.ResourceOperationStatus import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -48,6 +55,7 @@ class DoDeallocateTnNssi extends AbstractServiceTaskProcessor { JsonUtils jsonUtil = new JsonUtils() RequestDBUtil requestDBUtil = new RequestDBUtil() TnNssmfUtils tnNssmfUtils = new TnNssmfUtils() + OofUtils oofUtils = new OofUtils() JsonSlurper jsonSlurper = new JsonSlurper() ObjectMapper objectMapper = new ObjectMapper() private static final Logger logger = LoggerFactory.getLogger(DoDeallocateTnNssi.class) @@ -92,10 +100,69 @@ class DoDeallocateTnNssi extends AbstractServiceTaskProcessor { "enableSdnc", "enableSdnc"))) { tnNssmfUtils.setEnableSdncConfig(execution) } + if (isBlank(additionalPropJsonStr) || + isBlank(tnNssmfUtils.setExecVarFromJsonIfExists(execution, + additionalPropJsonStr, + "enableOof", "enableOof"))) { + tnNssmfUtils.setEnableOofConfig(execution) + } + String nsiId = jsonUtil.getJsonValue(additionalPropJsonStr, "nsiId") + execution.setVariable("nsiId", nsiId) logger.debug("Finish preProcessRequest") } + void prepareOOFNssiTerminationRequest(DelegateExecution execution) { + logger.debug("Start prepareOOFTnNssiTerminationRequest") + String requestId = execution.getVariable("msoRequestId") + String messageType = "TN_NSSITermination" + String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution); + String serviceInstanceId = execution.getVariable("sliceServiceInstanceId") + + String relatedNsiId = execution.getVariable("nsiId") + + String oofRequest = oofUtils.buildTerminateNxiRequest(requestId,serviceInstanceId, "NSSI",messageType,relatedNsiId) + execution.setVariable("oofTnNssiPayload", oofRequest) + logger.debug("Finish prepareOOFTnNssiTerminationRequest") + } + + void performOofNSSITerminationCall(DelegateExecution execution) { + boolean terminateTnNSSI = callOofAdapter(execution,execution.getVariable("oofTnNssiPayload")) + execution.setVariable("terminateTnNSSI", terminateTnNSSI) + } + + /** + * @param execution + * @param oofRequest - Request payload to be sent to adapter + * @return + */ + boolean callOofAdapter(DelegateExecution execution, Object oofRequest) { + logger.debug("Start callOofAdapter") + String requestId = execution.getVariable("msoRequestId") + String oofAdapterEndpoint = UrnPropertiesReader.getVariable("mso.adapters.oof.endpoint", execution) + URL requestUrl = new URL(oofAdapterEndpoint) + OofRequest oofPayload = new OofRequest() + oofPayload.setApiPath("/api/oof/terminate/nxi/v1") + oofPayload.setRequestDetails(oofRequest) + String requestJson = objectMapper.writeValueAsString(oofPayload) + logger.debug("Calling OOF adapter : ${requestUrl} with payload : ${requestJson}") + HttpClient httpClient = new HttpClientFactory().newJsonClient(requestUrl, ONAPComponents.EXTERNAL) + Response httpResponse = httpClient.post(requestJson) + int responseCode = httpResponse.getStatus() + logger.debug("OOF sync response code is: " + responseCode) + if(responseCode < 200 || responseCode >= 300){ + logger.debug("OOF request failed with reason : " + httpResponse) + exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from OOF.") + }else { + Map response = objectMapper.readValue(httpResponse.getEntity(),Map.class) + boolean terminateResponse = response.get("terminateResponse") + if(!terminateResponse) { + logger.debug("Terminate response is false because " + response.get("reason")) + } + return terminateResponse + } + } + void preprocessSdncDeallocateTnNssiRequest(DelegateExecution execution) { def method = getClass().getSimpleName() + '.preprocessSdncDeallocateTnNssiRequest(' + 'execution=' + execution.getId() + ')' @@ -174,4 +241,3 @@ class DoDeallocateTnNssi extends AbstractServiceTaskProcessor { requestDBUtil.prepareUpdateResourceOperationStatus(execution, roStatus) } } - diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy index 09bbb81b6b..9debd4011b 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy @@ -20,10 +20,16 @@ package org.onap.so.bpmn.infrastructure.scripts +import com.fasterxml.jackson.core.type.TypeReference import com.fasterxml.jackson.databind.ObjectMapper +import org.json.JSONArray import com.google.gson.JsonArray +import com.google.gson.GsonBuilder import com.google.gson.JsonObject +import com.google.gson.JsonParser import groovy.json.JsonSlurper +import org.onap.so.bpmn.common.scripts.OofUtils +import com.google.gson.Gson import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.ServiceInstance @@ -53,6 +59,7 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor { RequestDBUtil requestDBUtil = new RequestDBUtil() JsonSlurper jsonSlurper = new JsonSlurper() ObjectMapper objectMapper = new ObjectMapper() + OofUtils oofUtils = new OofUtils() TnNssmfUtils tnNssmfUtils = new TnNssmfUtils() private static final Logger logger = LoggerFactory.getLogger(TnAllocateNssi.class) @@ -96,7 +103,8 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor { msg = "Input sliceProfile is null" logger.debug(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else { + } + else { execution.setVariable("sliceProfile", sliceProfile) } @@ -105,7 +113,8 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor { msg = "Input transportSliceNetworks is null" logger.debug(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else { + } + else { execution.setVariable("transportSliceNetworks", transportSliceNetworks) } logger.debug("transportSliceNetworks: " + transportSliceNetworks) @@ -115,7 +124,8 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor { msg = "Input nsiInfo is null" logger.debug(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else { + } + else { execution.setVariable("nsiInfo", nsiInfoStr) } @@ -123,6 +133,14 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor { "enableSdnc", "enableSdnc"))) { tnNssmfUtils.setEnableSdncConfig(execution) } + + if (isBlank(additionalPropJsonStr) || + isBlank(tnNssmfUtils.setExecVarFromJsonIfExists(execution, + additionalPropJsonStr, + "enableOof", "enableOof"))) { + tnNssmfUtils.setEnableOofConfig(execution) + } + } catch (BpmnError e) { throw e } catch (Exception ex) { @@ -169,6 +187,7 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor { //TN NSST decomposition String tnModelVersion = tnNsstServiceDecomposition.getModelInfo().getModelVersion() String tnModelName = tnNsstServiceDecomposition.getModelInfo().getModelName() + List serviceProxyList = tnNsstServiceDecomposition.getServiceProxy() List nsstInfoList = new ArrayList<>() for (ServiceProxy serviceProxy : serviceProxyList) { @@ -188,7 +207,8 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor { String msg = "Exception in TN NSST processDecomposition. There is no NSST associated with TN NSST " logger.info(msg) //exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } else { + } + else { execution.setVariable("tnNsstInfoList", nsstInfoList) execution.setVariable("tnModelVersion", tnModelVersion) execution.setVariable("tnModelName", tnModelName) @@ -196,6 +216,8 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor { execution.setVariable("maxIndex", maxIndex) } + execution.setVariable("tnNfSliceProfile", execution.getVariable("sliceProfile")) + execution.setVariable("tnModelName", tnModelName) logger.debug("End processDecomposition") } @@ -205,90 +227,52 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor { String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution) logger.debug("get NSSI option OOF Url: " + urlString) //build oof request body + String requestId = execution.getVariable("msoRequestId") - String messageType = "NSISelectionResponse" - Map profileInfo = objectMapper.readValue(execution.getVariable("sliceProfile"), Map.class) + String messageType = "NSSISelectionResponse" + Map profileInfo = (Map) objectMapper.readValue(execution.getVariable("tnNfSliceProfile"), Map.class) String modelUuid = execution.getVariable("modelUuid") String modelInvariantUuid = execution.getVariable("modelInvariantUuid") String modelName = execution.getVariable("tnModelName") String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution); - List nsstInfoList = objectMapper.readValue(execution.getVariable("nsstInfoList"), List.class) - JsonArray capabilitiesList = new JsonArray() - execution.setVariable("nssiSelection_Url", "/api/oof/selection/nsi/v1") + execution.setVariable("nssiSelection_Url", "/api/oof/selection/nssi/v1") execution.setVariable("nssiSelection_messageType", messageType) execution.setVariable("nssiSelection_correlator", requestId) execution.setVariable("nssiSelection_timeout", timeout) - String oofRequest = buildSelectTnNssiRequest(requestId, messageType, modelUuid, modelInvariantUuid, - modelName, profileInfo, nsstInfoList, capabilitiesList, false) + String oofRequest = oofUtils.buildSelectNSSIRequest(requestId, messageType, modelUuid, modelInvariantUuid, modelName, profileInfo) execution.setVariable("nssiSelection_oofRequest", oofRequest) logger.debug("Finish prepareOofSelection") } - String buildSelectTnNssiRequest(String requestId, String messageType, String UUID, String invariantUUID, - String name, Map profileInfo, - List nsstInfoList, JsonArray capabilitiesList, Boolean preferReuse) { - - def transactionId = requestId - logger.debug("transactionId is: " + transactionId) - String correlator = requestId - String callbackUrl = UrnPropertiesReader.getVariable("mso.adapters.oof.callback.endpoint") + "/" + messageType + "/" + correlator - ObjectMapper objectMapper = new ObjectMapper() - String profileJson = objectMapper.writeValueAsString(profileInfo) - String nsstInfoListString = objectMapper.writeValueAsString(nsstInfoList) - //Prepare requestInfo object - JsonObject requestInfo = new JsonObject() - requestInfo.addProperty("transactionId", transactionId) - requestInfo.addProperty("requestId", requestId) - requestInfo.addProperty("callbackUrl", callbackUrl) - requestInfo.addProperty("sourceId", "SO") - requestInfo.addProperty("timeout", 600) - requestInfo.addProperty("numSolutions", 1) - - //Prepare serviceInfo object - JsonObject ranNsstInfo = new JsonObject() - ranNsstInfo.addProperty("UUID", UUID) - ranNsstInfo.addProperty("invariantUUID", invariantUUID) - ranNsstInfo.addProperty("name", name) - - JsonObject json = new JsonObject() - json.add("requestInfo", requestInfo) - json.add("NSTInfo", ranNsstInfo) - json.addProperty("serviceProfile", profileJson) - json.addProperty("NSSTInfo", nsstInfoListString) - json.add("subnetCapabilities", capabilitiesList) - json.addProperty("preferReuse", preferReuse) - - return json.toString() - } - void processOofSelection(DelegateExecution execution) { logger.debug(Prefix + "processOofSelection method start") String oofResponse = execution.getVariable("nssiSelection_asyncCallbackResponse") String requestStatus = jsonUtil.getJsonValue(oofResponse, "requestStatus") if (requestStatus.equals("completed")) { - List solution = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(oofResponse, "solutions")) - boolean existingNSI = jsonUtil.getJsonValue(solution.get(0), "existingNSI") - if (existingNSI) { - def sharedNSISolution = jsonUtil.getJsonValue(solution.get(0), "sharedNSISolution") - execution.setVariable("sharedTnNssiSolution", sharedNSISolution) - logger.debug("sharedTnNssiSolution from OOF " + sharedNSISolution) - String tnServiceInstanceId = jsonUtil.getJsonValue(solution.get(0), "sharedNSISolution.NSIId") - execution.setVariable("tnServiceInstanceId", tnServiceInstanceId) - org.onap.so.bpmn.core.domain.ServiceInstance serviceInstance = new org.onap.so.bpmn.core.domain.ServiceInstance(); - serviceInstance.setInstanceId(tnServiceInstanceId); - ServiceDecomposition serviceDecomposition = execution.getVariable("tnNsstServiceDecomposition") - serviceDecomposition.setServiceInstance(serviceInstance); - execution.setVariable("tnNsstServiceDecomposition", serviceDecomposition) + String solutions = jsonUtil.getJsonValue(oofResponse, "solutions") + JsonParser parser = new JsonParser() + JsonArray solution = parser.parse(solutions) as JsonArray + if (solution.size() >= 1) { + JsonObject sol = solution.get(0) as JsonObject + String tnNfNssiId = sol.get("NSSIId").getAsString() + String invariantUuid = sol.get("invariantUUID").getAsString() + String uuid = sol.get("UUID").getAsString() + String nssiName = sol.get("NSSIName").getAsString() + execution.setVariable("TnServiceInstanceId", tnNfNssiId) + execution.setVariable("TNNFInvariantUUID", invariantUuid) + execution.setVariable("TNNFUUID", uuid) + execution.setVariable("servicename", nssiName) + logger.debug("TnServiceInstanceId from OOF " + tnNfNssiId) execution.setVariable("isOofTnNssiSelected", true) - } else { - def sliceProfiles = jsonUtil.getJsonValue(solution.get(0), "newNSISolution.sliceProfiles") - execution.setVariable("tnConstituentSliceProfiles", sliceProfiles) + } + else { + logger.debug("No solutions returned from OOF .. Create new TN NF NSSI") execution.setVariable("isOofTnNssiSelected", false) - logger.debug("tnConstituentSliceProfiles list from OOF " + sliceProfiles) } - } else { + } + else { String statusMessage = jsonUtil.getJsonValue(oofResponse, "statusMessage") logger.error("received failed status from oof " + statusMessage) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Received a failed Async Response from OOF : " + statusMessage) @@ -297,6 +281,75 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor { logger.debug(Prefix + "processOofSelection method finished") } + void prepareModifyTnNssiInputs(DelegateExecution execution) { + logger.debug(Prefix + "prepareModifyTnNssiInputs method start") + String additionalPropJsonStr = execution.getVariable("sliceParams") + String sliceProfile = execution.getVariable("sliceProfile") + String snssaiList = jsonUtil.getJsonValue(sliceProfile, "snssaiList") + String sliceProfileId = jsonUtil.getJsonValue(sliceProfile, "sliceProfileId") + String nsiInfo = jsonUtil.getJsonValue(additionalPropJsonStr, "nsiInfo") + String scriptName = jsonUtil.getJsonValue(additionalPropJsonStr, "scriptName") + String modelInvariantUuid = execution.getVariable("modelInvariantUuid") + String modelUuid = execution.getVariable("modelUuid") + String serviceInstanceID = execution.getVariable("TnServiceInstanceId") + String servicename = execution.getVariable("servicename") + String transportSliceNetworks = jsonUtil.getJsonValue(additionalPropJsonStr, "transportSliceNetworks") + + JsonObject modifySliceParams = new JsonObject() + modifySliceParams.addProperty("nsiInfo", nsiInfo) + modifySliceParams.addProperty("serviceInstanceID", serviceInstanceID) + modifySliceParams.addProperty("servicename", servicename) + modifySliceParams.addProperty("sliceProfile", sliceProfile) + modifySliceParams.addProperty("sliceProfileId", sliceProfileId) + modifySliceParams.addProperty("modelInvariantUuid", modelInvariantUuid) + modifySliceParams.addProperty("modelUuid", modelUuid) + modifySliceParams.addProperty("scriptName", scriptName) + modifySliceParams.addProperty("snssaiList", snssaiList) + modifySliceParams.addProperty("transportSliceNetworks", transportSliceNetworks) + + execution.setVariable("modifySliceParams", modifySliceParams.toString()) + + logger.debug(Prefix + "prepareModifyTnNssiInputs method finished") + } + + def createModifyNssiQueryJobStatus = { DelegateExecution execution -> + logger.debug(Prefix + "createModifyNssiQueryJobStatus method start") + JsonObject esrInfo = new JsonObject() + esrInfo.addProperty("networkType", "tn") + esrInfo.addProperty("vendor", "ONAP_internal") + + execution.setVariable("esrInfo", esrInfo.toString()) + + JsonObject serviceInfo = new JsonObject() + serviceInfo.addProperty("nssiId", execution.getVariable("TnServiceInstanceId") as String) + serviceInfo.addProperty("nsiId", execution.getVariable("nsiId") as String) + serviceInfo.addProperty("nssiName", execution.getVariable("servicename") as String) + serviceInfo.addProperty("sST", execution.getVariable("sst") as String) + serviceInfo.addProperty("PLMNIdList", objectMapper.writeValueAsString(execution.getVariable("pLMNIdList"))) + serviceInfo.addProperty("globalSubscriberId", execution.getVariable("globalSubscriberId") as String) + serviceInfo.addProperty("subscriptionServiceType", execution.getVariable("subscriptionServiceType") as String) + serviceInfo.addProperty("serviceInvariantUuid", execution.getVariable("modelInvariantUuid") as String) + serviceInfo.addProperty("serviceUuid", execution.getVariable("modelUuid") as String) + execution.setVariable("serviceInfo", serviceInfo.toString()) + execution.setVariable("responseId", "") + } + + def processModifyJobStatusRsp = { DelegateExecution execution -> + logger.debug(Prefix + "processJobStatusRsp method start") + String jobResponse = execution.getVariable("jobResponse") + logger.debug("Job status response " + jobResponse) + String status = jsonUtil.getJsonValue(jobResponse, "status") + String nssi = jsonUtil.getJsonValue(jobResponse, "nssiId") + if (status.equalsIgnoreCase("finished")) { + logger.debug("Job successfully completed ... proceeding with flow for nssi : " + nssi) + } + else { + String statusDescription = jsonUtil.getJsonValue(jobResponse, "statusDescription") + logger.error("received failed status from job status query for nssi : " + nssi + " with status description : " + statusDescription) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "received failed status from job status query for nssi : " + nssi + " with status description : " + statusDescription) + } + } + void updateAAIOrchStatus(DelegateExecution execution) { logger.debug("Start updateAAIOrchStatus") String sliceServiceInstanceId = execution.getVariable("sliceServiceInstanceId") diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy index e0c2b776fe..d1e2b11676 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy @@ -377,12 +377,23 @@ class TnNssmfUtils { logger.debug("mso.workflow.TnNssmf.enableSDNCNetworkConfig is undefined, so use default value (true)") enableSdnc = "true" } - enableSdnc = "false" logger.debug("setEnableSdncConfig: enableSdnc=" + enableSdnc) execution.setVariable("enableSdnc", enableSdnc) } + void setEnableOofConfig(DelegateExecution execution) { + String enableOof = UrnPropertiesReader.getVariable( + "mso.workflow.TnNssmf.enableOOFNetworkConfig") + if (isBlank(enableOof)) { + logger.debug("mso.workflow.TnNssmf.enableOOFNetworkConfig is undefined, so use default value (true)") + enableOof = "true" + } + logger.debug("setEnableOofConfig: enableOof=" + enableOof) + + execution.setVariable("enableOof", enableOof) + } + String setExecVarFromJsonIfExists(DelegateExecution execution, String jsonStr, String jsonKey, String varName) { return setExecVarFromJsonStr(execution, jsonStr, jsonKey, varName, false) diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateTnNssiTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateTnNssiTest.groovy index 6ea2be8e55..b7cddd2d5a 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateTnNssiTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateTnNssiTest.groovy @@ -31,9 +31,12 @@ import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types +import org.onap.so.beans.nsmf.oof.TemplateInfo import org.onap.so.bpmn.common.scripts.MsoGroovyTest +import org.onap.so.bpmn.common.scripts.OofUtils import static org.junit.Assert.assertNotNull +import static org.junit.Assert.assertEquals import static org.mockito.ArgumentMatchers.eq import static org.mockito.Mockito.* @@ -166,4 +169,55 @@ class DoAllocateTnNssiTest extends MsoGroovyTest { }""" return expect.replaceAll("\\\\s+", "") } + + @Test + void testPrepareOofSelection() { + when(mockExecution.getVariable("msoRequestId")).thenReturn("10dad82d-4bd9-467a-b113-5f8ea7eaae3c") + when(mockExecution.getVariable("modelUuid")).thenReturn("e2eb2fe3-92a7-447b-8582-077db5cd0862") + when(mockExecution.getVariable("modelInvariantUuid")).thenReturn("22e6ce80-a55f-4171-a457-a7ecb1865669") + when(mockExecution.getVariable("tnModelName")).thenReturn("Tn_ONAP_internal_BH") + when(mockExecution.getVariable("mso.adapters.oof.timeout")).thenReturn("") + TnAllocateNssi obj = spy(TnAllocateNssi.class) + OofUtils oofUtils = spy(OofUtils.class) + String requestId = "10dad82d-4bd9-467a-b113-5f8ea7eaae3c" + String nsstInfo = "\"{\"UUID\":\"e2eb2fe3-92a7-447b-8582-077db5cd0862\",\"invariantUUID\":\"22e6ce80-a55f-4171-a457-a7ecb1865669\",\"name\":\"Tn_ONAP_internal_BH\"}" + String messageType = "NSSISelectionResponse" + String sliceProfile = "{\"maxBandwidth\":3000,\"sliceProfileId\":\"ab9af40f13f721b5f13539d87484098\",\"latency\":10,\"snssaiList\":[\"001-100001\"],\"pLMNIdList\":[\"460-00\",\"460-01\"],\"perfReq\":{},\"coverageAreaTAList\":[],\"resourceSharingLevel\":\"shared\"}}" + Integer timeout = 600 + + when(oofUtils.buildSelectNSSIRequest(requestId, nsstInfo as TemplateInfo, messageType, sliceProfile, timeout)).thenReturn(""" + { + "apiPath": "/api/oof/selection/nssi/v1", + "requestDetails": "{\\"requestInfo\\":{\\"transactionId\\":\\"10dad82d-4bd9-467a-b113-5f8ea7eaae3c\\",\\"requestId\\":\\"10dad82d-4bd9-467a-b113-5f8ea7eaae3c\\",\\"callbackUrl\\":\\"http://so-oof-adapter.onap:8090/so/adapters/oof/callback/v1/NSSISelectionResponse/10dad82d-4bd9-467a-b113-5f8ea7eaae3c\\",\\"sourceId\\":\\"SO\\",\\"timeout\\":600,\\"numSolutions\\":1},\\"NSSTInfo\\":{\\"UUID\\":\\"e2eb2fe3-92a7-447b-8582-077db5cd0862\\",\\"invariantUUID\\":\\"22e6ce80-a55f-4171-a457-a7ecb1865669\\",\\"name\\":\\"Tn_ONAP_internal_BH\\"},\\"sliceProfile\\":{\\"maxBandwidth\\":3000,\\"sliceProfileId\\":\\"ab9af40f13f721b5f13539d87484098\\",\\"latency\\":10,\\"snssaiList\\":[\\"001-100001\\"],\\"pLMNIdList\\":[\\"460-00\\",\\"460-01\\"],\\"perfReq\\":{},\\"coverageAreaTAList\\":[],\\"resourceSharingLevel\\":\\"shared\\"}}" + }""".replaceAll("\\\\s+", "")) + obj.prepareOofSelection(mockExecution) + verify(mockExecution, times(1)).setVariable(eq("nssiSelection_oofRequest"), captor.capture()) + String nssiSelection_oofRequest = captor.getValue() + assertNotNull(nssiSelection_oofRequest) + } + + @Test + void testprocessOofSelection() { + when(mockExecution.getVariable("nssiSelection_oofRequest")).thenReturn(""" + { + "requestId": "a727643a-bf89-4fd9-b33c-b7bdda18c2b7", + "transactionId": "a727643a-bf89-4fd9-b33c-b7bdda18c2b7", + "requestStatus": "completed", + "statusMessage": "", + "solutions": [ + { + "UUID": "e2eb2fe3-92a7-447b-8582-077db5cd0862", + "invariantUUID": "22e6ce80-a55f-4171-a457-a7ecb1865669", + "NSSIName": "nssi_tnservice12", + "NSSIId": "fe26a924-3845-4001-b84e-a439a27a88c0" + } + ] + }""".replaceAll("\\\\s+", "")) + TnAllocateNssi obj = spy(TnAllocateNssi.class) + ArrayList solution = new ArrayList<>() + assertEquals(1, solution.size()) + verify(mockExecution, times(1)).setVariable(eq("isOofTnNssiSelected"), captor.capture()) + String isOofTnNssiSelected = captor.getValue() + assertEquals("true", isOofTnNssiSelected) + } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSITest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSITest.groovy index acace8c1c7..9ee9255499 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSITest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSITest.groovy @@ -20,31 +20,30 @@ package org.onap.so.bpmn.infrastructure.scripts -import com.fasterxml.jackson.databind.ObjectMapper import org.junit.Before import org.junit.Test import org.mockito.Mockito -import org.onap.aai.domain.yang.v19.* +import org.onap.aai.domain.yang.v19.AllottedResource +import org.onap.aai.domain.yang.v19.AllottedResources +import org.onap.aai.domain.yang.v19.ServiceInstance +import org.onap.aai.domain.yang.v19.SliceProfile import org.onap.aaiclient.client.aai.entities.AAIResultWrapper import org.onap.aaiclient.client.aai.entities.Relationships import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types -import org.onap.logging.filter.base.ONAPComponents import org.onap.so.bpmn.common.scripts.ExternalAPIUtil -import org.onap.so.bpmn.common.scripts.ExternalAPIUtilFactory import org.onap.so.bpmn.common.scripts.MsoGroovyTest -import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.common.scripts.OofUtils import org.onap.so.client.HttpClient import org.onap.so.client.HttpClientFactory -import org.onap.so.serviceinstancebeans.RequestDetails import javax.ws.rs.core.Response import static org.junit.Assert.assertNotNull import static org.junit.Assert.assertTrue +import static org.mockito.ArgumentMatchers.any import static org.mockito.Mockito.* class DoDeallocateCoreNSSITest extends MsoGroovyTest { @@ -115,11 +114,6 @@ class DoDeallocateCoreNSSITest extends MsoGroovyTest { String authHeaderResponse = "auth-header" - /* String authHeaderResponse = "{\n" + - " \"errorCode\": \"401\",\n" + - " \"errorMessage\": \"Bad request\"\n" + - "}" */ - when(spy.getAuthHeader(mockExecution, "auth-value", "mso.msoKey")).thenReturn(authHeaderResponse) AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId)) @@ -209,60 +203,32 @@ class DoDeallocateCoreNSSITest extends MsoGroovyTest { currentNSSI.put("networkServiceInstance", networkServiceInstance) - when(mockExecution.getVariable("mso.infra.endpoint.url")).thenReturn("http://mso.onap:8088") - when(mockExecution.getVariable("mso.msoKey")).thenReturn("mso.msoKey") - when(mockExecution.getVariable("mso.infra.endpoint.auth")).thenReturn("mso.infra.endpoint.auth") + String externalAPIURL = "https://nbi.onap:8443/nbi/api/v4/serviceOrder" + when(mockExecution.getVariable("ExternalAPIURL")).thenReturn(externalAPIURL) DoDeallocateCoreNSSI spy = spy(DoDeallocateCoreNSSI.class) when(spy.getAAIClient()).thenReturn(client) - GenericVnf genericVnf = new GenericVnf() - genericVnf.setServiceId("service-id") - genericVnf.setVnfName("vnf-name") - genericVnf.setModelInvariantId("model-invariant-id") - genericVnf.setModelCustomizationId("model-customization-id") - genericVnf.setVnfName("vnf-name") - genericVnf.setVnfId("vnf-id") - - - currentNSSI.put("constituteVnf", genericVnf) + String serviceOrderRequest = "" - String urlString = String.format("http://mso.onap:8088/serviceInstantiation/v7/serviceInstances/%s/vnfs/%s", networkServiceInstance.getServiceInstanceId(), genericVnf.getVnfId()) + when(mockExecution.getVariable("serviceOrderRequest")).thenReturn(serviceOrderRequest) - RequestDetails requestDetails = new RequestDetails() - ObjectMapper mapper = new ObjectMapper() - String requestDetailsStr = mapper.writeValueAsString(requestDetails) - - when(spy.prepareRequestDetails(mockExecution)).thenReturn(requestDetailsStr) - - MsoUtils msoUtilsMock = mock(MsoUtils.class) - String basicAuth = "basicAuth" - when(msoUtilsMock.getBasicAuth(anyString(), anyString())).thenReturn(basicAuth) - - HttpClientFactory httpClientFactoryMock = mock(HttpClientFactory.class) - when(spy.getHttpClientFactory()).thenReturn(httpClientFactoryMock) Response responseMock = mock(Response.class) - HttpClient httpClientMock = mock(HttpClient.class) - - when(httpClientFactoryMock.newJsonClient(any(), any())).thenReturn(httpClientMock) - - when(httpClientMock.delete(requestDetailsStr)).thenReturn(responseMock) + ExternalAPIUtil externalAPIUtil = mock(ExternalAPIUtil.class) + when(spy.getExternalAPIUtil()).thenReturn(externalAPIUtil) + when(externalAPIUtil.executeExternalAPIPostCall(mockExecution, externalAPIURL, serviceOrderRequest)).thenReturn(responseMock) when(responseMock.getStatus()).thenReturn(200) - when(responseMock.hasEntity()).thenReturn(true) - String macroOperationId = "request-id" - String requestSelfLink = "request-self-link" - String entity = "{\"requestReferences\":{\"requestId\": \"${macroOperationId}\",\"requestSelfLink\":\"${requestSelfLink}\"}}" + String id = UUID.randomUUID().toString() + String entity = "{\"id\":\"${id}\"}" when(responseMock.readEntity(String.class)).thenReturn(entity) spy.deleteServiceOrder(mockExecution) - Mockito.verify(mockExecution,times(1)).setVariable("macroOperationId", macroOperationId) - Mockito.verify(mockExecution,times(1)).setVariable("requestSelfLink", requestSelfLink) + verify(mockExecution,times(1)).setVariable("ServiceOrderId", id) - assertTrue(currentNSSI['requestSelfLink'].equals(requestSelfLink)) } @@ -436,49 +402,44 @@ class DoDeallocateCoreNSSITest extends MsoGroovyTest { @Test void testDeleteServiceOrderProgressCompleted() { - executeDeleteServiceOrderProgress("COMPLETE") + executeDeleteServiceOrderProgress("COMPLETED") Mockito.verify(mockExecution,times(1)).setVariable("deleteStatus", "completed") } void executeDeleteServiceOrderProgress(String state) { def currentNSSI = [:] + currentNSSI.put("nssiId","5G-999") - when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI) - - String url = "http://nbi.onap:8088/api/v4/serviceOrder/NS-777" + ServiceInstance networkServiceInstance = new ServiceInstance() + networkServiceInstance.setServiceInstanceId("NS-777") + networkServiceInstance.setServiceRole("Network Service") - currentNSSI['requestSelfLink'] = url + when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI) - DoDeallocateCoreNSSI spy = spy(DoDeallocateCoreNSSI.class) + currentNSSI.put("networkServiceInstance", networkServiceInstance) - /*ExternalAPIUtilFactory externalAPIUtilFactoryMock = mock(ExternalAPIUtilFactory.class) - when(spy.getExternalAPIUtilFactory()).thenReturn(externalAPIUtilFactoryMock) + String serviceOrder = UUID.randomUUID().toString() - ExternalAPIUtil externalAPIUtilMock = mock(ExternalAPIUtil.class) + when(mockExecution.getVariable("ServiceOrderId")).thenReturn(serviceOrder) - when(externalAPIUtilFactoryMock.create()).thenReturn(externalAPIUtilMock) */ + String externalAPIURL = "https://nbi.onap:8443/nbi/api/v4/serviceOrder" + when(mockExecution.getVariable("ExternalAPIURL")).thenReturn(externalAPIURL) - MsoUtils msoUtilsMock = mock(MsoUtils.class) - String basicAuth = "basicAuth" - when(msoUtilsMock.getBasicAuth(anyString(), anyString())).thenReturn(basicAuth) + DoDeallocateCoreNSSI spy = spy(DoDeallocateCoreNSSI.class) - HttpClientFactory httpClientFactoryMock = mock(HttpClientFactory.class) - when(spy.getHttpClientFactory()).thenReturn(httpClientFactoryMock) Response responseMock = mock(Response.class) - HttpClient httpClientMock = mock(HttpClient.class) + ExternalAPIUtil externalAPIUtil = mock(ExternalAPIUtil.class) + when(spy.getExternalAPIUtil()).thenReturn(externalAPIUtil) - - when(httpClientFactoryMock.newJsonClient(any(), any())).thenReturn(httpClientMock) - - when(httpClientMock.get()).thenReturn(responseMock) -// when(externalAPIUtilMock.executeExternalAPIGetCall(mockExecution, url)).thenReturn(responseMock) + externalAPIURL += "/" + serviceOrder + when(externalAPIUtil.executeExternalAPIGetCall(mockExecution, externalAPIURL)).thenReturn(responseMock) when(responseMock.getStatus()).thenReturn(200) - when(responseMock.hasEntity()).thenReturn(true) - String entity = "{\"request\":{\"requestStatus\":{\"requestState\":\"${state}\"}},\"state\":\"ACCEPTED\"}" + String id = UUID.randomUUID().toString() + String entity = "{\"state\":\"ACCEPTED\",\"orderItem\":[{\"state\":\"${state}\",\"service\":{\"id\":\"${id}\"}}]}" when(responseMock.readEntity(String.class)).thenReturn(entity) spy.getDeleteServiceOrderProgress(mockExecution) diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssiTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssiTest.groovy index 31bd3b56f5..2bb2270928 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssiTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssiTest.groovy @@ -32,8 +32,10 @@ import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types import org.onap.so.bpmn.common.scripts.MsoGroovyTest +import org.onap.so.bpmn.common.scripts.OofUtils import static org.junit.Assert.assertNotNull +import static org.junit.Assert.assertTrue import static org.mockito.ArgumentMatchers.eq import static org.mockito.Mockito.* @@ -135,4 +137,41 @@ class DoDeallocateTnNssiTest extends MsoGroovyTest { obj.deleteServiceInstance(mockExecution) Mockito.verify(client, times(1)).delete(serviceInstanceUri) } + + @Test + void testPrepareOOFNssiTerminationRequest() { + when(mockExecution.getVariable("msoRequestId")).thenReturn("4c614769-f58a-4556-8ad9-dcd903077c82") + when(mockExecution.getVariable("sliceServiceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be") + when(mockExecution.getVariable("nsiId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("mso.adapters.oof.timeout")).thenReturn("") + DoDeallocateTnNssi obj = spy(DoDeallocateTnNssi.class) + OofUtils oofUtils = spy(OofUtils.class) + when(oofUtils.buildTerminateNxiRequest()).thenReturn(""" + { + "apiPath": "/api/oof/terminate/nxi/v1", + "requestDetails": "{\"type\":\"NSSI\",\"NxIId\":\"f78c1531-55a7-4dfa-8a12-1e2544c9b248\",\"requestInfo\":{\"transactionId\":\"863fb189-33d8-455f-9d3f-bf3f6a2e4509\",\"requestId\":\"863fb189-33d8-455f-9d3f-bf3f6a2e4509\",\"callbackUrl\":\"http://so-oof-adapter.onap:8090/so/adapters/oof/callback/v1/TN_NSSITermination/863fb189-33d8-455f-9d3f-bf3f6a2e4509\",\"sourceId\":\"SO\",\"timeout\":600,\"addtnlArgs\":{\"serviceInstanceId\":\"fe6f0901-292d-4493-bcad-485793605781\"}}}" + }""".replaceAll("\\\\s+", "")) + obj.prepareOOFNssiTerminationRequest(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("oofTnNssiPayload"), captor.capture()) + String oofTnNssiPayload = captor.getValue() + assertNotNull(oofTnNssiPayload) + } + + @Test + void testPerformOofNSSITerminationCall() { + when(mockExecution.getVariable("oofTnNssiPayload")).thenReturn(""" + { + "reason": "", + "requestId": "e0a026a9-dd6d-4800-ab27-0fdd8f5f64f5", + "requestStatus": "success", + "terminateResponse": true, + "transactionId": "e0a026a9-dd6d-4800-ab27-0fdd8f5f64f5" + }""".replaceAll("\\\\s+", "")) + DoDeallocateTnNssi obj = spy(DoDeallocateTnNssi.class) + when(obj.callOofAdapter()).thenReturn(true) + obj.performOofNSSITerminationCall(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("terminateTnNSSI"), captor.capture()) + String terminateTnNSSI = captor.getValue() + assertTrue(terminateTnNSSI) + } } diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateAccessNSSI.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateAccessNSSI.bpmn index 85aa7c2bf5..374ce4c459 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateAccessNSSI.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateAccessNSSI.bpmn @@ -1,5 +1,5 @@ - + Flow_163f3sq @@ -19,7 +19,7 @@ def nss = new DoAllocateAccessNSSI() nss.getSubnetCapabilities(execution) - Flow_1gxbsoi + Flow_0833cha Flow_1xw4abx import org.onap.so.bpmn.infrastructure.scripts.* def nss = new DoAllocateAccessNSSI() @@ -50,7 +50,7 @@ nss.prepareOperationStatusUpdate(execution) Flow_0ll5x3u - + @@ -80,7 +80,7 @@ nss.prepareTnMhRequest(execution) - Flow_0bd6dhi + Flow_06qv0en @@ -432,14 +432,7 @@ nss.updateAaiWithRANInstances(execution) - - - Flow_0833cha - Flow_1gxbsoi - import org.onap.so.bpmn.infrastructure.scripts.* -def nss = new DoAllocateAccessNSSI() -nss.updateAairelationships(execution) - + Flow_18rrdsq @@ -510,7 +503,6 @@ nss.prepareFailedOperationStatusUpdate(execution) - Flow_0rb4j9r @@ -561,11 +553,37 @@ nss.prepareFailedOperationStatusUpdate(execution) #{(execution.getVariable("IsRANNfAlonePresent" ) == true)} + + Flow_0bd6dhi + Flow_06qv0en + import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoAllocateAccessNSSI() +nss.updateAairelationships(execution) + + + + + + + + + + + + + + + + + + + + @@ -584,14 +602,24 @@ nss.prepareFailedOperationStatusUpdate(execution) + + + + + + + + + + + + + + - - - - @@ -604,7 +632,15 @@ nss.prepareFailedOperationStatusUpdate(execution) - + + + + + + + + + @@ -691,6 +727,14 @@ nss.prepareFailedOperationStatusUpdate(execution) + + + + + + + + @@ -765,64 +809,20 @@ nss.prepareFailedOperationStatusUpdate(execution) - - + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - + + + @@ -836,15 +836,6 @@ nss.prepareFailedOperationStatusUpdate(execution) - - - - - - - - - @@ -860,12 +851,6 @@ nss.prepareFailedOperationStatusUpdate(execution) - - - - - - @@ -893,6 +878,12 @@ nss.prepareFailedOperationStatusUpdate(execution) + + + + + + @@ -902,6 +893,12 @@ nss.prepareFailedOperationStatusUpdate(execution) + + + + + + @@ -929,6 +926,9 @@ nss.prepareFailedOperationStatusUpdate(execution) + + + @@ -938,6 +938,9 @@ nss.prepareFailedOperationStatusUpdate(execution) + + + @@ -980,59 +983,26 @@ nss.prepareFailedOperationStatusUpdate(execution) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - + + - + - - - - - + + + + + + + + @@ -1068,6 +1038,12 @@ nss.prepareFailedOperationStatusUpdate(execution) + + + + + + @@ -1083,6 +1059,18 @@ nss.prepareFailedOperationStatusUpdate(execution) + + + + + + + + + + + + @@ -1095,6 +1083,18 @@ nss.prepareFailedOperationStatusUpdate(execution) + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateTransportNSSI.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateTransportNSSI.bpmn index b70569b8ad..fb03f6fa45 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateTransportNSSI.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateTransportNSSI.bpmn @@ -1,11 +1,11 @@ - + SequenceFlow_03s744c - SequenceFlow_1fk37v7 + Flow_071hnt4 @@ -22,7 +22,7 @@ css.preProcessRequest(execution) def css = new TnAllocateNssi() css.processOofSelection(execution) - + SequenceFlow_197cm2e SequenceFlow_12t5exy SequenceFlow_038lb9m @@ -73,7 +73,7 @@ runScript.prepareUpdateJobStatus(execution,"INPROGRESS","10","Allocate TN NSSI s SequenceFlow_0jrclmc - + SequenceFlow_0kixzdj @@ -102,7 +102,7 @@ def runScript = new TnAllocateNssi() runScript.prepareDecomposeService(execution) - SequenceFlow_1fk37v7 + Flow_0nu9t8e SequenceFlow_0h2oree import org.onap.so.bpmn.infrastructure.scripts.* def css = new TnAllocateNssi() @@ -117,7 +117,7 @@ css.prepareOofSelection(execution) - Flow_0pbq5q0 + Flow_13ikwvr @@ -146,9 +146,11 @@ css.prepareOofSelection(execution) - #{(execution.getVariable("isOofTnNssiSelected") == false)} + #{execution.getVariable("isOofTnNssiSelected") == false} + + + #{execution.getVariable("isOofTnNssiSelected") == true} - @@ -160,7 +162,6 @@ css.prepareOofSelection(execution) - SequenceFlow_0n4xku8 @@ -171,14 +172,6 @@ def runScript = new TnAllocateNssi() runScript.updateAAIOrchStatus(execution) - - SequenceFlow_038lb9m - Flow_1853sgs - import org.onap.so.bpmn.infrastructure.scripts.* -def runScript = new TnAllocateNssi() -runScript.prepareUpdateJobStatus(execution,"FINISHED","100","Allocated TN NSSI successfully") - - @@ -192,29 +185,6 @@ runScript.prepareUpdateJobStatus(execution,"FINISHED","100","Allocated TN NSSI s SequenceFlow_0h2oree SequenceFlow_1cv0wop - - - - - ${dbAdapterEndpoint} - - - application/soap+xml - Basic YnBlbDpwYXNzd29yZDEk - - - ${updateResourceOperationStatus} - POST - ${statusCode} - ${response} - - http-connector - - - Flow_1853sgs - Flow_0pbq5q0 - - @@ -261,12 +231,125 @@ runScript.prepareUpdateJobStatus(execution,"FINISHED","100","Allocated TN NSSI s Flow_06rrcwf + + Flow_071hnt4 + Flow_0nu9t8e + Flow_0tz6v1f + + + #{execution.getVariable("enableOof") == true} + + + + + Flow_0tz6v1f + + + + SequenceFlow_038lb9m + Flow_10etjmr + import org.onap.so.bpmn.infrastructure.scripts.* +def css = new TnAllocateNssi() +css.prepareModifyTnNssiInputs(execution) + + + + + + + + + + + + + + + + + + + + Flow_10etjmr + Flow_01bdm61 + + + Flow_01bdm61 + Flow_0tvh0t6 + import org.onap.so.bpmn.infrastructure.scripts.* +def css = new TnAllocateNssi() +css.createModifyNssiQueryJobStatus(execution) + + + + + + + + + + + + + + Flow_0tvh0t6 + Flow_0rt0mvl + + + + Flow_0rt0mvl + Flow_13ikwvr + import org.onap.so.bpmn.infrastructure.scripts.* +def css = new TnAllocateNssi() +css.processModifyJobStatusRsp(execution) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -275,14 +358,6 @@ runScript.prepareUpdateJobStatus(execution,"FINISHED","100","Allocated TN NSSI s - - - - - - - - @@ -291,17 +366,13 @@ runScript.prepareUpdateJobStatus(execution,"FINISHED","100","Allocated TN NSSI s - - - - - - + + @@ -338,26 +409,27 @@ runScript.prepareUpdateJobStatus(execution,"FINISHED","100","Allocated TN NSSI s - - - + + + + - + - - + + - + - + - + @@ -387,9 +459,9 @@ runScript.prepareUpdateJobStatus(execution,"FINISHED","100","Allocated TN NSSI s - + - + @@ -404,6 +476,15 @@ runScript.prepareUpdateJobStatus(execution,"FINISHED","100","Allocated TN NSSI s + + + + + + + + + @@ -449,7 +530,7 @@ runScript.prepareUpdateJobStatus(execution,"FINISHED","100","Allocated TN NSSI s - + @@ -458,15 +539,9 @@ runScript.prepareUpdateJobStatus(execution,"FINISHED","100","Allocated TN NSSI s - + - - - - - - - + @@ -475,14 +550,8 @@ runScript.prepareUpdateJobStatus(execution,"FINISHED","100","Allocated TN NSSI s - - - - - - - + @@ -490,6 +559,30 @@ runScript.prepareUpdateJobStatus(execution,"FINISHED","100","Allocated TN NSSI s + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeallocateAccessNSSI.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeallocateAccessNSSI.bpmn index ae81364f90..513f715cde 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeallocateAccessNSSI.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeallocateAccessNSSI.bpmn @@ -1,5 +1,5 @@ - + Flow_14g5p2j @@ -623,13 +623,14 @@ deallocator.deleteRanNfSliceProfileInAAI(execution) Flow_12wqmdr - Flow_15ok12u + Flow_0kuminm import org.onap.so.bpmn.infrastructure.scripts.* def deallocator = new DoDeAllocateAccessNSSI() deallocator.deleteTNSliceProfileInAAI(execution) - Flow_183aijy + Flow_0kuminm + Flow_0e6ug2u Flow_1nh3x4j import org.onap.so.bpmn.infrastructure.scripts.* def deallocator = new DoDeAllocateAccessNSSI() @@ -638,7 +639,7 @@ deallocator.deleteANNSSI(execution) - + @@ -693,23 +694,53 @@ deallocator.deleteANNSSI(execution) Flow_0412ven Flow_12wqmdr - Flow_0r8ldai + Flow_0e6ug2u - + + #{(execution.getVariable("IsRANNfAlonePresent" ) == true)} - - - Flow_0r8ldai - Flow_15ok12u - Flow_183aijy - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -976,58 +1007,15 @@ deallocator.deleteANNSSI(execution) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - + - - - - - - - - - - - - @@ -1046,6 +1034,12 @@ deallocator.deleteANNSSI(execution) + + + + + + @@ -1067,6 +1061,12 @@ deallocator.deleteANNSSI(execution) + + + + + + @@ -1112,59 +1112,8 @@ deallocator.deleteANNSSI(execution) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -1331,6 +1280,12 @@ deallocator.deleteANNSSI(execution) + + + + + + @@ -1343,6 +1298,36 @@ deallocator.deleteANNSSI(execution) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeallocateTransportNSSI.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeallocateTransportNSSI.bpmn index 1dd362bf4b..48978500e3 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeallocateTransportNSSI.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeallocateTransportNSSI.bpmn @@ -1,5 +1,5 @@ - + SequenceFlow_03s744c @@ -26,7 +26,7 @@ ex.processJavaException(execution) Flow_0ca4l8d - SequenceFlow_1jygjln + Flow_14tkuoh SequenceFlow_1qv8qw1 import org.onap.so.bpmn.infrastructure.scripts.* def runScript = new DoDeallocateTnNssi() @@ -69,7 +69,7 @@ runScript.validateSDNCResponse(execution, response, "deallocate") SequenceFlow_1jdb2oq Flow_0dirb5b - SequenceFlow_1jygjln + Flow_14pzrs9 import org.onap.so.bpmn.infrastructure.scripts.* def runScript = new DoDeallocateTnNssi() runScript.deleteServiceInstance(execution) @@ -77,13 +77,11 @@ runScript.deleteServiceInstance(execution) SequenceFlow_03s744c - SequenceFlow_07e12rt + Flow_1xxj5g6 import org.onap.so.bpmn.infrastructure.scripts.* def runScript = new DoDeallocateTnNssi() runScript.preProcessRequest(execution) - - @@ -108,7 +106,7 @@ runScript.preProcessRequest(execution) - SequenceFlow_07e12rt + Flow_08so17j Flow_0sj0mtu Flow_0dirb5b @@ -116,119 +114,281 @@ runScript.preProcessRequest(execution) #{(execution.getVariable("enableSdnc" ) == true)} + + Flow_1xxj5g6 + Flow_0elnhnt + Flow_0buil9w + + + Flow_18xmkvl + Flow_1oxjcb2 + Flow_083usqs + + + + Flow_0elnhnt + Flow_1yadxwl + import org.onap.so.bpmn.infrastructure.scripts.* +def deallocator = new DoDeallocateTnNssi() +deallocator.prepareOOFNssiTerminationRequest(execution) + + + Flow_1yadxwl + Flow_18xmkvl + import org.onap.so.bpmn.infrastructure.scripts.* +def deallocator = new DoDeallocateTnNssi() +deallocator.performOofNSSITerminationCall(execution) + + + #{execution.getVariable("enableOof") == true} + + + + Flow_14tkuoh + + + + + Flow_14pzrs9 + + + + + Flow_1oxjcb2 + + + + + + Flow_083usqs + + + + #{execution.getVariable("terminateTnNSSI") == true} + + + Flow_08so17j + + + + + Flow_0buil9w + + + - - - + + + + + + - - - + + + + + + - - - + + + - - - - - + + + + + - - + + - - + + - - + + - - + + - - - + + + + + + + - + - - - + + + + + + + + + + + + + + + + + + + + - + - - + + + - + + + + + + + + + + + + + + + + + + + - - - - + + + + - + - + - + - - + + + + + - - + + + + + + + + + + + + + + - + + + + + + + + + + + + + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - + + - - + + - + - + - - - - + diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapterUpgradeTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapterUpgradeTasks.java new file mode 100644 index 0000000000..2eebde0687 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapterUpgradeTasks.java @@ -0,0 +1,129 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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 + * + * 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.cnf.tasks; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; +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.entities.GeneralBuildingBlock; +import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; +import org.onap.so.client.adapter.cnf.CnfAdapterClient; +import org.onap.so.client.adapter.cnf.entities.UpgradeInstanceRequest; +import org.onap.so.client.adapter.cnf.entities.UpgradeInstanceResponse; +import org.onap.so.client.adapter.vnf.mapper.AttributeNameValue; +import org.onap.so.client.adapter.vnf.mapper.Attributes; +import org.onap.so.client.adapter.vnf.mapper.VnfAdapterVfModuleObjectMapper; +import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.so.openstack.utils.MsoMulticloudUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +@Component +public class CnfAdapterUpgradeTasks { + private static final Logger logger = LoggerFactory.getLogger(CnfAdapterUpgradeTasks.class); + + public static final String SDNCQUERY_RESPONSE = "SDNCQueryResponse_"; + + @Autowired + private ExtractPojosForBB extractPojosForBB; + @Autowired + private ExceptionBuilder exceptionUtil; + @Autowired + private CnfAdapterClient cnfAdapterClient; + @Autowired + private VnfAdapterVfModuleObjectMapper vfModuleMapper; + + private ObjectMapper mapper = new ObjectMapper(); + + /** + * This method is used for updating the request for an Instance in Multicloud K8s Plugin. + * + * @param execution + * @return + */ + public void upgradeInstance(BuildingBlockExecution execution) { + try { + GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock(); + ServiceInstance serviceInstance = + gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0); + GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); + VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID); + RequestContext requestContext = gBBInput.getRequestContext(); + CloudRegion cloudRegion = gBBInput.getCloudRegion(); + String sdncVfModuleQueryResponse = execution.getVariable(SDNCQUERY_RESPONSE + vfModule.getVfModuleId()); + String sdncVnfQueryResponse = execution.getVariable(SDNCQUERY_RESPONSE + genericVnf.getVnfId()); + Map paramsMap = vfModuleMapper.buildVfModuleParamsMap(requestContext, serviceInstance, + genericVnf, vfModule, sdncVnfQueryResponse, sdncVfModuleQueryResponse); + Map sdncDirectives = getSdncDirectives(paramsMap); + UpgradeInstanceRequest upgradeInstanceRequest = + upgradeInstanceRequest(vfModule, cloudRegion, sdncDirectives); + UpgradeInstanceResponse response = cnfAdapterClient.upgradeVfModule(upgradeInstanceRequest); + execution.setVariable("heatStackId", response.getId()); + } catch (Exception ex) { + logger.error("Exception occurred", ex); + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + } + + protected Map getSdncDirectives(Map paramsMap) + throws JsonParseException, JsonMappingException, IOException { + Map sdncDirectivesMap = new HashMap<>(); + String sdncDirectivesString = (String) paramsMap.get(MsoMulticloudUtils.SDNC_DIRECTIVES); + Attributes sdncDirectives = mapper.readValue(sdncDirectivesString, Attributes.class); + for (AttributeNameValue nameVal : sdncDirectives.getAttributes()) { + sdncDirectivesMap.put(nameVal.getAttributeName(), (String) nameVal.getAttributeValue()); + } + return sdncDirectivesMap; + } + + protected UpgradeInstanceRequest upgradeInstanceRequest(VfModule vfModule, CloudRegion cloudRegion, + Map sdncDirectives) { + + UpgradeInstanceRequest request = new UpgradeInstanceRequest(); + + request.setModelInvariantId(vfModule.getModelInfoVfModule().getModelInvariantUUID()); + request.setModelCustomizationId(vfModule.getModelInfoVfModule().getModelCustomizationUUID()); + request.setCloudRegion(cloudRegion.getLcpCloudRegionId()); + request.setVfModuleUUID(vfModule.getVfModuleId()); + request.setProfileName(sdncDirectives.get("k8s-rb-profile-name")); + request.setLabels(sdncDirectives); + if (sdncDirectives.containsKey("k8s-rb-instance-status-check")) + request.setStatusCheck(sdncDirectives.get("k8s-rb-instance-status-check").equalsIgnoreCase("true")); + request.setOverrideValues(sdncDirectives); + return request; + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecuteBuildingBlockBuilder.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecuteBuildingBlockBuilder.java index b0182c1b00..d7f2b85ea0 100755 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecuteBuildingBlockBuilder.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecuteBuildingBlockBuilder.java @@ -55,6 +55,7 @@ public class ExecuteBuildingBlockBuilder { private static final String VFMODULE = "VfModule"; private static final String NETWORK = "Network"; private static final String HEALTH_CHECK = "HealthCheckBB"; + private static final String UPGRADE_CNF = "UpgradeVfModuleBB"; protected List buildExecuteBuildingBlockList(List orchFlows, List originalResourceList, String requestId, String apiVersion, String resourceId, @@ -133,6 +134,10 @@ public class ExecuteBuildingBlockBuilder { && (VNF).equalsIgnoreCase(orchFlow.getBpmnScope())) { addBuildingBlockToExecuteBBList(flowsToExecute, resource, WorkflowType.VNF, orchFlow, requestId, apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, false, false); + } else if ((orchFlow.getFlowName().equalsIgnoreCase(UPGRADE_CNF)) + && (VNF).equalsIgnoreCase(orchFlow.getBpmnScope())) { + addBuildingBlockToExecuteBBList(flowsToExecute, resource, WorkflowType.VNF, orchFlow, requestId, apiVersion, + resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, false, false); } else if (orchFlow.getFlowName().contains(PNF) || (orchFlow.getFlowName().contains(CONTROLLER) && (PNF).equalsIgnoreCase(orchFlow.getBpmnScope()))) { addBuildingBlockToExecuteBBList(flowsToExecute, resource, WorkflowType.PNF, orchFlow, requestId, apiVersion, diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/Resource.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/Resource.java index 0214a3f998..3617512d7b 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/Resource.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/Resource.java @@ -40,6 +40,8 @@ public class Resource implements Serializable { private String cvnfModuleCustomizationId; private String instanceName; private String modelInvariantId; + private String modelVersionId; + private String modelCustomizationId; private int processingPriority; private Resource parent; private List children; @@ -140,6 +142,21 @@ public class Resource implements Serializable { this.modelInvariantId = modelInvariantId; } + public String getModelVersionId() { + return modelVersionId; + } + + public void setModelVersionId(String modelVersionId) { + this.modelVersionId = modelVersionId; + } + + public String getModelCustomizationId() { + return modelCustomizationId; + } + + public void setModelCustomizationId(String modelCustomizationId) { + this.modelCustomizationId = modelCustomizationId; + } public int getProcessingPriority() { return processingPriority == 0 ? (isBaseVfModule() ? Integer.MIN_VALUE + 1 : 0) : processingPriority; 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 31a7caacda..35e11963a3 100755 --- 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 @@ -42,6 +42,7 @@ import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConst import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.UPDATE_INSTANCE; import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.HEALTH_CHECK; import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.WORKFLOW_ACTION_ERROR_MESSAGE; +import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.UPGRADE_CNF; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -306,6 +307,9 @@ public class WorkflowAction { } else if (resourceType == WorkflowType.VNF && HEALTH_CHECK.equalsIgnoreCase(requestAction)) { vnfEBBLoader.customTraverseAAIVnf(execution, resourceList, workflowResourceIds.getServiceInstanceId(), workflowResourceIds.getVnfId(), aaiResourceIds); + } else if (resourceType == WorkflowType.VNF && UPGRADE_CNF.equalsIgnoreCase(requestAction)) { + vnfEBBLoader.customTraverseAAIVnf(execution, resourceList, workflowResourceIds.getServiceInstanceId(), + workflowResourceIds.getVnfId(), aaiResourceIds); } else { buildAndThrowException(execution, "Current Macro Request is not supported"); } 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 dda217fc79..22d78bb672 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 @@ -23,6 +23,7 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks; import java.sql.Timestamp; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import java.util.Optional; import java.util.UUID; import java.util.stream.Collectors; @@ -49,6 +50,7 @@ import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds; import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils; import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.so.db.catalog.beans.BuildingBlockRollback; import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization; import org.onap.so.db.catalog.client.CatalogDbClient; import org.onap.so.db.request.beans.InfraActiveRequests; @@ -86,6 +88,9 @@ public class WorkflowActionBBTasks { private static final String VFMODULE = "VfModule"; private static final String CONFIGURATION_PATTERN = "(Ad|De)(.*)FabricConfiguration(.*)"; protected String maxRetries = "mso.rainyDay.maxRetries"; + private static final String ROLLBACK_TO_ASSIGNED = "RollbackToAssigned"; + private static final String UNASSIGN = "Unassign"; + private static final String DELETE = "Delete"; private static final Logger logger = LoggerFactory.getLogger(WorkflowActionBBTasks.class); @Autowired @@ -316,94 +321,98 @@ public class WorkflowActionBBTasks { public void rollbackExecutionPath(DelegateExecution execution) { final String action = (String) execution.getVariable(BBConstants.G_ACTION); final String resourceName = (String) execution.getVariable("resourceName"); - if (!(boolean) execution.getVariable("isRollback")) { - List flowsToExecute = - (List) execution.getVariable("flowsToExecute"); - - List flowsToExecuteChangeBBs = flowsToExecute.stream() - .filter(buildingBlock -> buildingBlock.getBuildingBlock().getBpmnFlowName().startsWith("Change")) - .collect(Collectors.toList()); - - List rollbackFlows = new ArrayList<>(); - int currentSequence = (int) execution.getVariable(BBConstants.G_CURRENT_SEQUENCE); - int listSize = flowsToExecute.size(); + if ((boolean) execution.getVariable("isRollback")) { + workflowAction.buildAndThrowException(execution, + "Rollback has already been called. Cannot rollback a request that is currently in the rollback state."); + } + List flowsToExecute = + (List) execution.getVariable("flowsToExecute"); - for (int i = listSize - 1; i >= 0; i--) { - if (i > currentSequence - 1) { - flowsToExecute.remove(i); - } else { - String flowName = flowsToExecute.get(i).getBuildingBlock().getBpmnFlowName(); - if (flowName.startsWith("Assign")) { - flowName = flowName.replaceFirst("Assign", "Unassign"); - } else if (flowName.startsWith("Create")) { - flowName = flowName.replaceFirst("Create", "Delete"); - } else if (flowName.startsWith("Activate")) { - flowName = flowName.replaceFirst("Activate", "Deactivate"); - } else if (flowName.startsWith("Add")) { - flowName = flowName.replaceFirst("Add", "Delete"); - } else if (flowName.startsWith("VNF")) { - if (flowName.startsWith("VNFSet")) { - flowName = flowName.replaceFirst("VNFSet", "VNFUnset"); - } else if (flowName.startsWith("VNFLock")) { - flowName = flowName.replaceFirst("VNFLock", "VNFUnlock"); - } else if (flowName.startsWith("VNFStop")) { - flowName = flowName.replaceFirst("VNFStop", "VNFStart"); - } else if (flowName.startsWith("VNFQuiesce")) { - flowName = flowName.replaceFirst("VNFQuiesce", "VNFResume"); - } else { - continue; - } - } else { - continue; + List flowsToExecuteChangeBBs = flowsToExecute.stream() + .filter(buildingBlock -> buildingBlock.getBuildingBlock().getBpmnFlowName().startsWith("Change")) + .collect(Collectors.toList()); + List rollbackFlows = new ArrayList<>(); + int currentSequence = (int) execution.getVariable(BBConstants.G_CURRENT_SEQUENCE); + int listSize = flowsToExecute.size(); + List bbRollbackList = catalogDbClient.getBuildingBlockRollbackEntries(); + + for (int i = listSize - 1; i >= 0; i--) { + if (i > currentSequence - 1) { + flowsToExecute.remove(i); + } else { + // filter bbRollbackList for bbrollback, and check if action exists, then filter by action + BuildingBlock bb = flowsToExecute.get(i).getBuildingBlock(); + String flowName = bb.getBpmnFlowName(); + String scope = Objects.toString(bb.getBpmnScope(), ""); + String bbAction = Objects.toString(bb.getBpmnAction(), ""); + ExecuteBuildingBlock currentBB = (ExecuteBuildingBlock) execution.getVariable("buildingBlock"); + + List filteredList = bbRollbackList.stream() + .filter(k -> k.getBuildingBlockName().equals((flowName))).collect(Collectors.toList()); + Optional matchedBBRollback = + "".equals(bbAction) ? filteredList.stream().findFirst() + : filteredList.stream().filter(k -> bbAction.equals(k.getAction())).findFirst(); + if (matchedBBRollback.isPresent()) { + final BuildingBlockRollback buildingBlockRollbackItem = matchedBBRollback.get(); + String rollbackFlow = buildingBlockRollbackItem.getRollbackBuildingBlockName(); + flowsToExecute.get(i).getBuildingBlock().setBpmnFlowName(rollbackFlow); + // if we have an action, search the filtered list for the bbrollback that matches the given action. + if (null != buildingBlockRollbackItem.getRollbackAction()) { + logger.info("Setting rollback_action {} for BB: {} action: {}", + buildingBlockRollbackItem.getRollbackAction(), + buildingBlockRollbackItem.getBuildingBlockName(), + buildingBlockRollbackItem.getAction()); + flowsToExecute.get(i).getBuildingBlock() + .setBpmnAction(buildingBlockRollbackItem.getRollbackAction()); } - flowsToExecute.get(i).getBuildingBlock().setBpmnFlowName(flowName); rollbackFlows.add(flowsToExecute.get(i)); } } + } - String handlingCode = (String) execution.getVariable(HANDLINGCODE); - List rollbackFlowsFiltered = new ArrayList<>(rollbackFlows); - if ("RollbackToAssigned".equals(handlingCode) || ROLLBACKTOCREATED.equals(handlingCode) - || ROLLBACKTOCREATEDNOCONFIGURATION.equals(handlingCode)) { - for (ExecuteBuildingBlock rollbackFlow : rollbackFlows) { - if (rollbackFlow.getBuildingBlock().getBpmnFlowName().contains("Unassign") - && !rollbackFlow.getBuildingBlock().getBpmnFlowName().contains("FabricConfiguration")) { - rollbackFlowsFiltered.remove(rollbackFlow); - } else if (rollbackFlow.getBuildingBlock().getBpmnFlowName().contains("Delete") - && ((!rollbackFlow.getBuildingBlock().getBpmnFlowName().contains("FabricConfiguration") - && (ROLLBACKTOCREATED.equals(handlingCode) - || ROLLBACKTOCREATEDNOCONFIGURATION.equals(handlingCode))) - || (rollbackFlow.getBuildingBlock().getBpmnFlowName() - .contains("FabricConfiguration") - && ROLLBACKTOCREATEDNOCONFIGURATION.equals(handlingCode)))) { - rollbackFlowsFiltered.remove(rollbackFlow); - } + String handlingCode = (String) execution.getVariable(HANDLINGCODE); + List rollbackFlowsFiltered = new ArrayList<>(rollbackFlows); + if (ROLLBACK_TO_ASSIGNED.equals(handlingCode) || ROLLBACKTOCREATED.equals(handlingCode) + || ROLLBACKTOCREATEDNOCONFIGURATION.equals(handlingCode)) { + for (ExecuteBuildingBlock rollbackFlow : rollbackFlows) { + if (rollbackFlow.getBuildingBlock().getBpmnFlowName().contains(UNASSIGN) + && !rollbackFlow.getBuildingBlock().getBpmnFlowName().contains(FABRIC_CONFIGURATION)) { + rollbackFlowsFiltered.remove(rollbackFlow); + } else if (rollbackFlow.getBuildingBlock().getBpmnFlowName().contains(DELETE) + && ((!rollbackFlow.getBuildingBlock().getBpmnFlowName().contains(FABRIC_CONFIGURATION) + && (ROLLBACKTOCREATED.equals(handlingCode) + || ROLLBACKTOCREATEDNOCONFIGURATION.equals(handlingCode))) + || (rollbackFlow.getBuildingBlock().getBpmnFlowName().contains(FABRIC_CONFIGURATION) + && ROLLBACKTOCREATEDNOCONFIGURATION.equals(handlingCode)))) { + rollbackFlowsFiltered.remove(rollbackFlow); } } + } - List rollbackFlowsFilteredNonChangeBBs = new ArrayList<>(); - if (action.equals(REPLACEINSTANCE) && resourceName.equals(VFMODULE)) { - for (ExecuteBuildingBlock executeBuildingBlock : rollbackFlowsFiltered) { - if (!executeBuildingBlock.getBuildingBlock().getBpmnFlowName().startsWith("Change")) { - rollbackFlowsFilteredNonChangeBBs.add(executeBuildingBlock); - } + List rollbackFlowsFilteredNonChangeBBs = new ArrayList<>(); + if (action.equals(REPLACEINSTANCE) && resourceName.equals(VFMODULE)) { + for (ExecuteBuildingBlock executeBuildingBlock : rollbackFlowsFiltered) { + if (!executeBuildingBlock.getBuildingBlock().getBpmnFlowName().startsWith("Change")) { + rollbackFlowsFilteredNonChangeBBs.add(executeBuildingBlock); } - rollbackFlowsFiltered.clear(); - rollbackFlowsFiltered.addAll(flowsToExecuteChangeBBs); - rollbackFlowsFiltered.addAll(rollbackFlowsFilteredNonChangeBBs); } - - workflowActionBBFailure.updateRequestErrorStatusMessage(execution); - execution.setVariable("isRollbackNeeded", !rollbackFlows.isEmpty()); - execution.setVariable("flowsToExecute", rollbackFlowsFiltered); - execution.setVariable(HANDLINGCODE, "PreformingRollback"); - execution.setVariable("isRollback", true); - execution.setVariable(BBConstants.G_CURRENT_SEQUENCE, 0); - execution.setVariable(RETRY_COUNT, 0); - } else { - workflowAction.buildAndThrowException(execution, - "Rollback has already been called. Cannot rollback a request that is currently in the rollback state."); + rollbackFlowsFiltered.clear(); + rollbackFlowsFiltered.addAll(flowsToExecuteChangeBBs); + rollbackFlowsFiltered.addAll(rollbackFlowsFilteredNonChangeBBs); } + + logger.info("List of BuildingBlocks to execute for rollback"); + rollbackFlowsFiltered.forEach(item -> { + logger.info(item.getBuildingBlock().getBpmnFlowName()); + }); + + workflowActionBBFailure.updateRequestErrorStatusMessage(execution); + execution.setVariable("isRollbackNeeded", !rollbackFlows.isEmpty()); + execution.setVariable("flowsToExecute", rollbackFlowsFiltered); + execution.setVariable(HANDLINGCODE, "PreformingRollback"); + execution.setVariable("isRollback", true); + execution.setVariable(BBConstants.G_CURRENT_SEQUENCE, 0); + execution.setVariable(RETRY_COUNT, 0); } protected void updateInstanceId(DelegateExecution execution) { diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionConstants.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionConstants.java index 7bbc9f3739..7ffd066de5 100755 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionConstants.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionConstants.java @@ -53,5 +53,6 @@ public final class WorkflowActionConstants { public static final String VOLUMEGROUP = "VolumeGroup"; public static final String HEALTH_CHECK = "healthCheck"; public static final String WORKFLOW_ACTION_ERROR_MESSAGE = "WorkflowActionErrorMessage"; + public static final String UPGRADE_CNF = "upgradeCnf"; } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoader.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoader.java index f16365b742..9d76707e5a 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoader.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoader.java @@ -42,6 +42,8 @@ import org.onap.so.bpmn.infrastructure.workflow.tasks.VrfBondingServiceException import org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowType; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoPnf; import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetup; import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils; import org.onap.so.client.exception.ExceptionBuilder; @@ -207,6 +209,7 @@ public class ServiceEBBLoader { var serviceResource = new Resource(WorkflowType.SERVICE, serviceInstanceMSO.getServiceInstanceId(), false, null); serviceResource.setModelInvariantId(serviceInstanceAAI.getModelInvariantId()); + serviceResource.setModelVersionId(serviceInstanceAAI.getModelVersionId()); resourceList.add(serviceResource); traverseServiceInstanceChildService(resourceList, serviceResource, serviceInstanceAAI); traverseServiceInstanceMSOVnfs(resourceList, serviceResource, aaiResourceIds, serviceInstanceMSO); @@ -215,8 +218,15 @@ public class ServiceEBBLoader { for (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network network : serviceInstanceMSO .getNetworks()) { aaiResourceIds.add(new Pair<>(WorkflowType.NETWORK, network.getNetworkId())); - resourceList - .add(new Resource(WorkflowType.NETWORK, network.getNetworkId(), false, serviceResource)); + Resource networkResource = + new Resource(WorkflowType.NETWORK, network.getNetworkId(), false, serviceResource); + ModelInfoNetwork modelInfoNetwork = network.getModelInfoNetwork(); + if (modelInfoNetwork != null) { + networkResource.setModelCustomizationId(modelInfoNetwork.getModelCustomizationUUID()); + networkResource.setModelVersionId(modelInfoNetwork.getModelUUID()); + networkResource.setModelCustomizationId(modelInfoNetwork.getModelCustomizationUUID()); + } + resourceList.add(networkResource); } } if (serviceInstanceMSO.getCollection() != null) { @@ -261,6 +271,8 @@ public class ServiceEBBLoader { GenericVnf genericVnf = bbInputSetupUtils.getAAIGenericVnf(vnf.getVnfId()); Resource vnfResource = new Resource(WorkflowType.VNF, vnf.getVnfId(), false, serviceResource); vnfResource.setVnfCustomizationId(genericVnf.getModelCustomizationId()); + vnfResource.setModelCustomizationId(genericVnf.getModelCustomizationId()); + vnfResource.setModelVersionId(genericVnf.getModelVersionId()); resourceList.add(vnfResource); traverseVnfModules(resourceList, vnfResource, aaiResourceIds, vnf); if (vnf.getVolumeGroups() != null) { @@ -281,7 +293,13 @@ public class ServiceEBBLoader { } for (org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf pnf : serviceInstanceMSO.getPnfs()) { aaiResourceIds.add(new Pair<>(WorkflowType.PNF, pnf.getPnfId())); - resourceList.add(new Resource(WorkflowType.PNF, pnf.getPnfId(), false, serviceResource)); + Resource resource = new Resource(WorkflowType.PNF, pnf.getPnfId(), false, serviceResource); + ModelInfoPnf modelInfo = pnf.getModelInfoPnf(); + if (modelInfo != null) { + resource.setModelVersionId(modelInfo.getModelUuid()); + resource.setModelCustomizationId(modelInfo.getModelCustomizationUuid()); + } + resourceList.add(resource); } } @@ -494,6 +512,10 @@ public class ServiceEBBLoader { for (VfModule vfModule : vnf.getVfModules()) { aaiResourceIds.add(new Pair<>(WorkflowType.VFMODULE, vfModule.getVfModuleId())); Resource resource = new Resource(WorkflowType.VFMODULE, vfModule.getVfModuleId(), false, vnfResource); + org.onap.aai.domain.yang.VfModule aaiVfModule = + bbInputSetupUtils.getAAIVfModule(vnf.getVnfId(), vfModule.getVfModuleId()); + resource.setModelCustomizationId(aaiVfModule.getModelCustomizationId()); + resource.setModelInvariantId(aaiVfModule.getModelInvariantId()); resource.setBaseVfModule(vfModule.getModelInfoVfModule().getIsBaseBoolean()); resourceList.add(resource); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/UserParamsServiceTraversal.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/UserParamsServiceTraversal.java index b8b9c458fa..b56bd905a6 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/UserParamsServiceTraversal.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/UserParamsServiceTraversal.java @@ -38,6 +38,7 @@ import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization; import org.onap.so.db.catalog.beans.CvnfcCustomization; import org.onap.so.db.catalog.beans.VfModuleCustomization; import org.onap.so.db.catalog.client.CatalogDbClient; +import org.onap.so.serviceinstancebeans.ModelInfo; import org.onap.so.serviceinstancebeans.Networks; import org.onap.so.serviceinstancebeans.Pnfs; import org.onap.so.serviceinstancebeans.Service; @@ -93,6 +94,11 @@ public class UserParamsServiceTraversal { List resourceList = new ArrayList<>(); Resource serviceResource = new Resource(WorkflowType.SERVICE, validate.getModelInfo().getModelVersionId(), false, null); + ModelInfo modelInfo = validate.getModelInfo(); + if (modelInfo != null) { + serviceResource.setModelVersionId(modelInfo.getModelVersionId()); + serviceResource.setModelInvariantId(modelInfo.getModelInvariantUuid()); + } resourceList.add(serviceResource); if (validate.getResources().getServices() != null) { setResourceListForChildServices(execution, resourceList, serviceResource, validate); @@ -129,6 +135,11 @@ public class UserParamsServiceTraversal { serviceResource); vnfResource.setProcessingPriority(vnf.getProcessingPriority()); vnfResource.setInstanceName(vnf.getInstanceName()); + ModelInfo modelInfo = vnf.getModelInfo(); + if (modelInfo != null) { + vnfResource.setModelCustomizationId(modelInfo.getModelCustomizationUuid()); + vnfResource.setModelVersionId(modelInfo.getModelVersionId()); + } resourceList.add(vnfResource); setResourceListForVfModules(execution, resourceList, vnfResource, validate, vnf); } @@ -174,6 +185,11 @@ public class UserParamsServiceTraversal { foundVfModuleOrVG = true; Resource resource = setVfModuleWorkFlowTypeToResourceList(resourceList, vnfResource, vfModuleCustomization, vfModule); + if (vnf.getModelInfo() != null) { + resource.setModelVersionId(vnf.getModelInfo().getModelVersionId()); + } + resource.setVfModuleCustomizationId(vfModuleCustomization.getModelCustomizationUUID()); + resource.setModelCustomizationId(vfModuleCustomization.getModelCustomizationUUID()); setConfigurationWorkFlowTypeToResourceList(resourceList, vnfResource, validate, vnf, vfModule, resource); } } @@ -225,6 +241,11 @@ public class UserParamsServiceTraversal { for (Pnfs pnf : validate.getResources().getPnfs()) { Resource pnfResource = new Resource(WorkflowType.PNF, pnf.getModelInfo().getModelCustomizationId(), false, serviceResource); + ModelInfo modelInfo = pnf.getModelInfo(); + if (modelInfo != null) { + pnfResource.setModelCustomizationId(modelInfo.getModelCustomizationUuid()); + pnfResource.setModelVersionId(modelInfo.getModelVersionId()); + } pnfResource.setProcessingPriority(pnf.getProcessingPriority()); resourceList.add(pnfResource); } @@ -236,6 +257,11 @@ public class UserParamsServiceTraversal { Resource networkResource = new Resource(WorkflowType.NETWORK, network.getModelInfo().getModelCustomizationId(), false, serviceResource); networkResource.setProcessingPriority(network.getProcessingPriority()); + ModelInfo modelInfo = network.getModelInfo(); + if (modelInfo != null) { + networkResource.setModelCustomizationId(modelInfo.getModelCustomizationUuid()); + networkResource.setModelVersionId(modelInfo.getModelVersionId()); + } resourceList.add(networkResource); } if (requestAction.equals(CREATE_INSTANCE)) { diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoader.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoader.java index b950eb41be..3778f64612 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoader.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoader.java @@ -40,7 +40,6 @@ 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; -import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule; import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetup; import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils; import org.onap.so.client.exception.ExceptionBuilder; @@ -117,6 +116,9 @@ public class VnfEBBLoader { if (vnf.getVnfId().equals(vnfId)) { aaiResourceIds.add(new Pair<>(WorkflowType.VNF, vnf.getVnfId())); Resource vnfResource = new Resource(WorkflowType.VNF, vnf.getVnfId(), false, serviceResource); + org.onap.aai.domain.yang.GenericVnf aaiGenericVnf = bbInputSetupUtils.getAAIGenericVnf(vnfId); + vnfResource.setModelCustomizationId(aaiGenericVnf.getModelCustomizationId()); + vnfResource.setModelVersionId(aaiGenericVnf.getModelVersionId()); resourceList.add(vnfResource); processVfModules(vnf, aaiResourceIds, resourceList, vnfResource, execution); processVolumeGroups(vnf, aaiResourceIds, resourceList, vnfResource); @@ -131,8 +133,11 @@ public class VnfEBBLoader { for (GenericVnf vnf : serviceInstanceMSO.getVnfs()) { if (vnf.getVnfId().equals(vnfId)) { aaiResourceIds.add(new Pair<>(WorkflowType.VNF, vnf.getVnfId())); - Resource vnfResource = new Resource(WorkflowType.VNF, - bbInputSetupUtils.getAAIGenericVnf(vnfId).getModelCustomizationId(), false, serviceResource); + org.onap.aai.domain.yang.GenericVnf aaiGenericVnf = bbInputSetupUtils.getAAIGenericVnf(vnfId); + Resource vnfResource = + new Resource(WorkflowType.VNF, aaiGenericVnf.getModelCustomizationId(), false, serviceResource); + vnfResource.setModelCustomizationId(aaiGenericVnf.getModelCustomizationId()); + vnfResource.setModelVersionId(aaiGenericVnf.getModelVersionId()); resourceList.add(vnfResource); processVfModules(vnf, aaiResourceIds, resourceList, vnfResource, execution); processVolumeGroups(vnf, aaiResourceIds, resourceList, vnfResource); @@ -141,10 +146,10 @@ public class VnfEBBLoader { } } - private void findConfigurationsInsideVfModule(DelegateExecution execution, String vnfId, String vfModuleId, - List resourceList, Resource vfModuleResource, List> aaiResourceIds) { + private void findConfigurationsInsideVfModule(DelegateExecution execution, + org.onap.aai.domain.yang.VfModule aaiVfModule, List resourceList, Resource vfModuleResource, + List> aaiResourceIds) { try { - org.onap.aai.domain.yang.VfModule aaiVfModule = bbInputSetupUtils.getAAIVfModule(vnfId, vfModuleId); AAIResultWrapper vfModuleWrapper = new AAIResultWrapper( new AAICommonObjectMapperProvider().getMapper().writeValueAsString(aaiVfModule)); Optional relationshipsOp; @@ -166,11 +171,14 @@ public class VnfEBBLoader { aaiResourceIds.add(new Pair<>(WorkflowType.VFMODULE, vfModule.getVfModuleId())); Resource vfModuleResource = new Resource(WorkflowType.VFMODULE, vfModule.getVfModuleId(), false, vnfResource); - Optional.ofNullable(vfModule.getModelInfoVfModule()).map(ModelInfoVfModule::getIsBaseBoolean) - .ifPresent(vfModuleResource::setBaseVfModule); + org.onap.aai.domain.yang.VfModule aaiVfModule = + bbInputSetupUtils.getAAIVfModule(vnf.getVnfId(), vfModule.getVfModuleId()); + vfModuleResource.setModelInvariantId(aaiVfModule.getModelInvariantId()); + vfModuleResource.setModelCustomizationId(aaiVfModule.getModelCustomizationId()); + vfModuleResource.setBaseVfModule(aaiVfModule.isIsBaseVfModule()); resourceList.add(vfModuleResource); - findConfigurationsInsideVfModule(execution, vnf.getVnfId(), vfModule.getVfModuleId(), resourceList, - vfModuleResource, aaiResourceIds); + findConfigurationsInsideVfModule(execution, aaiVfModule, resourceList, vfModuleResource, + aaiResourceIds); } } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListener.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListener.java index ff6c113af3..dc77ea1f0c 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListener.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListener.java @@ -24,12 +24,10 @@ import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; -import org.apache.logging.log4j.util.Strings; import org.onap.so.bpmn.common.BBConstants; import org.onap.so.bpmn.common.BuildingBlockExecution; -import org.onap.so.bpmn.common.listener.flowmanipulator.FlowManipulatorListenerRunner; import org.onap.so.bpmn.common.listener.flowmanipulator.PreFlowManipulator; -import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.infrastructure.workflow.tasks.Resource; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.db.catalog.beans.PnfResourceCustomization; import org.onap.so.db.catalog.beans.Service; @@ -40,7 +38,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import org.springframework.util.CollectionUtils; @Component public class SkipCDSBuildingBlockListener implements PreFlowManipulator { @@ -76,43 +73,37 @@ public class SkipCDSBuildingBlockListener implements PreFlowManipulator { @Override public void run(List flowsToExecute, ExecuteBuildingBlock currentBB, BuildingBlockExecution execution) { - String customizationUUID = currentBB.getBuildingBlock().getKey(); + String resourceKey = currentBB.getBuildingBlock().getKey(); + List resources = execution.getVariable("resources"); + Resource resource = resources.stream().filter(r -> resourceKey.equals(r.getResourceId())).findFirst() + .orElseThrow(() -> new IllegalArgumentException("Resource not found for key:" + resourceKey)); - if ("SERVICE".equalsIgnoreCase(currentBB.getBuildingBlock().getBpmnScope())) { - String modelUUID = currentBB.getRequestDetails().getModelInfo().getModelUuid(); - Service service = catalogDbClient.getServiceByID(modelUUID); - currentSequenceSkipCheck(execution, service.getSkipPostInstConf()); - } else if (currentBB.getBuildingBlock().getBpmnScope().equalsIgnoreCase("VNF") - && containsIgnoreCaseAction(currentBB, vnfActions)) { - List vnfResourceCustomizations = - catalogDbClient.getVnfResourceCustomizationByModelUuid( - currentBB.getRequestDetails().getModelInfo().getModelUuid()); - if (!CollectionUtils.isEmpty(vnfResourceCustomizations)) { - VnfResourceCustomization vrc = catalogDbClient.findVnfResourceCustomizationInList(customizationUUID, - vnfResourceCustomizations); - if (null != vrc) { - logger.debug("getSkipPostInstConf value: " + vrc.getSkipPostInstConf().booleanValue()); - boolean skipConfigVNF = vrc.getSkipPostInstConf().booleanValue(); - currentSequenceSkipCheck(execution, skipConfigVNF); - } + String scope = currentBB.getBuildingBlock().getBpmnScope(); + if ("SERVICE".equalsIgnoreCase(scope)) { + Service service = catalogDbClient.getServiceByID(resource.getModelVersionId()); + currentSequenceSkipCheck(execution, service.getSkipPostInstConf()); + } else if ("VNF".equalsIgnoreCase(scope) && containsIgnoreCaseAction(currentBB, vnfActions)) { + VnfResourceCustomization vrc = catalogDbClient + .getVnfResourceCustomizationByModelCustomizationUUID(resource.getModelCustomizationId()); + if (vrc != null) { + logger.debug("getSkipPostInstConf value: " + vrc.getSkipPostInstConf()); + boolean skipConfigVNF = vrc.getSkipPostInstConf(); + currentSequenceSkipCheck(execution, skipConfigVNF); } } else if (currentBB.getBuildingBlock().getBpmnScope().equalsIgnoreCase("VFModule") && containsIgnoreCaseAction(currentBB, vFModuleAction)) { - - VfModuleCustomization vfc = - catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID(customizationUUID); - + VfModuleCustomization vfc = catalogDbClient + .getVfModuleCustomizationByModelCuztomizationUUID(resource.getModelCustomizationId()); if (null != vfc) { logger.debug("getSkipPostInstConf value: " + vfc.getSkipPostInstConf().booleanValue()); boolean skipVfModule = vfc.getSkipPostInstConf(); currentSequenceSkipCheck(execution, skipVfModule); } - } else if (currentBB.getBuildingBlock().getBpmnScope().equalsIgnoreCase("PNF") && containsIgnoreCaseAction(currentBB, pnfActions)) { - PnfResourceCustomization pnfResourceCustomization = - catalogDbClient.getPnfResourceCustomizationByModelCustomizationUUID(customizationUUID); + PnfResourceCustomization pnfResourceCustomization = catalogDbClient + .getPnfResourceCustomizationByModelCustomizationUUID(resource.getModelCustomizationId()); if (null != pnfResourceCustomization) { logger.debug("getSkipPostInstConf value: " + pnfResourceCustomization.getSkipPostInstConf()); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/CnfAdapterClient.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/CnfAdapterClient.java index da36a6f040..e8122e7784 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/CnfAdapterClient.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/CnfAdapterClient.java @@ -27,6 +27,8 @@ import javax.ws.rs.core.UriBuilder; import org.apache.http.HttpStatus; import org.onap.so.client.adapter.cnf.entities.InstanceRequest; import org.onap.so.client.adapter.cnf.entities.InstanceResponse; +import org.onap.so.client.adapter.cnf.entities.UpgradeInstanceResponse; +import org.onap.so.client.adapter.cnf.entities.UpgradeInstanceRequest; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -115,6 +117,25 @@ public class CnfAdapterClient { } } + @Retryable(value = {HttpServerErrorException.class}, maxAttempts = 3, backoff = @Backoff(delay = 3000)) + public UpgradeInstanceResponse upgradeVfModule(UpgradeInstanceRequest request) throws CnfAdapterClientException { + try { + String uri = "http://so-cnf-adapter:8090"; + String endpoint = UriBuilder.fromUri(uri).path("/api/cnf-adapter/v1/instance/{instanceID}/upgrade").build() + .toString(); + HttpEntity entity = getHttpEntity(request); + ResponseEntity result = + restTemplate.exchange(endpoint, HttpMethod.POST, entity, UpgradeInstanceResponse.class); + return result.getBody(); + } catch (HttpClientErrorException e) { + logger.error("Error Calling CNF Adapter, e"); + if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) { + throw new EntityNotFoundException(e.getResponseBodyAsString()); + } + throw e; + } + } + protected HttpHeaders getHttpHeaders() { HttpHeaders headers = new HttpHeaders(); List acceptableMediaTypes = new ArrayList<>(); @@ -135,4 +156,8 @@ public class CnfAdapterClient { return new HttpEntity<>(request, headers); } + protected HttpEntity getHttpEntity(UpgradeInstanceRequest request) { + HttpHeaders headers = getHttpHeaders(); + return new HttpEntity<>(request, headers); + } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/UpgradeInstanceRequest.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/UpgradeInstanceRequest.java new file mode 100644 index 0000000000..ef516d4967 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/UpgradeInstanceRequest.java @@ -0,0 +1,100 @@ + +package org.onap.so.client.adapter.cnf.entities; + +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpgradeInstanceRequest { + + @JsonProperty("modelInvariantId") + private String modelInvariantId; + + @JsonProperty("modelCustomizationId") + private String modelCustomizationId; + + @JsonProperty("k8sRBProfileName") + private String profileName; + + @JsonProperty("k8sRBInstanceStatusCheck") + private Boolean statusCheck = false; + + @JsonProperty("cloudRegionId") + private String cloudRegion; + + @JsonProperty("vfModuleUUID") + private String vfModuleUUID; + + @JsonProperty("labels") + private Map labels; + + @JsonProperty("override-values") + private Map overrideValues; + + public String getModelInvariantId() { + return modelInvariantId; + } + + public void setModelInvariantId(String modelInvariantId) { + this.modelInvariantId = modelInvariantId; + } + + public String getModelCustomizationId() { + return modelCustomizationId; + } + + public void setModelCustomizationId(String modelCustomizationId) { + this.modelCustomizationId = modelCustomizationId; + } + + public String getProfileName() { + return profileName; + } + + public void setProfileName(String profileName) { + this.profileName = profileName; + } + + public Boolean getStatusCheck() { + return statusCheck; + } + + public void setStatusCheck(Boolean statusCheck) { + this.statusCheck = statusCheck; + } + + public String getCloudRegion() { + return cloudRegion; + } + + public void setCloudRegion(String cloudRegion) { + this.cloudRegion = cloudRegion; + } + + public Map getLabels() { + return labels; + } + + public void setLabels(Map labels) { + this.labels = labels; + } + + public String getVfModuleUUID() { + return vfModuleUUID; + } + + public void setVfModuleUUID(String vfModuleUUID) { + this.vfModuleUUID = vfModuleUUID; + } + + public Map getOverrideValues() { + return overrideValues; + } + + public void setOverrideValues(Map overrideValues) { + this.overrideValues = overrideValues; + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/UpgradeInstanceResponse.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/UpgradeInstanceResponse.java new file mode 100644 index 0000000000..6498279870 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/UpgradeInstanceResponse.java @@ -0,0 +1,78 @@ + +package org.onap.so.client.adapter.cnf.entities; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"id", "request", "namespace", "release-name", "resources"}) +public class UpgradeInstanceResponse { + + @JsonProperty("id") + private String id; + + @JsonProperty("request") + private InstanceRequest request; + + @JsonProperty("namespace") + private String namespace; + + @JsonProperty("release-name") + private String releaseName; + + @JsonProperty("resources") + private List resources = null; + + @JsonProperty("id") + public String getId() { + return id; + } + + @JsonProperty("id") + public void setId(String id) { + this.id = id; + } + + @JsonProperty("request") + public InstanceRequest getRequest() { + return request; + } + + @JsonProperty("request") + public void setRequest(InstanceRequest request) { + this.request = request; + } + + @JsonProperty("namespace") + public String getNamespace() { + return namespace; + } + + @JsonProperty("namespace") + public void setNamespace(String namespace) { + this.namespace = namespace; + } + + @JsonProperty("resources") + public List getResources() { + return resources; + } + + @JsonProperty("resources") + public void setResources(List resources) { + this.resources = resources; + } + + @JsonProperty("release-name") + public String getReleaseName() { + return releaseName; + } + + @JsonProperty("release-name") + public void setReleaseName(String releaseName) { + this.releaseName = releaseName; + } + +} 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 28d2abc792..7d4267efbb 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 @@ -25,13 +25,16 @@ package org.onap.so.bpmn.infrastructure.aai.tasks; import org.camunda.bpm.engine.delegate.BpmnError; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; import org.mockito.ArgumentMatchers; import org.mockito.InjectMocks; +import org.mockito.Mock; import org.mockito.Mockito; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.so.adapters.nwrest.CreateNetworkResponse; import org.onap.so.adapters.nwrest.UpdateNetworkResponse; -import org.onap.so.bpmn.BaseTaskTest; import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.data.TestDataSetup; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; @@ -42,7 +45,17 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet; 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.exception.BBObjectNotFoundException; +import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.so.client.orchestration.AAICollectionResources; +import org.onap.so.client.orchestration.AAIConfigurationResources; +import org.onap.so.client.orchestration.AAINetworkResources; +import org.onap.so.client.orchestration.AAIPnfResources; +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.db.catalog.beans.OrchestrationStatus; import java.util.HashMap; import static org.junit.Assert.assertEquals; @@ -57,8 +70,29 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -public class AAIUpdateTasksTest extends BaseTaskTest { - +@RunWith(MockitoJUnitRunner.Silent.class) +public class AAIUpdateTasksTest extends TestDataSetup { + + @Mock + protected ExtractPojosForBB extractPojosForBB; + @Mock + protected ExceptionBuilder exceptionUtil; + @Mock + protected AAIServiceInstanceResources aaiServiceInstanceResources; + @Mock + protected AAIPnfResources aaiPnfResources; + @Mock + protected AAIVnfResources aaiVnfResources; + @Mock + protected AAIVfModuleResources aaiVfModuleResources; + @Mock + protected AAIVolumeGroupResources aaiVolumeGroupResources; + @Mock + protected AAINetworkResources aaiNetworkResources; + @Mock + protected AAICollectionResources aaiCollectionResources; + @Mock + protected AAIConfigurationResources aaiConfigurationResources; @InjectMocks private AAIUpdateTasks aaiUpdateTasks = new AAIUpdateTasks(); @@ -99,7 +133,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest { } @Test - public void updateOrchestrationStatusAssignedServiceTest() throws Exception { + public void updateOrchestrationStatusAssignedServiceTest() { doNothing().when(aaiServiceInstanceResources).updateOrchestrationStatusServiceInstance(serviceInstance, OrchestrationStatus.ASSIGNED); @@ -110,7 +144,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest { } @Test - public void updateOrchestrationStatusAssignedServiceExceptionTest() throws Exception { + public void updateOrchestrationStatusAssignedServiceExceptionTest() { expectedException.expect(BpmnError.class); doThrow(RuntimeException.class).when(aaiServiceInstanceResources) @@ -120,7 +154,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest { } @Test - public void updateOrchestrationStatusActiveServiceTest() throws Exception { + public void updateOrchestrationStatusActiveServiceTest() { doNothing().when(aaiServiceInstanceResources).updateOrchestrationStatusServiceInstance(serviceInstance, OrchestrationStatus.ACTIVE); @@ -131,7 +165,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest { } @Test - public void updateOrchestrationStatusActiveServiceExceptionTest() throws Exception { + public void updateOrchestrationStatusActiveServiceExceptionTest() { expectedException.expect(BpmnError.class); doThrow(RuntimeException.class).when(aaiServiceInstanceResources) @@ -221,7 +255,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest { } @Test - public void updateOrchestrationStatusAssignedVnfTest() throws Exception { + public void updateOrchestrationStatusAssignedVnfTest() { doNothing().when(aaiVnfResources).updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.ASSIGNED); aaiUpdateTasks.updateOrchestrationStatusAssignedVnf(execution); @@ -230,7 +264,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest { } @Test - public void updateOrchestrationStatusAssignedVnfExceptionTest() throws Exception { + public void updateOrchestrationStatusAssignedVnfExceptionTest() { expectedException.expect(BpmnError.class); doThrow(RuntimeException.class).when(aaiVnfResources).updateOrchestrationStatusVnf(genericVnf, @@ -240,7 +274,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest { } @Test - public void updateOrchestrationStatusActiveVnfTest() throws Exception { + public void updateOrchestrationStatusActiveVnfTest() { doNothing().when(aaiVnfResources).updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.ACTIVE); aaiUpdateTasks.updateOrchestrationStatusActiveVnf(execution); @@ -249,7 +283,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest { } @Test - public void updateOrchestrationStatusActiveVnfExceptionTest() throws Exception { + public void updateOrchestrationStatusActiveVnfExceptionTest() { expectedException.expect(BpmnError.class); doThrow(RuntimeException.class).when(aaiVnfResources).updateOrchestrationStatusVnf(genericVnf, @@ -259,7 +293,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest { } @Test - public void updateOrchestrationStatusAssignVfModuleTest() throws Exception { + public void updateOrchestrationStatusAssignVfModuleTest() { doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ASSIGNED); aaiUpdateTasks.updateOrchestrationStatusAssignedVfModule(execution); @@ -269,7 +303,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest { } @Test - public void updateOrchestrationStatusAssignVfModuleExceptionTest() throws Exception { + public void updateOrchestrationStatusAssignVfModuleExceptionTest() { doThrow(RuntimeException.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ASSIGNED); @@ -279,7 +313,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest { } @Test - public void updateOrchestrationStatusCreatedVfModuleTest() throws Exception { + public void updateOrchestrationStatusCreatedVfModuleTest() { doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.CREATED); aaiUpdateTasks.updateOrchestrationStatusCreatedVfModule(execution); @@ -288,7 +322,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest { } @Test - public void updateOrchestrationStatusCreatedVfModuleExceptionTest() throws Exception { + public void updateOrchestrationStatusCreatedVfModuleExceptionTest() { doThrow(RuntimeException.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.CREATED); @@ -298,7 +332,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest { } @Test - public void updateOrchestrationStatusPendingActivatefModuleTest() throws Exception { + public void updateOrchestrationStatusPendingActivatefModuleTest() { doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.PENDING_ACTIVATION); @@ -309,7 +343,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest { } @Test - public void updateOrchestrationStatusPendingActivatefModuleExceptionTest() throws Exception { + public void updateOrchestrationStatusPendingActivatefModuleExceptionTest() { doThrow(RuntimeException.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.PENDING_ACTIVATION); @@ -319,7 +353,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest { } @Test - public void updateOrchestrationStatusDectivateVfModuleTest() throws Exception { + public void updateOrchestrationStatusDectivateVfModuleTest() { doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.CREATED); @@ -330,7 +364,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest { } @Test - public void updateOrchestrationStatusDectivateVfModuleExceptionTest() throws Exception { + public void updateOrchestrationStatusDectivateVfModuleExceptionTest() { doThrow(RuntimeException.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.CREATED); @@ -340,7 +374,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest { } @Test - public void updateHeatStackIdVfModuleTest() throws Exception { + public void updateHeatStackIdVfModuleTest() { execution.setVariable("heatStackId", "newHeatStackId"); doNothing().when(aaiVfModuleResources).updateHeatStackIdVfModule(vfModule, genericVnf); @@ -351,18 +385,18 @@ public class AAIUpdateTasksTest extends BaseTaskTest { } @Test - public void updateHeatStackIdVfModuleToNullTest() throws Exception { + public void updateHeatStackIdVfModuleToNullTest() { execution.setVariable("heatStackId", null); doNothing().when(aaiVfModuleResources).updateHeatStackIdVfModule(vfModule, genericVnf); aaiUpdateTasks.updateHeatStackIdVfModule(execution); verify(aaiVfModuleResources, times(1)).updateHeatStackIdVfModule(vfModule, genericVnf); - assertEquals(vfModule.getHeatStackId(), ""); + assertEquals("", vfModule.getHeatStackId()); } @Test - public void updateHeatStackIdVfModuleExceptionTest() throws Exception { + public void updateHeatStackIdVfModuleExceptionTest() { doThrow(RuntimeException.class).when(aaiVfModuleResources).updateHeatStackIdVfModule(vfModule, genericVnf); expectedException.expect(BpmnError.class); @@ -371,7 +405,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest { } @Test - public void updateOrchestrationStatusActiveVolumeGroupTest() throws Exception { + public void updateOrchestrationStatusActiveVolumeGroupTest() { doNothing().when(aaiVolumeGroupResources).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.ACTIVE); @@ -382,7 +416,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest { } @Test - public void updateOrchestrationStatusActiveVolumeGroupExceptionTest() throws Exception { + public void updateOrchestrationStatusActiveVolumeGroupExceptionTest() { expectedException.expect(BpmnError.class); doThrow(RuntimeException.class).when(aaiVolumeGroupResources).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.ACTIVE); @@ -390,7 +424,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest { } @Test - public void updateOrchestrationStatusCreatedVolumeGroupTest() throws Exception { + public void updateOrchestrationStatusCreatedVolumeGroupTest() { doNothing().when(aaiVolumeGroupResources).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.CREATED); @@ -401,7 +435,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest { } @Test - public void updateOrchestrationStatusCreatedVolumeGroupExceptionTest() throws Exception { + public void updateOrchestrationStatusCreatedVolumeGroupExceptionTest() { expectedException.expect(BpmnError.class); doThrow(RuntimeException.class).when(aaiVolumeGroupResources).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.CREATED); @@ -409,7 +443,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest { } @Test - public void test_updateOrchestrationStatusAssignedVolumeGroup() throws Exception { + public void test_updateOrchestrationStatusAssignedVolumeGroup() { doNothing().when(aaiVolumeGroupResources).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.ASSIGNED); @@ -421,7 +455,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest { } @Test - public void test_updateOrchestrationStatusAssignedVolumeGroup_exception() throws Exception { + public void test_updateOrchestrationStatusAssignedVolumeGroup_exception() { expectedException.expect(BpmnError.class); doThrow(RuntimeException.class).when(aaiVolumeGroupResources).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.ASSIGNED); @@ -429,7 +463,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest { } @Test - public void updateHeatStackIdVolumeGroupTest() throws Exception { + public void updateHeatStackIdVolumeGroupTest() { execution.setVariable("heatStackId", "newHeatStackId"); doNothing().when(aaiVolumeGroupResources).updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion); @@ -440,18 +474,18 @@ public class AAIUpdateTasksTest extends BaseTaskTest { } @Test - public void updateHeatStackIdVolumeGroupToNullTest() throws Exception { + public void updateHeatStackIdVolumeGroupToNullTest() { execution.setVariable("heatStackId", null); doNothing().when(aaiVolumeGroupResources).updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion); aaiUpdateTasks.updateHeatStackIdVolumeGroup(execution); verify(aaiVolumeGroupResources, times(1)).updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion); - assertEquals(volumeGroup.getHeatStackId(), ""); + assertEquals("", volumeGroup.getHeatStackId()); } @Test - public void updateHeatStackIdVolumeGroupExceptionTest() throws Exception { + public void updateHeatStackIdVolumeGroupExceptionTest() { expectedException.expect(BpmnError.class); doThrow(RuntimeException.class).when(aaiVolumeGroupResources).updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion); @@ -459,7 +493,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest { } @Test - public void updateNetworkExceptionTest() throws Exception { + public void updateNetworkExceptionTest() { expectedException.expect(BpmnError.class); doThrow(RuntimeException.class).when(aaiNetworkResources).updateNetwork(network); @@ -468,21 +502,21 @@ public class AAIUpdateTasksTest extends BaseTaskTest { } @Test - public void updateOstatusActivedNetworkCollectionTest() throws Exception { + public void updateOstatusActivedNetworkCollectionTest() { doNothing().when(aaiCollectionResources).updateCollection(serviceInstance.getCollection()); aaiUpdateTasks.updateOrchestrationStatusActiveNetworkCollection(execution); verify(aaiCollectionResources, times(1)).updateCollection(serviceInstance.getCollection()); } @Test - public void updateOstatusActiveNetworkColectionExceptionTest() throws Exception { + public void updateOstatusActiveNetworkColectionExceptionTest() { expectedException.expect(BpmnError.class); doThrow(RuntimeException.class).when(aaiCollectionResources).updateCollection(serviceInstance.getCollection()); aaiUpdateTasks.updateOrchestrationStatusActiveNetworkCollection(execution); } @Test - public void updateOrchestrationStatusActivateVfModuleTest() throws Exception { + public void updateOrchestrationStatusActivateVfModuleTest() { doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ACTIVE); @@ -493,7 +527,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest { } @Test - public void updateOrchestrationStatusActivateVfModuleExceptionTest() throws Exception { + public void updateOrchestrationStatusActivateVfModuleExceptionTest() { doThrow(RuntimeException.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ACTIVE); @@ -642,7 +676,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest { } @Test - public void updateOrchestrationStatusDeleteVfModuleTest() throws Exception { + public void updateOrchestrationStatusDeleteVfModuleTest() { doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ASSIGNED); @@ -668,7 +702,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest { } @Test - public void updateOrchestrationStatusDeactivateFabricConfigurationTest() throws Exception { + public void updateOrchestrationStatusDeactivateFabricConfigurationTest() { gBBInput = execution.getGeneralBuildingBlock(); doNothing().when(aaiConfigurationResources).updateOrchestrationStatusConfiguration(configuration, OrchestrationStatus.ASSIGNED); @@ -680,7 +714,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest { } @Test - public void updateOrchestrationStatusActivateFabricConfigurationTest() throws Exception { + public void updateOrchestrationStatusActivateFabricConfigurationTest() { gBBInput = execution.getGeneralBuildingBlock(); doNothing().when(aaiConfigurationResources).updateOrchestrationStatusConfiguration(configuration, OrchestrationStatus.ACTIVE); @@ -692,7 +726,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest { } @Test - public void updateOrchestrationStatusAssignedFabricConfigurationTest() throws Exception { + public void updateOrchestrationStatusAssignedFabricConfigurationTest() { gBBInput = execution.getGeneralBuildingBlock(); doNothing().when(aaiConfigurationResources).updateOrchestrationStatusConfiguration(configuration, OrchestrationStatus.ASSIGNED); @@ -704,7 +738,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest { } @Test - public void updateContrailServiceInstanceFqdnVfModuleTest() throws Exception { + public void updateContrailServiceInstanceFqdnVfModuleTest() { execution.setVariable("contrailServiceInstanceFqdn", "newContrailServiceInstanceFqdn"); doNothing().when(aaiVfModuleResources).updateContrailServiceInstanceFqdnVfModule(vfModule, genericVnf); @@ -715,13 +749,13 @@ public class AAIUpdateTasksTest extends BaseTaskTest { } @Test - public void updateContrailServiceInstanceFqdnVfModuleNoUpdateTest() throws Exception { + public void updateContrailServiceInstanceFqdnVfModuleNoUpdateTest() { aaiUpdateTasks.updateContrailServiceInstanceFqdnVfModule(execution); verify(aaiVfModuleResources, times(0)).updateContrailServiceInstanceFqdnVfModule(vfModule, genericVnf); } @Test - public void updateIpv4OamAddressVnfTest() throws Exception { + public void updateIpv4OamAddressVnfTest() { execution.setVariable("oamManagementV4Address", "newIpv4OamAddress"); doNothing().when(aaiVnfResources).updateObjectVnf(genericVnf); @@ -732,13 +766,13 @@ public class AAIUpdateTasksTest extends BaseTaskTest { } @Test - public void updateIpv4OamAddressVnfNoUpdateTest() throws Exception { + public void updateIpv4OamAddressVnfNoUpdateTest() { aaiUpdateTasks.updateIpv4OamAddressVnf(execution); verify(aaiVnfResources, times(0)).updateObjectVnf(genericVnf); } @Test - public void updateManagementV6AddressVnfTest() throws Exception { + public void updateManagementV6AddressVnfTest() { execution.setVariable("oamManagementV6Address", "newManagementV6Address"); doNothing().when(aaiVnfResources).updateObjectVnf(genericVnf); @@ -749,13 +783,13 @@ public class AAIUpdateTasksTest extends BaseTaskTest { } @Test - public void updateManagementV6AddressVnfNoUpdateTest() throws Exception { + public void updateManagementV6AddressVnfNoUpdateTest() { aaiUpdateTasks.updateManagementV6AddressVnf(execution); verify(aaiVnfResources, times(0)).updateObjectVnf(genericVnf); } @Test - public void updateOrchestrationStatusVnfConfigureTest() throws Exception { + public void updateOrchestrationStatusVnfConfigureTest() { doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.CONFIGURE); @@ -763,7 +797,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest { } @Test - public void updateOrchestrationStatusVnfConfiguredTest() throws Exception { + public void updateOrchestrationStatusVnfConfiguredTest() { doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.CONFIGURED); @@ -777,7 +811,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest { } @Test - public void updateOrchestrationStatusVnfConfigAssignedTest() throws Exception { + public void updateOrchestrationStatusVnfConfigAssignedTest() { doNothing().when(aaiVnfResources).updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.CONFIGASSIGNED); aaiUpdateTasks.updateOrchestrationStatus(execution, "vnf", "config-assign"); @@ -786,7 +820,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest { } @Test - public void updateOrchestrationStatusVnfConfigDeployedTest() throws Exception { + public void updateOrchestrationStatusVnfConfigDeployedTest() { doNothing().when(aaiVnfResources).updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.CONFIGDEPLOYED); aaiUpdateTasks.updateOrchestrationStatus(execution, "vnf", "config-deploy"); @@ -795,7 +829,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest { } @Test - public void updateOrchestrationStatusVfModuleConfigDeployedTest() throws Exception { + public void updateOrchestrationStatusVfModuleConfigDeployedTest() { doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.CONFIGDEPLOYED); aaiUpdateTasks.updateOrchestrationStatus(execution, "vfmodule", "config-deploy"); @@ -804,7 +838,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest { } @Test - public void updateOrchestrationStatusVfModuleConfigAssignedTest() throws Exception { + public void updateOrchestrationStatusVfModuleConfigAssignedTest() { doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.CONFIGASSIGNED); aaiUpdateTasks.updateOrchestrationStatus(execution, "vfmodule", "config-assign"); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterCreateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterCreateTasksTest.java index 60bed17447..9e70a66b76 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterCreateTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterCreateTasksTest.java @@ -31,11 +31,14 @@ import java.util.Map; import java.util.Optional; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; import org.mockito.ArgumentMatchers; import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.so.adapters.nwrest.CreateNetworkRequest; import org.onap.so.adapters.nwrest.CreateNetworkResponse; -import org.onap.so.bpmn.BaseTaskTest; +import org.onap.so.bpmn.common.data.TestDataSetup; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; @@ -43,9 +46,20 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; +import org.onap.so.client.adapter.network.mapper.NetworkAdapterObjectMapper; import org.onap.so.client.exception.BBObjectNotFoundException; +import org.onap.so.client.orchestration.NetworkAdapterResources; -public class NetworkAdapterCreateTasksTest extends BaseTaskTest { +@RunWith(MockitoJUnitRunner.Silent.class) +public class NetworkAdapterCreateTasksTest extends TestDataSetup { + + @Mock + protected ExtractPojosForBB extractPojosForBB; + @Mock + protected NetworkAdapterObjectMapper networkAdapterObjectMapper; + @Mock + protected NetworkAdapterResources networkAdapterResources; @InjectMocks private NetworkAdapterCreateTasks networkAdapterCreateTasks = new NetworkAdapterCreateTasks(); @@ -77,7 +91,7 @@ public class NetworkAdapterCreateTasksTest extends BaseTaskTest { } @Test - public void createNetworkTest() throws Exception { + public void createNetworkTest() { String cloudRegionPo = "cloudRegionPo"; CreateNetworkRequest createNetworkRequest = new CreateNetworkRequest(); execution.setVariable("cloudRegionPo", cloudRegionPo); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterDeleteTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterDeleteTasksTest.java index eb481651f0..6c9ec5932e 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterDeleteTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterDeleteTasksTest.java @@ -27,27 +27,36 @@ 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.io.UnsupportedEncodingException; import org.camunda.bpm.engine.delegate.BpmnError; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; import org.mockito.ArgumentMatchers; import org.mockito.InjectMocks; import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.so.adapters.nwrest.DeleteNetworkRequest; -import org.onap.so.bpmn.BaseTaskTest; import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.data.TestDataSetup; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; 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.adapter.network.NetworkAdapterClientException; +import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; +import org.onap.so.client.adapter.network.mapper.NetworkAdapterObjectMapper; import org.onap.so.client.exception.BBObjectNotFoundException; +import org.onap.so.client.exception.ExceptionBuilder; +@RunWith(MockitoJUnitRunner.Silent.class) +public class NetworkAdapterDeleteTasksTest extends TestDataSetup { -public class NetworkAdapterDeleteTasksTest extends BaseTaskTest { - + @Mock + protected ExtractPojosForBB extractPojosForBB; + @Mock + protected ExceptionBuilder exceptionUtil; + @Mock + protected NetworkAdapterObjectMapper networkAdapterObjectMapper; @InjectMocks private NetworkAdapterDeleteTasks networkAdapterDeleteTasks = new NetworkAdapterDeleteTasks(); @@ -72,7 +81,7 @@ public class NetworkAdapterDeleteTasksTest extends BaseTaskTest { } @Test - public void test_deleteNetwork() throws UnsupportedEncodingException, NetworkAdapterClientException { + public void test_deleteNetwork() { DeleteNetworkRequest deleteNetworkRequest = new DeleteNetworkRequest(); doReturn(deleteNetworkRequest).when(networkAdapterObjectMapper).deleteNetworkRequestMapper(requestContext, cloudRegion, serviceInstance, l3Network); @@ -83,7 +92,7 @@ public class NetworkAdapterDeleteTasksTest extends BaseTaskTest { } @Test - public void test_deleteNetwork_exception() throws UnsupportedEncodingException, NetworkAdapterClientException { + public void test_deleteNetwork_exception() { expectedException.expect(BpmnError.class); doThrow(RuntimeException.class).when(networkAdapterObjectMapper).deleteNetworkRequestMapper( diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterImplTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterImplTest.java index 10cc09cdcc..cf97fa0b82 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterImplTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterImplTest.java @@ -5,13 +5,20 @@ import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; import static org.junit.Assert.assertNotNull; import javax.xml.bind.JAXBException; import org.junit.Test; +import org.junit.runner.RunWith; import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.so.FileUtil; import org.onap.so.adapters.nwrest.CreateNetworkResponse; -import org.onap.so.bpmn.BaseTaskTest; +import org.onap.so.bpmn.common.data.TestDataSetup; +import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; -public class NetworkAdapterImplTest extends BaseTaskTest { +@RunWith(MockitoJUnitRunner.Silent.class) +public class NetworkAdapterImplTest extends TestDataSetup { + @Mock + protected ExtractPojosForBB extractPojosForBB; @InjectMocks private NetworkAdapterImpl networkAdapterImpl = new NetworkAdapterImpl(); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterUpdateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterUpdateTasksTest.java index 64a315ad4d..082d410f96 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterUpdateTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterUpdateTasksTest.java @@ -21,28 +21,22 @@ package org.onap.so.bpmn.infrastructure.adapter.network.tasks; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.isA; 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.io.UnsupportedEncodingException; import java.util.Map; -import java.util.Optional; -import org.camunda.bpm.engine.delegate.BpmnError; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; import org.mockito.ArgumentMatchers; import org.mockito.InjectMocks; -import org.onap.so.adapters.nwrest.CreateNetworkRequest; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.so.adapters.nwrest.UpdateNetworkRequest; -import org.onap.so.adapters.nwrest.UpdateNetworkResponse; -import org.onap.so.bpmn.BaseTaskTest; -import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.data.TestDataSetup; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; @@ -50,11 +44,16 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; -import org.onap.so.client.adapter.network.NetworkAdapterClientException; +import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; +import org.onap.so.client.adapter.network.mapper.NetworkAdapterObjectMapper; import org.onap.so.client.exception.BBObjectNotFoundException; -import org.springframework.beans.factory.annotation.Autowired; -public class NetworkAdapterUpdateTasksTest extends BaseTaskTest { +@RunWith(MockitoJUnitRunner.Silent.class) +public class NetworkAdapterUpdateTasksTest extends TestDataSetup { + @Mock + protected ExtractPojosForBB extractPojosForBB; + @Mock + protected NetworkAdapterObjectMapper networkAdapterObjectMapper; @InjectMocks private NetworkAdapterUpdateTasks networkAdapterUpdateTasks = new NetworkAdapterUpdateTasks(); @@ -84,7 +83,7 @@ public class NetworkAdapterUpdateTasksTest extends BaseTaskTest { } @Test - public void updateNetworkTest() throws Exception { + public void updateNetworkTest() { String cloudRegionPo = "cloudRegionPo"; UpdateNetworkRequest updateNetworkRequest = new UpdateNetworkRequest(); execution.setVariable("cloudRegionPo", cloudRegionPo); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterCreateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterCreateTasksTest.java index 13f2b81fd9..ef2e742795 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterCreateTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterCreateTasksTest.java @@ -30,12 +30,15 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import org.camunda.bpm.engine.delegate.BpmnError; import org.junit.Test; +import org.junit.runner.RunWith; import org.mockito.ArgumentMatchers; import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.so.adapters.vnfrest.CreateVfModuleRequest; import org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest; -import org.onap.so.bpmn.BaseTaskTest; import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.data.TestDataSetup; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; @@ -44,9 +47,22 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; +import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.so.client.orchestration.VnfAdapterVfModuleResources; +import org.onap.so.client.orchestration.VnfAdapterVolumeGroupResources; import org.onap.so.db.catalog.beans.OrchestrationStatus; -public class VnfAdapterCreateTasksTest extends BaseTaskTest { +@RunWith(MockitoJUnitRunner.Silent.class) +public class VnfAdapterCreateTasksTest extends TestDataSetup { + @Mock + protected ExceptionBuilder exceptionUtil; + @Mock + protected ExtractPojosForBB extractPojosForBB; + @Mock + protected VnfAdapterVolumeGroupResources vnfAdapterVolumeGroupResources; + @Mock + protected VnfAdapterVfModuleResources vnfAdapterVfModuleResources; @InjectMocks private VnfAdapterCreateTasks vnfAdapterCreateTasks = new VnfAdapterCreateTasks(); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterDeleteTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterDeleteTasksTest.java index c680978953..e7b3d3e403 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterDeleteTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterDeleteTasksTest.java @@ -31,12 +31,15 @@ import static org.mockito.Mockito.when; import org.camunda.bpm.engine.delegate.BpmnError; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; import org.mockito.ArgumentMatchers; import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.so.adapters.vnfrest.DeleteVfModuleRequest; import org.onap.so.adapters.vnfrest.DeleteVolumeGroupRequest; -import org.onap.so.bpmn.BaseTaskTest; import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.data.TestDataSetup; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; @@ -45,8 +48,22 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; - -public class VnfAdapterDeleteTasksTest extends BaseTaskTest { +import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; +import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.so.client.orchestration.VnfAdapterVfModuleResources; +import org.onap.so.client.orchestration.VnfAdapterVolumeGroupResources; + +@RunWith(MockitoJUnitRunner.Silent.class) +public class VnfAdapterDeleteTasksTest extends TestDataSetup { + + @Mock + protected ExceptionBuilder exceptionUtil; + @Mock + protected ExtractPojosForBB extractPojosForBB; + @Mock + protected VnfAdapterVfModuleResources vnfAdapterVfModuleResources; + @Mock + protected VnfAdapterVolumeGroupResources vnfAdapterVolumeGroupResources; @InjectMocks private VnfAdapterDeleteTasks vnfAdapterDeleteTasks = new VnfAdapterDeleteTasks(); 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 16e8c2de7d..51bd77065b 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 @@ -30,22 +30,30 @@ import static org.mockito.Mockito.when; import org.camunda.bpm.engine.delegate.BpmnError; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; import org.mockito.ArgumentMatchers; import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.so.FileUtil; -import org.onap.so.bpmn.BaseTaskTest; import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.data.TestDataSetup; 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; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; import org.onap.so.client.exception.BBObjectNotFoundException; -import org.springframework.beans.factory.annotation.Autowired; - -public class VnfAdapterImplTest extends BaseTaskTest { - +import org.onap.so.client.exception.ExceptionBuilder; + +@RunWith(MockitoJUnitRunner.Silent.class) +public class VnfAdapterImplTest extends TestDataSetup { + @Mock + protected ExceptionBuilder exceptionUtil; + @Mock + protected ExtractPojosForBB extractPojosForBB; @InjectMocks private VnfAdapterImpl vnfAdapterImpl = new VnfAdapterImpl(); @@ -159,12 +167,12 @@ public class VnfAdapterImplTest extends BaseTaskTest { execution.setVariable("WorkflowResponse", 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("", 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")); } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessorTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessorTest.java index d7d6da209e..ad965373dc 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessorTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessorTest.java @@ -34,13 +34,16 @@ import java.nio.file.Paths; import java.util.ArrayList; import java.util.Optional; import org.junit.Test; +import org.junit.runner.RunWith; import org.mockito.ArgumentMatchers; import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.aai.domain.yang.Vserver; import org.onap.appc.client.lcm.model.Action; import org.onap.so.appc.orchestrator.service.beans.ApplicationControllerTaskRequest; import org.onap.so.appc.orchestrator.service.beans.ApplicationControllerVnf; -import org.onap.so.bpmn.BaseTaskTest; +import org.onap.so.bpmn.common.data.TestDataSetup; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; @@ -48,14 +51,23 @@ import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters; import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; +import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; +import org.onap.so.client.orchestration.AAIVnfResources; import org.onap.so.client.policy.JettisonStyleMapperProvider; import org.onap.so.db.catalog.beans.ControllerSelectionReference; import com.fasterxml.jackson.databind.ObjectMapper; +import org.onap.so.db.catalog.client.CatalogDbClient; -public class AppcOrchestratorPreProcessorTest extends BaseTaskTest { +@RunWith(MockitoJUnitRunner.Silent.class) +public class AppcOrchestratorPreProcessorTest extends TestDataSetup { private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/"; - + @Mock + protected ExtractPojosForBB extractPojosForBB; + @Mock + protected AAIVnfResources aaiVnfResources; + @Mock + protected CatalogDbClient catalogDbClient; @InjectMocks private AppcOrchestratorPreProcessor appcOrchestratorPreProcessor = new AppcOrchestratorPreProcessor(); @@ -111,7 +123,7 @@ public class AppcOrchestratorPreProcessorTest extends BaseTaskTest { } @Test - public void addVmInfoToAppcTaskRequestTest() throws Exception { + public void addVmInfoToAppcTaskRequestTest() { ApplicationControllerTaskRequest appcTaskRequest = new ApplicationControllerTaskRequest(); ApplicationControllerVnf applicationControllerVnf = new ApplicationControllerVnf(); appcTaskRequest.setApplicationControllerVnf(applicationControllerVnf); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksTest.java index d2a38cb693..e386dff4a1 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksTest.java @@ -37,25 +37,43 @@ import java.util.HashMap; import java.util.Map; import java.util.Optional; import org.junit.Test; +import org.junit.runner.RunWith; import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.aai.domain.yang.Vserver; import org.onap.appc.client.lcm.model.Action; -import org.onap.so.bpmn.BaseTaskTest; import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.data.TestDataSetup; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; +import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; +import org.onap.so.client.appc.ApplicationControllerAction; import org.onap.so.client.exception.BBObjectNotFoundException; +import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.so.client.orchestration.AAIVnfResources; import org.onap.so.db.catalog.beans.ControllerSelectionReference; import com.fasterxml.jackson.databind.ObjectMapper; +import org.onap.so.db.catalog.client.CatalogDbClient; -public class AppcRunTasksTest extends BaseTaskTest { +@RunWith(MockitoJUnitRunner.Silent.class) +public class AppcRunTasksTest extends TestDataSetup { private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/"; - + @Mock + protected ExtractPojosForBB extractPojosForBB; + @Mock + protected CatalogDbClient catalogDbClient; + @Mock + protected ExceptionBuilder exceptionUtil; + @Mock + protected ApplicationControllerAction appCClient; + @Mock + protected AAIVnfResources aaiVnfResources; @InjectMocks private AppcRunTasks appcRunTasks = new AppcRunTasks(); @@ -171,7 +189,7 @@ public class AppcRunTasksTest extends BaseTaskTest { } @Test - public void testUserParams() throws Exception { + public void testUserParams() { Map userParams = new HashMap(); userParams.put("existing_software_version", "3.1"); userParams.put("new_software_version", "3.2"); 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 cbb746d514..2e4d99f9c6 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 @@ -35,6 +35,8 @@ import static org.mockito.Mockito.doReturn; 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.Collections; import java.util.ArrayList; import java.util.List; import java.util.Optional; @@ -64,6 +66,7 @@ import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds; +import org.onap.so.db.catalog.beans.BuildingBlockRollback; import org.onap.so.db.catalog.beans.ConfigurationResource; import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization; import org.onap.so.db.catalog.beans.VnfResourceCustomization; @@ -108,6 +111,11 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { @Mock private DelegateExecution mockExecution; + @Before + public void initCatalogDBRollbackTable() { + when(catalogDbClient.getBuildingBlockRollbackEntries()).thenReturn(getRollbackBuildingBlockList()); + } + @Before public void before() throws Exception { execution = new DelegateExecutionFake(); @@ -613,6 +621,52 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { assertEquals(2, ebbs.size()); } + @Test + public void rollbackExecutionRollbackControllerExecutionBBTest() { + execution.setVariable("isRollback", false); + execution.setVariable("handlingCode", "Rollback"); + execution.setVariable("requestAction", EMPTY_STRING); + execution.setVariable("resourceName", EMPTY_STRING); + List flowsToExecute = new ArrayList<>(); + BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignServiceInstanceBB"); + ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1); + flowsToExecute.add(ebb1); + + BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("AssignNetworkBB"); + ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2); + flowsToExecute.add(ebb2); + + BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("AssignVnfBB"); + ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3); + flowsToExecute.add(ebb3); + + BuildingBlock buildingBlock4 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB"); + ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock4); + flowsToExecute.add(ebb4); + + BuildingBlock buildingBlock5 = new BuildingBlock().setBpmnFlowName("ControllerExecutionBB"); + buildingBlock5.setBpmnScope("vnf"); + buildingBlock5.setBpmnAction("config-assign"); + ExecuteBuildingBlock ebb5 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock5); + flowsToExecute.add(ebb5); + + BuildingBlock buildingBlock6 = new BuildingBlock().setBpmnFlowName("CreateVfModuleBB"); + ExecuteBuildingBlock ebb6 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock6); + flowsToExecute.add(ebb6); + + execution.setVariable("flowsToExecute", flowsToExecute); + execution.setVariable("gCurrentSequence", 5); + + workflowActionBBTasks.rollbackExecutionPath(execution); + List ebbs = (List) execution.getVariable("flowsToExecute"); + BuildingBlock bb = ebbs.get(0).getBuildingBlock(); + assertEquals("ControllerExecutionBB", bb.getBpmnFlowName()); + assertEquals("vnf", bb.getBpmnScope()); + assertEquals("config-unassign", bb.getBpmnAction()); + assertEquals(0, execution.getVariable("gCurrentSequence")); + assertEquals(5, ebbs.size()); + } + @Test public void postProcessingExecuteBBActivateVfModuleNotReplaceInstanceTest() throws CloneNotSupportedException { WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); @@ -1061,4 +1115,40 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { execution.setVariable("homing", false); execution.setVariable("calledHoming", false); } + + private List getRollbackBuildingBlockList() { + List rollbackBBList = Collections.unmodifiableList(Arrays.asList( + new BuildingBlockRollback(1, "ActivateNetworkBB", null, "DeactivateNetworkBB", null), + new BuildingBlockRollback(2, "ActivatePnfBB", null, "DeactivatePnfBB", null), + new BuildingBlockRollback(3, "ActivateServiceInstanceBB", null, "DeactivateServiceInstanceBB", null), + new BuildingBlockRollback(4, "ActivateVfModuleBB", null, "DeactivateVfModuleBB", null), + new BuildingBlockRollback(5, "ActivateVnfBB", null, "DeactivateVnfBB", null), + new BuildingBlockRollback(6, "ActivateVolumeGroupBB", null, "DeactivateVolumeGroupBB", null), + new BuildingBlockRollback(7, "AssignNetworkBB", null, "UnassignNetworkBB", null), + new BuildingBlockRollback(8, "AssignServiceInstanceBB", null, "UnassignServiceInstanceBB", null), + new BuildingBlockRollback(9, "AssignVfModuleBB", null, "UnassignVfModuleBB", null), + new BuildingBlockRollback(10, "AssignVnfBB", null, "UnassignVnfBB", null), + new BuildingBlockRollback(11, "AssignVolumeGroupBB", null, "UnassignVolumeGroupBB", null), + new BuildingBlockRollback(12, "ControllerExecutionBB", "config-assign", "ControllerExecutionBB", + "config-unassign"), + new BuildingBlockRollback(13, "ControllerExecutionBB", "config-deploy", "ControllerExecutionBB", + "config-undeploy"), + new BuildingBlockRollback(14, "ControllerExecutionBB", "service-config-deploy", "ControllerExecutionBB", + "service-config-undeploy"), + new BuildingBlockRollback(15, "CreateNetworkBB", null, "DeleteNetworkBB", null), + new BuildingBlockRollback(16, "CreateNetworkCollectionBB", null, "DeleteNetworkCollectionBB", null), + new BuildingBlockRollback(17, "CreateVfModuleBB", null, "DeleteVfModuleBB", null), + new BuildingBlockRollback(18, "CreateVolumeGroupBB", null, "DeleteVolumeGroupBB", null), + new BuildingBlockRollback(19, "VNFSetInMaintFlagActivity", null, "VNFUnsetInMaintFlagActivity", null), + new BuildingBlockRollback(20, "VNFSetClosedLoopDisabledFlagActivity", null, + "VNFUnsetClosedLoopDisabledFlagActivity", null), + new BuildingBlockRollback(21, "VNFLockActivity", null, "VNFUnlockActivity", null), + new BuildingBlockRollback(22, "VNFStopActivity", null, "VNFStartActivity", null), + new BuildingBlockRollback(23, "VNFQuiesceTrafficActivity", null, "VNFResumeTrafficActivity", null), + new BuildingBlockRollback(24, "EtsiVnfInstantiateBB", null, "EtsiVnfDeleteBB", null), + // AddFabricConfigurationBB this does not seem to be present as a bpmn in Guilin + new BuildingBlockRollback(25, "AddFabricConfigurationBB", null, "DeleteFabricConfigurationBB", null))); + return rollbackBBList; + } + } 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 52196aae49..a044944f29 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 @@ -409,6 +409,10 @@ public class WorkflowActionTest extends BaseTaskTest { serviceInstanceMSO.getVnfs().add(vnf); + VfModule aaiVfModule = new VfModule(); + aaiVfModule.setIsBaseVfModule(false); + + doReturn(aaiVfModule).when(bbSetupUtils).getAAIVfModule(any(), any()); doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById("si0"); doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI); doReturn(Mockito.mock(GenericVnf.class)).when(bbSetupUtils).getAAIGenericVnf(any()); @@ -932,6 +936,10 @@ public class WorkflowActionTest extends BaseTaskTest { serviceInstanceMSO.getVnfs().add(vnf); serviceInstanceMSO.getPnfs().add(pnf); + VfModule aaiVfModule = new VfModule(); + aaiVfModule.setIsBaseVfModule(false); + + doReturn(aaiVfModule).when(bbSetupUtils).getAAIVfModule(any(), any()); doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById("123"); doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI); doReturn(Mockito.mock(GenericVnf.class)).when(bbSetupUtils).getAAIGenericVnf(any()); @@ -1013,6 +1021,10 @@ public class WorkflowActionTest extends BaseTaskTest { serviceInstanceMSO.getVnfs().add(vnf); + VfModule aaiVfModule = new VfModule(); + aaiVfModule.setIsBaseVfModule(false); + + doReturn(aaiVfModule).when(bbSetupUtils).getAAIVfModule(any(), any()); doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById("123"); doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI); doReturn(Mockito.mock(GenericVnf.class)).when(bbSetupUtils).getAAIGenericVnf(any()); @@ -1104,6 +1116,11 @@ public class WorkflowActionTest extends BaseTaskTest { serviceInstanceMSO.getVnfs().add(vnf); + org.onap.aai.domain.yang.VfModule aaiVfModule = new org.onap.aai.domain.yang.VfModule(); + aaiVfModule.setIsBaseVfModule(false); + + doReturn(aaiVfModule).when(bbSetupUtils).getAAIVfModule(any(), any()); + doReturn(new org.onap.aai.domain.yang.GenericVnf()).when(bbSetupUtils).getAAIGenericVnf(vnf.getVnfId()); doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById("123"); doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI); when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, @@ -1151,21 +1168,26 @@ public class WorkflowActionTest extends BaseTaskTest { vfModule2.setVfModuleId("vfModule2"); vnf.getVfModules().add(vfModule2); serviceInstanceMSO.getVnfs().add(vnf); - VfModule vfModuleAAI = new VfModule(); - vfModuleAAI.setVfModuleId("vfModule2"); + VfModule vfModuleAAI1 = new VfModule(); + vfModuleAAI1.setIsBaseVfModule(false); + VfModule vfModuleAAI2 = new VfModule(); + vfModuleAAI2.setIsBaseVfModule(false); + vfModuleAAI2.setVfModuleId("vfModule2"); RelationshipList relationshipList = new RelationshipList(); Relationship relationship = new Relationship(); relationshipList.getRelationship().add(relationship); - vfModuleAAI.setRelationshipList(relationshipList); + vfModuleAAI2.setRelationshipList(relationshipList); Relationships relationships = new Relationships("abc"); Configuration config = new Configuration(); config.setConfigurationId("configId"); Optional configOp = Optional.of(config); Optional relationshipsOp = Optional.of(relationships); + doReturn(new org.onap.aai.domain.yang.GenericVnf()).when(bbSetupUtils).getAAIGenericVnf(vnf.getVnfId()); doReturn(relationshipsOp).when(workflowActionUtils).extractRelationshipsVnfc(isA(Relationships.class)); doReturn(configOp).when(workflowActionUtils).extractRelationshipsConfiguration(isA(Relationships.class)); - doReturn(vfModuleAAI).when(bbSetupUtils).getAAIVfModule("1234", "vfModule2"); + doReturn(vfModuleAAI1).when(bbSetupUtils).getAAIVfModule("1234", "vfModule1"); + doReturn(vfModuleAAI2).when(bbSetupUtils).getAAIVfModule("1234", "vfModule2"); doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById("123"); doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI); when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoaderTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoaderTest.java index 9377daea5e..2d41a24ac3 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoaderTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoaderTest.java @@ -243,6 +243,9 @@ public class ServiceEBBLoaderTest extends BaseTaskTest { aaiConfiguration2.setConfigurationId("testConfigurationId2"); aaiConfiguration2.setRelationshipList(relationshipList1); + org.onap.aai.domain.yang.VfModule aaiVfModule = new org.onap.aai.domain.yang.VfModule(); + aaiVfModule.setIsBaseVfModule(true); + try { doReturn(genericVnfAai).when(mockBbInputSetupUtils).getAAIGenericVnf(genericVnf.getVnfId()); doReturn(serviceInstanceAAI).when(mockBbInputSetupUtils).getAAIServiceInstanceById(resourceId); @@ -251,6 +254,7 @@ public class ServiceEBBLoaderTest extends BaseTaskTest { .getConfiguration("testConfigurationId"); doReturn(Optional.of(aaiConfiguration2)).when(mockAaiConfigurationResources) .getConfiguration("testConfigurationId2"); + doReturn(aaiVfModule).when(mockBbInputSetupUtils).getAAIVfModule(any(), any()); serviceEBBLoader.traverseAAIService(execution, resourceCounter, resourceId, aaiResourceIds); assertEquals(8, resourceCounter.size()); assertTrue(resourceCounter.get(2).isBaseVfModule()); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoaderTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoaderTest.java index 78a9628243..2775c6d7b9 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoaderTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoaderTest.java @@ -47,12 +47,14 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.only; public class VnfEBBLoaderTest { private String serviceId; private String vnfId; + private String vfModuleId; private BBInputSetupUtils bbInputSetupUtils; private BBInputSetup bbInputSetup; private WorkflowActionExtractResourcesAAI workflowActionUtils; @@ -67,6 +69,7 @@ public class VnfEBBLoaderTest { public void setup() { serviceId = "service123"; vnfId = "vnf123"; + vfModuleId = "vfModule123"; serviceInstanceAAI = mock(org.onap.aai.domain.yang.ServiceInstance.class); serviceInstanceMSO = mock(ServiceInstance.class); bbInputSetupUtils = mock(BBInputSetupUtils.class); @@ -95,11 +98,19 @@ public class VnfEBBLoaderTest { GenericVnf genericVnf = mock(GenericVnf.class); doReturn(vnfId).when(genericVnf).getVnfId(); + org.onap.aai.domain.yang.GenericVnf aaiVnf = mock(org.onap.aai.domain.yang.GenericVnf.class); + doReturn(aaiVnf).when(bbInputSetupUtils).getAAIGenericVnf(vnfId); + VfModule vfModule = mock(VfModule.class); + doReturn(vfModuleId).when(vfModule).getVfModuleId(); ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule(); modelInfoVfModule.setIsBaseBoolean(true); doReturn(modelInfoVfModule).when(vfModule).getModelInfoVfModule(); + org.onap.aai.domain.yang.VfModule aaiVfModule = new org.onap.aai.domain.yang.VfModule(); + aaiVfModule.setIsBaseVfModule(true); + doReturn(aaiVfModule).when(bbInputSetupUtils).getAAIVfModule(vnfId, vfModuleId); + doReturn(serviceInstanceAAI).when(bbInputSetupUtils).getAAIServiceInstanceById(serviceId); doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI); doReturn(List.of(genericVnf)).when(serviceInstanceMSO).getVnfs(); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListenerTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListenerTest.java index b23147e351..1fbee2dbc8 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListenerTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListenerTest.java @@ -24,6 +24,7 @@ import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.when; import java.util.ArrayList; import java.util.List; +import java.util.UUID; import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake; import org.junit.Before; import org.junit.Test; @@ -34,6 +35,8 @@ import org.mockito.junit.MockitoJUnitRunner; import org.onap.so.bpmn.common.BBConstants; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.common.DelegateExecutionImpl; +import org.onap.so.bpmn.infrastructure.workflow.tasks.Resource; +import org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowType; import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.db.catalog.beans.PnfResourceCustomization; @@ -41,7 +44,6 @@ import org.onap.so.db.catalog.beans.Service; import org.onap.so.db.catalog.beans.VfModuleCustomization; import org.onap.so.db.catalog.beans.VnfResourceCustomization; import org.onap.so.db.catalog.client.CatalogDbClient; -import org.onap.so.serviceinstancebeans.ModelInfo; import org.onap.so.serviceinstancebeans.RequestDetails; @RunWith(MockitoJUnitRunner.Silent.class) @@ -51,25 +53,24 @@ public class SkipCDSBuildingBlockListenerTest { private static final String VNF_SCOPE = "VNF"; private static final String VF_SCOPE = "VFModule"; private static final String PNF_SCOPE = "pnf"; - private static final String TEST_MODELUUID = "123456789"; private static final String VNF_TEST_ACTION = "VnfConfigAssign"; private static final String VFModule_TEST_ACTION = "VfModuleConfigAssign"; private static final String PNFModule_TEST_ACTION = "config-assign"; - private static final String MODELCUSTOMIZATIONUUID = "123456789"; + private static final String SERVICE_MODEL_VERSION_ID = UUID.randomUUID().toString(); + private static final String VNF_MODEL_CUSTOMIZATION_ID = UUID.randomUUID().toString(); + private static final String VF_MODULE_CUSTOMIZATION_ID = UUID.randomUUID().toString(); + private static final String PNF_CUSTOMIZATION_ID = UUID.randomUUID().toString(); private static final String BBNAME = "ControllerExecutionBB"; private static final boolean ISFIRST = true; - private int actual; private List flowsToExecute = new ArrayList<>(); - private List vnfResourceCustomization; - private List vfModuleCustomization; - private ExecuteBuildingBlock executeBuildingBlock = new ExecuteBuildingBlock(); + private ExecuteBuildingBlock executeBuildingBlock; private RequestDetails reqDetail = new RequestDetails(); private BuildingBlockExecution buildingBlockExecution = new DelegateExecutionImpl(new DelegateExecutionFake()); - private VnfResourceCustomization vnfCust = new VnfResourceCustomization(); - private VfModuleCustomization vfCust = new VfModuleCustomization(); - private PnfResourceCustomization pnfResourceCustomization = new PnfResourceCustomization(); - private BuildingBlock buildingBlock = new BuildingBlock(); + private VnfResourceCustomization vnfCust; + private VfModuleCustomization vfCust; + private PnfResourceCustomization pnfResourceCustomization; + private BuildingBlock buildingBlock; @InjectMocks private SkipCDSBuildingBlockListener skipCDSBuildingBlockListener; @@ -78,10 +79,27 @@ public class SkipCDSBuildingBlockListenerTest { @Before public void before() { - ModelInfo model = new ModelInfo(); - model.setModelUuid(TEST_MODELUUID); - reqDetail.setModelInfo(model); - executeBuildingBlock.setRequestDetails(reqDetail); + executeBuildingBlock = new ExecuteBuildingBlock(); + buildingBlock = new BuildingBlock(); + + ArrayList resources = new ArrayList<>(); + Resource service = new Resource(WorkflowType.SERVICE, SERVICE_MODEL_VERSION_ID, false, null); + service.setModelVersionId(SERVICE_MODEL_VERSION_ID); + resources.add(service); + Resource vnf = new Resource(WorkflowType.VNF, VNF_MODEL_CUSTOMIZATION_ID, false, null); + vnf.setModelCustomizationId(VNF_MODEL_CUSTOMIZATION_ID); + resources.add(vnf); + Resource vfModule = new Resource(WorkflowType.VFMODULE, VF_MODULE_CUSTOMIZATION_ID, false, null); + vfModule.setModelCustomizationId(VF_MODULE_CUSTOMIZATION_ID); + resources.add(vfModule); + Resource pnf = new Resource(WorkflowType.PNF, PNF_CUSTOMIZATION_ID, false, null); + pnf.setModelCustomizationId(PNF_CUSTOMIZATION_ID); + resources.add(pnf); + buildingBlockExecution.setVariable("resources", resources); + + vnfCust = new VnfResourceCustomization(); + vfCust = new VfModuleCustomization(); + pnfResourceCustomization = new PnfResourceCustomization(); } @Test @@ -93,133 +111,83 @@ public class SkipCDSBuildingBlockListenerTest { @Test public void testSkipCDSforService() { - setBuildingBlockAndCurrentSequence(SERVICE_SCOPE, "service-config-assign", 0); - Service service = new Service(); - when(catalogDbClient.getServiceByID(TEST_MODELUUID)).thenReturn(service); + setBuildingBlockAndCurrentSequence(SERVICE_SCOPE, "service-config-assign", SERVICE_MODEL_VERSION_ID, 0); + when(catalogDbClient.getServiceByID(SERVICE_MODEL_VERSION_ID)).thenReturn(new Service()); skipCDSBuildingBlockListener.run(flowsToExecute, executeBuildingBlock, buildingBlockExecution); - actual = buildingBlockExecution.getVariable(BBConstants.G_CURRENT_SEQUENCE); - assertEquals(1, actual); + assertEquals(1, (int) buildingBlockExecution.getVariable(BBConstants.G_CURRENT_SEQUENCE)); } @Test public void testProcessForVNFToSkipCDSBB() { - // given - setBuildingBlockAndCurrentSequence(VNF_SCOPE, VNF_TEST_ACTION, 0); - vnfResourceCustomization = getVnfResourceCustomizationList(true); + setBuildingBlockAndCurrentSequence(VNF_SCOPE, VNF_TEST_ACTION, VNF_MODEL_CUSTOMIZATION_ID, 0); + when(catalogDbClient.getVnfResourceCustomizationByModelCustomizationUUID(VNF_MODEL_CUSTOMIZATION_ID)) + .thenReturn(vnfCust); - when(catalogDbClient.getVnfResourceCustomizationByModelUuid( - executeBuildingBlock.getRequestDetails().getModelInfo().getModelUuid())) - .thenReturn(vnfResourceCustomization); - when(catalogDbClient.findVnfResourceCustomizationInList(executeBuildingBlock.getBuildingBlock().getKey(), - vnfResourceCustomization)).thenReturn(vnfCust); - - // when skipCDSBuildingBlockListener.run(flowsToExecute, executeBuildingBlock, buildingBlockExecution); - // then - actual = buildingBlockExecution.getVariable(BBConstants.G_CURRENT_SEQUENCE); - assertEquals(1, actual); - + assertEquals(1, (int) buildingBlockExecution.getVariable(BBConstants.G_CURRENT_SEQUENCE)); } @Test public void testProcessForVNFNotToSkipCDSBB() { - // given - setBuildingBlockAndCurrentSequence(VNF_SCOPE, VNF_TEST_ACTION, 0); - vnfResourceCustomization = getVnfResourceCustomizationList(false); - - when(catalogDbClient.getVnfResourceCustomizationByModelUuid( - executeBuildingBlock.getRequestDetails().getModelInfo().getModelUuid())) - .thenReturn(vnfResourceCustomization); - when(catalogDbClient.findVnfResourceCustomizationInList(executeBuildingBlock.getBuildingBlock().getKey(), - vnfResourceCustomization)).thenReturn(vnfCust); + setBuildingBlockAndCurrentSequence(VNF_SCOPE, VNF_TEST_ACTION, VNF_MODEL_CUSTOMIZATION_ID, 0); + vnfCust.setSkipPostInstConf(false); + when(catalogDbClient.getVnfResourceCustomizationByModelCustomizationUUID(VNF_MODEL_CUSTOMIZATION_ID)) + .thenReturn(vnfCust); - // when skipCDSBuildingBlockListener.run(flowsToExecute, executeBuildingBlock, buildingBlockExecution); - // then - actual = buildingBlockExecution.getVariable(BBConstants.G_CURRENT_SEQUENCE); - assertEquals(0, actual); - + assertEquals(0, (int) buildingBlockExecution.getVariable(BBConstants.G_CURRENT_SEQUENCE)); } @Test public void testProcessForVFToSkipCDSBB() { - // given - setBuildingBlockAndCurrentSequence(VF_SCOPE, VFModule_TEST_ACTION, 0); - vfModuleCustomization = getVfModuleCustomizationList(true); - - when(catalogDbClient - .getVfModuleCustomizationByModelCuztomizationUUID(executeBuildingBlock.getBuildingBlock().getKey())) - .thenReturn(vfCust); + setBuildingBlockAndCurrentSequence(VF_SCOPE, VFModule_TEST_ACTION, VF_MODULE_CUSTOMIZATION_ID, 0); + when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID(VF_MODULE_CUSTOMIZATION_ID)) + .thenReturn(vfCust); - // when skipCDSBuildingBlockListener.run(flowsToExecute, executeBuildingBlock, buildingBlockExecution); - // then - actual = buildingBlockExecution.getVariable(BBConstants.G_CURRENT_SEQUENCE); - assertEquals(1, actual); - + assertEquals(1, (int) buildingBlockExecution.getVariable(BBConstants.G_CURRENT_SEQUENCE)); } @Test public void testProcessForVFNotToSkipCDSBB() { - // given - setBuildingBlockAndCurrentSequence(VF_SCOPE, VFModule_TEST_ACTION, 0); - vfModuleCustomization = getVfModuleCustomizationList(false); - + setBuildingBlockAndCurrentSequence(VF_SCOPE, VFModule_TEST_ACTION, VF_MODULE_CUSTOMIZATION_ID, 0); + vfCust.setSkipPostInstConf(false); when(catalogDbClient .getVfModuleCustomizationByModelCuztomizationUUID(executeBuildingBlock.getBuildingBlock().getKey())) .thenReturn(vfCust); - // when skipCDSBuildingBlockListener.run(flowsToExecute, executeBuildingBlock, buildingBlockExecution); - // then - actual = buildingBlockExecution.getVariable(BBConstants.G_CURRENT_SEQUENCE); - assertEquals(0, actual); - + assertEquals(0, (int) buildingBlockExecution.getVariable(BBConstants.G_CURRENT_SEQUENCE)); } @Test public void testProcessForPNFToSkipCDSBB() { - // given - setBuildingBlockAndCurrentSequence(PNF_SCOPE, PNFModule_TEST_ACTION, 0); - pnfResourceCustomization = getPnfResourceCustomization(true); - - when(catalogDbClient - .getPnfResourceCustomizationByModelCustomizationUUID(executeBuildingBlock.getBuildingBlock().getKey())) - .thenReturn(pnfResourceCustomization); + setBuildingBlockAndCurrentSequence(PNF_SCOPE, PNFModule_TEST_ACTION, PNF_CUSTOMIZATION_ID, 0); + when(catalogDbClient.getPnfResourceCustomizationByModelCustomizationUUID(PNF_CUSTOMIZATION_ID)) + .thenReturn(pnfResourceCustomization); - // when skipCDSBuildingBlockListener.run(flowsToExecute, executeBuildingBlock, buildingBlockExecution); - // then - actual = buildingBlockExecution.getVariable(BBConstants.G_CURRENT_SEQUENCE); - assertEquals(1, actual); - + assertEquals(1, (int) buildingBlockExecution.getVariable(BBConstants.G_CURRENT_SEQUENCE)); } @Test public void testProcessForPNFNotToSkipCDSBB() { - // given - setBuildingBlockAndCurrentSequence(PNF_SCOPE, PNFModule_TEST_ACTION, 0); - pnfResourceCustomization = getPnfResourceCustomization(false); - - when(catalogDbClient - .getPnfResourceCustomizationByModelCustomizationUUID(executeBuildingBlock.getBuildingBlock().getKey())) - .thenReturn(pnfResourceCustomization); + setBuildingBlockAndCurrentSequence(PNF_SCOPE, PNFModule_TEST_ACTION, PNF_CUSTOMIZATION_ID, 0); + pnfResourceCustomization.setSkipPostInstConf(false); + when(catalogDbClient.getPnfResourceCustomizationByModelCustomizationUUID(PNF_CUSTOMIZATION_ID)) + .thenReturn(pnfResourceCustomization); - // when skipCDSBuildingBlockListener.run(flowsToExecute, executeBuildingBlock, buildingBlockExecution); - // then - actual = buildingBlockExecution.getVariable(BBConstants.G_CURRENT_SEQUENCE); - assertEquals(0, actual); - + assertEquals(0, (int) buildingBlockExecution.getVariable(BBConstants.G_CURRENT_SEQUENCE)); } /** @@ -229,37 +197,13 @@ public class SkipCDSBuildingBlockListenerTest { * @param action * @param squence */ - private void setBuildingBlockAndCurrentSequence(String scope, String action, int sequence) { + private void setBuildingBlockAndCurrentSequence(String scope, String action, String key, int sequence) { buildingBlock.setBpmnScope(scope); buildingBlock.setBpmnAction(action); buildingBlock.setBpmnFlowName("ControllerExecutionBB"); - buildingBlock.setKey(MODELCUSTOMIZATIONUUID); + buildingBlock.setKey(key); executeBuildingBlock.setBuildingBlock(buildingBlock); buildingBlockExecution.setVariable(BBConstants.G_CURRENT_SEQUENCE, sequence); - - } - - private List getVnfResourceCustomizationList(boolean setSkippost) { - List vnfResourceCustomizations = new ArrayList<>(); - vnfCust.setModelCustomizationUUID(MODELCUSTOMIZATIONUUID); - vnfCust.setSkipPostInstConf(setSkippost); - vnfResourceCustomizations.add(vnfCust); - return vnfResourceCustomizations; - } - - private List getVfModuleCustomizationList(boolean setSkippost) { - List vfModuleCustomizations = new ArrayList<>(); - vfCust.setModelCustomizationUUID(MODELCUSTOMIZATIONUUID); - vfCust.setSkipPostInstConf(setSkippost); - vfModuleCustomizations.add(vfCust); - return vfModuleCustomizations; - } - - private PnfResourceCustomization getPnfResourceCustomization(boolean setSkippost) { - PnfResourceCustomization pnfResourceCustomization = new PnfResourceCustomization(); - pnfResourceCustomization.setModelCustomizationUUID(MODELCUSTOMIZATIONUUID); - pnfResourceCustomization.setSkipPostInstConf(setSkippost); - return pnfResourceCustomization; } } diff --git a/common/src/main/java/org/onap/so/beans/nsmf/ServiceInfo.java b/common/src/main/java/org/onap/so/beans/nsmf/ServiceInfo.java index 5146685058..df137d0c01 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/ServiceInfo.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/ServiceInfo.java @@ -56,4 +56,7 @@ public class ServiceInfo implements Serializable { private String pLMNIdList; private String actionType; + + private String resourceSharingLevel; + } diff --git a/common/src/main/java/org/onap/so/beans/nsmf/SliceProfileAdapter.java b/common/src/main/java/org/onap/so/beans/nsmf/SliceProfileAdapter.java index 7cc940ddde..2b315611ad 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/SliceProfileAdapter.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/SliceProfileAdapter.java @@ -176,6 +176,7 @@ public class SliceProfileAdapter implements Serializable { BeanUtils.copyProperties(this, tnSliceProfile); tnSliceProfile.setSNSSAIList(Arrays.asList(this.sNSSAIList.split("\\|"))); tnSliceProfile.setPLMNIdList(Arrays.asList(this.pLMNIdList.split("\\|"))); + tnSliceProfile.setResourceSharingLevel(ResourceSharingLevel.fromString(this.resourceSharingLevel)); return tnSliceProfile; } } diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/Service.java b/common/src/main/java/org/onap/so/serviceinstancebeans/Service.java index 14b1ab5974..90df220b52 100644 --- a/common/src/main/java/org/onap/so/serviceinstancebeans/Service.java +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/Service.java @@ -42,7 +42,7 @@ public class Service implements Serializable { @JsonProperty("instanceName") protected String instanceName; @JsonProperty("instanceParams") - private List> instanceParams = new ArrayList<>(); + private List> instanceParams = new ArrayList<>(); @JsonProperty("resources") protected Resources resources; @JsonProperty("processingPriority") @@ -73,11 +73,11 @@ public class Service implements Serializable { this.instanceName = instanceName; } - public List> getInstanceParams() { + public List> getInstanceParams() { return instanceParams; } - public void setInstanceParams(List> instanceParams) { + public void setInstanceParams(List> instanceParams) { this.instanceParams = instanceParams; } diff --git a/common/src/test/java/org/onap/so/client/HttpClientTest.java b/common/src/test/java/org/onap/so/client/HttpClientTest.java index e9e8fe7853..3966d183f7 100644 --- a/common/src/test/java/org/onap/so/client/HttpClientTest.java +++ b/common/src/test/java/org/onap/so/client/HttpClientTest.java @@ -97,4 +97,113 @@ public class HttpClientTest { postRequestedFor(urlEqualTo("/services/sdnc/post")).withHeader("Accept", equalTo("application/json"))); } + @Test + public void testPostUsingXmlClient_success() throws MalformedURLException { + + wireMockRule.stubFor(post(urlEqualTo("/services/sdnc/post")) + .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/xml").withBody(""))); + + URL url = new URL("http://localhost:" + wireMockRule.port() + "/services/sdnc/post"); + HttpClient client = httpClientFactory.newXmlClient(url, ONAPComponents.BPMN); + + client.addBasicAuthHeader( + "97FF88AB352DA16E00DDD81E3876431DEF8744465DACA489EB3B3BE1F10F63EDA1715E626D0A4827A3E19CD88421BF", + "123"); + client.addAdditionalHeader("Accept", "application/xml"); + + client.post("{}"); + + verify(exactly(1), postRequestedFor(urlEqualTo("/services/sdnc/post"))); + } + + @Test + public void testPostUsingXmlClient_nullHeader() throws MalformedURLException { + + wireMockRule.stubFor(post(urlEqualTo("/services/sdnc/post")) + .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/xml").withBody(""))); + + URL url = new URL("http://localhost:" + wireMockRule.port() + "/services/sdnc/post"); + HttpClient client = httpClientFactory.newXmlClient(url, ONAPComponents.BPMN); + + client.accept = "application/xml"; + client.addAdditionalHeader("id", null); + + client.post("{}"); + + verify(exactly(1), + postRequestedFor(urlEqualTo("/services/sdnc/post")).withHeader("Accept", equalTo("application/xml"))); + } + + @Test + public void testPostUsingXmlClient_nullBasicAuth() throws MalformedURLException { + + wireMockRule.stubFor(post(urlEqualTo("/services/sdnc/post")) + .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/xml").withBody(""))); + + URL url = new URL("http://localhost:" + wireMockRule.port() + "/services/sdnc/post"); + HttpClient client = httpClientFactory.newXmlClient(url, ONAPComponents.BPMN); + + client.accept = "application/xml"; + client.addBasicAuthHeader("", "12345"); + + client.post("{}"); + + verify(exactly(1), + postRequestedFor(urlEqualTo("/services/sdnc/post")).withHeader("Accept", equalTo("application/xml"))); + } + + @Test + public void testPostUsingTextXmlClient_success() throws MalformedURLException { + + wireMockRule.stubFor(post(urlEqualTo("/services/sdnc/post")) + .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml").withBody(""))); + + URL url = new URL("http://localhost:" + wireMockRule.port() + "/services/sdnc/post"); + HttpClient client = httpClientFactory.newTextXmlClient(url, ONAPComponents.BPMN); + + client.addBasicAuthHeader( + "97FF88AB352DA16E00DDD81E3876431DEF8744465DACA489EB3B3BE1F10F63EDA1715E626D0A4827A3E19CD88421BF", + "123"); + client.addAdditionalHeader("Accept", "text/xml"); + + client.post("{}"); + + verify(exactly(1), postRequestedFor(urlEqualTo("/services/sdnc/post"))); + } + + @Test + public void testPostUsingTextXmlClient_nullHeader() throws MalformedURLException { + + wireMockRule.stubFor(post(urlEqualTo("/services/sdnc/post")) + .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml").withBody(""))); + + URL url = new URL("http://localhost:" + wireMockRule.port() + "/services/sdnc/post"); + HttpClient client = httpClientFactory.newTextXmlClient(url, ONAPComponents.BPMN); + + client.addAdditionalHeader("Accept", "text/xml"); + client.addAdditionalHeader("id", null); + + client.post("{}"); + + verify(exactly(1), + postRequestedFor(urlEqualTo("/services/sdnc/post")).withHeader("Accept", equalTo("text/xml"))); + } + + @Test + public void testPostUsingTextXmlClient_nullBasicAuth() throws MalformedURLException { + + wireMockRule.stubFor(post(urlEqualTo("/services/sdnc/post")) + .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml").withBody(""))); + + URL url = new URL("http://localhost:" + wireMockRule.port() + "/services/sdnc/post"); + HttpClient client = httpClientFactory.newTextXmlClient(url, ONAPComponents.BPMN); + + client.addBasicAuthHeader("", "12345"); + client.addAdditionalHeader("Accept", "text/xml"); + + client.post("{}"); + + verify(exactly(1), + postRequestedFor(urlEqualTo("/services/sdnc/post")).withHeader("Accept", equalTo("text/xml"))); + } } diff --git a/common/src/test/java/org/onap/so/security/UserDetailsServiceImplTest.java b/common/src/test/java/org/onap/so/security/UserDetailsServiceImplTest.java new file mode 100644 index 0000000000..51de61a66a --- /dev/null +++ b/common/src/test/java/org/onap/so/security/UserDetailsServiceImplTest.java @@ -0,0 +1,45 @@ +package org.onap.so.security; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import java.util.ArrayList; +import org.junit.Test; +import java.util.List; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.security.core.userdetails.UsernameNotFoundException; + +public class UserDetailsServiceImplTest { + + private static final String USERNAME = "usernameTest"; + private static final String PASSWORD = "passTest"; + private static final String ROLE = "roleTest"; + + @Test + public void loadUserByUsername_Success() { + UserDetailsServiceImpl testedObject = new UserDetailsServiceImpl(); + testedObject.setUsercredentials(prepareUserCredentials()); + UserDetails result = testedObject.loadUserByUsername(USERNAME); + assertThat(result.getUsername()).isEqualTo(USERNAME); + assertThat(result.getPassword()).isEqualTo(PASSWORD); + } + + @Test + public void loadUserByUsername_userNotFoundEx() { + UserDetailsServiceImpl testedObject = new UserDetailsServiceImpl(); + testedObject.setUsercredentials(prepareUserCredentials()); + assertThatThrownBy(() -> testedObject.loadUserByUsername("notExistingUser")) + .isInstanceOf(UsernameNotFoundException.class); + } + + private List prepareUserCredentials() { + UserCredentials userCredentials = new UserCredentials(); + userCredentials.setUsername(USERNAME); + userCredentials.setPassword(PASSWORD); + userCredentials.setRole(ROLE); + List list = new ArrayList<>(); + list.add(userCredentials); + return list; + } + + +} diff --git a/docs/architecture/SO Internal Arc.pptx b/docs/architecture/SO Internal Arc.pptx index 3472b92a73..ccb7ee78ce 100644 Binary files a/docs/architecture/SO Internal Arc.pptx and b/docs/architecture/SO Internal Arc.pptx differ diff --git a/docs/architecture/architecture.rst b/docs/architecture/architecture.rst index d59429a366..7cfb276cf7 100644 --- a/docs/architecture/architecture.rst +++ b/docs/architecture/architecture.rst @@ -9,7 +9,7 @@ SO - Architecture SO Functional View ------------------ -.. image:: ../images/SO_Architecture_1.png +.. image:: ../images/SO_Architecture_2.png SO Deployment View -------------------- @@ -110,9 +110,22 @@ SO Sub-Components * Create, Instantiate, Terminate and Delete VNF, including Granting, Subscription and Lifecycle Notifications * Tracking capability which VNFM instance has handled with which VNF instance * BPMN Building Block workflows and Java-based recipes for VNF LCM + * Conformance of SOL001 VNFD and SOL004 VNF package specifications + * Interfacing with the ETSI Catalog Manager (a.k.a. etsicatalog) for retrieving ETSI VNF descriptors and artifacts * VNFM Simulator for validating SO VNFM Adapter NBI and SBI for integration testing - * The SO ETSI CSIT Tests and running them, https://wiki.onap.org/display/DW/SO+ETSI+CSIT - * Testing the SO ETSI Alignment manually (Instantiate VNF using SVNFM), https://wiki.onap.org/pages/viewpage.action?pageId=68524128 + +.. image:: ../images/SO-SOL003-Adapter-Architecture-1.png + +**SO ETSI NFVO** + + Support ETSI NFVO functions which manages Network Service LCM + * Create, Instantiate, Terminate and Delete NS + * Decomposing an NS request into associated VNF request(s) and managing VNF LCM (Create, Instantiate, Terminate, Delete VNF) through SO VNFMN Adapter + * Leveraging SOL005 for its NBI and SOl003 for its SBI + * Conformance of SOL001 NSD and SOL007 NS package specifications + * Interfacing with the ETSI Catalog Manager (a.k.a. etsicatalog) for retrieving ETSI NS descriptors and artifacts + +.. image:: ../images/SO-NFVO-Architecture-1.png Third Party and Open Source --------------------------- diff --git a/docs/developer_info/BPMN-INFRA_Workflow_Understanding.rst b/docs/developer_info/BPMN-INFRA_Workflow_Understanding.rst index b1ef356c35..3af3dc8dc9 100644 --- a/docs/developer_info/BPMN-INFRA_Workflow_Understanding.rst +++ b/docs/developer_info/BPMN-INFRA_Workflow_Understanding.rst @@ -16,8 +16,8 @@ curl -v -H "Content-Type: application/json" -X POST --data @request_body_file_na Request Body: - { - "service":{ + { + "service":{ "name":"SliceService", "description":"SliceService", "serviceInvariantUuid":"dfcd7471-16c7-444e-8268-d4c50d90593a", @@ -62,18 +62,18 @@ curl -v -H "Content-Type: application/json" -X POST --data @request_body_file_na "nstar0_allottedresource0_providing_service_invariant_uuid": "1899e5c1-df4e-43a8-a889-48c157dad7bc" } } - } + } .. code-block:: bash Response body: - { + { "service": { "serviceId": "ebe2d37f-f65b-43d8-8906-f81811ed8f22", "operationId": "ed9b4c84-17db-4874-8896-25324a0401fe" + } } - } Code flows: @@ -120,8 +120,8 @@ Payload will be reaching to bpmn in the form of: .. code-block:: bash - { - "variables": { + { + "variables": { "bpmnRequest": { "value": { "requestDetails": { @@ -305,8 +305,8 @@ Payload will be reaching to bpmn in the form of: "value": false, "type": "Boolean" } - } - } + } + } Based on the serviceUuid which is mentioned in the request body it will call the the CreateCommunicationService.bpmn file and This CreateCommunicationService.bpmn is taken as a example to this workflow Understanding which then call the subprocess of this flow and so on. @@ -349,8 +349,8 @@ Based on the serviceUuid which is mentioned in the request body it will call the .. code-block:: bash - { - "serviceResources": { + { + "serviceResources": { "modelInfo": { "modelName": "CST", "modelUuid": "bfc2775b-64ad-41e5-95fe-d3bc57df6c73", @@ -547,8 +547,8 @@ Based on the serviceUuid which is mentioned in the request body it will call the } ], "serviceAllottedResources": [] - } - } + } + } 5. CreateCommunicationService--> prepareDoComposeE2E() @@ -572,17 +572,17 @@ Based on the serviceUuid which is mentioned in the request body it will call the d. Request body for PUT request to the AAI from bpmn: -{ - "service-instance-name": "SliceService", - "service-role": "communication-service", - "environment-context": "01-70CAA6B", - "created-at": "2020-06-23 05:02:56", - "model-invariant-id": "d4df55ca-c985-46c9-8088-f952181f553e", - "model-version-id": "bfc2775b-64ad-41e5-95fe-d3bc57df6c73", - "orchestration-status": "processing", - "input-parameters": "{ \"service\":{ \"name\":\"SliceService\", \"description\":\"SliceService\", \"serviceInvariantUuid\":\"d4df55ca-c985-46c9-8088-f952181f553e\", \"serviceUuid\":\"bfc2775b-64ad-41e5-95fe-d3bc57df6c73\", \"globalSubscriberId\":\"5GCustomer\", \"serviceType\":\"5G\", \"parameters\":{ \"locationConstraints\":[ ], \"resources\":[ { \"resourceIndex\":\"1\", \"resourceName\":\"allottedResource\", \"resourceInvariantUuid\":\"eeefcd86-7b5b-41ae-9516-08acc5d59d92\", \"resourceUuid\":\"265da937-76c7-4152-98e3-5f0d0a844b7f\", \"resourceCustomizationUuid\":\"a4eda1d9-1af4-424b-997f-12c57b74c67a\", \"parameters\":{ \"locationConstraints\":[ ], \"resources\":[ ], \"requestInputs\":{ } } } ], \"requestInputs\":{\t\t\t \"sST\": \"embb\", \"sNSSAI\": \"1-10101\", \"uEMobilityLevel\": \"stationary\", \"areaTrafficCapDL\": 123, \"maxNumberofUEs\": 1000, \"expDataRateUL\": 2000, \"plmnIdList\": \"39-00|39-01\", \"areaTrafficCapUL\": 456, \"latency\": 300, \"expDataRateDL\": 400, \"coverageAreaTAList\": 101001, \"activityFactor\": 99, \"resourceSharingLevel\": \"shared\", \"nstar0_allottedresource0_providing_service_uuid\": \"4e8d930b-7483-4b9b-8c82-4708638ade4a\", \"nstar0_allottedresource0_providing_service_invariant_uuid\": \"1899e5c1-df4e-43a8-a889-48c157dad7bc\" } } }}" - -} + { + "service-instance-name": "SliceService", + "service-role": "communication-service", + "environment-context": "01-70CAA6B", + "created-at": "2020-06-23 05:02:56", + "model-invariant-id": "d4df55ca-c985-46c9-8088-f952181f553e", + "model-version-id": "bfc2775b-64ad-41e5-95fe-d3bc57df6c73", + "orchestration-status": "processing", + "input-parameters": "{ \"service\":{ \"name\":\"SliceService\", \"description\":\"SliceService\", \"serviceInvariantUuid\":\"d4df55ca-c985-46c9-8088-f952181f553e\", \"serviceUuid\":\"bfc2775b-64ad-41e5-95fe-d3bc57df6c73\", \"globalSubscriberId\":\"5GCustomer\", \"serviceType\":\"5G\", \"parameters\":{ \"locationConstraints\":[ ], \"resources\":[ { \"resourceIndex\":\"1\", \"resourceName\":\"allottedResource\", \"resourceInvariantUuid\":\"eeefcd86-7b5b-41ae-9516-08acc5d59d92\", \"resourceUuid\":\"265da937-76c7-4152-98e3-5f0d0a844b7f\", \"resourceCustomizationUuid\":\"a4eda1d9-1af4-424b-997f-12c57b74c67a\", \"parameters\":{ \"locationConstraints\":[ ], \"resources\":[ ], \"requestInputs\":{ } } } ], \"requestInputs\":{\t\t\t \"sST\": \"embb\", \"sNSSAI\": \"1-10101\", \"uEMobilityLevel\": \"stationary\", \"areaTrafficCapDL\": 123, \"maxNumberofUEs\": 1000, \"expDataRateUL\": 2000, \"plmnIdList\": \"39-00|39-01\", \"areaTrafficCapUL\": 456, \"latency\": 300, \"expDataRateDL\": 400, \"coverageAreaTAList\": 101001, \"activityFactor\": 99, \"resourceSharingLevel\": \"shared\", \"nstar0_allottedresource0_providing_service_uuid\": \"4e8d930b-7483-4b9b-8c82-4708638ade4a\", \"nstar0_allottedresource0_providing_service_invariant_uuid\": \"1899e5c1-df4e-43a8-a889-48c157dad7bc\" } } }}" + + } Response: Response is returned with an empty entity @@ -593,7 +593,7 @@ https://aai.onap:8443/aai/v19/business/customers/customer/5GCustomer/service-sub payload: -{"profile-id":"202a5e9a-d1d7-4afd-922f-3e7a709c780c","max-number-of-UEs":1000,"latency":300,"exp-data-rate-UL":2000,"exp-data-rate-DL":400,"ue-mobility-level":"stationary","resource-sharing-level":"shared"} + {"profile-id":"202a5e9a-d1d7-4afd-922f-3e7a709c780c","max-number-of-UEs":1000,"latency":300,"exp-data-rate-UL":2000,"exp-data-rate-DL":400,"ue-mobility-level":"stationary","resource-sharing-level":"shared"} Response: Response is returned with an empty entity @@ -603,13 +603,13 @@ Response: Response is returned with an empty entity b. Response Body: - { + { "service": { "serviceId":"8a95e3ac-32cd-4ffb-b9e3-5366b393a7a2", "operationId":"a970a804-7ac5-4de9-b6db-17352afbc6fa" - } + } 9. CreateCommunicationService--> generateE2EServiceProfile() @@ -641,11 +641,10 @@ Response: Response is returned with an empty entity b. Request body: - { + { "related-link":"aai/v16/business/customers/customer/5GCustomer/service-subscriptions/service- subscription/5G/service-instances/service-instance/2e6c2d7f-85c0-4b1f-b7fd-5f2364c27ea7" - - } + } 15. CreateCommunicationService--> prepareUpdateOperationStatus() diff --git a/docs/developer_info/CSIT_Macroflow_developer_info.rst b/docs/developer_info/CSIT_Macroflow_developer_info.rst new file mode 100644 index 0000000000..d8c52a4a71 --- /dev/null +++ b/docs/developer_info/CSIT_Macroflow_developer_info.rst @@ -0,0 +1,153 @@ +.. This work is licensed under a Creative Commons Attribution 4.0 International License. +.. http://creativecommons.org/licenses/by/4.0 +.. Copyright 2022 Huawei Technologies Co., Ltd. + +SO CSIT (Macroflow) +======================== + +Ensure you have a healthy ONAP Deployment running. The following components will be required/used as part of this guide: + +- SO +- SDC +- AAI +- DMAAP +- SDNC +- MultiCloud + +What is Macroflow? +----------------- + +The SO building blocks are a set of database-driven, configurable and generic process steps to be leveraged through several actions defined as 'Macro' flows. For each of the macro flows, there are a set of actions to be performed which are implemented as building blocks - which then implement generic logic to handle the orchestration of services and various type of resources orchestrated by ONAP, as well as their corresponding actions. + +**Macroflow** method allows the user to build and send only one request to instantiate all objects : Service, VNFs, VFModules and Networks. + +How to run CSIT Macroflow? +-------------------------- + +The follow steps are to be installed and run on an Ubuntu 18.04 (desktop) installation. +Later versions of Ubuntu and Java may work for the tests. + +**Prerequisite:** +Install Java 11, Maven, docker, docker-compose + +Following steps need to be followed to run the CSIT Macroflow: + +First pull the CSIT repo from Gerrit, either with or without the hooks + +… code-block:: + + git clone "https://gerrit.onap.org/r/integration/csit" +or + +.. code-block:: + + git clone "https://gerrit.onap.org/r/integration/csit" && (cd "csit" && mkdir -p .git/hooks && curl -Lo `git rev-parse --git-dir`/hooks/commit-msg https://gerrit.onap.org/r/tools/hooks/commit-msg; chmod +x `git rev-parse --git-dir`/hooks/commit-msg) + +Once this is downloaded a few more installations are required. + +Install pip (if required) + +.. code-block:: + + sudo apt install python-pip + +Install Robot Framework through pip + +.. code-block:: + + pip install robotframework + +Run Script + +Once all of this is done, then the tests should be run by calling the run-csit.sh script and giving it the location of our test folder (csit/plans/so/macroflow). + +From the csit projects root folder run the following command: + +.. code-block:: + + ./run-csit.sh plans/so/macroflow + +This should successfully run the CSIT Macroflow + +The run-csit.sh will automatically set up a Robot environment for you, and execute the test plan defined in the plans/so/macroflow directory. + +If you look at the contents of the plans/so/macroflow you will see the following: + +**setup.sh:** the shell script that starts all the necessary docker containers required by this test plan, as well as passing the necessary environment variables to Robot. +**testplan.txt:** the text file listing, in order, the test suites that should be executed by Robot for this particular test plan. This allows you to refactor test suites to be reused by multiple test plans as necessary. +**teardown.sh:** the shell script that kills all the docker containers that were started by this test plan. +**docker-compose.yml:** This lists all the requrired docker. + +How to run tests against specific SO versions +-------------------------------------------- +It is possible to run the CSIT Macroflow suite against local docker images although it is not the default. Through this method specific versions of SO can be tested. + +There are two changes required to make this work. + +1. The env file, located at [containing folder]/csit/plans/so/macroflow/config/env, first needs to be changed. The DOCKER_ENVIROMENT needs to be changed from "remote" to "local". Also the TAG value might need to be changed. This Tag relates to the version of images being used. Make sure the cnf-adapter image version also need to be changed here. + +2. Secondly all of the required docker images must be present on system. + +This should be enough to run the CSIT Macroflow test suite locally. + +CSIT Macroflow Tests High Level Scenarios +--------------------------------------------------- + +**Step 1:** + +Perform Configuration / Setup Steps prior to running tests + +**Step 2:** + +Onoboard the Macroflow Csar Package to complete the distribution from sdc-controller. This will be done by RoboFramework itlself. ASDC saves both heat and helm info into mso catalogdb. + +**Step 3:** + +Once the distribution done, next Instantiation will be executed for Macrolfow. RoboFramework is used to trigger the Instantiation flow. In this case, API handler receives the call and fetches required information from mso catalogdb. + +**Step 4:** + +Bpmn-Infra is called and fetches required information from mso catalogdb and executes all the selected building blocks which will call cnf-adapter or openstack adapter on the basis of usecase whether it is Macroflow Heat or Macroflow Helm. + +**Step 5:** + +Bpmn-Infra also fetches and updates Action infromation to the AAI-Simulator and SDNC-Simulator + +**Step 6:** + +Cnf-Adapter will then call to Multicloud (Multicloud-Simulator) and complete the Execution of Macroflow. + +Follow the diagram in the image below to understand the step + +.. image:: ../images/Architecture_flow.png + +What are the tests doing? +------------------------- +There are three tests currently being run "Distribute Service Template", "Invoke Service Instantiation". + +**Distribute Service Template** + +As the name would suggest the aim for the "Distribute Service Template" test is to distribute a service template within the SDC controller pod. Once a http session of the SDC controller is created a post request can be made to it. This post requests sends binary data from "serviceBasicVfCnfnotification.json" for Macroflow heat and "serviceBasicVfCnfWithHelm.json" for Macroflow helm. These json files contain the information of resources and artifacts required to distribute a service. These json file gather information from the Csar package which resides in the plans/so/macroflow/config/distribution-test-zip directory. Once this post request is sent, the response status code is checked to see if it is 200. If the code is not equal to 200 then the test is thought to be a failure. + +**Invoke Service Instantiation** + +The aim of the "Invoke Service Instantiation" test is to invoke the service distributed to the sdc controller in the previous test. A http session of the api handler pod is created. This session is sent a post request containing "macroflow.json" for Macroflow heat and "MacroflowWithHelm.json" for Macroflow helm. Once these request are made the response is checked if it a valid code is returned. A for loop is used to continually make calls to check the orchestration request for both the request, to check the status of service instantiation. Only once this orchestration returns either a fail or success, will we break out of the for loop. Once outside the for loop a final statement is used to check if service has been successfully instantiated. + +Troubleshooting +--------------- +There are a number of simple issues relating from Python and its libraries + +A correct installation of the robot framework to run our tests requiring python and the following pip libraries. + +- robotframework +- robotframework-extendedselenium2library +- robotframework-httplibrary +- robotframework-onap +- robotframework-requests +- robotframework-selenium2library + +To make sure each of the previous libraries is installed run the following command + +.. code-block:: + + pip -list diff --git a/docs/developer_info/Docker-Config_Understanding.rst b/docs/developer_info/Docker-Config_Understanding.rst index e684c6c480..d62503e1c8 100644 --- a/docs/developer_info/Docker-Config_Understanding.rst +++ b/docs/developer_info/Docker-Config_Understanding.rst @@ -58,132 +58,132 @@ Path:- /docker-config/volumes/so/config/api-handler-infra/onapheat/override.yaml .. code-block:: bash - server: - port: 8080 - tomcat: - max-threads: 50 - ssl-enable: false - - mso: - msoKey: 07a7159d3bf51a0e53be7a8f89699be7 - logPath: logs - site-name: onapheat - adapters: - requestDb: - endpoint: http://request-db-adapter:8083 - auth: Basic YnBlbDpwYXNzd29yZDEk - catalog: - db: - spring: - endpoint: http://catalog-db-adapter:8082 - db: - auth: Basic YnBlbDpwYXNzd29yZDEk - config: - path: /src/main/resources/ - infra: - default: - alacarte: - orchestrationUri: /mso/async/services/ALaCarteOrchestrator - recipeTimeout: 180 - testApi: VNF_API - service: - macro: - default: - testApi: GR_API - camundaURL: http://bpmn-infra:8081 - camundaAuth: AE2E9BE6EF9249085AF98689C4EE087736A5500629A72F35068FFB88813A023581DD6E765071F1C04075B36EA4213A - async: - core-pool-size: 50 - max-pool-size: 50 - queue-capacity: 500 - sdc: - client: - auth: F3473596C526938329DF877495B494DC374D1C4198ED3AD305EA3ADCBBDA1862 - activate: - instanceid: test - userid: cs0008 - endpoint: http://c1.vm1.mso.simpledemo.onap.org:28090 - tenant: - isolation: - retry: - count: 3 - aai: - endpoint: https://aai.api.simpledemo.onap.org:8443 - auth: 2630606608347B7124C244AB0FE34F6F - extApi: - endpoint: http://nbi.onap:8080/nbi/api/v3 - so: - operational-environment: - dmaap: - username: testuser - password: VjR5NDcxSzA= - host: http://c1.vm1.mso.simpledemo.onap.org:28090 - auth: 51EA5414022D7BE536E7516C4D1A6361416921849B72C0D6FC1C7F262FD9F2BBC2AD124190A332D9845A188AD80955567A4F975C84C221EEA8243BFD92FFE6896CDD1EA16ADD34E1E3D47D4A - publisher: - topic: com.att.ecomp.mso.operationalEnvironmentEvent - - spring: - datasource: - hikari: - jdbcUrl: jdbc:mariadb://mariadb:3306/catalogdb - username: cataloguser - password: catalog123 - driver-class-name: org.mariadb.jdbc.Driver - pool-name: catdb-pool - registerMbeans: true - jpa: - show-sql: true - hibernate: - dialect: org.hibernate.dialect.MySQL5Dialect - ddl-auto: validate - naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy - enable-lazy-load-no-trans: true - jersey: - type: filter - - security: - usercredentials: - - - username: sitecontrol - password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke' - role: SiteControl-Client - - - username: gui - password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke' - role: GUI-Client - - - username: infraportal - password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke' - role: InfraPortal-Client - - - username: InfraPortalClient - password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke' - role: InfraPortal-Client - - - username: bpel - password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke' - role: BPEL-Client - - - username: mso_admin - password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke' - role: ACTUATOR - - request: - datasource: - hikari: - jdbcUrl: jdbc:mariadb://mariadb:3306/requestdb - username: requestuser - password: request123 - driver-class-name: org.mariadb.jdbc.Driver - pool-name: reqdb-pool - registerMbeans: true - org: - onap: - so: - cloud-owner: CloudOwner + server: + port: 8080 + tomcat: + max-threads: 50 + ssl-enable: false + + mso: + msoKey: 07a7159d3bf51a0e53be7a8f89699be7 + logPath: logs + site-name: onapheat adapters: - network: - encryptionKey: 07a7159d3bf51a0e53be7a8f89699be7 + requestDb: + endpoint: http://request-db-adapter:8083 + auth: Basic YnBlbDpwYXNzd29yZDEk + catalog: + db: + spring: + endpoint: http://catalog-db-adapter:8082 + db: + auth: Basic YnBlbDpwYXNzd29yZDEk + config: + path: /src/main/resources/ + infra: + default: + alacarte: + orchestrationUri: /mso/async/services/ALaCarteOrchestrator + recipeTimeout: 180 + testApi: VNF_API + service: + macro: + default: + testApi: GR_API + camundaURL: http://bpmn-infra:8081 + camundaAuth: AE2E9BE6EF9249085AF98689C4EE087736A5500629A72F35068FFB88813A023581DD6E765071F1C04075B36EA4213A + async: + core-pool-size: 50 + max-pool-size: 50 + queue-capacity: 500 + sdc: + client: + auth: F3473596C526938329DF877495B494DC374D1C4198ED3AD305EA3ADCBBDA1862 + activate: + instanceid: test + userid: cs0008 + endpoint: http://c1.vm1.mso.simpledemo.onap.org:28090 + tenant: + isolation: + retry: + count: 3 + aai: + endpoint: https://aai.api.simpledemo.onap.org:8443 + auth: 2630606608347B7124C244AB0FE34F6F + extApi: + endpoint: http://nbi.onap:8080/nbi/api/v3 + so: + operational-environment: + dmaap: + username: testuser + password: VjR5NDcxSzA= + host: http://c1.vm1.mso.simpledemo.onap.org:28090 + auth: 51EA5414022D7BE536E7516C4D1A6361416921849B72C0D6FC1C7F262FD9F2BBC2AD124190A332D9845A188AD80955567A4F975C84C221EEA8243BFD92FFE6896CDD1EA16ADD34E1E3D47D4A + publisher: + topic: com.att.ecomp.mso.operationalEnvironmentEvent + + spring: + datasource: + hikari: + jdbcUrl: jdbc:mariadb://mariadb:3306/catalogdb + username: cataloguser + password: catalog123 + driver-class-name: org.mariadb.jdbc.Driver + pool-name: catdb-pool + registerMbeans: true + jpa: + show-sql: true + hibernate: + dialect: org.hibernate.dialect.MySQL5Dialect + ddl-auto: validate + naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy + enable-lazy-load-no-trans: true + jersey: + type: filter + + security: + usercredentials: + - + username: sitecontrol + password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke' + role: SiteControl-Client + - + username: gui + password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke' + role: GUI-Client + - + username: infraportal + password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke' + role: InfraPortal-Client + - + username: InfraPortalClient + password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke' + role: InfraPortal-Client + - + username: bpel + password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke' + role: BPEL-Client + - + username: mso_admin + password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke' + role: ACTUATOR + + request: + datasource: + hikari: + jdbcUrl: jdbc:mariadb://mariadb:3306/requestdb + username: requestuser + password: request123 + driver-class-name: org.mariadb.jdbc.Driver + pool-name: reqdb-pool + registerMbeans: true + org: + onap: + so: + cloud-owner: CloudOwner + adapters: + network: + encryptionKey: 07a7159d3bf51a0e53be7a8f89699be7 @@ -245,8 +245,8 @@ Example Output: .. code-block:: bash - [ - { + [ + { "Id": "sha256:2573165483e9ac87826da9c08984a9d0e1d93a90c681b22d9b4f90ed579350dc", "RepoTags": [ "onap/so/api-handler-infra:1.3.0-SNAPSHOT", @@ -360,5 +360,5 @@ Example Output: "sha256:2163a1f989859fdb3af6e253b74094e92a0fc1ee59f5eb959971f94eb1f98094" ] } - } - ] + } + ] diff --git a/docs/developer_info/E2E_Network_Slicing_Understanding.rst b/docs/developer_info/E2E_Network_Slicing_Understanding.rst new file mode 100644 index 0000000000..169dd64a79 --- /dev/null +++ b/docs/developer_info/E2E_Network_Slicing_Understanding.rst @@ -0,0 +1,111 @@ +.. This work is licensed under a Creative Commons Attribution 4.0 International License. +.. http://creativecommons.org/licenses/by/4.0 +.. Copyright 2021 Wipro Ltd. + +E2E Network Slicing +=================== +The objective of this use case is to realize **End-to-End 5G Network +Slicing** using ONAP. An End-to-End Network Slice consists of RAN (Radio +Access Network), Transport Network (TN) and Core Network (CN) slice +sub-nets. This use case intends to demonstrate the modeling, +orchestration (life cycle and resources) and assurance of a network +slice which are implemented in alignment with relevant standards. + +Overall High level view for ONAP-based Slice Management +======================================================= + +Architecture Choice +------------------- + +3GPP(TS 28.801) defines three layer slice management functions which include: + +CSMF(Communication Service Management Function): + +- Responsible for translating the communication service related requirement to network slice related requirements. + +- Communicate with Network Slice Management Function (NSMF). + +NSMF(Network Slice Management Function): + +- Responsible for management and orchestration of NSI. + +- Derive network slice subnet related requirements from network slice related requirements. + +- Communicate with the Network Slice Subnet Management Function (NSSMF) and Communication Service Management Function. + +NSSMF(Network Slice Subnet Management Function): + +- Responsible for management and orchestration of NSSI. + +- Communicate with the NSMF. + +.. image:: ../images/e2e-network-slicing-architecture.png + +To realize the three layers of the slice management function, we need to decide whether to implement CSMF, NSMF or NSMF within ONAP, or use the external CSMF, NSMF or NSSMF. This implies that for ONAP-based network slice management, we have different choices from an architectural perspective: + +1. Implement CSMF, NSMF, NSSMF all within ONAP; + +2. Connect an external CSMF from the Northbound, Implement NSMF and NSSMF within ONAP; + +3. Connect an external CSMF from the Northbound, Implement NSMF within ONAP, Connect a 3rd party NSSMF from the Southbound; + +4. Implement CSMF, NSMF within ONAP, Connect a 3rd party NSSMF from then Southbound. + +5. Use external CSMF and NSMF, only implement NSSMF within ONAP. + +.. image:: ../images/architecture-choices-e2e-slicing.png + +Slice Management Functions - Realization in SO +---------------------------------------------- + +- CSMF and NSMF is realized within ONAP (enhancement in Frankfurt functionality), and the NB interfaces is standardized using ExtAPI. + +- All 3 NSSMFs shall be realized within ONAP (From Guilin). + +- ONAP acting as NSMF shall also interact with external RAN and Transport NSSMF using 3GPP APIs + +- CSMF reliazed within SO receives service requirements from EXT-API, which translates service requirements to slice profile(NST selection) and sends request to NSMF for slice allocation. + +- NSMF reliazed within SO receives request for slice allocation (slice profile, S-NSSAI, NST) and determines slice instantiation/modification (with OOF) to fulfil the slice allocation request. + +- NSSMF reliazed within SO receive information from NSMF & trigger RAN/Core/Transport NSSMF for orchestration actions. + +Network Slice Instance (NSI) Life Cycle View +-------------------------------------------- + +Design and pre-provision: Creation of necessary slice/slice sub-net templates. Creation, activation, deactivation and termination of NSI, including its constituent slice sub-nets (RAN, Core and Transport) + +3GPP Specification (3GPP TS 28.530) describes management aspects of a Network Slice Instance, which can be described by the four phases: + +Preparation: The preparation phase includes network slice design, network slice capacity planning, on-boarding and evaluation of the network functions, preparing the network environment and other necessary preparations required to be done before the creation of an NSI + +Commisioning: NSI provisioning in the commissioning phase includes creation of the NSI. During NSI creation all needed resources are allocated and configured to satisfy the network slice requirements. The creation of an NSI can include creation and/or modification of the NSI constituents + +Operation: The Operation phase includes the activation, supervision, performance reporting (e.g. for KPI monitoring), resource capacity planning, modification,and de-activation of an NSI. + +Decommissioning: Network slice instance provisioning in the decommissioning phase includes decommissioning of non-shared constituents if required and removing the NSI specific configuration from the shared constituents. After the decommissioning phase, the NSI is terminated and does not exist anymore. The ONAP-based NSI lifecycle management will finally provide the demonstration of all these phases. + +The ONAP-based NSI lifecycle management will finally provide the demonstration of all these phases. + +.. image:: ../images/lifecycle-of-network-slice-instance.png + +Support for Option1 &Option2 in E2E Network Slicing +--------------------------------------------------- + +ONAP E2E Network Slicing option 1 and 2 differs on the RAN and FH/BH relationship. + +- In option 1, RAN NSSMF will decide FH/MH requirements and send to TN side, so RAN NSST will nest FH/MH NSST, and slice profile requirements will contain not only RAN side requirements but also FH/MH. + +Template design for option 1: https://wiki.onap.org/display/DW/Template+Design+for+Option+1 + +.. image:: ../images/slicing-option1.png + +- In option 2, FH and MH are independent requirments when doing E2E requirements decomposition. Detailed background of option 1 and 2, please see E2E Network Slicing Use Case in R7 Guilin. + +Template design for option 2: https://wiki.onap.org/display/DW/Template+Design+for+Option2 + +.. image:: ../images/slicing-option2.png + +3 domain combination solution -Endpoint +--------------------------------------- +In order to enable 3 subnet connectivity, making end-to-end forwarding and control plane interacting, in slicing services, we need slicing interworking identifier and information to tell how RAN and Core connect with TN. Slicing interworking identifier(in ONAP is vlan Id, allocated by NSMF) is used to isolate differerent service datas, and identify the unique slicing service across RAN, TN and Core, 1 S-NSSAI will need to be assigned with 1 slicing interworking identifier(vlan Id). The slicing interworking information is used as bridges to connect RAN/Core and TN,it should be RAN/Core side outgress and TN ingress, like port, ipAddress, next hops and etc. diff --git a/docs/developer_info/ETSI_CSIT_NFVO_VNFM.rst b/docs/developer_info/ETSI_CSIT_NFVO_VNFM.rst new file mode 100644 index 0000000000..3bc8393d56 --- /dev/null +++ b/docs/developer_info/ETSI_CSIT_NFVO_VNFM.rst @@ -0,0 +1,227 @@ +.. This work is licensed under a Creative Commons Attribution 4.0 International License. +.. http://creativecommons.org/licenses/by/4.0 +.. Copyright 2022 Ericsson Software Technologies + +SO ETSI CSIT (NFVO and VNFM) +============================ +This guide will go through the CSIT of the ETSI NFVO and VNFM. + +Ensure you have a healthy ONAP Deployment running. The following components will be required/used as part of this guide: + +- SO +- SDC +- AAI +- DMAAP +- Modeling + +What is ETSI? +------------- +The European Telecommunications Standards Institute (ETSI) produces globally-applicable standards +for Information and Communications Technologies. ETSI set out standards covering the functionalities +of the interfaces specified on the reference points, which use the acronym NFV-SOL +(standing for “NFV Solutions”). As of ONAPs Dublin release the SO SVNFM adapter supports +SOL003 standards for Create, Instantiate, Terminate and Delete operations with Granting, Subscription +and Notification. As of ONAP Honolulu release, the SO ETSI NFVO sub-component supports +SOL005 (NBI) and SOL003 (SBI) standards for Create, Instantiate, Terminate and Delete NS and VNF +(through the SOL003 Adapter) operations. + +How to Run CSIT Tests +--------------------- +The follow steps are to install and run on an Ubuntu 18.04 (desktop) installation. +Later versions of Ubuntu and Java may work for the tests. + +First pull the CSIT repo from Gerrit, either with or without the hooks + +.. code-block:: + + git clone "https://gerrit.onap.org/r/integration/csit" + +or + +.. code-block:: + + git clone "https://gerrit.onap.org/r/integration/csit" && (cd "csit" && mkdir -p .git/hooks && curl -Lo `git rev-parse --git-dir`/hooks/commit-msg https://gerrit.onap.org/r/tools/hooks/commit-msg; chmod +x `git rev-parse --git-dir`/hooks/commit-msg) + +Once this is downloaded a few more installations are required. + +Install pip (if required) + +.. code-block:: + + sudo apt install python-pip + +Install Robot Framework through pip + +.. code-block:: + + pip install robotframework + +Run Script + +Once all of this is done, then the tests should be run by calling the run-csit.sh script and giving it the location of our test folder (csit/plans/so/integration-etsi-testing). +From the csit projects root folder run the following command: + +.. code-block:: + + ./run-csit.sh plans/so/integration-etsi-testing + +This should successfully run the ETSI CSIT suite + +How to run tests againt specific SO versions +-------------------------------------------- +It is possible to run the ETSI CSIT suite against local docker images although it is not the default. +Through this method specific versions of SO can be tested. +There are two changes required to make this work. +The env file, located at [containing folder]/csit/plans/so/integration-etsi-testing/config/env, +first needs to be changed. The DOCKER_ENVIROMENT needs to be changed from "remote" to "local". +Also the TAG value might need to be changed. This Tag relates to the version of images being used. + +Secondly all of the required docker images must be present on system. + +This should be enough to run the ETSI CSIT test suite locally. + +ETSI NFVO Automated CSIT Tests High Level Scenarios +--------------------------------------------------- +**Step 1:** + +Perform Configuration / Setup Steps prior to running tests + +**Step 2:** + +Onboard SOL004 Package and SOL007 directly into ETSI Catalog using ROBOT framework + +**Step 3:** + +ETSI Catalog Gets Package from SDC Simulator (New: ETSI Catalog and Modeling ETSI Catalog DB will need to be set up and spun up for CSIT. May be some impact on SDC Simulator here) + +**Step 4:** + +ETSI Catalog Stores Package in its Modeling ETSI Catalog DB + +**Step 5:** + +ROBOT framework used to trigger NS LCM requests, e.g., INSTANTIATE NS + +**Step 6:** + +ETSI NFVO NS LCM gets required data from ETSI Catalog, e.g., Get and Parse NSD + +**Step 7:** + +If e.g., a CREATE NS task, ETSI NFVO NS LCM checks to see if already exists in ETSI NFVO DB + +**Step 8:** + +Create Generic VNF and connect to Service Instance in A&AI Simulator (May be some impact on A&AI Simulator here) + +**Step 9:** + +Instantiate VNF through SOL003 Adapter + +**Step 10:** + +SOL003 Adapter processes requests through A&AI and (May be some impact on A&AI Simulator here) + +**Step 11:** + +SOL003 Adapter processes requests through ETSI-Catalog + +**Step 12:** + +SOL003 Adapter sends notification to SOL003 NBI, etc. + +What are the tests doing? +------------------------- +There are three tests currently being run "Distribute Service Template", "Invoke Service Instantiation", +"Invoke NS Instantiation", "Delete NS Instance", "Invoke VNF Instantiation", "Delete VNF Instance" and +"Delete Service Instance". + +Distribute Service Template + +As the name would suggest the aim for the "Distribute Service Template" test is to distribute a service +template within the SDC controller pod. Once a http session of the SDC controller is created a post request +can be made to it. This post requests sends binary data from "distributeServiceTemplate.json". +This json file contains resources and artifacts required to distribute a service. Once this post request +is sent, the response status code is checked to see if it is 200. If the code is not equal to 200 then +the test is thought to be a failure. + +Invoke Service Instantiation + +The aim of the "Invoke Service Instantiation" test is to invoke the service distributed to the sdc controller +in the previous test. A http session of the api handler pod is created. This session is sent a post request +containing "serviceInstantiationRequest.json". Once this request is made the response is checked if it +a valid code is returned. A for loop is used to continually make calls to check the orchestration request, +to check the status of service instantiation. Only once this orchestration returns either a fail or success, +will we break out of the for loop.Once outside the for loop a final statement is used to check if service +has been successfully instantiated. + +Invoke NS Instance + +The aim of "Invoke NS Instantiation" test is to now instantiate the NS that relates to service in the +previous test. This test requires the ID of the service instance created in the previous test. If this is +not provided then the test will fail from the get go. Once again a http session of the api handler pod is +created. Similarly a post request using the json data within "nsInstantiationRequest.json". +Once this request is made if it returns a success code then the test moves on to a for loop. Within this +for a loop an orchestration request is made each time, when this request signals that either the instantiation +request has failed or fully succeeded then the loop is escaped. The test will either be a pass or fail depending +on this final orchestration request. + +Delete NS Instance + +This test will delete the NS Instance created in the previous test. Both the ID of the NS instance created +in the previous test and the service instance created in the test before that. If either of these values is +not provided then the test will fail. This test once again makes use of a session of the api handler pod. +A post request is made using the data from "nsDeleteRequest.json". Once this request is made if it returns +a success code then the test moves on to a for loop. Within this for a loop an orchestration request is made +each time, when this request signals that either the instantiation request has failed or fully succeeded +then the loop is escaped. The test will either be a pass or fail depending on this final orchestration request. + +Invoke VNF Instance + +The aim of "Invoke VNF Instantiation" test is to now instantiate the VNF that relates to service in +the previous test. This test requires the ID of the service instance created in the previous test. +If this is not provided then the test will fail from the get go. Once again a http session of the +api handler pod is created. Similarly a post request using the json data within "vnfInstantiationRequest.json". +Once this request is made if it returns a success code then the test moves on to a for loop. Within this +for a loop an orchestration request is made each time, when this request signals that either the instantiation +request has failed or fully succeeded then the loop is escaped. The test will either be a pass or fail +depending on this final orchestration request. + +Delete VNF Instance + +This test will delete the VNF Instance created in the previous test. Both the ID of the vnf instance created +in the previous test and the service instance created in the test before that. If either of these values is +not provided then the test will fail. This test once again makes use of a session of the api handler pod. +A post request is made using the data from "vnfDeleteRequest.json". Once this request is made if it returns +a success code then the test moves on to a for loop. Within this for a loop an orchestration request is made +each time, when this request signals that either the instantiation request has failed or fully succeeded then +the loop is escaped. The test will either be a pass or fail depending on this final orchestration request. + +Delete Service Instance + +This test will delete the service instance created in earlier test. To delete the service the ID of previously + created Service Instance is required, if this is not supplied then the test will fail before starting. + A post request is then made to the API handler containing data from "serviceDeleteRquest.json". + Once this request is made if it returns a success code then the test moves on to a for loop. + Within this for a loop an orchestration request is made each time, when this request signals that either + the instantiation request has failed or fully succeeded then the loop is escaped. The test will either be + a pass or fail depending on this final orchestration request. + +Troubleshooting +--------------- +There are a number of simple issues relating from Python and its libraries + +A correct installation of the robot framework to run our tests requiring python and the following pip libraries. + +- robotframework +- robotframework-extendedselenium2library +- robotframework-httplibrary +- robotframework-onap +- robotframework-requests +- robotframework-selenium2library + +To make sure each of the previous libraries is installed run the following command + +.. code-block:: + + pip -list \ No newline at end of file diff --git a/docs/developer_info/developer_information.rst b/docs/developer_info/developer_information.rst index e174133d6f..11b515248a 100644 --- a/docs/developer_info/developer_information.rst +++ b/docs/developer_info/developer_information.rst @@ -15,6 +15,7 @@ SO Developer Information Camunda_Cockpit_Community_Edition.rst Camunda_Cockpit_Enterprise_Edition.rst Camunda_Modeler.rst + CSIT_Macroflow_developer_info.rst BPMN_Project_Structure.rst BPMN_Main_Process_Flows.rst BPMN_Subprocess_Process_Flows.rst diff --git a/docs/images/Architecture_flow.png b/docs/images/Architecture_flow.png new file mode 100644 index 0000000000..112192560d Binary files /dev/null and b/docs/images/Architecture_flow.png differ diff --git a/docs/images/SO-NFVO-Architecture-1.png b/docs/images/SO-NFVO-Architecture-1.png new file mode 100644 index 0000000000..dd04a7b2e4 Binary files /dev/null and b/docs/images/SO-NFVO-Architecture-1.png differ diff --git a/docs/images/SO-SOL003-Adapter-Architecture-1.png b/docs/images/SO-SOL003-Adapter-Architecture-1.png new file mode 100644 index 0000000000..932d5d1bcd Binary files /dev/null and b/docs/images/SO-SOL003-Adapter-Architecture-1.png differ diff --git a/docs/images/SO_Architecture_2.png b/docs/images/SO_Architecture_2.png new file mode 100644 index 0000000000..45ffd953e6 Binary files /dev/null and b/docs/images/SO_Architecture_2.png differ diff --git a/docs/images/architecture-choices-e2e-slicing.png b/docs/images/architecture-choices-e2e-slicing.png new file mode 100644 index 0000000000..b240215017 Binary files /dev/null and b/docs/images/architecture-choices-e2e-slicing.png differ diff --git a/docs/images/e2e-network-slicing-architecture.png b/docs/images/e2e-network-slicing-architecture.png new file mode 100644 index 0000000000..922419d0a8 Binary files /dev/null and b/docs/images/e2e-network-slicing-architecture.png differ diff --git a/docs/images/lifecycle-of-network-slice-instance.png b/docs/images/lifecycle-of-network-slice-instance.png new file mode 100644 index 0000000000..0959783b89 Binary files /dev/null and b/docs/images/lifecycle-of-network-slice-instance.png differ diff --git a/docs/images/slicing-option1.png b/docs/images/slicing-option1.png new file mode 100644 index 0000000000..e19a257828 Binary files /dev/null and b/docs/images/slicing-option1.png differ diff --git a/docs/images/slicing-option2.png b/docs/images/slicing-option2.png new file mode 100644 index 0000000000..945c7c5612 Binary files /dev/null and b/docs/images/slicing-option2.png differ diff --git a/docs/release-notes.rst b/docs/release-notes.rst index 58902f3d27..4299041911 100644 --- a/docs/release-notes.rst +++ b/docs/release-notes.rst @@ -14,6 +14,127 @@ The SO provides the highest level of service orchestration in the ONAP architect Release Notes ============= +Version: 1.10.0 +============== + + :Release Date: 2022-04-08 + +SO Release Image Versions +-------------------------- + - so-bpmn-infra + + :Version: 1.10.0 + + - so-catalog-db-adapter + + :Version: 1.10.0 + + - so-admin-cockpit + + :Version: 1.8.3 + + - so-nssmf-adapter + + :Version: 1.9.1 + + - so-openstack-adapter + + :Version: 1.10.0 + + - so-request-db-adapter + + :Version: 1.10.0 + + - so-sdc-controller + + :Version: 1.10.0 + + - so-sdnc-adapter + + :Version: 1.10.0 + + - so-sol003-adapter + + :Version: 1.8.2 + + - so-api-handler + + :Version: 1.10.0 + + - so-etsi-nfvo-ns-lcm + + :Version: 1.8.2 + + - so-oof-adapter + + :Version: 1.8.3 + + - so-cnf-adapter + + :Version: 1.10.0 + +Release Purpose +---------------- +SO Jakarta Release. +The key deliverable for this release is refactoring SO for better internal architecture. + + +**Epics** + +* `REQ-890 `_ - ONAP CNF orchestration - Jakarta Enhancements +* `REQ-1041 `_ - VNF LCM Support in SO +* `SO-3802 `_ - Global Requirements Approval +* `SO-3826 `_ - SO impacts for E2E Network Slicing in Jakarta Release + +**Stories** + +The full list of implemented tasks is available on `JIRA Jakarta STORY `_ + + +**Tasks** + +The full list of implemented tasks is available on `JIRA Jakarta TASKS `_ + +**Bug Fixes** + +The full list of fixed bugs is available on `JIRA Jakarta BUGS +`_ + +Security Notes +-------------- + +*Fixed Security Issues* + +* `SO-3735 `_ +* `SO-3825 `_ +* `SO-3846 `_ + + +Quick Links: + +- `SO project page `__ +- `Passing Badge information for SDC `__ + +**Known Issues** + +* `SO-3237 `_ - Exposed HTTP port. +* `SO-3745 `_ - SO images contain 1 GPLv3 lib + +**Upgrade Notes** + + N/A + +**Deprecation Notes** + + SO modules Ve-Vnfm-adapter and appc-orchestrator are deprectaed since istanbul release. + +**Other** + + N/A +*************************************************************************************** + + + Version: 1.9.2 ============== diff --git a/docs/requirements-docs.txt b/docs/requirements-docs.txt index 74a3b7a3fd..3b3441a807 100644 --- a/docs/requirements-docs.txt +++ b/docs/requirements-docs.txt @@ -1 +1,3 @@ lfdocs-conf +sphinx>=4.2.0 # BSD +sphinx-rtd-theme>=1.0.0 # MIT diff --git a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIObjectTypeTest.java b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIObjectTypeTest.java index 12051fb07d..1696445c88 100644 --- a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIObjectTypeTest.java +++ b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIObjectTypeTest.java @@ -3,6 +3,7 @@ * ONAP - SO * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2022 Samsung Electronics * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,9 +49,6 @@ public class AAIObjectTypeTest { AAIObjectType genericVnf2 = AAIFluentTypeBuilder.network().genericVnf("test2").build(); assertEquals(genericVnf2, genericVnf); - - assertEquals(genericVnf, Types.GENERIC_VNF); - } @Test diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Action.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Action.java index 469c99eeb0..5d238112cc 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Action.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Action.java @@ -48,5 +48,6 @@ public enum Action implements Actions { healthCheck, addMembers, removeMembers, - forCustomWorkflow + forCustomWorkflow, + upgradeCnf } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java index 99c0fc23fa..5bf33b417a 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java @@ -369,16 +369,7 @@ public class OrchestrationRequests { } } catch (IOException e) { - logger.error("Exception occurred", e); - ErrorLoggerInfo errorLoggerInfo = - new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError) - .build(); - ValidateException validateException = - new ValidateException.Builder("Mapping of request to JSON object failed : ", - HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e) - .errorInfo(errorLoggerInfo).build(); - - throw validateException; + logger.error(String.format("Failed to parse request (id: %s) : ", request.getRequestId()), e); } } request.setRequestDetails(requestDetails); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java index cddb1ada31..531d87c229 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java @@ -33,7 +33,10 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; import javax.ws.rs.container.ContainerRequestContext; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.Response; @@ -841,7 +844,11 @@ public class RequestHandlerUtils extends AbstractRestHandler { if (params.containsKey("service")) { Service service = serviceMapper(params); - addUserParams(userParams, service.getInstanceParams()); + // Filter out non-string params for backward compatibility + Map svcStrParams = service.getInstanceParams().stream().map(Map::entrySet) + .flatMap(Set::stream).filter(e -> e.getValue() instanceof String) + .collect(Collectors.toMap(Entry::getKey, e -> (String) e.getValue())); + userParams.putAll(svcStrParams); for (Networks network : service.getResources().getNetworks()) { addUserParams(userParams, network.getInstanceParams()); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java index ed4a52ada0..4aa9cd0696 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java @@ -432,6 +432,24 @@ public class ServiceInstances extends AbstractRestHandler { requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); } + @POST + @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/upgradeCnf") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @Operation(description = "Upgrade CNF instance", responses = @ApiResponse( + content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class))))) + @Transactional + public Response cnfUpgrade(String request, @PathParam("version") String version, + @PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("vnfInstanceId") String vnfInstanceId, + @Context ContainerRequestContext requestContext) throws ApiException { + String requestId = requestHandlerUtils.getRequestId(requestContext); + HashMap instanceIdMap = new HashMap<>(); + instanceIdMap.put("serviceInstanceId", serviceInstanceId); + instanceIdMap.put("vnfInstanceId", vnfInstanceId); + return serviceInstances(request, Action.upgradeCnf, instanceIdMap, version, requestId, + requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); + } + @PUT @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}") @Consumes(MediaType.APPLICATION_JSON) diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/BuildingBlockRollback.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/BuildingBlockRollback.java index 798604e4fb..67a19c005d 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/BuildingBlockRollback.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/BuildingBlockRollback.java @@ -65,6 +65,17 @@ public class BuildingBlockRollback implements Serializable { @Column(name = "ROLLBACK_ACTION", length = 200) private String rollbackAction; + public BuildingBlockRollback() {} + + public BuildingBlockRollback(Integer id, String buildingBlockName, String action, String rollbackBuildingBlockName, + String rollbackAction) { + this.id = id; + this.buildingBlockName = buildingBlockName; + this.action = action; + this.rollbackBuildingBlockName = rollbackBuildingBlockName; + this.rollbackAction = rollbackAction; + } + public Integer getId() { return id; } diff --git a/mso-catalog-db/src/test/resources/schema.sql b/mso-catalog-db/src/test/resources/schema.sql index db800b2b49..cf1b188a21 100644 --- a/mso-catalog-db/src/test/resources/schema.sql +++ b/mso-catalog-db/src/test/resources/schema.sql @@ -1424,3 +1424,27 @@ CREATE TABLE IF NOT EXISTS `building_block_rollback` ( `ROLLBACK_ACTION` varchar(200) NULL, PRIMARY KEY (`ID`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +INSERT INTO building_block_rollback(BUILDING_BLOCK_NAME,ACTION,ROLLBACK_BUILDING_BLOCK_NAME,ROLLBACK_ACTION) +VALUES ("ActivateNetworkBB",NULL,"DeactivateNetworkBB",NULL), +("ActivatePnfBB",NULL,"DeactivatePnfBB",NULL), +("ActivateServiceInstanceBB",NULL,"DeactivateServiceInstanceBB",NULL), +("ActivateVfModuleBB",NULL,"DeactivateVfModuleBB",NULL), +("ActivateVnfBB",NULL,"DeactivateVnfBB",NULL), +("ActivateVolumeGroupBB",NULL,"DeactivateVolumeGroupBB",NULL), +("AssignNetworkBB",NULL,"UnassignNetworkBB",NULL), +("AssignServiceInstanceBB",NULL,"UnassignServiceInstanceBB",NULL), +("AssignVfModuleBB",NULL,"UnassignVfModuleBB",NULL), +("AssignVnfBB",NULL,"UnassignVnfBB",NULL), +("AssignVolumeGroupBB",NULL,"UnassignVolumeGroupBB",NULL), +("CreateNetworkBB",NULL,"DeleteNetworkBB",NULL), +("CreateNetworkCollectionBB",NULL,"DeleteNetworkCollectionBB",NULL), +("CreateVfModuleBB",NULL,"DeleteVfModuleBB",NULL), +("CreateVolumeGroupBB",NULL,"DeleteVolumeGroupBB",NULL), +("VNFSetInMaintFlagActivity",NULL,"VNFUnsetInMaintFlagActivity",NULL), +("VNFSetClosedLoopDisabledFlagActivity",NULL,"VNFUnsetClosedLoopDisabledFlagActivity",NULL), +("VNFLockActivity",NULL,"VNFUnlockActivity",NULL), +("VNFStopActivity",NULL,"VNFStartActivity",NULL), +("VNFQuiesceTrafficActivity",NULL,"VNFResumeTrafficActivity",NULL), +("EtsiVnfInstantiateBB", null, "EtsiVnfDeleteBB", null), +("AddFabricConfigurationBB", null, "DeleteFabricConfigurationBB", null); diff --git a/releases/1.10.0.yaml b/releases/1.10.0.yaml new file mode 100644 index 0000000000..726d5e0a99 --- /dev/null +++ b/releases/1.10.0.yaml @@ -0,0 +1,22 @@ + +--- +distribution_type: 'container' +container_release_tag: '1.10.0' +project: 'so' +log_dir: 'so-maven-docker-stage-master/1043/' +ref: 'ffb0aa14936fae9bb3c9d2a11b311d294b1186d0' +containers: + - name: 'so/catalog-db-adapter' + version: '1.10.0-20220324T0419' + - name: 'so/request-db-adapter' + version: '1.10.0-20220324T0419' + - name: 'so/openstack-adapter' + version: '1.10.0-20220324T0419' + - name: 'so/sdnc-adapter' + version: '1.10.0-20220324T0419' + - name: 'so/sdc-controller' + version: '1.10.0-20220324T0419' + - name: 'so/bpmn-infra' + version: '1.10.0-20220324T0419' + - name: 'so/api-handler-infra' + version: '1.10.0-20220324T0419' diff --git a/so-optimization-clients/src/main/java/org/onap/so/client/sniro/SniroValidator.java b/so-optimization-clients/src/main/java/org/onap/so/client/sniro/SniroValidator.java index fc16125433..9a66f75311 100644 --- a/so-optimization-clients/src/main/java/org/onap/so/client/sniro/SniroValidator.java +++ b/so-optimization-clients/src/main/java/org/onap/so/client/sniro/SniroValidator.java @@ -24,7 +24,7 @@ package org.onap.so.client.sniro; import static org.apache.commons.lang3.StringUtils.*; -import java.util.LinkedHashMap; +import java.util.Map; import org.json.JSONObject; import org.onap.so.client.exception.BadResponseException; import org.slf4j.Logger; @@ -38,12 +38,14 @@ public class SniroValidator { private static final Logger logger = LoggerFactory.getLogger(SniroValidator.class); + private static final String MESSAGE_NOT_PROVIDED = "error message not provided"; + /** * Validates the synchronous homing response from sniro manager * * @throws BadResponseException */ - public void validateDemandsResponse(LinkedHashMap response) throws BadResponseException { + public void validateDemandsResponse(Map response) throws BadResponseException { logger.debug("Validating Sniro Managers synchronous response"); if (!response.isEmpty()) { JSONObject jsonResponse = new JSONObject(response); @@ -54,10 +56,10 @@ public class SniroValidator { } else { String message = jsonResponse.getString("statusMessage"); if (isNotBlank(message)) { - logger.debug("Sniro Managers response indicates failed: " + message); + logger.debug("Sniro Managers response indicates failed: {}", message); } else { logger.debug("Sniro Managers response indicates failed: no status message provided"); - message = "error message not provided"; + message = MESSAGE_NOT_PROVIDED; } throw new BadResponseException("Sniro Managers synchronous response indicates failed: " + message); } @@ -67,7 +69,7 @@ public class SniroValidator { } } else { logger.debug("Sniro Managers synchronous response is empty"); - throw new BadResponseException("Sniro Managers synchronous response i is empty"); + throw new BadResponseException("Sniro Managers synchronous response is empty"); } } @@ -85,11 +87,11 @@ public class SniroValidator { } else { String message = jsonResponse.getJSONObject("serviceException").getString("text"); if (isNotBlank(message)) { - logger.debug("Sniro Managers response contains a service exception: " + message); + logger.debug("Sniro Managers response contains a service exception: {}", message); } else { logger.debug( "Sniro Managers response contains a service exception: no service exception text provided"); - message = "error message not provided"; + message = MESSAGE_NOT_PROVIDED; } throw new BadResponseException( "Sniro Managers asynchronous response contains a service exception: " + message); @@ -106,7 +108,7 @@ public class SniroValidator { * * @throws BadResponseException */ - public void validateReleaseResponse(LinkedHashMap response) throws BadResponseException { + public void validateReleaseResponse(Map response) throws BadResponseException { logger.debug("Validating Sniro Conductors response"); if (!response.isEmpty()) { String status = (String) response.get("status"); @@ -116,10 +118,10 @@ public class SniroValidator { } else { String message = (String) response.get("message"); if (isNotBlank(message)) { - logger.debug("Sniro Conductors response indicates failed: " + message); + logger.debug("Sniro Conductors response indicates failed: {}", message); } else { logger.debug("Sniro Conductors response indicates failed: error message not provided"); - message = "error message not provided"; + message = MESSAGE_NOT_PROVIDED; } throw new BadResponseException( "Sniro Conductors synchronous response indicates failed: " + message); diff --git a/so-optimization-clients/src/test/java/org/onap/so/client/oof/OofValidatorTest.java b/so-optimization-clients/src/test/java/org/onap/so/client/oof/OofValidatorTest.java index 5f9be78491..eaea1abeaa 100644 --- a/so-optimization-clients/src/test/java/org/onap/so/client/oof/OofValidatorTest.java +++ b/so-optimization-clients/src/test/java/org/onap/so/client/oof/OofValidatorTest.java @@ -20,10 +20,13 @@ package org.onap.so.client.oof; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.fail; import java.util.Collections; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; +import org.apache.logging.log4j.util.Strings; import org.junit.Test; import org.onap.so.client.exception.BadResponseException; @@ -55,4 +58,41 @@ public class OofValidatorTest { map.put("statusMessage", "a"); new OofValidator().validateDemandsResponse(map); } + + @Test + public void validateSolution_success() throws Exception { + String json = "{\"value\" : \"test1\"}"; + new OofValidator().validateSolution(json); + } + + @Test + public void validateSolution_EmptyResponse() { + try { + new OofValidator().validateSolution(""); + } catch (BadResponseException e) { + assertThat(e.getMessage()).contains("oofs asynchronous response is empty"); + } + } + + @Test + public void validateSolution_serviceExceptionWithMessage() { + String json = "{\"serviceException\" : {\"text\" : \"serviceExceptionOccurred\"}}"; + try { + new OofValidator().validateSolution(json); + fail("Exception should be thrown"); + } catch (BadResponseException e) { + assertThat(e.getMessage()).contains("serviceExceptionOccurred"); + } + } + + @Test + public void validateSolution_serviceExceptionWithEmptyMessage() { + String json = "{\"serviceException\" : {\"text\" : \"\"}}"; + try { + new OofValidator().validateSolution(json); + fail("Exception should be thrown"); + } catch (BadResponseException e) { + assertThat(e.getMessage()).contains("error message not provided"); + } + } } diff --git a/so-optimization-clients/src/test/java/org/onap/so/client/sniro/SniroValidatorTest.java b/so-optimization-clients/src/test/java/org/onap/so/client/sniro/SniroValidatorTest.java new file mode 100644 index 0000000000..9ad22ce492 --- /dev/null +++ b/so-optimization-clients/src/test/java/org/onap/so/client/sniro/SniroValidatorTest.java @@ -0,0 +1,150 @@ +package org.onap.so.client.sniro; + +import static org.assertj.core.api.Assertions.assertThat; +import java.util.LinkedHashMap; +import java.util.Map; +import org.junit.Test; +import org.onap.so.client.exception.BadResponseException; + +public class SniroValidatorTest { + + @Test + public void validateDemandsResponse_success() throws BadResponseException { + Map testMap = new LinkedHashMap<>(); + testMap.put("requestStatus", "accepted"); + new SniroValidator().validateDemandsResponse(testMap); + } + + @Test + public void validateDemandsResponse_emptyResponse() { + try { + new SniroValidator().validateDemandsResponse(new LinkedHashMap<>()); + } catch (BadResponseException e) { + assertThat(e.getMessage()).contains("Sniro Managers synchronous response is empty"); + } + } + + @Test + public void validateDemandsResponse_responseWithErrorMessage() { + String message = "An error occurred"; + Map testMap = new LinkedHashMap<>(); + testMap.put("requestStatus", "not_accepted"); + testMap.put("statusMessage", message); + try { + new SniroValidator().validateDemandsResponse(testMap); + } catch (BadResponseException e) { + assertThat(e.getMessage()).contains("Sniro Managers synchronous response indicates failed: " + message); + } + } + + @Test + public void validateDemandsResponse_responseWithoutMessage() { + Map testMap = new LinkedHashMap<>(); + testMap.put("requestStatus", "not_accepted"); + testMap.put("statusMessage", ""); + try { + new SniroValidator().validateDemandsResponse(testMap); + } catch (BadResponseException e) { + assertThat(e.getMessage()).contains("error message not provided"); + } + } + + @Test + public void validateDemandsResponse_responseWithoutRequestStatus() { + Map testMap = new LinkedHashMap<>(); + testMap.put("statusMessage", ""); + try { + new SniroValidator().validateDemandsResponse(testMap); + } catch (BadResponseException e) { + assertThat(e.getMessage()).contains("Sniro Managers synchronous response does not contain: request status"); + } + } + + @Test + public void validateSolution_success() throws BadResponseException { + SniroValidator.validateSolution("{statusMessage:key}"); + } + + @Test + public void validateSolution_emptyResponse() { + try { + SniroValidator.validateSolution(""); + } catch (BadResponseException e) { + assertThat(e.getMessage()).contains("Sniro Managers asynchronous response is empty"); + } + } + + @Test + public void validateSolution_errorResponseWithoutMessage() { + try { + SniroValidator.validateSolution("{\"serviceException\":{\"text\":\"\"}}"); + } catch (BadResponseException e) { + assertThat(e.getMessage()).contains( + "Sniro Managers asynchronous response contains a service exception: error message not provided"); + } + } + + @Test + public void validateSolution_errorResponseWithErrorMessage() { + String message = "An error occurred"; + try { + SniroValidator.validateSolution("{\"serviceException\":{\"text\":\"" + message + "\"}}"); + } catch (BadResponseException e) { + assertThat(e.getMessage()) + .contains("Sniro Managers asynchronous response contains a service exception: " + message); + } + } + + @Test + public void validateReleaseResponse_success() throws BadResponseException { + Map testMap = new LinkedHashMap<>(); + testMap.put("status", "success"); + new SniroValidator().validateReleaseResponse(testMap); + } + + @Test + public void validateReleaseResponse_emptyResponse() { + try { + new SniroValidator().validateReleaseResponse(new LinkedHashMap<>()); + } catch (BadResponseException e) { + assertThat(e.getMessage()).contains("Sniro Conductors response is empty"); + } + } + + @Test + public void validateReleaseResponse_errorResponseWithErrorMessage() { + String message = "An error occurred"; + Map testMap = new LinkedHashMap<>(); + testMap.put("status", "failed"); + testMap.put("message", message); + try { + new SniroValidator().validateReleaseResponse(testMap); + } catch (BadResponseException e) { + assertThat(e.getMessage()).contains("Sniro Conductors synchronous response indicates failed: " + message); + } + } + + @Test + public void validateReleaseResponse_errorResponseWithNoMessage() { + Map testMap = new LinkedHashMap<>(); + testMap.put("status", "failed"); + testMap.put("message", ""); + try { + new SniroValidator().validateReleaseResponse(testMap); + } catch (BadResponseException e) { + assertThat(e.getMessage()) + .contains("Sniro Conductors synchronous response indicates failed: error message not provided"); + } + } + + @Test + public void validateReleaseResponse_responseWithoutStatus() { + Map testMap = new LinkedHashMap<>(); + testMap.put("statusMessage", ""); + try { + new SniroValidator().validateReleaseResponse(testMap); + } catch (BadResponseException e) { + assertThat(e.getMessage()).contains("Sniro Conductors synchronous response does not contain: status"); + } + } +} diff --git a/version.properties b/version.properties index ccc7b6172b..f6bcc5a3a1 100644 --- a/version.properties +++ b/version.properties @@ -3,8 +3,8 @@ # because they are used in Jenkins, whose plug-in doesn't support major=1 -minor=9 -patch=2 +minor=11 +patch=0 base_version=${major}.${minor}.${patch}