skip post instantiation configuration 79/83379/9
authoreeginux <henry.xie@est.tech>
Tue, 2 Apr 2019 13:11:08 +0000 (14:11 +0100)
committereeginux <henry.xie@est.tech>
Wed, 3 Apr 2019 09:52:15 +0000 (10:52 +0100)
Update the schema to include new column
Ingest the property from tosca to DB
https://jira.onap.org/browse/SO-1671

Issue-ID: SO-1671
Change-Id: Ic6d8d2cfccaa24ba1f9320e4fc2f4255d532fb08
Signed-off-by: eeginux <henry.xie@est.tech>
adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V5.9__AddSkipPostInstantiationConfiguration.sql [new file with mode: 0644]
adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java
adapters/mso-openstack-adapters/src/test/resources/schema.sql
asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
asdc-controller/src/test/resources/schema.sql
mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/PnfResourceCustomization.java
mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResourceCustomization.java
mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/PnfCustomizationRepositoryTest.java
mso-catalog-db/src/test/resources/schema.sql

diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V5.9__AddSkipPostInstantiationConfiguration.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V5.9__AddSkipPostInstantiationConfiguration.sql
new file mode 100644 (file)
index 0000000..b44ee1f
--- /dev/null
@@ -0,0 +1,8 @@
+use catalogdb;
+
+ALTER TABLE vnf_resource_customization
+ADD SKIP_POST_INSTANTIATION_CONFIGURATION boolean default true;
+
+ALTER TABLE pnf_resource_customization
+ADD SKIP_POST_INSTANTIATION_CONFIGURATION boolean default true;
+
index 461fce5..599c99b 100644 (file)
@@ -23,6 +23,7 @@ package org.onap.so.db.catalog.client;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
 import java.util.List;
 import java.util.UUID;
@@ -190,6 +191,7 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest {
         Assert.assertNotNull(vnfResourceCustomization.getVnfResources());
         Assert.assertNotNull(vnfResourceCustomization.getVfModuleCustomizations());
         Assert.assertEquals("vSAMP10a", vnfResourceCustomization.getVnfResources().getModelName());
+        assertTrue("skip post instantiation configuration", vnfResourceCustomization.isSkipPostInstConf());
     }
 
     @Test
