From 0f65f07915ae81528fa40ab90087ef4987be26ee Mon Sep 17 00:00:00 2001 From: eeginux Date: Thu, 7 Nov 2019 15:19:58 +0000 Subject: SO CDS Metadata ingestion Add support for controller_actor ingestion Add support for blueprint in service Add support for skip conf flag in vf module Ingest new properties into SO database Sample csar files are cleaned without comment and description Issue-ID: SO-2313 Change-Id: I657f997faf33a366f3c234c3e41b164275beedac Signed-off-by: eeginux --- .../V8.1__AddControllerActorAndBlueprint.sql | 23 +++ .../src/test/resources/schema.sql | 7 + .../so/asdc/installer/ToscaResourceStructure.java | 3 +- .../installer/heat/ToscaResourceInstaller.java | 23 ++- .../onap/so/asdc/client/ASDCControllerITTest.java | 205 ++++++++++++++++++--- .../resources/download/service-pnfservice.csar | Bin 0 -> 27525 bytes .../resources/download/service-vnfservice.csar | Bin 0 -> 27602 bytes asdc-controller/src/test/resources/schema.sql | 9 +- .../src/test/resources/schema.sql | 7 + .../db/catalog/beans/PnfResourceCustomization.java | 12 +- .../java/org/onap/so/db/catalog/beans/Service.java | 43 +++++ .../so/db/catalog/beans/VfModuleCustomization.java | 11 ++ .../db/catalog/beans/VnfResourceCustomization.java | 12 +- mso-catalog-db/src/test/resources/schema.sql | 7 + 14 files changed, 325 insertions(+), 37 deletions(-) create mode 100644 adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V8.1__AddControllerActorAndBlueprint.sql create mode 100644 asdc-controller/src/test/resources/download/service-pnfservice.csar create mode 100644 asdc-controller/src/test/resources/download/service-vnfservice.csar diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V8.1__AddControllerActorAndBlueprint.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V8.1__AddControllerActorAndBlueprint.sql new file mode 100644 index 0000000000..5560dcc0de --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V8.1__AddControllerActorAndBlueprint.sql @@ -0,0 +1,23 @@ +use catalogdb; + +ALTER TABLE service +ADD CONTROLLER_ACTOR varchar(200) null; + +ALTER TABLE service +ADD CDS_BLUEPRINT_NAME varchar(200) null; + +ALTER TABLE service +ADD CDS_BLUEPRINT_VERSION varchar(20) null; + +ALTER TABLE service +ADD SKIP_POST_INSTANTIATION_CONFIGURATION boolean default true; + +ALTER TABLE vnf_resource_customization +ADD CONTROLLER_ACTOR varchar(200) null; + +ALTER TABLE pnf_resource_customization +ADD CONTROLLER_ACTOR varchar(200) null; + +ALTER TABLE vf_module_customization +ADD SKIP_POST_INSTANTIATION_CONFIGURATION boolean default true; + diff --git a/adapters/mso-openstack-adapters/src/test/resources/schema.sql b/adapters/mso-openstack-adapters/src/test/resources/schema.sql index 9406bc445d..b96d58f419 100644 --- a/adapters/mso-openstack-adapters/src/test/resources/schema.sql +++ b/adapters/mso-openstack-adapters/src/test/resources/schema.sql @@ -806,6 +806,10 @@ CREATE TABLE `service` ( `OVERALL_DISTRIBUTION_STATUS` varchar(45), `ONAP_GENERATED_NAMING` TINYINT(1) DEFAULT NULL, `NAMING_POLICY` varchar(200) DEFAULT NULL, + `CDS_BLUEPRINT_NAME` varchar(200) DEFAULT NULL, + `CDS_BLUEPRINT_VERSION` varchar(20) DEFAULT NULL, + `CONTROLLER_ACTOR` varchar(200) DEFAULT NULL, + `SKIP_POST_INSTANTIATION_CONFIGURATION` boolean default true, PRIMARY KEY (`MODEL_UUID`), KEY `fk_service__tosca_csar1_idx` (`TOSCA_CSAR_ARTIFACT_UUID`), CONSTRAINT `fk_service__tosca_csar1` FOREIGN KEY (`TOSCA_CSAR_ARTIFACT_UUID`) REFERENCES `tosca_csar` (`ARTIFACT_UUID`) ON DELETE CASCADE ON UPDATE CASCADE @@ -960,6 +964,7 @@ CREATE TABLE `vf_module_customization` ( `CREATION_TIMESTAMP` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, `VF_MODULE_MODEL_UUID` varchar(200) NOT NULL, `VNF_RESOURCE_CUSTOMIZATION_ID` int(13) DEFAULT NULL, + `SKIP_POST_INSTANTIATION_CONFIGURATION` boolean default true, PRIMARY KEY (`ID`), KEY `fk_vf_module_customization__vf_module1_idx` (`VF_MODULE_MODEL_UUID`), KEY `fk_vf_module_customization__heat_env__heat_environment1_idx` (`HEAT_ENVIRONMENT_ARTIFACT_UUID`), @@ -1111,6 +1116,7 @@ CREATE TABLE `vnf_resource_customization` ( `SERVICE_MODEL_UUID` varchar(200) NOT NULL, `NF_DATA_VALID` tinyint(1) DEFAULT '0', `VNFCINSTANCEGROUP_ORDER` varchar(200) default NULL, + `CONTROLLER_ACTOR` varchar(200) DEFAULT NULL, PRIMARY KEY (`ID`), UNIQUE KEY `UK_vnf_resource_customization` (`MODEL_CUSTOMIZATION_UUID`,`SERVICE_MODEL_UUID`), KEY `fk_vnf_resource_customization__vnf_resource1_idx` (`VNF_RESOURCE_MODEL_UUID`), @@ -1192,6 +1198,7 @@ CREATE TABLE IF NOT EXISTS `pnf_resource_customization` ( `CDS_BLUEPRINT_NAME` varchar(200) DEFAULT NULL, `CDS_BLUEPRINT_VERSION` varchar(20) DEFAULT NULL, `SKIP_POST_INSTANTIATION_CONFIGURATION` boolean default true, + `CONTROLLER_ACTOR` varchar(200) DEFAULT NULL, PRIMARY KEY (`MODEL_CUSTOMIZATION_UUID`), KEY `fk_pnf_resource_customization__pnf_resource1_idx` (`PNF_RESOURCE_MODEL_UUID`), CONSTRAINT `fk_pnf_resource_customization__pnf_resource1` FOREIGN KEY (`PNF_RESOURCE_MODEL_UUID`) REFERENCES `pnf_resource` (`MODEL_UUID`) ON DELETE CASCADE ON UPDATE CASCADE diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/ToscaResourceStructure.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/ToscaResourceStructure.java index 3f1b080ec1..dcb49478f4 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/ToscaResourceStructure.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/ToscaResourceStructure.java @@ -25,7 +25,6 @@ package org.onap.so.asdc.installer; import java.io.File; import java.nio.file.Paths; import java.util.List; -import org.onap.so.logger.LoggingAnchor; import org.onap.sdc.api.notification.IArtifactInfo; import org.onap.sdc.tosca.parser.api.ISdcCsarHelper; import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory; @@ -52,10 +51,10 @@ import org.onap.so.db.catalog.beans.VfModule; import org.onap.so.db.catalog.beans.VfModuleCustomization; import org.onap.so.db.catalog.beans.VnfResourceCustomization; import org.onap.so.logger.ErrorCode; +import org.onap.so.logger.LoggingAnchor; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Value; public class ToscaResourceStructure { diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java index 8d51d5b894..5987c5ad93 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java @@ -182,6 +182,12 @@ public class ToscaResourceInstaller { protected static final String SKIP_POST_INST_CONF = "skip_post_instantiation_configuration"; + private static final String CONTROLLER_ACTOR = "controller_actor"; + + private static final String CDS_MODEL_NAME = "cds_model_name"; + + private static final String CDS_MODEL_VERSION = "cds_model_version"; + @Autowired protected ServiceRepository serviceRepo; @@ -975,8 +981,8 @@ public class ToscaResourceInstaller { pnfResourceCustomization.setBlueprintName(getStringValue(properties.get(SDNC_MODEL_NAME))); pnfResourceCustomization.setBlueprintVersion(getStringValue(properties.get(SDNC_MODEL_VERSION))); pnfResourceCustomization.setSkipPostInstConf(getBooleanValue(properties.get(SKIP_POST_INST_CONF))); + pnfResourceCustomization.setControllerActor(getStringValue(properties.get(CONTROLLER_ACTOR))); pnfResourceCustomization.setPnfResources(pnfResource); - return pnfResourceCustomization; } @@ -1401,7 +1407,6 @@ public class ToscaResourceInstaller { ResourceStructure resourceStructure) { Metadata serviceMetadata = toscaResourceStructure.getServiceMetadata(); - List services = serviceRepo.findByModelUUID(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); Service service; @@ -1438,6 +1443,10 @@ public class ToscaResourceInstaller { generateNamingValue = "true".equalsIgnoreCase(generateNaming); } service.setOnapGeneratedNaming(generateNamingValue); + service.setBlueprintName(serviceMetadata.getValue(CDS_MODEL_NAME)); + service.setBlueprintVersion(serviceMetadata.getValue(CDS_MODEL_VERSION)); + service.setSkipPostInstConf(Boolean.valueOf(serviceMetadata.getValue(SKIP_POST_INST_CONF))); + service.setControllerActor(serviceMetadata.getValue(CONTROLLER_ACTOR)); } @@ -2382,6 +2391,14 @@ public class ToscaResourceInstaller { if (minInstances != null && minInstances.length() > 0) { vfModuleCustomization.setMinInstances(Integer.valueOf(minInstances)); } + + String skipPostInstConfText = getLeafPropertyValue(vfModuleEntityDetails, SKIP_POST_INST_CONF); + + if (skipPostInstConfText != null) { + vfModuleCustomization.setSkipPostInstConf( + Boolean.parseBoolean(getLeafPropertyValue(vfModuleEntityDetails, SKIP_POST_INST_CONF))); + } + return vfModuleCustomization; } @@ -2576,7 +2593,7 @@ public class ToscaResourceInstaller { Boolean.parseBoolean(getLeafPropertyValue(entityDetails, SKIP_POST_INST_CONF))); } - + vnfResourceCustomization.setControllerActor(getLeafPropertyValue(entityDetails, CONTROLLER_ACTOR)); vnfResourceCustomization.setVnfResources(vnfResource); vnfResourceCustomization.setAvailabilityZoneMaxCount(Integer.getInteger( entityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT))); diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerITTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerITTest.java index 0c7f97759b..3db017cac5 100644 --- a/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerITTest.java +++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerITTest.java @@ -1,15 +1,20 @@ -/* - * ============LICENSE_START======================================================= Copyright (C) 2019 Nordix - * Foundation. ================================================================================ Licensed under the - * Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may - * obtain a copy of the License at +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix + * ================================================================================ + * 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. + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * SPDX-License-Identifier: Apache-2.0 ============LICENSE_END========================================================= + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= */ package org.onap.so.asdc.client; @@ -20,6 +25,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import java.util.ArrayList; import java.util.Collections; @@ -29,7 +35,6 @@ import java.util.UUID; import javax.persistence.EntityNotFoundException; import org.junit.After; import org.junit.Before; -import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TestName; @@ -64,7 +69,10 @@ import org.springframework.transaction.annotation.Transactional; * This is used to run some basic integration test(BIT) for ASDC controller. It will test the csar install and all the * testing csar files are located underneath src/main/resources/download folder, * - * PNF csar: service-Testservice140-csar.csar VNF csar: service-Svc140-VF-csar.csar + * PNF csar: service-pnfservice.csar VNF csar: service-Svc140-VF-csar.csar + * + * All the csar files are cleaned, i.e, removing the comments and most of the description to avoid violation of + * security. */ @Transactional public class ASDCControllerITTest extends BaseTest { @@ -141,12 +149,148 @@ public class ASDCControllerITTest extends BaseTest { * Mock the AAI using wireshark. */ private void initMockAaiServer(final String serviceUuid, final String serviceInvariantUuid) { - String modelEndpoint = "/aai/v15/service-design-and-creation/models/model/" + serviceInvariantUuid + String modelEndpoint = "/aai/v17/service-design-and-creation/models/model/" + serviceInvariantUuid + "/model-vers/model-ver/" + serviceUuid + "?depth=0"; wireMockServer.stubFor(post(urlEqualTo(modelEndpoint)).willReturn(ok())); } + /** + * Test with service-pnfservice.csar. + */ + @Test + public void treatNotification_ValidPnfResource_ExpectedOutput() { + + /** + * service UUID/invariantUUID from global metadata in service-PnfServiceTestCds-template.yml. + */ + String serviceUuid = "77cf276e-905c-43f6-8d54-dda474be2f2e"; + String serviceInvariantUuid = "913e6776-4bc3-49b9-b399-b5bb4690f0c7"; + + initMockAaiServer(serviceUuid, serviceInvariantUuid); + + NotificationDataImpl notificationData = new NotificationDataImpl(); + notificationData.setServiceUUID(serviceUuid); + notificationData.setDistributionID(distributionId); + notificationData.setServiceInvariantUUID(serviceInvariantUuid); + notificationData.setServiceVersion("1.0"); + + ResourceInfoImpl resourceInfo = constructPnfResourceInfo(); + List resourceInfoList = new ArrayList<>(); + resourceInfoList.add(resourceInfo); + notificationData.setResources(resourceInfoList); + + ArtifactInfoImpl artifactInfo = constructPnfServiceArtifact(); + List artifactInfoList = new ArrayList<>(); + artifactInfoList.add(artifactInfo); + notificationData.setServiceArtifacts(artifactInfoList); + + try { + asdcController.treatNotification(notificationData); + + logger.info("Checking the database for PNF ingestion"); + + /** + * Check the tosca csar entity, it should be the same as provided from NotficationData. + */ + ToscaCsar toscaCsar = toscaCsarRepository.findById(artifactUuid) + .orElseThrow(() -> new EntityNotFoundException("Tosca csar: " + artifactUuid + " not found")); + assertEquals("tosca csar UUID", artifactUuid, toscaCsar.getArtifactUUID()); + assertEquals("tosca csar name", "service-pnfservice.csar", toscaCsar.getName()); + assertEquals("tosca csar version", "1.0", toscaCsar.getVersion()); + assertNull("tosca csar descrption", toscaCsar.getDescription()); + assertEquals("tosca csar checksum", "MANUAL_RECORD", toscaCsar.getArtifactChecksum()); + assertEquals("toscar csar URL", "/download/service-pnfservice.csar", toscaCsar.getUrl()); + + /** + * Check the service entity, it should be the same as global metadata information in + * service-Testservice140-template.yml inside csar. + */ + Service service = serviceRepository.findById(serviceUuid) + .orElseThrow(() -> new EntityNotFoundException("Service: " + serviceUuid + " not found")); + assertEquals("model UUID", serviceUuid, service.getModelUUID()); + assertEquals("model name", "PNF Service Test CDS", service.getModelName()); + assertEquals("model invariantUUID", serviceInvariantUuid, service.getModelInvariantUUID()); + assertEquals("model version", "1.0", service.getModelVersion()); + assertEquals("description", "123123", service.getDescription().trim()); + assertEquals("tosca csar artifact UUID", artifactUuid, service.getCsar().getArtifactUUID()); + assertEquals("service type", "", service.getServiceType()); + assertEquals("service role", "", service.getServiceRole()); + assertEquals("environment context", "General_Revenue-Bearing", service.getEnvironmentContext()); + assertEquals("service category", "Network L1-3", service.getCategory()); + assertNull("workload context", service.getWorkloadContext()); + assertEquals("resource order", "PNF CDS Test", service.getResourceOrder()); + assertEquals("CDS blueprint name", "Blueprint140", service.getBlueprintName()); + assertEquals("CDS blueprint version", "v1.4.0", service.getBlueprintVersion()); + assertEquals("controller actor", "SO-REF-DATA", service.getControllerActor()); + + /** + * Check PNF resource, it should be the same as metadata in the topology template in + * service-PnfServiceTestCds-template.yml OR global metadata in the resource-PnfServiceTestCds-template.yml + */ + String pnfResourceKey = "aa5d0562-80e7-43e9-af74-3085e57ab09f"; + PnfResource pnfResource = pnfResourceRepository.findById(pnfResourceKey) + .orElseThrow(() -> new EntityNotFoundException("PNF resource:" + pnfResourceKey + " not found")); + assertNull("orchestration mode", pnfResource.getOrchestrationMode()); + assertEquals("Description", "123123", pnfResource.getDescription().trim()); + assertEquals("model UUID", pnfResourceKey, pnfResource.getModelUUID()); + assertEquals("model invariant UUID", "17d9d183-cee5-4a46-b5c4-6d5203f7d2e8", + pnfResource.getModelInvariantUUID()); + assertEquals("model version", "1.0", pnfResource.getModelVersion()); + assertEquals("model name", "PNF CDS Test", pnfResource.getModelName()); + assertEquals("tosca node type", "org.openecomp.resource.pnf.PnfCdsTest", pnfResource.getToscaNodeType()); + assertEquals("resource category", "Application L4+", pnfResource.getCategory()); + assertEquals("resource sub category", "Firewall", pnfResource.getSubCategory()); + + /** + * Check PNF resource customization, it should be the same as metadata in the topology template in + * service-PnfServiceTestCds-template.yml OR global metadata in the resource-PnfServiceTestCds-template.yml + */ + String pnfCustomizationKey = "9f01263a-eaf7-4d98-a37b-3785f751903e"; + PnfResourceCustomization pnfCustomization = pnfCustomizationRepository.findById(pnfCustomizationKey) + .orElseThrow(() -> new EntityNotFoundException( + "PNF resource customization: " + pnfCustomizationKey + " not found")); + assertEquals("model customizationUUID", pnfCustomizationKey, pnfCustomization.getModelCustomizationUUID()); + assertEquals("model instance name", "PNF CDS Test 0", pnfCustomization.getModelInstanceName()); + assertEquals("NF type", "", pnfCustomization.getNfType()); + assertEquals("NF Role", "nf", pnfCustomization.getNfRole()); + assertEquals("NF function", "nf", pnfCustomization.getNfFunction()); + assertEquals("NF naming code", "", pnfCustomization.getNfNamingCode()); + assertEquals("PNF resource model UUID", pnfResourceKey, pnfCustomization.getPnfResources().getModelUUID()); + assertEquals("Multi stage design", "", pnfCustomization.getMultiStageDesign()); + assertNull("resource input", pnfCustomization.getResourceInput()); + assertEquals("cds blueprint name(sdnc_model_name property)", "Blueprint140", + pnfCustomization.getBlueprintName()); + assertEquals("cds blueprint version(sdnc_model_version property)", "v1.4.0", + pnfCustomization.getBlueprintVersion()); + assertTrue("skip post instantiation configuration", pnfCustomization.isSkipPostInstConf()); + assertEquals("controller actor", "SO-REF-DATA", pnfCustomization.getControllerActor()); + + /** + * Check the pnf resource customization with service mapping + */ + List pnfCustList = service.getPnfCustomizations(); + assertEquals("PNF resource customization entity", 1, pnfCustList.size()); + assertEquals(pnfCustomizationKey, pnfCustList.get(0).getModelCustomizationUUID()); + + /** + * Check the watchdog for component distribution status + */ + List distributionList = + watchdogCDStatusRepository.findByDistributionId(this.distributionId); + assertNotNull(distributionList); + assertEquals(1, distributionList.size()); + WatchdogComponentDistributionStatus distributionStatus = distributionList.get(0); + assertEquals("COMPONENT_DONE_OK", distributionStatus.getComponentDistributionStatus()); + assertEquals("SO", distributionStatus.getComponentName()); + + + } catch (Exception e) { + logger.info(e.getMessage(), e); + fail(e.getMessage()); + } + } + /** * Test to check RequestId is being set using the DistributionID. */ @@ -179,8 +323,8 @@ public class ASDCControllerITTest extends BaseTest { private ArtifactInfoImpl constructPnfServiceArtifact() { ArtifactInfoImpl artifactInfo = new ArtifactInfoImpl(); artifactInfo.setArtifactType(ASDCConfiguration.TOSCA_CSAR); - artifactInfo.setArtifactURL("/download/service-Testservice140-csar.csar"); - artifactInfo.setArtifactName("service-Testservice140-csar.csar"); + artifactInfo.setArtifactURL("/download/service-pnfservice.csar"); + artifactInfo.setArtifactName("service-pnfservice.csar"); artifactInfo.setArtifactVersion("1.0"); artifactInfo.setArtifactUUID(artifactUuid); return artifactInfo; @@ -192,13 +336,13 @@ public class ASDCControllerITTest extends BaseTest { */ private ResourceInfoImpl constructPnfResourceInfo() { ResourceInfoImpl resourceInfo = new ResourceInfoImpl(); - resourceInfo.setResourceInstanceName("Test140PNF"); - resourceInfo.setResourceInvariantUUID("d832a027-75f3-455d-9de4-f02fcdee7e7e"); + resourceInfo.setResourceInstanceName("PNF CDS Test"); + resourceInfo.setResourceInvariantUUID("17d9d183-cee5-4a46-b5c4-6d5203f7d2e8"); resourceInfo.setResoucreType("PNF"); resourceInfo.setCategory("Application L4+"); - resourceInfo.setSubcategory("Call Control"); - resourceInfo.setResourceUUID("9c54e269-122b-4e8a-8b2a-6eac849b441a"); - resourceInfo.setResourceCustomizationUUID("428a3d73-f962-4cc2-ba62-2483c45d6b12"); + resourceInfo.setSubcategory("Firewall"); + resourceInfo.setResourceUUID("aa5d0562-80e7-43e9-af74-3085e57ab09f"); + resourceInfo.setResourceCustomizationUUID("9f01263a-eaf7-4d98-a37b-3785f751903e"); resourceInfo.setResourceVersion("1.0"); return resourceInfo; } @@ -207,7 +351,6 @@ public class ASDCControllerITTest extends BaseTest { * Testing with the service-Svc140-VF-csar.csar. */ @Test - @Ignore public void treatNotification_ValidVnfResource_ExpectedOutput() { /** @@ -244,11 +387,11 @@ public class ASDCControllerITTest extends BaseTest { ToscaCsar toscaCsar = toscaCsarRepository.findById(artifactUuid) .orElseThrow(() -> new EntityNotFoundException("Tosca csar: " + artifactUuid + " not found")); assertEquals("tosca csar UUID", artifactUuid, toscaCsar.getArtifactUUID()); - assertEquals("tosca csar name", "service-Svc140-VF-csar.csar", toscaCsar.getName()); + assertEquals("tosca csar name", "service-vnfservice.csar", toscaCsar.getName()); assertEquals("tosca csar version", "1.0", toscaCsar.getVersion()); assertNull("tosca csar descrption", toscaCsar.getDescription()); assertEquals("tosca csar checksum", "MANUAL_RECORD", toscaCsar.getArtifactChecksum()); - assertEquals("toscar csar URL", "/download/service-Svc140-VF-csar.csar", toscaCsar.getUrl()); + assertEquals("toscar csar URL", "/download/service-vnfservice.csar", toscaCsar.getUrl()); /** * Check the service entity, it should be the same as global metadata information in @@ -268,6 +411,9 @@ public class ASDCControllerITTest extends BaseTest { assertEquals("service category", "Network Service", service.getCategory()); assertNull("workload context", service.getWorkloadContext()); assertEquals("resource order", "TestVF140", service.getResourceOrder()); + assertEquals("CDS blueprint name", "BP140", service.getBlueprintName()); + assertEquals("CDS blueprint version", "v1.4.0", service.getBlueprintVersion()); + assertEquals("controller actor", "SO-REF-DATA", service.getControllerActor()); /** * Check VNF resource, it should be the same as metadata in the topology template in @@ -304,11 +450,12 @@ public class ASDCControllerITTest extends BaseTest { assertNull("NF naming code", vnfCustomization.getNfNamingCode()); assertEquals("VNF resource model UUID", vnfResourceKey, vnfCustomization.getVnfResources().getModelUUID()); assertEquals("Multi stage design", "false", vnfCustomization.getMultiStageDesign()); - assertNull("resource input", vnfCustomization.getResourceInput()); - assertEquals("cds blueprint name(sdnc_model_name property)", vnfCustomization.getBlueprintName(), - vnfCustomization.getBlueprintName()); - assertEquals("cds blueprint version(sdnc_model_version property)", vnfCustomization.getBlueprintVersion(), + assertNotNull("resource input", vnfCustomization.getResourceInput()); + assertEquals("cds blueprint name(sdnc_model_name property)", "BP140", vnfCustomization.getBlueprintName()); + assertEquals("cds blueprint version(sdnc_model_version property)", "v1.4.0", vnfCustomization.getBlueprintVersion()); + assertEquals("controller actor", "SO-REF-DATA", vnfCustomization.getControllerActor()); + /** * Check the vnf resource customization with service mapping */ @@ -335,8 +482,8 @@ public class ASDCControllerITTest extends BaseTest { private ArtifactInfoImpl constructVnfServiceArtifact() { ArtifactInfoImpl artifactInfo = new ArtifactInfoImpl(); artifactInfo.setArtifactType(ASDCConfiguration.TOSCA_CSAR); - artifactInfo.setArtifactURL("/download/service-Svc140-VF-csar.csar"); - artifactInfo.setArtifactName("service-Svc140-VF-csar.csar"); + artifactInfo.setArtifactURL("/download/service-vnfservice.csar"); + artifactInfo.setArtifactName("service-vnfservice.csar"); artifactInfo.setArtifactVersion("1.0"); artifactInfo.setArtifactUUID(artifactUuid); return artifactInfo; diff --git a/asdc-controller/src/test/resources/download/service-pnfservice.csar b/asdc-controller/src/test/resources/download/service-pnfservice.csar new file mode 100644 index 0000000000..89d24a18ee Binary files /dev/null and b/asdc-controller/src/test/resources/download/service-pnfservice.csar differ diff --git a/asdc-controller/src/test/resources/download/service-vnfservice.csar b/asdc-controller/src/test/resources/download/service-vnfservice.csar new file mode 100644 index 0000000000..25d2ebd6c6 Binary files /dev/null and b/asdc-controller/src/test/resources/download/service-vnfservice.csar differ diff --git a/asdc-controller/src/test/resources/schema.sql b/asdc-controller/src/test/resources/schema.sql index d138d9e236..ed6cb89bf6 100644 --- a/asdc-controller/src/test/resources/schema.sql +++ b/asdc-controller/src/test/resources/schema.sql @@ -809,6 +809,10 @@ CREATE TABLE `service` ( `OVERALL_DISTRIBUTION_STATUS` varchar(45), `ONAP_GENERATED_NAMING` TINYINT(1) DEFAULT NULL, `NAMING_POLICY` varchar(200) DEFAULT NULL, + `CDS_BLUEPRINT_NAME` varchar(200) DEFAULT NULL, + `CDS_BLUEPRINT_VERSION` varchar(20) DEFAULT NULL, + `CONTROLLER_ACTOR` varchar(200) DEFAULT NULL, + `SKIP_POST_INSTANTIATION_CONFIGURATION` boolean default true, PRIMARY KEY (`MODEL_UUID`), KEY `fk_service__tosca_csar1_idx` (`TOSCA_CSAR_ARTIFACT_UUID`), CONSTRAINT `fk_service__tosca_csar1` FOREIGN KEY (`TOSCA_CSAR_ARTIFACT_UUID`) REFERENCES `tosca_csar` (`ARTIFACT_UUID`) ON DELETE CASCADE ON UPDATE CASCADE @@ -963,6 +967,7 @@ CREATE TABLE `vf_module_customization` ( `CREATION_TIMESTAMP` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, `VF_MODULE_MODEL_UUID` varchar(200) NOT NULL, `VNF_RESOURCE_CUSTOMIZATION_ID` int(13) DEFAULT NULL, + `SKIP_POST_INSTANTIATION_CONFIGURATION` boolean default true, PRIMARY KEY (`ID`), KEY `fk_vf_module_customization__vf_module1_idx` (`VF_MODULE_MODEL_UUID`), KEY `fk_vf_module_customization__heat_env__heat_environment1_idx` (`HEAT_ENVIRONMENT_ARTIFACT_UUID`), @@ -1113,7 +1118,8 @@ CREATE TABLE `vnf_resource_customization` ( `VNF_RESOURCE_MODEL_UUID` varchar(200) NOT NULL, `SERVICE_MODEL_UUID` varchar(200) NOT NULL, `VNFCINSTANCEGROUP_ORDER` varchar(200) default NULL, - `NF_DATA_VALID` tinyint(1) DEFAULT '0', + `NF_DATA_VALID` tinyint(1) DEFAULT '0', + `CONTROLLER_ACTOR` varchar(200) DEFAULT NULL, PRIMARY KEY (`ID`), UNIQUE KEY `UK_vnf_resource_customization` (`MODEL_CUSTOMIZATION_UUID`,`SERVICE_MODEL_UUID`), KEY `fk_vnf_resource_customization__vnf_resource1_idx` (`VNF_RESOURCE_MODEL_UUID`), @@ -1195,6 +1201,7 @@ CREATE TABLE IF NOT EXISTS `pnf_resource_customization` ( `CDS_BLUEPRINT_NAME` varchar(200) DEFAULT NULL, `CDS_BLUEPRINT_VERSION` varchar(20) DEFAULT NULL, `SKIP_POST_INSTANTIATION_CONFIGURATION` boolean default true, + `CONTROLLER_ACTOR` varchar(200) DEFAULT NULL, PRIMARY KEY (`MODEL_CUSTOMIZATION_UUID`), KEY `fk_pnf_resource_customization__pnf_resource1_idx` (`PNF_RESOURCE_MODEL_UUID`), CONSTRAINT `fk_pnf_resource_customization__pnf_resource1` FOREIGN KEY (`PNF_RESOURCE_MODEL_UUID`) REFERENCES `pnf_resource` (`MODEL_UUID`) ON DELETE CASCADE ON UPDATE CASCADE diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql b/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql index a93ffd46a8..55db69b9d2 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql @@ -809,6 +809,10 @@ CREATE TABLE `service` ( `OVERALL_DISTRIBUTION_STATUS` varchar(45), `ONAP_GENERATED_NAMING` TINYINT(1) DEFAULT NULL, `NAMING_POLICY` varchar(200) DEFAULT NULL, + `CDS_BLUEPRINT_NAME` varchar(200) DEFAULT NULL, + `CDS_BLUEPRINT_VERSION` varchar(20) DEFAULT NULL, + `CONTROLLER_ACTOR` varchar(200) DEFAULT NULL, + `SKIP_POST_INSTANTIATION_CONFIGURATION` boolean default true, PRIMARY KEY (`MODEL_UUID`), KEY `fk_service__tosca_csar1_idx` (`TOSCA_CSAR_ARTIFACT_UUID`), CONSTRAINT `fk_service__tosca_csar1` FOREIGN KEY (`TOSCA_CSAR_ARTIFACT_UUID`) REFERENCES `tosca_csar` (`ARTIFACT_UUID`) ON DELETE CASCADE ON UPDATE CASCADE @@ -963,6 +967,7 @@ CREATE TABLE `vf_module_customization` ( `CREATION_TIMESTAMP` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, `VF_MODULE_MODEL_UUID` varchar(200) NOT NULL, `VNF_RESOURCE_CUSTOMIZATION_ID` int(13) DEFAULT NULL, + `SKIP_POST_INSTANTIATION_CONFIGURATION` boolean default true, PRIMARY KEY (`ID`), KEY `fk_vf_module_customization__vf_module1_idx` (`VF_MODULE_MODEL_UUID`), KEY `fk_vf_module_customization__heat_env__heat_environment1_idx` (`HEAT_ENVIRONMENT_ARTIFACT_UUID`), @@ -1113,6 +1118,7 @@ CREATE TABLE `vnf_resource_customization` ( `SERVICE_MODEL_UUID` varchar(200) NOT NULL, `NF_DATA_VALID` tinyint(1) DEFAULT '0', `VNFCINSTANCEGROUP_ORDER` varchar(200) default NULL, + `CONTROLLER_ACTOR` varchar(200) DEFAULT NULL, PRIMARY KEY (`ID`), UNIQUE KEY `UK_vnf_resource_customization` (`MODEL_CUSTOMIZATION_UUID`,`SERVICE_MODEL_UUID`), KEY `fk_vnf_resource_customization__vnf_resource1_idx` (`VNF_RESOURCE_MODEL_UUID`), @@ -1193,6 +1199,7 @@ CREATE TABLE IF NOT EXISTS `pnf_resource_customization` ( `RESOURCE_INPUT` varchar(2000) DEFAULT NULL, `CDS_BLUEPRINT_NAME` varchar(200) DEFAULT NULL, `CDS_BLUEPRINT_VERSION` varchar(20) DEFAULT NULL, + `CONTROLLER_ACTOR` varchar(200) DEFAULT NULL, PRIMARY KEY (`MODEL_CUSTOMIZATION_UUID`), KEY `fk_pnf_resource_customization__pnf_resource1_idx` (`PNF_RESOURCE_MODEL_UUID`), CONSTRAINT `fk_pnf_resource_customization__pnf_resource1` FOREIGN KEY (`PNF_RESOURCE_MODEL_UUID`) REFERENCES `pnf_resource` (`MODEL_UUID`) ON DELETE CASCADE ON UPDATE CASCADE diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/PnfResourceCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/PnfResourceCustomization.java index fabbc5007f..db0e0abd3c 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/PnfResourceCustomization.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/PnfResourceCustomization.java @@ -83,6 +83,9 @@ public class PnfResourceCustomization implements Serializable { @Column(name = "SKIP_POST_INSTANTIATION_CONFIGURATION") private Boolean skipPostInstConf; + @Column(name = "CONTROLLER_ACTOR") + private String controllerActor; + @Override public String toString() { return new ToStringBuilder(this).append("modelCustomizationUUID", modelCustomizationUUID) @@ -90,7 +93,7 @@ public class PnfResourceCustomization implements Serializable { .append("nfFunction", nfFunction).append("nfType", nfType).append("nfRole", nfRole) .append("nfNamingCode", nfNamingCode).append("multiStageDesign", multiStageDesign) .append("pnfResources", pnfResources).append("blueprintName", blueprintName) - .append("blueprintVersion", blueprintVersion).toString(); + .append("blueprintVersion", blueprintVersion).append("controllerActor", controllerActor).toString(); } @Override @@ -222,4 +225,11 @@ public class PnfResourceCustomization implements Serializable { this.skipPostInstConf = skipPostInstConf; } + public String getControllerActor() { + return controllerActor; + } + + public void setControllerActor(String controllerActor) { + this.controllerActor = controllerActor; + } } diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Service.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Service.java index e591552ebf..ab40cefb4e 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Service.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Service.java @@ -142,6 +142,18 @@ public class Service implements Serializable { @Column(name = "ONAP_GENERATED_NAMING") private Boolean onapGeneratedNaming; + @Column(name = "CDS_BLUEPRINT_NAME") + private String blueprintName; + + @Column(name = "CDS_BLUEPRINT_VERSION") + private String blueprintVersion; + + @Column(name = "SKIP_POST_INSTANTIATION_CONFIGURATION") + private Boolean skipPostInstConf; + + @Column(name = "CONTROLLER_ACTOR") + private String controllerActor; + @Override public String toString() { return new ToStringBuilder(this).append("modelName", modelName).append("description", description) @@ -399,4 +411,35 @@ public class Service implements Serializable { this.onapGeneratedNaming = onapGeneratedNaming; } + public String getBlueprintName() { + return blueprintName; + } + + public void setBlueprintName(String blueprintName) { + this.blueprintName = blueprintName; + } + + public String getBlueprintVersion() { + return blueprintVersion; + } + + public void setBlueprintVersion(String blueprintVersion) { + this.blueprintVersion = blueprintVersion; + } + + public Boolean isSkipPostInstConf() { + return skipPostInstConf; + } + + public void setSkipPostInstConf(Boolean skipPostInstConf) { + this.skipPostInstConf = skipPostInstConf; + } + + public String getControllerActor() { + return controllerActor; + } + + public void setControllerActor(String controllerActor) { + this.controllerActor = controllerActor; + } } diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VfModuleCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VfModuleCustomization.java index 29f8bcece5..3420682900 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VfModuleCustomization.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VfModuleCustomization.java @@ -100,6 +100,9 @@ public class VfModuleCustomization implements Serializable { @OneToMany(cascade = CascadeType.ALL, mappedBy = "vfModuleCustomization") private Set cvnfcCustomization; + @Column(name = "SKIP_POST_INSTANTIATION_CONFIGURATION") + private Boolean skipPostInstConf; + @Override public boolean equals(final Object other) { if (!(other instanceof VfModuleCustomization)) { @@ -239,4 +242,12 @@ public class VfModuleCustomization implements Serializable { public void setCvnfcCustomization(Set cvnfcCustomization) { this.cvnfcCustomization = cvnfcCustomization; } + + public Boolean isSkipPostInstConf() { + return skipPostInstConf; + } + + public void setSkipPostInstConf(Boolean skipPostInstConf) { + this.skipPostInstConf = skipPostInstConf; + } } diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResourceCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResourceCustomization.java index aec1c7fb22..094a1f0bf3 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResourceCustomization.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResourceCustomization.java @@ -124,6 +124,9 @@ public class VnfResourceCustomization implements Serializable { @Column(name = "NF_DATA_VALID") private Boolean nfDataValid; + @Column(name = "CONTROLLER_ACTOR") + private String controllerActor; + @Override public boolean equals(final Object other) { if (!(other instanceof VnfResourceCustomization)) { @@ -152,7 +155,8 @@ public class VnfResourceCustomization implements Serializable { .append("multiStageDesign", multiStageDesign).append("vnfResources", vnfResources) .append("vfModuleCustomizations", vfModuleCustomizations) .append("vnfcInstanceGroupOrder", vnfcInstanceGroupOrder) - .append("vnfcInstanceGroupCustomizations", vnfcInstanceGroupCustomizations).toString(); + .append("vnfcInstanceGroupCustomizations", vnfcInstanceGroupCustomizations) + .append("controllerActor", controllerActor).toString(); } @PrePersist @@ -345,5 +349,11 @@ public class VnfResourceCustomization implements Serializable { this.nfDataValid = nfDataValid; } + public String getControllerActor() { + return controllerActor; + } + public void setControllerActor(String controllerActor) { + this.controllerActor = controllerActor; + } } diff --git a/mso-catalog-db/src/test/resources/schema.sql b/mso-catalog-db/src/test/resources/schema.sql index 73370e1078..67584133f8 100644 --- a/mso-catalog-db/src/test/resources/schema.sql +++ b/mso-catalog-db/src/test/resources/schema.sql @@ -807,6 +807,10 @@ CREATE TABLE `service` ( `OVERALL_DISTRIBUTION_STATUS` varchar(45), `ONAP_GENERATED_NAMING` TINYINT(1) DEFAULT NULL, `NAMING_POLICY` varchar(200) DEFAULT NULL, + `CDS_BLUEPRINT_NAME` varchar(200) DEFAULT NULL, + `CDS_BLUEPRINT_VERSION` varchar(20) DEFAULT NULL, + `CONTROLLER_ACTOR` varchar(200) DEFAULT NULL, + `SKIP_POST_INSTANTIATION_CONFIGURATION` boolean default true, PRIMARY KEY (`MODEL_UUID`), KEY `fk_service__tosca_csar1_idx` (`TOSCA_CSAR_ARTIFACT_UUID`), CONSTRAINT `fk_service__tosca_csar1` FOREIGN KEY (`TOSCA_CSAR_ARTIFACT_UUID`) REFERENCES `tosca_csar` (`ARTIFACT_UUID`) ON DELETE CASCADE ON UPDATE CASCADE @@ -961,6 +965,7 @@ CREATE TABLE `vf_module_customization` ( `CREATION_TIMESTAMP` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, `VF_MODULE_MODEL_UUID` varchar(200) NOT NULL, `VNF_RESOURCE_CUSTOMIZATION_ID` int(13) DEFAULT NULL, + `SKIP_POST_INSTANTIATION_CONFIGURATION` boolean default true, PRIMARY KEY (`ID`), KEY `fk_vf_module_customization__vf_module1_idx` (`VF_MODULE_MODEL_UUID`), KEY `fk_vf_module_customization__heat_env__heat_environment1_idx` (`HEAT_ENVIRONMENT_ARTIFACT_UUID`), @@ -1112,6 +1117,7 @@ CREATE TABLE `vnf_resource_customization` ( `SERVICE_MODEL_UUID` varchar(200) NOT NULL, `NF_DATA_VALID` tinyint(1) DEFAULT '0', `VNFCINSTANCEGROUP_ORDER` varchar(200) default NULL, + `CONTROLLER_ACTOR` varchar(200) DEFAULT NULL, PRIMARY KEY (`ID`), UNIQUE KEY `UK_vnf_resource_customization` (`MODEL_CUSTOMIZATION_UUID`,`SERVICE_MODEL_UUID`), KEY `fk_vnf_resource_customization__vnf_resource1_idx` (`VNF_RESOURCE_MODEL_UUID`), @@ -1193,6 +1199,7 @@ CREATE TABLE IF NOT EXISTS `pnf_resource_customization` ( `CDS_BLUEPRINT_NAME` varchar(200) DEFAULT NULL, `CDS_BLUEPRINT_VERSION` varchar(20) DEFAULT NULL, `SKIP_POST_INSTANTIATION_CONFIGURATION` boolean default true, + `CONTROLLER_ACTOR` varchar(200) DEFAULT NULL, PRIMARY KEY (`MODEL_CUSTOMIZATION_UUID`), KEY `fk_pnf_resource_customization__pnf_resource1_idx` (`PNF_RESOURCE_MODEL_UUID`), CONSTRAINT `fk_pnf_resource_customization__pnf_resource1` FOREIGN KEY (`PNF_RESOURCE_MODEL_UUID`) REFERENCES `pnf_resource` (`MODEL_UUID`) ON DELETE CASCADE ON UPDATE CASCADE -- cgit 1.2.3-korg