summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/db/migration/R__CloudConfigMigration.java40
-rw-r--r--adapters/mso-openstack-adapters/src/main/resources/application.yaml4
-rw-r--r--packages/docker/src/main/docker/docker-files/configs/logging/logback-spring.xml3
3 files changed, 37 insertions, 10 deletions
diff --git a/adapters/mso-openstack-adapters/src/main/java/db/migration/R__CloudConfigMigration.java b/adapters/mso-openstack-adapters/src/main/java/db/migration/R__CloudConfigMigration.java
index fd2ec179dc..87ea49ee5e 100644
--- a/adapters/mso-openstack-adapters/src/main/java/db/migration/R__CloudConfigMigration.java
+++ b/adapters/mso-openstack-adapters/src/main/java/db/migration/R__CloudConfigMigration.java
@@ -13,6 +13,8 @@ import org.onap.so.db.catalog.beans.CloudSite;
import org.onap.so.db.catalog.beans.CloudifyManager;
import org.onap.so.logger.MsoLogger;
+import java.io.FileInputStream;
+import java.io.InputStream;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
@@ -33,10 +35,31 @@ public class R__CloudConfigMigration implements JdbcMigration , MigrationInfoPro
@Override
public void migrate(Connection connection) throws Exception {
LOGGER.debug("Starting migration for CloudConfig");
- CloudConfig cloudConfig = loadCloudConfig();
- if(cloudConfig == null){
- LOGGER.debug("No CloudConfig defined in :"+getApplicationYamlName()+" exiting.");
- }else{
+
+ CloudConfig cloudConfig = null;
+
+ // Try the override file
+ String configLocation = System.getProperty("spring.config.location");
+ if (configLocation != null) {
+ try (InputStream stream = new FileInputStream(configLocation)) {
+ cloudConfig = loadCloudConfig(stream);
+ }
+ }
+
+ if (cloudConfig == null) {
+ LOGGER.debug("No CloudConfig defined in " + configLocation);
+
+ // Try the application.yaml file
+ try (InputStream stream = R__CloudConfigMigration.class.getResourceAsStream(getApplicationYamlName())) {
+ cloudConfig = loadCloudConfig(stream);
+ }
+
+ if (cloudConfig == null) {
+ LOGGER.debug("No CloudConfig defined in " + getApplicationYamlName());
+ }
+ }
+
+ if(cloudConfig != null){
migrateCloudIdentity(cloudConfig.getIdentityServices().values(), connection);
migrateCloudSite(cloudConfig.getCloudSites().values(), connection);
migrateCloudifyManagers(cloudConfig.getCloudifyManagers().values(), connection);
@@ -51,13 +74,14 @@ public class R__CloudConfigMigration implements JdbcMigration , MigrationInfoPro
this.cloudConfig = cloudConfig;
}
- private CloudConfig loadCloudConfig() throws Exception {
+ private CloudConfig loadCloudConfig(InputStream stream) throws Exception {
ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
- R__CloudConfigMigration cloudConfigMigration = mapper.readValue(R__CloudConfigMigration.class
- .getResourceAsStream(getApplicationYamlName()), R__CloudConfigMigration.class);
+ R__CloudConfigMigration cloudConfigMigration =
+ mapper.readValue(stream, R__CloudConfigMigration.class);
CloudConfig cloudConfig = cloudConfigMigration.getCloudConfig();
+
if(cloudConfig != null){
- cloudConfig.populateId();
+ cloudConfig.populateId();
}
return cloudConfig;
diff --git a/adapters/mso-openstack-adapters/src/main/resources/application.yaml b/adapters/mso-openstack-adapters/src/main/resources/application.yaml
index 4a4c83e4a5..4b2cf8eb60 100644
--- a/adapters/mso-openstack-adapters/src/main/resources/application.yaml
+++ b/adapters/mso-openstack-adapters/src/main/resources/application.yaml
@@ -41,4 +41,6 @@ management:
flyway:
outOfOrder: true
- ignoreMissingMigrations: true \ No newline at end of file
+ ignoreMissingMigrations: true
+ baseline-on-migrate: true
+ validate-on-migrate: false
diff --git a/packages/docker/src/main/docker/docker-files/configs/logging/logback-spring.xml b/packages/docker/src/main/docker/docker-files/configs/logging/logback-spring.xml
index dbba5da9b0..df6d92163b 100644
--- a/packages/docker/src/main/docker/docker-files/configs/logging/logback-spring.xml
+++ b/packages/docker/src/main/docker/docker-files/configs/logging/logback-spring.xml
@@ -166,6 +166,7 @@
name="org.camunda.bpm.engine.impl.persistence.entity.JobEntity.level"
level="WARN" />
+ <logger name="db.migration" level="DEBUG" />
<logger name="org.apache.wire" level="DEBUG" />
<logger name="org.onap" level="DEBUG" />
<logger name="com.att.ecomp" level="DEBUG" />
@@ -185,4 +186,4 @@
<appender-ref ref="asyncError" />
</root>
-</configuration> \ No newline at end of file
+</configuration>