@@ -639,9 +641,9 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest {
         assertEquals("modelInstanceName", "PNF routing", pnfResourceCustomization.getModelInstanceName());
         assertEquals("blueprintName", "test_configuration_restconf", pnfResourceCustomization.getBlueprintName());
         assertEquals("blueprintVersion", "1.0.0", pnfResourceCustomization.getBlueprintVersion());
+        assertTrue("skip post instantiation configuration", pnfResourceCustomization.isSkipPostInstConf());
         PnfResource pnfResource = pnfResourceCustomization.getPnfResources();
         assertNotNull(pnfResource);
-
         assertEquals("PNFResource modelUUID", "ff2ae348-214a-11e7-93ae-92361f002680", pnfResource.getModelUUID());
         assertEquals("PNFResource modelInvariantUUID", "2fff5b20-214b-11e7-93ae-92361f002680",
             pnfResource.getModelInvariantUUID());
index 622e465..d9a38be 100644 (file)
@@ -1110,6 +1110,7 @@ CREATE TABLE `vnf_resource_customization` (
   `RESOURCE_INPUT` varchar(20000) DEFAULT NULL,
   `CDS_BLUEPRINT_NAME` varchar(200) default null,
   `CDS_BLUEPRINT_VERSION` varchar(20) default null,
+  `SKIP_POST_INSTANTIATION_CONFIGURATION` boolean default true,
   `CREATION_TIMESTAMP` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
   `VNF_RESOURCE_MODEL_UUID` varchar(200) NOT NULL,
   `SERVICE_MODEL_UUID` varchar(200) NOT NULL,
@@ -1191,6 +1192,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,
+  `SKIP_POST_INSTANTIATION_CONFIGURATION` boolean default true,
   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
index 9f914c5..04e3782 100644 (file)
@@ -174,6 +174,7 @@ public class ToscaResourceInstaller {
 
        private static String CUSTOMIZATION_UUID = "customizationUUID";
 
+       protected static final String SKIP_POST_INST_CONF = "skip_post_instantiation_configuration";
 
        @Autowired
        protected ServiceRepository serviceRepo;
@@ -887,12 +888,23 @@ public class ToscaResourceInstaller {
                pnfResourceCustomization.setMultiStageDesign(getStringValue(properties.get(MULTI_STAGE_DESIGN)));
                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.setPnfResources(pnfResource);
 
                return pnfResourceCustomization;
        }
 
+       /**
+        * Get value from {@link Property} and cast to boolean value. Return true if property is null.
+        */
+       private boolean getBooleanValue(Property property) {
+               if (null == property) {
+                       return true;
+               }
+               Object value = property.getValue();
+               return new Boolean(String.valueOf(value));
+       }
+
        /**
         * Get value from {@link Property} and cast to String value. Return empty String if property is null value.
         */
@@ -2151,6 +2163,11 @@ public class ToscaResourceInstaller {
                vnfResourceCustomization.setBlueprintVersion(testNull(toscaResourceStructure.getSdcCsarHelper()
                        .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SDNC_MODEL_VERSION)));
 
+               String skipPostInstConfText = toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfNodeTemplate, SKIP_POST_INST_CONF);
+               if (skipPostInstConfText != null){
+                       vnfResourceCustomization.setSkipPostInstConf(Boolean.parseBoolean(skipPostInstConfText));
+               }
+
                vnfResourceCustomization.setVnfResources(vnfResource);
                vnfResourceCustomization.setAvailabilityZoneMaxCount(Integer.getInteger(
                                vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT)));  
index ec8e25d..2db2dfb 100644 (file)
@@ -1114,6 +1114,7 @@ CREATE TABLE `vnf_resource_customization` (
   `RESOURCE_INPUT` varchar(20000) DEFAULT NULL,
   `CDS_BLUEPRINT_NAME` varchar(200) default null,
   `CDS_BLUEPRINT_VERSION` varchar(20) default null,
+  `SKIP_POST_INSTANTIATION_CONFIGURATION` boolean default true,
   `CREATION_TIMESTAMP` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
   `VNF_RESOURCE_MODEL_UUID` varchar(200) NOT NULL,
   `SERVICE_MODEL_UUID` varchar(200) NOT NULL,
@@ -1195,6 +1196,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,
+  `SKIP_POST_INSTANTIATION_CONFIGURATION` boolean default true,
   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
index b2d40b8..0c23689 100644 (file)
@@ -85,6 +85,9 @@ public class PnfResourceCustomization implements Serializable {
     @Column(name = "CDS_BLUEPRINT_VERSION")
     private String blueprintVersion;
 
+    @Column(name = "SKIP_POST_INSTANTIATION_CONFIGURATION")
+    private Boolean skipPostInstConf;
+
     @Override
     public String toString() {
         return new ToStringBuilder(this).append("modelCustomizationUUID", modelCustomizationUUID)
@@ -217,4 +220,12 @@ public class PnfResourceCustomization implements Serializable {
         this.blueprintVersion = blueprintVersion;
     }
 
+    public Boolean isSkipPostInstConf() {
+        return skipPostInstConf;
+    }
+
+    public void setSkipPostInstConf(Boolean skipPostInstConf) {
+        this.skipPostInstConf = skipPostInstConf;
+    }
+
 }
index e569c3b..1cbc7b5 100644 (file)
@@ -122,6 +122,9 @@ public class VnfResourceCustomization implements Serializable {
     @Column(name = "CDS_BLUEPRINT_VERSION")
     private String blueprintVersion;
 
+    @Column(name = "SKIP_POST_INSTANTIATION_CONFIGURATION")
+    private Boolean skipPostInstConf;
+
     @Override
     public boolean equals(final Object other) {
         if (!(other instanceof VnfResourceCustomization)) {
@@ -318,4 +321,11 @@ public class VnfResourceCustomization implements Serializable {
         this.blueprintVersion = blueprintVersion;
     }
 
+    public Boolean isSkipPostInstConf() {
+        return skipPostInstConf;
+    }
+
+    public void setSkipPostInstConf(Boolean skipPostInstConf) {
+        this.skipPostInstConf = skipPostInstConf;
+    }
 }
index 7ac80e2..4ba344c 100644 (file)
@@ -21,6 +21,7 @@ package org.onap.so.db.catalog.data.repository;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
 import org.junit.Test;
 import org.onap.so.db.catalog.BaseTest;
@@ -46,6 +47,7 @@ public class PnfCustomizationRepositoryTest extends BaseTest {
         assertEquals("modelInstanceName", "PNF routing", pnfResourceCustomization.getModelInstanceName());
         assertEquals("blueprintName", "test_configuration_restconf", pnfResourceCustomization.getBlueprintName());
         assertEquals("blueprintVersion", "1.0.0", pnfResourceCustomization.getBlueprintVersion());
+        assertTrue("skip post instantiation configuration", pnfResourceCustomization.isSkipPostInstConf());
         PnfResource pnfResource = pnfResourceCustomization.getPnfResources();
         assertNotNull(pnfResource);
 
index e61f5fc..9002c92 100644 (file)
@@ -1110,6 +1110,7 @@ CREATE TABLE `vnf_resource_customization` (
   `RESOURCE_INPUT` varchar(20000) DEFAULT NULL,
   `CDS_BLUEPRINT_NAME` varchar(200) default null,
   `CDS_BLUEPRINT_VERSION` varchar(20) default null,
+  `SKIP_POST_INSTANTIATION_CONFIGURATION` boolean default true,
   `CREATION_TIMESTAMP` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
   `VNF_RESOURCE_MODEL_UUID` varchar(200) NOT NULL,
   `SERVICE_MODEL_UUID` varchar(200) NOT NULL,
@@ -1191,6 +1192,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,
+  `SKIP_POST_INSTANTIATION_CONFIGURATION` boolean default true,
   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