diff options
author | Marcus Williams <marcus.williams@intel.com> | 2018-08-21 23:32:59 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-08-21 23:32:59 +0000 |
commit | 4d4177a26a5ccbead0da4818cbf93be6aeb39617 (patch) | |
tree | 80fc32137573f3afdaad415e6d528ecd01f0d4ff /adapters/mso-openstack-adapters/src | |
parent | 377069ff37c83a21acb406f77703b1256aa41a9c (diff) | |
parent | 5bea41b162b9c4d6a24640790028fa7750ff15f3 (diff) |
Merge "openstack_adapter container fails to start"
Diffstat (limited to 'adapters/mso-openstack-adapters/src')
-rw-r--r-- | adapters/mso-openstack-adapters/src/main/java/db/migration/R__CloudConfigMigration.java | 40 | ||||
-rw-r--r-- | adapters/mso-openstack-adapters/src/main/resources/application.yaml | 4 |
2 files changed, 35 insertions, 9 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 |