From e8689688629582187b2484eda21524ee70abbb9f Mon Sep 17 00:00:00 2001 From: "Benjamin, Max (mb388a)" Date: Wed, 20 Mar 2019 16:19:39 -0400 Subject: Corrected hibernate for cfvc customization table fix two tests that did not ignore some properties fix schema sql file that was missing fields Properly wire hibernate entities, clean up db tables Update schema.sql files to be consistent add junit for customization linked to same cvnfc Change-Id: I4bc0a83cb3908f5b34224416e75446b6cd166b9e Issue-ID: SO-1689 Signed-off-by: Benjamin, Max (mb388a) --- .../installer/heat/ToscaResourceInstaller.java | 19 +---- .../onap/so/asdc/util/ASDCNotificationLogging.java | 59 +++++++++++++++ asdc-controller/src/test/resources/schema.sql | 86 ++++++++++++++-------- 3 files changed, 118 insertions(+), 46 deletions(-) (limited to 'asdc-controller/src') 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 ef0b4921e4..5af427a81a 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 @@ -1487,8 +1487,6 @@ public class ToscaResourceInstaller { List cvfcList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(vfTemplate, SdcTypes.CVFC); for(NodeTemplate cvfcTemplate : cvfcList) { - - CvnfcCustomization existingCvnfcCustomization = findExistingCvfc(existingCvnfcSet, cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); if(vfModuleMemberName != null && vfModuleMemberName.equalsIgnoreCase(cvfcTemplate.getName())){ @@ -1529,13 +1527,8 @@ public class ToscaResourceInstaller { // This check is needed incase the VFC subcategory is something other than Abstract. In that case we want to skip adding that record to our DB. if(vnfcCustomization.getModelCustomizationUUID() != null){ - CvnfcCustomization cvnfcCustomization = null; - - if(existingCvnfcCustomization != null){ - cvnfcCustomization = existingCvnfcCustomization; - } - else{ - + CvnfcCustomization cvnfcCustomization = new CvnfcCustomization(); + cvnfcCustomization = new CvnfcCustomization(); cvnfcCustomization.setModelCustomizationUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); cvnfcCustomization.setModelInstanceName(cvfcTemplate.getName()); @@ -1562,7 +1555,6 @@ public class ToscaResourceInstaller { cvnfcCustomizations.add(cvnfcCustomization); existingCvnfcSet.add(cvnfcCustomization); - } //***************************************************************************************************************************************** //* Extract Fabric Configuration @@ -1586,18 +1578,15 @@ public class ToscaResourceInstaller { VnfVfmoduleCvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization = createVfCnvfConfigCustomization(fabricTemplate, toscaResourceStructure, vnfResource, vfModuleCustomization, cvnfcCustomization, fabricConfig, vfTemplate, vfModuleMemberName); - vnfVfmoduleCvnfcConfigurationCustomizations.add(vnfVfmoduleCvnfcConfigurationCustomization); } - + cvnfcCustomization.setVnfVfmoduleCvnfcConfigurationCustomization(vnfVfmoduleCvnfcConfigurationCustomizations); } } } - } - vfModuleCustomization.setCvnfcCustomization(cvnfcCustomizations); vfModuleCustomization.setVnfVfmoduleCvnfcConfigurationCustomization(vnfVfmoduleCvnfcConfigurationCustomizations); @@ -1609,7 +1598,7 @@ public class ToscaResourceInstaller { ConfigurationResource configResource, NodeTemplate vfTemplate, String vfModuleMemberName) { Metadata fabricMetadata = fabricTemplate.getMetaData(); - + VnfVfmoduleCvnfcConfigurationCustomization vfModuleToCvnfc = new VnfVfmoduleCvnfcConfigurationCustomization(); vfModuleToCvnfc.setConfigurationResource(configResource); diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java b/asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java index de28ca2446..0d75c56c58 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java @@ -323,9 +323,67 @@ public class ASDCNotificationLogging { buffer.append(System.lineSeparator()); } + buffer.append(System.lineSeparator()); + buffer.append("VF Module Customization Properties:"); + buffer.append(System.lineSeparator()); + buffer.append("Model Customization UUID:"); + buffer.append(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_VFMODULECUSTOMIZATIONUUID))); + buffer.append(System.lineSeparator()); } + List vfConfigList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(vfNodeTemplate, SdcTypes.CONFIGURATION); + + if(vfConfigList != null){ + for (NodeTemplate configNodeTemplate : vfConfigList) { + + buffer.append(System.lineSeparator()); + buffer.append(System.lineSeparator()); + buffer.append("Fabric Configuration Properties:"); + buffer.append(System.lineSeparator()); + + buffer.append("Model Name:"); + buffer.append(configNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)); + buffer.append(System.lineSeparator()); + buffer.append("Model UUID:"); + buffer.append(configNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); + buffer.append(System.lineSeparator()); + buffer.append("Description:"); + buffer.append(configNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)); + buffer.append(System.lineSeparator()); + buffer.append("Version:"); + buffer.append(configNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)); + buffer.append(System.lineSeparator()); + buffer.append("InvariantUuid:"); + buffer.append(configNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)); + buffer.append(System.lineSeparator()); + buffer.append("Tosca Node Type:"); + buffer.append(configNodeTemplate.getType()); + + buffer.append(System.lineSeparator()); + buffer.append(System.lineSeparator()); + buffer.append("Fabric Configuration Customization Properties:"); + buffer.append(System.lineSeparator()); + + buffer.append("Model Customization UUID:"); + buffer.append(configNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); + buffer.append(System.lineSeparator()); + buffer.append("Model Instance Name:"); + buffer.append(configNodeTemplate.getName()); + buffer.append(System.lineSeparator()); + buffer.append("NFFunction:"); + buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(configNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)); + buffer.append(System.lineSeparator()); + buffer.append("NFRole:"); + buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(configNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE)); + buffer.append(System.lineSeparator()); + buffer.append("NFType:"); + buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(configNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE)); + buffer.append(System.lineSeparator()); + + } + } + List cvfcList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(vfNodeTemplate, SdcTypes.CVFC); for(NodeTemplate cvfcTemplate : cvfcList) { @@ -523,6 +581,7 @@ public class ASDCNotificationLogging { buffer.append(System.lineSeparator()); } + List groupList = toscaResourceStructure.getSdcCsarHelper().getGroupsOfOriginOfNodeTemplateByToscaGroupType(crNode, "org.openecomp.groups.NetworkCollection"); diff --git a/asdc-controller/src/test/resources/schema.sql b/asdc-controller/src/test/resources/schema.sql index 5f78c85c98..aef33c3aed 100644 --- a/asdc-controller/src/test/resources/schema.sql +++ b/asdc-controller/src/test/resources/schema.sql @@ -801,38 +801,62 @@ UPDATE CASCADE) ENGINE = InnoDB AUTO_INCREMENT = 20654 DEFAULT CHARACTER SET = l CREATE TABLE IF NOT EXISTS vnf_vfmodule_cvnfc_configuration_customization ( - `ID` INT(11) NOT NULL AUTO_INCREMENT, - `MODEL_CUSTOMIZATION_UUID` VARCHAR(200) NOT NULL, - `VNF_RESOURCE_CUST_MODEL_CUSTOMIZATION_UUID` VARCHAR(200) NOT NULL, - `VF_MODULE_MODEL_CUSTOMIZATION_UUID` VARCHAR(200) NOT NULL, - `CVNFC_MODEL_CUSTOMIZATION_UUID` VARCHAR(200) NOT NULL, - `MODEL_INSTANCE_NAME` VARCHAR(200) NOT NULL, - `CONFIGURATION_TYPE` VARCHAR(200) NULL, - `CONFIGURATION_ROLE` VARCHAR(200) NULL, - `CONFIGURATION_FUNCTION` VARCHAR(200) NULL, - `POLICY_NAME` VARCHAR(200) NULL, - `CREATION_TIMESTAMP` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - `CONFIGURATION_MODEL_UUID` VARCHAR(200) NOT NULL, - PRIMARY KEY (`ID`), - INDEX `fk_vnf_vfmodule_cvnfc_config_cust__configuration_idx` (`CONFIGURATION_MODEL_UUID` ASC), - UNIQUE INDEX `UK_vnf_vfmodule_cvnfc_configuration_customization` (`VNF_RESOURCE_CUST_MODEL_CUSTOMIZATION_UUID` ASC , `VF_MODULE_MODEL_CUSTOMIZATION_UUID` ASC , `CVNFC_MODEL_CUSTOMIZATION_UUID` ASC , `MODEL_CUSTOMIZATION_UUID` ASC), - INDEX `fk_vnf_vfmodule_cvnfc_config_cust__cvnfc_cust1_idx` (`CVNFC_MODEL_CUSTOMIZATION_UUID` ASC), - INDEX `fk_vnf_vfmodule_cvnfc_config_cust__vf_module_cust_idx` (`VF_MODULE_MODEL_CUSTOMIZATION_UUID` ASC), - INDEX `fk_vnf_vfmodule_cvnfc_config_cust__vnf_res_cust_idx` (`VNF_RESOURCE_CUST_MODEL_CUSTOMIZATION_UUID` ASC), - CONSTRAINT `fk_vnf_vfmod_cvnfc_config_cust__configuration_resource` FOREIGN KEY (`CONFIGURATION_MODEL_UUID`) - REFERENCES `configuration` (`MODEL_UUID`) - ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `fk_cvnfc_configuration_customization__cvnfc_customization1` FOREIGN KEY (`CVNFC_MODEL_CUSTOMIZATION_UUID`) - REFERENCES `cvnfc_customization` (`MODEL_CUSTOMIZATION_UUID`) - ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `fk_vnf_configuration_cvnfc_customization__vf_module_customiza1` FOREIGN KEY (`VF_MODULE_MODEL_CUSTOMIZATION_UUID`) - REFERENCES `vf_module_customization` (`MODEL_CUSTOMIZATION_UUID`) - ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `fk_vfmodule_cvnfc_configuration_customization__vnf_resource_c1` FOREIGN KEY (`VNF_RESOURCE_CUST_MODEL_CUSTOMIZATION_UUID`) - REFERENCES `vnf_resource_customization` (`MODEL_CUSTOMIZATION_UUID`) - ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=INNODB AUTO_INCREMENT=20654 DEFAULT CHARACTER SET=LATIN1; + `ID` INT(11) NOT NULL AUTO_INCREMENT, + `MODEL_CUSTOMIZATION_UUID` VARCHAR(200) NOT NULL, + `MODEL_INSTANCE_NAME` VARCHAR(200) NOT NULL, + `CONFIGURATION_TYPE` VARCHAR(200) NULL, + `CONFIGURATION_ROLE` VARCHAR(200) NULL, + `CONFIGURATION_FUNCTION` VARCHAR(200) NULL, + `POLICY_NAME` VARCHAR(200) NULL, + `CREATION_TIMESTAMP` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + `CONFIGURATION_MODEL_UUID` VARCHAR(200) NOT NULL, + `VNF_RESOURCE_CUST_MODEL_CUSTOMIZATION_UUID` VARCHAR(200) DEFAULT NULL, + `VF_MODULE_MODEL_CUSTOMIZATION_UUID` VARCHAR(200) DEFAULT NULL, + `CVNFC_CUSTOMIZATION_ID` INT(11) DEFAULT NULL, + PRIMARY KEY (`ID`), + INDEX `fk_vnf_vfmodule_cvnfc_config_cust__configuration_idx` (`CONFIGURATION_MODEL_UUID` ASC), + + CONSTRAINT `fk_vnf_vfmod_cvnfc_config_cust__configuration_resource` FOREIGN KEY (`CONFIGURATION_MODEL_UUID`) + REFERENCES `configuration` (`MODEL_UUID`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE = INNODB AUTO_INCREMENT = 20654 DEFAULT CHARACTER SET = LATIN1; + +CREATE TABLE IF NOT EXISTS `pnf_resource` ( + `ORCHESTRATION_MODE` varchar(20) NOT NULL DEFAULT 'HEAT', + `DESCRIPTION` varchar(1200) DEFAULT NULL, + `CREATION_TIMESTAMP` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + `MODEL_UUID` varchar(200) NOT NULL, + `MODEL_INVARIANT_UUID` varchar(200) DEFAULT NULL, + `MODEL_VERSION` varchar(20) NOT NULL, + `MODEL_NAME` varchar(200) DEFAULT NULL, + `TOSCA_NODE_TYPE` varchar(200) DEFAULT NULL, + `RESOURCE_CATEGORY` varchar(200) DEFAULT NULL, + `RESOURCE_SUB_CATEGORY` varchar(200) DEFAULT NULL, + PRIMARY KEY (`MODEL_UUID`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +CREATE TABLE IF NOT EXISTS `pnf_resource_customization` ( + `MODEL_CUSTOMIZATION_UUID` varchar(200) NOT NULL, + `MODEL_INSTANCE_NAME` varchar(200) NOT NULL, + `NF_TYPE` varchar(200) DEFAULT NULL, + `NF_ROLE` varchar(200) DEFAULT NULL, + `NF_FUNCTION` varchar(200) DEFAULT NULL, + `NF_NAMING_CODE` varchar(200) DEFAULT NULL, + `CREATION_TIMESTAMP` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + `PNF_RESOURCE_MODEL_UUID` varchar(200) NOT NULL, + `MULTI_STAGE_DESIGN` varchar(20) DEFAULT NULL, + `RESOURCE_INPUT` varchar(2000) DEFAULT NULL, + `CDS_BLUEPRINT_NAME` varchar(200) DEFAULT NULL, + `CDS_BLUEPRINT_VERSION` varchar(20) 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 +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +CREATE TABLE IF NOT EXISTS `pnf_resource_customization_to_service` ( + `SERVICE_MODEL_UUID` varchar(200) NOT NULL, + `RESOURCE_MODEL_CUSTOMIZATION_UUID` varchar(200) NOT NULL, + PRIMARY KEY (`SERVICE_MODEL_UUID`,`RESOURCE_MODEL_CUSTOMIZATION_UUID`) +)ENGINE=InnoDB DEFAULT CHARSET=latin1; --------START Request DB SCHEMA -------- CREATE DATABASE requestdb; USE requestdb; -- cgit 1.2.3-korg