aboutsummaryrefslogtreecommitdiffstats
path: root/adapters/mso-openstack-adapters/src
diff options
context:
space:
mode:
authorBenjamin, Max (mb388a) <mb388a@us.att.com>2018-08-13 09:48:57 -0400
committerBenjamin, Max (mb388a) <mb388a@us.att.com>2018-08-13 09:51:54 -0400
commita81aef2172c2cb4c6735f6018aee7deb04140b5d (patch)
tree2ef9daca8d8a075142d1f900bb8862c6ce322491 /adapters/mso-openstack-adapters/src
parentc703669697084b5bd9be0f8f016bbf8ed11213a4 (diff)
Cloud config database table support
added cloud config database entities added cloud config repository converted existing cloud config class converted all code interacting with previous cloud config object created migration to automatically load cloud config properties from application.yaml Issue-ID: SO-854 Change-Id: Icf408e5d0fcabd1b7e97298963c555fae6964930 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'adapters/mso-openstack-adapters/src')
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/db/migration/CloudConfig.java67
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/db/migration/R__CloudConfigMigration.java167
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/db/migration/V4_2__DummyMigration.java12
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java8
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/MsoOpenstackAdaptersApplication.java4
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java10
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImpl.java6
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java6
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestUtils.java2
-rw-r--r--adapters/mso-openstack-adapters/src/main/resources/application-local.yaml20
-rw-r--r--adapters/mso-openstack-adapters/src/main/resources/application.yaml4
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/db/migration/CloudConfigMigrationTest.java107
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/TenantAdapterRestTest.java4
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/BaseRestTestUtils.java64
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java7
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImplTest.java22
-rw-r--r--adapters/mso-openstack-adapters/src/test/resources/__files/CreateTenantResponse_Created.json4
-rw-r--r--adapters/mso-openstack-adapters/src/test/resources/__files/CreateTenantResponse_Exists.json4
-rw-r--r--adapters/mso-openstack-adapters/src/test/resources/application-nomigrate.yaml122
-rw-r--r--adapters/mso-openstack-adapters/src/test/resources/application-test.yaml31
-rw-r--r--adapters/mso-openstack-adapters/src/test/resources/data.sql4
-rw-r--r--adapters/mso-openstack-adapters/src/test/resources/schema.sql51
22 files changed, 655 insertions, 71 deletions
diff --git a/adapters/mso-openstack-adapters/src/main/java/db/migration/CloudConfig.java b/adapters/mso-openstack-adapters/src/main/java/db/migration/CloudConfig.java
new file mode 100644
index 0000000000..0309c88dac
--- /dev/null
+++ b/adapters/mso-openstack-adapters/src/main/java/db/migration/CloudConfig.java
@@ -0,0 +1,67 @@
+package db.migration;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.onap.so.db.catalog.beans.CloudIdentity;
+import org.onap.so.db.catalog.beans.CloudSite;
+import org.onap.so.db.catalog.beans.CloudifyManager;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @deprecated
+ * This class is introduced as deprecated as its only purpose is for migration of cloud config data. It shouldnt be used elsewhere.
+ */
+
+@Deprecated
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class CloudConfig {
+ @JsonProperty("identity_services")
+ private Map<String, CloudIdentity> identityServices = new HashMap<>();
+
+ @JsonProperty("cloud_sites")
+ private Map<String, CloudSite> cloudSites = new HashMap<>();
+
+ @JsonProperty("cloudify_managers")
+ private Map<String, CloudifyManager> cloudifyManagers = new HashMap<>();
+
+
+ public Map<String, CloudIdentity> getIdentityServices() {
+ return identityServices;
+ }
+
+ public void setIdentityServices(Map<String, CloudIdentity> identityServices) {
+ this.identityServices = identityServices;
+ }
+
+ public Map<String, CloudSite> getCloudSites() {
+ return cloudSites;
+ }
+
+ public void setCloudSites(Map<String, CloudSite> cloudSites) {
+ this.cloudSites = cloudSites;
+ }
+
+ public Map<String, CloudifyManager> getCloudifyManagers() {
+ return cloudifyManagers;
+ }
+
+ public void setCloudifyManagers(Map<String, CloudifyManager> cloudifyManagers) {
+ this.cloudifyManagers = cloudifyManagers;
+ }
+
+ public void populateId(){
+ for (Map.Entry<String, CloudIdentity> entry : identityServices.entrySet()) {
+ entry.getValue().setId(entry.getKey());
+ }
+
+ for (Map.Entry <String, CloudSite> entry : cloudSites.entrySet()) {
+ entry.getValue().setId(entry.getKey());
+ }
+
+ for (Map.Entry<String, CloudifyManager> entry : cloudifyManagers.entrySet()) {
+ entry.getValue().setId(entry.getKey());
+ }
+ }
+}
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
new file mode 100644
index 0000000000..fd2ec179dc
--- /dev/null
+++ b/adapters/mso-openstack-adapters/src/main/java/db/migration/R__CloudConfigMigration.java
@@ -0,0 +1,167 @@
+package db.migration;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
+import org.flywaydb.core.api.MigrationVersion;
+import org.flywaydb.core.api.migration.MigrationChecksumProvider;
+import org.flywaydb.core.api.migration.MigrationInfoProvider;
+import org.flywaydb.core.api.migration.jdbc.JdbcMigration;
+import org.onap.so.db.catalog.beans.CloudIdentity;
+import org.onap.so.db.catalog.beans.CloudSite;
+import org.onap.so.db.catalog.beans.CloudifyManager;
+import org.onap.so.logger.MsoLogger;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.Statement;
+import java.util.Collection;
+
+/**
+ * Performs migration using JDBC Connection from the cloud config provided in the environment (application-{profile}.yaml) and persist data (when not already present) to the catalod database.
+ */
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class R__CloudConfigMigration implements JdbcMigration , MigrationInfoProvider, MigrationChecksumProvider {
+ public static final String FLYWAY = "FLYWAY";
+
+ private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA, R__CloudConfigMigration.class);
+ @JsonProperty("cloud_config")
+ private CloudConfig cloudConfig;
+
+ @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{
+ migrateCloudIdentity(cloudConfig.getIdentityServices().values(), connection);
+ migrateCloudSite(cloudConfig.getCloudSites().values(), connection);
+ migrateCloudifyManagers(cloudConfig.getCloudifyManagers().values(), connection);
+ }
+ }
+
+ public CloudConfig getCloudConfig() {
+ return cloudConfig;
+ }
+
+ public void setCloudConfig(CloudConfig cloudConfig) {
+ this.cloudConfig = cloudConfig;
+ }
+
+ private CloudConfig loadCloudConfig() throws Exception {
+ ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
+ R__CloudConfigMigration cloudConfigMigration = mapper.readValue(R__CloudConfigMigration.class
+ .getResourceAsStream(getApplicationYamlName()), R__CloudConfigMigration.class);
+ CloudConfig cloudConfig = cloudConfigMigration.getCloudConfig();
+ if(cloudConfig != null){
+ cloudConfig.populateId();
+ }
+
+ return cloudConfig;
+ }
+
+ private String getApplicationYamlName() {
+ String profile = System.getProperty("spring.profiles.active") == null ? "" : "-" + System.getProperty("spring.profiles.active");
+ return "/application" + profile + ".yaml";
+ }
+
+ private void migrateCloudIdentity(Collection<CloudIdentity> entities, Connection connection) throws Exception {
+ LOGGER.debug("Starting migration for CloudConfig-->IdentityService");
+ String insert = "INSERT INTO `identity_services` (`ID`, `IDENTITY_URL`, `MSO_ID`, `MSO_PASS`, `ADMIN_TENANT`, `MEMBER_ROLE`, `TENANT_METADATA`, `IDENTITY_SERVER_TYPE`, `IDENTITY_AUTHENTICATION_TYPE`, `LAST_UPDATED_BY`) " +
+ "VALUES (?,?,?,?,?,?,?,?,?,?);";
+ PreparedStatement ps = connection.prepareStatement(insert);
+ try (Statement stmt = connection.createStatement()) {
+ for (CloudIdentity cloudIdentity : entities) {
+ try (ResultSet rows = stmt.executeQuery("Select count(1) from identity_services where id='" + cloudIdentity.getId() + "'")) {
+ int count = 0;
+ while (rows.next()) {
+ count = rows.getInt(1);
+ }
+ if (count == 0) {
+ ps.setString(1, cloudIdentity.getId());
+ ps.setString(2, cloudIdentity.getIdentityUrl());
+ ps.setString(3, cloudIdentity.getMsoId());
+ ps.setString(4, cloudIdentity.getMsoPass());
+ ps.setString(5, cloudIdentity.getAdminTenant());
+ ps.setString(6, cloudIdentity.getMemberRole());
+ ps.setBoolean(7, cloudIdentity.getTenantMetadata());
+ ps.setString(8, cloudIdentity.getIdentityServerType() != null ? cloudIdentity.getIdentityServerType().name() : null);
+ ps.setString(9, cloudIdentity.getIdentityAuthenticationType() != null ? cloudIdentity.getIdentityAuthenticationType().name() : null);
+ ps.setString(10, FLYWAY);
+ ps.executeUpdate();
+ }
+ }
+ }
+ }
+ }
+
+ private void migrateCloudSite(Collection<CloudSite> entities, Connection connection) throws Exception {
+ LOGGER.debug("Starting migration for CloudConfig-->CloudSite");
+ String insert = "INSERT INTO `cloud_sites` (`ID`, `REGION_ID`, `IDENTITY_SERVICE_ID`, `CLOUD_VERSION`, `CLLI`, `CLOUDIFY_ID`, `PLATFORM`, `ORCHESTRATOR`, `LAST_UPDATED_BY`) " +
+ "VALUES (?,?,?,?,?,?,?,?,?);";
+ PreparedStatement ps = connection.prepareStatement(insert);
+ try (Statement stmt = connection.createStatement()) {
+ for (CloudSite cloudSite : entities) {
+ try (ResultSet rows = stmt.executeQuery("Select count(1) from cloud_sites where id='" + cloudSite.getId() + "'")) {
+ int count = 0;
+ while (rows.next()) {
+ count = rows.getInt(1);
+ }
+ if (count == 0) {
+ ps.setString(1, cloudSite.getId());
+ ps.setString(2, cloudSite.getRegionId());
+ ps.setString(3, cloudSite.getIdentityServiceId());
+ ps.setString(4, cloudSite.getCloudVersion());
+ ps.setString(5, cloudSite.getClli());
+ ps.setString(6, cloudSite.getCloudifyId());
+ ps.setString(7, cloudSite.getPlatform());
+ ps.setString(8, cloudSite.getOrchestrator());
+ ps.setString(9, FLYWAY);
+ ps.executeUpdate();
+ }
+ }
+ }
+ }
+ }
+
+ private void migrateCloudifyManagers(Collection<CloudifyManager> entities, Connection connection) throws Exception {
+ String insert = "INSERT INTO `cloudify_managers` (`ID`, `CLOUDIFY_URL`, `USERNAME`, `PASSWORD`, `VERSION`, `LAST_UPDATED_BY`)" +
+ " VALUES (?,?,?,?,?,?);";
+ PreparedStatement ps = connection.prepareStatement(insert);
+ try (Statement stmt = connection.createStatement()) {
+ for (CloudifyManager cloudifyManager : entities) {
+ try (ResultSet rows = stmt.executeQuery("Select count(1) from cloudify_managers where id='" + cloudifyManager.getId() + "'")) {
+ int count = 0;
+ while (rows.next()) {
+ count = rows.getInt(1);
+ }
+ if (count == 0) {
+ ps.setString(1, cloudifyManager.getId());
+ ps.setString(2, cloudifyManager.getCloudifyUrl());
+ ps.setString(3, cloudifyManager.getUsername());
+ ps.setString(4, cloudifyManager.getPassword());
+ ps.setString(5, cloudifyManager.getVersion());
+ ps.setString(6, FLYWAY);
+ ps.executeUpdate();
+ }
+ }
+ }
+ }
+ }
+
+ public MigrationVersion getVersion() {
+ return null;
+ }
+
+ public String getDescription() {
+ return "R_CloudConfigMigration";
+ }
+
+ public Integer getChecksum() {
+ return Math.toIntExact(System.currentTimeMillis() / 1000);
+ }
+}
+
diff --git a/adapters/mso-openstack-adapters/src/main/java/db/migration/V4_2__DummyMigration.java b/adapters/mso-openstack-adapters/src/main/java/db/migration/V4_2__DummyMigration.java
new file mode 100644
index 0000000000..6530b7ba7c
--- /dev/null
+++ b/adapters/mso-openstack-adapters/src/main/java/db/migration/V4_2__DummyMigration.java
@@ -0,0 +1,12 @@
+package db.migration;
+
+import org.flywaydb.core.api.migration.jdbc.JdbcMigration;
+
+import java.sql.Connection;
+
+public class V4_2__DummyMigration implements JdbcMigration {
+ @Override
+ public void migrate(Connection connection) throws Exception {
+
+ }
+}
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java
index f5a05b7333..e5a8d3faa1 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java
@@ -36,7 +36,7 @@ import org.onap.so.adapters.network.beans.ContrailSubnet;
import org.onap.so.adapters.network.exceptions.NetworkException;
import org.onap.so.adapters.network.mappers.ContrailSubnetMapper;
import org.onap.so.cloud.CloudConfig;
-import org.onap.so.cloud.CloudSite;
+import org.onap.so.db.catalog.beans.CloudSite;
import org.onap.so.db.catalog.beans.HeatTemplate;
import org.onap.so.db.catalog.beans.NetworkResource;
import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
@@ -1167,7 +1167,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
}
MavenLikeVersioning aicV = new MavenLikeVersioning();
- aicV.setVersion(cloudSite.getAicVersion());
+ aicV.setVersion(cloudSite.getCloudVersion());
if ((aicV.isMoreRecentThan(networkResource.getAicVersionMin()) || aicV
.isTheSameVersion(networkResource.getAicVersionMin())) // aic
// >=
@@ -1181,13 +1181,13 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
+ networkResource.getAicVersionMin() + " VersionMax:"
+ networkResource.getAicVersionMax()
+ " supported on Cloud:" + cloudSiteId
- + " with AIC_Version:" + cloudSite.getAicVersion());
+ + " with AIC_Version:" + cloudSite.getCloudVersion());
} else {
String error = "Network Type:" + networkType + " Version_Min:"
+ networkResource.getAicVersionMin() + " Version_Max:"
+ networkResource.getAicVersionMax()
+ " not supported on Cloud:" + cloudSiteId
- + " with AIC_Version:" + cloudSite.getAicVersion();
+ + " with AIC_Version:" + cloudSite.getCloudVersion();
LOGGER.error(MessageEnum.RA_CONFIG_EXC, error, "OpenStack", "",
MsoLogger.ErrorCode.DataError,
"Network Type not supported on Cloud");
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/MsoOpenstackAdaptersApplication.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/MsoOpenstackAdaptersApplication.java
index d67a4b684c..02aa0843ae 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/MsoOpenstackAdaptersApplication.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/MsoOpenstackAdaptersApplication.java
@@ -34,8 +34,8 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
@SpringBootApplication(scanBasePackages = { "org.onap.so" })
@EnableAsync
@EnableJpaRepositories({ "org.onap.so.db.catalog.data.repository",
- "org.onap.so.db.request.data.repository" })
-@EntityScan({ "org.onap.so.db.catalog.beans", "org.onap.so.db.request.beans" })
+ "org.onap.so.db.request.data.repository"})
+@EntityScan({ "org.onap.so.db.catalog.beans", "org.onap.so.db.request.beans"})
public class MsoOpenstackAdaptersApplication {
@Value("${mso.async.core-pool-size}")
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java
index 8a55e0717e..29d8f297bf 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java
@@ -39,7 +39,7 @@ import org.onap.so.adapters.vnf.exceptions.VnfAlreadyExists;
import org.onap.so.adapters.vnf.exceptions.VnfException;
import org.onap.so.adapters.vnf.exceptions.VnfNotFound;
import org.onap.so.cloud.CloudConfig;
-import org.onap.so.cloud.CloudSite;
+import org.onap.so.db.catalog.beans.CloudSite;
import org.onap.so.db.catalog.beans.HeatEnvironment;
import org.onap.so.db.catalog.beans.HeatFiles;
import org.onap.so.db.catalog.beans.HeatTemplate;
@@ -859,7 +859,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
if (this.cloudConfig != null) {
Optional<CloudSite> cloudSiteOpt = this.cloudConfig.getCloudSite(cloudSiteId);
if (cloudSiteOpt.isPresent()) {
- aicV.setVersion(cloudSiteOpt.get().getAicVersion());
+ aicV.setVersion(cloudSiteOpt.get().getCloudVersion());
// Add code to handle unexpected values in here
boolean moreThanMin = true;
boolean equalToMin = true;
@@ -878,10 +878,10 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
if (!doNotTest) {
if ((moreThanMin || equalToMin) // aic >= min
&& (equalToMax || !(moreThanMax))) { //aic <= max
- LOGGER.debug("VNF Resource " + vnfResource.getModelName() + ", ModelUuid=" + vnfResource.getModelUUID() + " VersionMin=" + minVersionVnf + " VersionMax:" + maxVersionVnf + " supported on Cloud: " + cloudSiteId + " with AIC_Version:" + cloudSiteOpt.get().getAicVersion());
+ LOGGER.debug("VNF Resource " + vnfResource.getModelName() + ", ModelUuid=" + vnfResource.getModelUUID() + " VersionMin=" + minVersionVnf + " VersionMax:" + maxVersionVnf + " supported on Cloud: " + cloudSiteId + " with AIC_Version:" + cloudSiteOpt.get().getCloudVersion());
} else {
// ERROR
- String error = "VNF Resource type: " + vnfResource.getModelName() + ", ModelUuid=" + vnfResource.getModelUUID() + " VersionMin=" + minVersionVnf + " VersionMax:" + maxVersionVnf + " NOT supported on Cloud: " + cloudSiteId + " with AIC_Version:" + cloudSiteOpt.get().getAicVersion();
+ String error = "VNF Resource type: " + vnfResource.getModelName() + ", ModelUuid=" + vnfResource.getModelUUID() + " VersionMin=" + minVersionVnf + " VersionMax:" + maxVersionVnf + " NOT supported on Cloud: " + cloudSiteId + " with AIC_Version:" + cloudSiteOpt.get().getCloudVersion();
LOGGER.error(MessageEnum.RA_CONFIG_EXC, error, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - setVersion");
LOGGER.debug(error);
throw new VnfException(error, MsoExceptionCategory.USERDATA);
@@ -1606,7 +1606,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
if (this.cloudConfig != null) {
Optional<CloudSite> cloudSiteOpt = this.cloudConfig.getCloudSite(cloudSiteId);
if (cloudSiteOpt.isPresent()) {
- aicV.setVersion(cloudSiteOpt.get().getAicVersion());
+ aicV.setVersion(cloudSiteOpt.get().getCloudVersion());
boolean moreThanMin = true;
boolean equalToMin = true;
boolean moreThanMax = true;
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImpl.java
index 0266e87523..1cf65cb6fc 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImpl.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImpl.java
@@ -34,7 +34,7 @@ import javax.xml.ws.Holder;
import org.onap.so.adapters.vnf.exceptions.VnfAlreadyExists;
import org.onap.so.adapters.vnf.exceptions.VnfException;
import org.onap.so.cloud.CloudConfig;
-import org.onap.so.cloud.CloudSite;
+import org.onap.so.db.catalog.beans.CloudSite;
import org.onap.so.cloudify.beans.DeploymentInfo;
import org.onap.so.cloudify.beans.DeploymentStatus;
import org.onap.so.cloudify.exceptions.MsoCloudifyManagerNotFound;
@@ -663,7 +663,7 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter {
}
CloudSite cloudSite = cloudSiteOp.get();
MavenLikeVersioning aicV = new MavenLikeVersioning();
- aicV.setVersion(cloudSite.getAicVersion());
+ aicV.setVersion(cloudSite.getCloudVersion());
String vnfMin = vnfResource.getAicVersionMin();
String vnfMax = vnfResource.getAicVersionMax();
@@ -672,7 +672,7 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter {
(vnfMax != null && aicV.isMoreRecentThan(vnfMax)))
{
// ERROR
- String error = "VNF Resource type: " + vnfResource.getModelName() + ", ModelUuid=" + vnfResource.getModelUUID() + " VersionMin=" + vnfMin + " VersionMax:" + vnfMax + " NOT supported on Cloud: " + cloudSiteId + " with AIC_Version:" + cloudSite.getAicVersion();
+ String error = "VNF Resource type: " + vnfResource.getModelName() + ", ModelUuid=" + vnfResource.getModelUUID() + " VersionMin=" + vnfMin + " VersionMax:" + vnfMax + " NOT supported on Cloud: " + cloudSiteId + " with AIC_Version:" + cloudSite.getCloudVersion();
LOGGER.error(MessageEnum.RA_CONFIG_EXC, error, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - setVersion");
LOGGER.debug(error);
throw new VnfException(error, MsoExceptionCategory.USERDATA);
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java
index 0a7b30f9ca..b440f7d521 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java
@@ -59,7 +59,7 @@ import org.onap.so.adapters.vdu.mapper.VfModuleCustomizationToVduMapper;
import org.onap.so.adapters.vnf.exceptions.VnfAlreadyExists;
import org.onap.so.adapters.vnf.exceptions.VnfException;
import org.onap.so.cloud.CloudConfig;
-import org.onap.so.cloud.CloudSite;
+import org.onap.so.db.catalog.beans.CloudSite;
import org.onap.so.cloudify.utils.MsoCloudifyUtils;
import org.onap.so.db.catalog.beans.HeatEnvironment;
import org.onap.so.db.catalog.beans.HeatTemplate;
@@ -705,7 +705,7 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter {
}
CloudSite cloudSite = cloudSiteOp.get();
MavenLikeVersioning aicV = new MavenLikeVersioning();
- aicV.setVersion(cloudSite.getAicVersion());
+ aicV.setVersion(cloudSite.getCloudVersion());
String vnfMin = vnfResource.getAicVersionMin();
String vnfMax = vnfResource.getAicVersionMax();
@@ -714,7 +714,7 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter {
(vnfMax != null && aicV.isMoreRecentThan(vnfMax)))
{
// ERROR
- String error = "VNF Resource type: " + vnfResource.getModelName() + ", ModelUuid=" + vnfResource.getModelUUID() + " VersionMin=" + vnfMin + " VersionMax:" + vnfMax + " NOT supported on Cloud: " + cloudSiteId + " with AIC_Version:" + cloudSite.getAicVersion();
+ String error = "VNF Resource type: " + vnfResource.getModelName() + ", ModelUuid=" + vnfResource.getModelUUID() + " VersionMin=" + vnfMin + " VersionMax:" + vnfMax + " NOT supported on Cloud: " + cloudSiteId + " with AIC_Version:" + cloudSite.getCloudVersion();
LOGGER.error(MessageEnum.RA_CONFIG_EXC, error, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - setVersion");
LOGGER.debug(error);
throw new VnfException(error, MsoExceptionCategory.USERDATA);
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestUtils.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestUtils.java
index 876aae8a37..4da026f454 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestUtils.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestUtils.java
@@ -23,7 +23,7 @@ package org.onap.so.adapters.vnf;
import java.util.Optional;
import org.onap.so.cloud.CloudConfig;
-import org.onap.so.cloud.CloudSite;
+import org.onap.so.db.catalog.beans.CloudSite;
import org.onap.so.logger.MsoLogger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
diff --git a/adapters/mso-openstack-adapters/src/main/resources/application-local.yaml b/adapters/mso-openstack-adapters/src/main/resources/application-local.yaml
index fa6078689e..469744d2de 100644
--- a/adapters/mso-openstack-adapters/src/main/resources/application-local.yaml
+++ b/adapters/mso-openstack-adapters/src/main/resources/application-local.yaml
@@ -114,21 +114,7 @@ spring:
management:
context-path: /manage
-cloud_config:
- identity_services:
- MTN13:
- identity_url: "http://localhost:5000/v2.0"
- mso_id: "m93945"
- mso_pass: "93937EA01B94A10A49279D4572B48369"
- admin_tenant: "admin"
- member_role: "admin"
- tenant_metadata: true
- identity_server_type: "KEYSTONE"
- identity_authentication_type: "USERNAME_PASSWORD"
- cloud_sites:
- mtn13:
- region_id: "mtn13"
- clli: "MDT13"
- aic_version: "3.0"
- identity_service_id: "MTN13"
+flyway:
+ outOfOrder: true
+ ignoreMissingMigrations: true
diff --git a/adapters/mso-openstack-adapters/src/main/resources/application.yaml b/adapters/mso-openstack-adapters/src/main/resources/application.yaml
index faca1a3056..4a4c83e4a5 100644
--- a/adapters/mso-openstack-adapters/src/main/resources/application.yaml
+++ b/adapters/mso-openstack-adapters/src/main/resources/application.yaml
@@ -38,3 +38,7 @@ spring:
#Actuator
management:
context-path: /manage
+
+flyway:
+ outOfOrder: true
+ ignoreMissingMigrations: true \ No newline at end of file
diff --git a/adapters/mso-openstack-adapters/src/test/java/db/migration/CloudConfigMigrationTest.java b/adapters/mso-openstack-adapters/src/test/java/db/migration/CloudConfigMigrationTest.java
new file mode 100644
index 0000000000..b29e1f57a7
--- /dev/null
+++ b/adapters/mso-openstack-adapters/src/test/java/db/migration/CloudConfigMigrationTest.java
@@ -0,0 +1,107 @@
+package db.migration;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.so.adapters.vnf.BaseRestTestUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.Statement;
+
+public class CloudConfigMigrationTest extends BaseRestTestUtils {
+
+ @Qualifier("dataSource")
+ @Autowired
+ DataSource dataSource;
+
+ R__CloudConfigMigration cloudConfigMigration;
+
+ @Before
+ public void setup() {
+ cloudConfigMigration = new R__CloudConfigMigration();
+ }
+
+ @Test
+ public void testMigrate() throws Exception {
+ System.setProperty("spring.profiles.active", "test");
+ cloudConfigMigration.migrate(dataSource.getConnection());
+ assertMigratedIdentityServiceData();
+ assertMigratedCloudSiteData();
+ assertMigratedCloudManagerData();
+ }
+
+ @Test
+ public void testMigrateNoData() throws Exception {
+ System.setProperty("spring.profiles.active", "nomigrate");
+ int identityCount = getDataCount("identity_services");
+ int cloudSiteCount = getDataCount("cloud_sites");
+ int cloudManagerCount = getDataCount("cloudify_managers");
+
+ cloudConfigMigration.migrate(dataSource.getConnection());
+
+ Assert.assertEquals(identityCount, getDataCount("identity_services"));
+ Assert.assertEquals(cloudSiteCount, getDataCount("cloud_sites"));
+ Assert.assertEquals(cloudManagerCount, getDataCount("cloudify_managers"));
+ }
+
+
+ private int getDataCount(String tableName) throws Exception {
+ try (Connection con = dataSource.getConnection(); Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("select count(1) from " + tableName)) {
+ while (rs.next()) {
+ return rs.getInt(1);
+ }
+ }
+ return 0;
+ }
+
+ private void assertMigratedIdentityServiceData() throws Exception {
+ try (Connection con = dataSource.getConnection(); Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("select * from identity_services where id='MTKEYSTONE'")) {
+ boolean dataAvailable = false;
+ while (rs.next()) {
+ dataAvailable = true;
+ Assert.assertEquals("MTKEYSTONE", rs.getString("id"));
+ Assert.assertEquals("http://localhost:5000/v2.0", rs.getString("identity_url"));
+ Assert.assertEquals("john", rs.getString("mso_id"));
+ Assert.assertEquals("313DECE408AF7759D442D7B06DD9A6AA", rs.getString("mso_pass"));
+ Assert.assertEquals("admin", rs.getString("admin_tenant"));
+ Assert.assertEquals("_member_", rs.getString("member_role"));
+ Assert.assertEquals("KEYSTONE", rs.getString("identity_server_type"));
+ Assert.assertEquals("USERNAME_PASSWORD", rs.getString("identity_authentication_type"));
+ }
+ Assert.assertTrue("Expected data in identity_services table post migration but didnt find any!!!", dataAvailable);
+ }
+ }
+
+ private void assertMigratedCloudSiteData() throws Exception {
+ try (Connection con = dataSource.getConnection(); Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("select * from cloud_sites where id='regionOne'")) {
+ boolean dataAvailable = false;
+ while (rs.next()) {
+ dataAvailable = true;
+ Assert.assertEquals("regionOne", rs.getString("id"));
+ Assert.assertEquals("regionOne", rs.getString("region_id"));
+ Assert.assertEquals("MT2", rs.getString("clli"));
+ Assert.assertEquals("2.5", rs.getString("cloud_version"));
+ Assert.assertEquals("MTKEYSTONE", rs.getString("identity_service_id"));
+ }
+ Assert.assertTrue("Expected data in identity_services table post migration but didnt find any!!!", dataAvailable);
+ }
+ }
+
+ private void assertMigratedCloudManagerData() throws Exception {
+ try (Connection con = dataSource.getConnection(); Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("select * from cloudify_managers where id='manager'")) {
+ boolean dataAvailable = false;
+ while (rs.next()) {
+ dataAvailable = true;
+ Assert.assertEquals("http://localhost:8080", rs.getString("cloudify_url"));
+ Assert.assertEquals("user", rs.getString("username"));
+ Assert.assertEquals("password", rs.getString("password"));
+ Assert.assertEquals("2.0", rs.getString("version"));
+ }
+ Assert.assertTrue("Expected data in identity_services table post migration but didnt find any!!!", dataAvailable);
+ }
+ }
+}
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/TenantAdapterRestTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/TenantAdapterRestTest.java
index acfe6568af..ea21687bc5 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/TenantAdapterRestTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/TenantAdapterRestTest.java
@@ -75,7 +75,7 @@ public class TenantAdapterRestTest extends BaseRestTestUtils {
cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0");
CreateTenantRequest request = new CreateTenantRequest();
- String cloudSiteId = "mtn13";
+ String cloudSiteId = "MTN13";
String requestId = "62265093-277d-4388-9ba6-449838ade586";
String serviceInstanceId = "4147e06f-1b89-49c5-b21f-4faf8dc9805a";
String tenantName = "testingTenantName";
@@ -127,7 +127,7 @@ public class TenantAdapterRestTest extends BaseRestTestUtils {
cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0");
CreateTenantRequest request = new CreateTenantRequest();
- String cloudSiteId = "mtn13";
+ String cloudSiteId = "MTN13";
String requestId = "62265093-277d-4388-9ba6-449838ade586";
String serviceInstanceId = "4147e06f-1b89-49c5-b21f-4faf8dc9805a";
String tenantName = "testingTenantName";
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/BaseRestTestUtils.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/BaseRestTestUtils.java
index a2faaaff78..cf68f097dc 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/BaseRestTestUtils.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/BaseRestTestUtils.java
@@ -24,10 +24,16 @@ import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.http.HttpStatus;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.so.adapters.openstack.MsoOpenstackAdaptersApplication;
+import org.onap.so.db.catalog.beans.AuthenticationType;
+import org.onap.so.db.catalog.beans.CloudIdentity;
+import org.onap.so.db.catalog.beans.CloudSite;
+import org.onap.so.db.catalog.beans.ServerType;
+import org.onap.so.db.catalog.data.repository.CloudIdentityRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
@@ -36,16 +42,20 @@ import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock;
import org.springframework.http.HttpHeaders;
-import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
+import javax.ws.rs.core.MediaType;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.reset;
+import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = MsoOpenstackAdaptersApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@@ -63,6 +73,11 @@ public class BaseRestTestUtils {
@LocalServerPort
private int port;
+
+ public ObjectMapper mapper;
+
+ @Autowired
+ private CloudIdentityRepository cloudIdentityRepository;
protected String readJsonFileAsString(String fileLocation) throws JsonParseException, JsonMappingException, IOException{
ObjectMapper mapper = new ObjectMapper();
@@ -87,10 +102,53 @@ public class BaseRestTestUtils {
return sb.toString();
}
}
-
+
+ /***
+ * Before each test execution, updating IdentityUrl port value to the ramdom wireMockPort
+ * Since URL will be used as a rest call and required to be mocked in unit tests
+ */
@Before
- public void setUp(){
+ public void setUp() throws Exception {
reset();
+ mapper = new ObjectMapper();
+
+ CloudIdentity identity = new CloudIdentity();
+ identity.setId("MTN13");
+ identity.setMsoId("m93945");
+ identity.setMsoPass("93937EA01B94A10A49279D4572B48369");
+ identity.setAdminTenant("admin");
+ identity.setMemberRole("admin");
+ identity.setTenantMetadata(new Boolean(true));
+ identity.setIdentityUrl("http://localhost:"+wireMockPort+"/v2.0");
+ identity.setIdentityAuthenticationType(AuthenticationType.USERNAME_PASSWORD);
+
+ CloudSite cloudSite = new CloudSite();
+ cloudSite.setId("MTN13");
+ cloudSite.setCloudVersion("3.0");
+ cloudSite.setClli("MDT13");
+ cloudSite.setRegionId("mtn13");
+ cloudSite.setOrchestrator("orchestrator" +
+ "");
+ identity.setIdentityServerType(ServerType.KEYSTONE);
+ cloudSite.setIdentityService(identity);
+
+
+ stubFor(get(urlPathEqualTo("/cloudSite/MTN13")).willReturn(aResponse()
+ .withBody(getBody(mapper.writeValueAsString(cloudSite),wireMockPort, ""))
+ .withHeader(org.apache.http.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withStatus(HttpStatus.SC_OK)));
+ stubFor(get(urlPathEqualTo("/cloudSite/default")).willReturn(aResponse()
+ .withBody(getBody(mapper.writeValueAsString(cloudSite),wireMockPort, ""))
+ .withHeader(org.apache.http.HttpHeaders.CONTENT_TYPE,MediaType.APPLICATION_JSON)
+ .withStatus(HttpStatus.SC_OK)));
+ stubFor(get(urlPathEqualTo("/cloudIdentity/MTN13")).willReturn(aResponse()
+ .withBody(getBody(mapper.writeValueAsString(identity),wireMockPort, ""))
+ .withHeader(org.apache.http.HttpHeaders.CONTENT_TYPE,MediaType.APPLICATION_JSON)
+ .withStatus(HttpStatus.SC_OK)));
+ }
+
+ protected static String getBody(String body, int port, String urlPath) throws IOException {
+ return body.replaceAll("port", "http://localhost:" + port + urlPath);
}
@Test
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java
index 0ce3683a1e..005586e3ad 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java
@@ -81,9 +81,10 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils {
String vnfName = "DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001/stackId";
@Before
- public void before() {
+ public void before() throws Exception {
MockitoAnnotations.initMocks(this);
WireMock.reset();
+ setUp();
}
@Test
@@ -105,7 +106,7 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils {
Map<String, String> map = new HashMap<>();
map.put("key1", "value1");
- instance.createVfModule("mtn13", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", vnfName, "VFMOD",
+ instance.createVfModule("MTN13", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", vnfName, "VFMOD",
"volumeGroupHeatStackId|1", "baseVfHeatStackId", "88a6ca3ee0394ade9403f075db23167e", map,
Boolean.FALSE, Boolean.TRUE, Boolean.FALSE, msoRequest, new Holder<>(), new Holder<Map<String, String>>(),
new Holder<VnfRollback>());
@@ -510,7 +511,7 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils {
vfModuleCustomization.getVfModule().getModuleHeatTemplate().setParameters(new HashSet<>());
Map<String, String> map = new HashMap<>();
map.put("key1", "value1");
- instance.updateVfModule("mtn13", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", vnfName, "VFMOD",
+ instance.updateVfModule("MTN13", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", vnfName, "VFMOD",
"volumeGroupHeatStackId", "baseVfHeatStackId", "vfModuleStackId",
"b4ea86b4-253f-11e7-93ae-92361f002671", map, msoRequest, new Holder<Map<String, String>>(),
new Holder<VnfRollback>());
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImplTest.java
index 6f2c6cf86d..6674c7171f 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImplTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImplTest.java
@@ -22,14 +22,13 @@
package org.onap.so.adapters.vnf;
import org.apache.http.HttpStatus;
-import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.onap.so.adapters.vnf.exceptions.VnfException;
import org.onap.so.cloud.CloudConfig;
-import org.onap.so.cloud.CloudifyManager;
+import org.onap.so.db.catalog.beans.CloudifyManager;
import org.onap.so.entity.MsoRequest;
import org.onap.so.openstack.beans.VnfRollback;
import org.springframework.beans.factory.annotation.Autowired;
@@ -38,11 +37,7 @@ import javax.xml.ws.Holder;
import java.util.HashMap;
import java.util.Map;
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.get;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
+import static com.github.tomakehurst.wiremock.client.WireMock.*;
public class MsoVnfCloudifyAdapterImplTest extends BaseRestTestUtils {
@@ -56,23 +51,18 @@ public class MsoVnfCloudifyAdapterImplTest extends BaseRestTestUtils {
private CloudConfig cloudConfig;
@Before
- public void before(){
+ public void before() throws Exception {
super.setUp();
CloudifyManager cloudifyManager = new CloudifyManager();
cloudifyManager.setId("mtn13");
cloudifyManager.setCloudifyUrl("http://localhost:"+wireMockPort+"/v2.0");
cloudifyManager.setUsername("m93945");
cloudifyManager.setPassword("93937EA01B94A10A49279D4572B48369");
- cloudConfig.getCloudifyManagers().put("mtn13",cloudifyManager);
}
- @After
- public void after(){
- cloudConfig.getCloudifyManagers().clear();
- }
-
- @Test
- public void queryVnfNullPointerExceptionTest() throws Exception {
+ @Test
+ public void queryVnfExceptionTest() throws Exception {
+ reset();
expectedException.expect(VnfException.class);
MsoRequest msoRequest = new MsoRequest();
msoRequest.setRequestId("12345");
diff --git a/adapters/mso-openstack-adapters/src/test/resources/__files/CreateTenantResponse_Created.json b/adapters/mso-openstack-adapters/src/test/resources/__files/CreateTenantResponse_Created.json
index 934e075220..b78f700fd9 100644
--- a/adapters/mso-openstack-adapters/src/test/resources/__files/CreateTenantResponse_Created.json
+++ b/adapters/mso-openstack-adapters/src/test/resources/__files/CreateTenantResponse_Created.json
@@ -1,11 +1,11 @@
{
"createTenantResponse": {
- "cloudSiteId": "mtn13",
+ "cloudSiteId": "MTN13",
"tenantId": "tenantId",
"tenantCreated": true,
"tenantRollback": {
"tenantId": "tenantId",
- "cloudId": "mtn13",
+ "cloudId": "MTN13",
"tenantCreated": true,
"msoRequest": {
"requestId": "62265093-277d-4388-9ba6-449838ade586",
diff --git a/adapters/mso-openstack-adapters/src/test/resources/__files/CreateTenantResponse_Exists.json b/adapters/mso-openstack-adapters/src/test/resources/__files/CreateTenantResponse_Exists.json
index 6f81ebcd36..977aa542b3 100644
--- a/adapters/mso-openstack-adapters/src/test/resources/__files/CreateTenantResponse_Exists.json
+++ b/adapters/mso-openstack-adapters/src/test/resources/__files/CreateTenantResponse_Exists.json
@@ -1,10 +1,10 @@
{
"createTenantResponse": {
- "cloudSiteId": "mtn13",
+ "cloudSiteId": "MTN13",
"tenantId": "tenantId",
"tenantCreated": false,
"tenantRollback": {
- "cloudId": "mtn13",
+ "cloudId": "MTN13",
"tenantCreated": false,
"msoRequest": {
"requestId": "62265093-277d-4388-9ba6-449838ade586",
diff --git a/adapters/mso-openstack-adapters/src/test/resources/application-nomigrate.yaml b/adapters/mso-openstack-adapters/src/test/resources/application-nomigrate.yaml
new file mode 100644
index 0000000000..c508b6e2d6
--- /dev/null
+++ b/adapters/mso-openstack-adapters/src/test/resources/application-nomigrate.yaml
@@ -0,0 +1,122 @@
+# will be used as entry in DB to say SITE OFF/ON for healthcheck
+# MSO Properties go here
+org:
+ onap:
+ so:
+ adapters:
+ default_keystone_url_version: /v2.0
+ default_keystone_reg_ex: "/[vV][0-9]"
+ vnf:
+ bpelauth: 481E6A95CE97E393A53363750D5E1E75
+ checkRequiredParameters: true
+ addGetFilesOnVolumeReq: false
+ sockettimeout: 30
+ connecttimeout: 30
+ retrycount: 5
+ retryinterval: -15
+ retrylist: 408,429,500,502,503,504,900
+ network:
+ bpelauth: 481E6A95CE97E393A53363750D5E1E75
+ sockettimeout: 5
+ connecttimeout: 5
+ retrycount: 5
+ retryinterval: -15
+ retrylist: 408,429,500,502,503,504,900
+ tenant:
+ default_x_aic_orm_client_string: ONAP-SO
+ default_keystone_url_version: /v2.0
+ default_keystone_reg_ex: "/[vV][0-9]"
+ default_tenant_description: ECOMP Tenant
+ default_region_type: single
+ default_user_role: admin
+ default_success_status_string: Success
+ default_no_regions_status_string: no regions
+ default_orm_request_path: /v1/orm/customers/
+ default_orm_url_replace_this: 8080
+ default_orm_url_replace_with_this: 7080
+ default_quota_value: 10
+ set_default_quota: false
+ valet:
+ base_url: http://localhost:${wiremock.server.port}
+ base_path: /api/valet/placement/v1/
+ valet_auth:
+ecomp:
+ mso:
+ adapters:
+ po:
+ retryCodes: 504
+ retryDelay: 5
+ retryCount: 3
+ vnf:
+ heat:
+ create:
+ pollInterval: 15
+ delete:
+ pollTimeout: 7500
+ pollInterval: 15
+ network:
+ heat:
+ create:
+ pollInterval: 15
+ delete:
+ pollTimeout: 300
+ pollInterval: 15
+
+server-port: 8080
+ssl-enable: false
+tomcat:
+ max-threads: 50
+mso:
+ logPath: logs
+ catalog:
+ db:
+ spring:
+ endpoint: http://localhost:${wiremock.server.port}
+ db:
+ auth: Basic YnBlbDptc28tZGItMTUwNyE=
+ site-name: localDevEnv
+ async:
+ core-pool-size: 50
+ max-pool-size: 50
+ queue-capacity: 500
+spring:
+ datasource:
+ url: jdbc:mariadb://localhost:3307/catalogdb
+ username: root
+ password: password
+ driver-class-name: org.mariadb.jdbc.Driver
+ initialize: true
+ initialization-mode: never
+ jpa:
+ generate-ddl: false
+ show-sql: false
+ hibernate:
+ ddl-auto: none
+ naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy
+ enable-lazy-load-no-trans: true
+ database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
+ security:
+ usercredentials:
+ -
+ username: test
+ password: '$2a$12$Zi3AuYcZoZO/gBQyUtST2.F5N6HqcTtaNci2Et.ufsQhski56srIu'
+ role: MSO-Client
+
+mariaDB4j:
+ dataDir:
+ port: 3307
+ databaseName: catalogdb
+
+
+#Actuator
+management:
+ endpoints:
+ enabled-by-default: false
+ endpoint:
+ info:
+ enabled: true
+
+flyway:
+ baseline-on-migrate: true
+ outOfOrder: true
+ ignoreMissingMigrations: true \ No newline at end of file
diff --git a/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml b/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml
index 97eecc2423..d15978357a 100644
--- a/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml
+++ b/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml
@@ -71,7 +71,7 @@ mso:
catalog:
db:
spring:
- endpoint: "http://localhost:"
+ endpoint: http://localhost:${wiremock.server.port}
db:
auth: Basic YnBlbDptc28tZGItMTUwNyE=
site-name: localDevEnv
@@ -118,13 +118,13 @@ management:
cloud_config:
identity_services:
- MTN13:
- identity_url: "http://localhost:${wiremock.server.port}/v2.0"
- mso_id: "m93945"
- mso_pass: "93937EA01B94A10A49279D4572B48369"
+ MTKEYSTONE:
+ identity_url: "http://localhost:5000/v2.0"
+ mso_id: "john"
+ mso_pass: "313DECE408AF7759D442D7B06DD9A6AA"
admin_tenant: "admin"
- member_role: "admin"
- tenant_metadata: true
+ member_role: "_member_"
+ tenant_metadata: false
identity_server_type: "KEYSTONE"
identity_authentication_type: "USERNAME_PASSWORD"
cloud_sites:
@@ -135,3 +135,20 @@ cloud_config:
identity_service_id: "MTN13"
orchestrator: "orchestrator"
cloudify_id: "mtn13"
+ regionOne:
+ region_id: "regionOne"
+ clli: "MT2"
+ aic_version: "2.5"
+ identity_service_id: "MTKEYSTONE"
+ cloudify_managers:
+ manager:
+ cloudify_url: "http://localhost:8080"
+ username: "user"
+ password: "password"
+ version: "2.0"
+
+
+flyway:
+ baseline-on-migrate: true
+ outOfOrder: true
+ ignoreMissingMigrations: true \ No newline at end of file
diff --git a/adapters/mso-openstack-adapters/src/test/resources/data.sql b/adapters/mso-openstack-adapters/src/test/resources/data.sql
index 5fabec6c8a..d16ca4528c 100644
--- a/adapters/mso-openstack-adapters/src/test/resources/data.sql
+++ b/adapters/mso-openstack-adapters/src/test/resources/data.sql
@@ -136,7 +136,11 @@ INSERT INTO `heat_environment` (`ARTIFACT_UUID`, `NAME`, `VERSION`, `DESCRIPTION
INSERT INTO `vf_module_customization` (`MODEL_CUSTOMIZATION_UUID`, `LABEL`, `INITIAL_COUNT`, `MIN_INSTANCES`, `MAX_INSTANCES`, `AVAILABILITY_ZONE_COUNT`, `HEAT_ENVIRONMENT_ARTIFACT_UUID`, `VOL_ENVIRONMENT_ARTIFACT_UUID`, `CREATION_TIMESTAMP`, `VF_MODULE_MODEL_UUID`) VALUES ('9b339a61-69ca-465f-86b8-1c72c582b8e8', 'base_vmme', 1, 1, 1, NULL, 'f4a21b58-5654-4cf6-9c50-de42004fe2b4', '3375f64b-4709-4802-8713-7a164763f9cd', '2018-05-13 12:12:09', '207fe0dc-4c89-4e5d-9a78-345e99ef7fbe');
+INSERT INTO `cloudify_managers` (`ID`, `CLOUDIFY_URL`, `USERNAME`, `PASSWORD`, `VERSION`, `LAST_UPDATED_BY`, `CREATION_TIMESTAMP`, `UPDATE_TIMESTAMP`) VALUES ('mtn13', 'http://localhost:28090/v2.0', 'm93945', '93937EA01B94A10A49279D4572B48369', NULL, 'MSO_USER', '2018-07-17 14:05:08', '2018-07-17 14:05:08');
+INSERT INTO `identity_services` (`ID`, `IDENTITY_URL`, `MSO_ID`, `MSO_PASS`, `ADMIN_TENANT`, `MEMBER_ROLE`, `TENANT_METADATA`, `IDENTITY_SERVER_TYPE`, `IDENTITY_AUTHENTICATION_TYPE`, `LAST_UPDATED_BY`, `CREATION_TIMESTAMP`, `UPDATE_TIMESTAMP`) VALUES ('MTN13', 'http://localhost:28090/v2.0', 'm939454', '93937EA01B94A10A49279D4572B48369', 'admin', 'admin', 1, 'KEYSTONE', 'USERNAME_PASSWORD', 'MSO_USER', '2018-07-17 14:02:33', '2018-07-17 14:02:33');
+
+INSERT INTO `cloud_sites` (`ID`, `region_id`, `identity_service_id`, `cloud_version`, `clli`, `cloudify_id`, `platform`, `orchestrator`, `CREATION_TIMESTAMP`, `UPDATE_TIMESTAMP`) VALUES ('MTN13', 'mtn13', 'MTN13', '3.0', 'MDT13', 'mtn13', null, 'orchestrator', '2018-07-17 14:06:28', '2018-07-17 14:06:28');
diff --git a/adapters/mso-openstack-adapters/src/test/resources/schema.sql b/adapters/mso-openstack-adapters/src/test/resources/schema.sql
index d24d16d577..a051417cc1 100644
--- a/adapters/mso-openstack-adapters/src/test/resources/schema.sql
+++ b/adapters/mso-openstack-adapters/src/test/resources/schema.sql
@@ -781,4 +781,53 @@ create table if not exists model (
PRIMARY KEY (`ID`),
CONSTRAINT uk1_model UNIQUE (`MODEL_TYPE`, `MODEL_VERSION_ID`),
FOREIGN KEY (`RECIPE`) REFERENCES `model_recipe` (`MODEL_ID`) ON DELETE CASCADE ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=latin1; \ No newline at end of file
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+CREATE TABLE IF NOT EXISTS `identity_services` (
+ `ID` varchar(50) NOT NULL,
+ `IDENTITY_URL` varchar(200) DEFAULT NULL,
+ `MSO_ID` varchar(255) DEFAULT NULL,
+ `MSO_PASS` varchar(255) DEFAULT NULL,
+ `ADMIN_TENANT` varchar(50) DEFAULT NULL,
+ `MEMBER_ROLE` varchar(50) DEFAULT NULL,
+ `TENANT_METADATA` tinyint(1) DEFAULT 0,
+ `IDENTITY_SERVER_TYPE` varchar(50) DEFAULT NULL,
+ `IDENTITY_AUTHENTICATION_TYPE` varchar(50) DEFAULT NULL,
+ `LAST_UPDATED_BY` varchar(120) DEFAULT NULL,
+ `CREATION_TIMESTAMP` timestamp NULL DEFAULT current_timestamp(),
+ `UPDATE_TIMESTAMP` timestamp NULL DEFAULT current_timestamp(),
+ PRIMARY KEY (`ID`)
+) ;
+
+
+
+CREATE TABLE IF NOT EXISTS `cloudify_managers` (
+ `ID` varchar(50) NOT NULL,
+ `CLOUDIFY_URL` varchar(200) DEFAULT NULL,
+ `USERNAME` varchar(255) DEFAULT NULL,
+ `PASSWORD` varchar(255) DEFAULT NULL,
+ `VERSION` varchar(20) DEFAULT NULL,
+ `LAST_UPDATED_BY` varchar(120) DEFAULT NULL,
+ `CREATION_TIMESTAMP` timestamp NULL DEFAULT current_timestamp(),
+ `UPDATE_TIMESTAMP` timestamp NULL DEFAULT current_timestamp(),
+ PRIMARY KEY (`ID`)
+) ;
+
+
+
+CREATE TABLE IF NOT EXISTS `cloud_sites` (
+ `ID` varchar(50) NOT NULL,
+ `REGION_ID` varchar(11) DEFAULT NULL,
+ `IDENTITY_SERVICE_ID` varchar(50) DEFAULT NULL,
+ `CLOUD_VERSION` varchar(20) DEFAULT NULL,
+ `CLLI` varchar(11) DEFAULT NULL,
+ `CLOUDIFY_ID` varchar(50) DEFAULT NULL,
+ `PLATFORM` varchar(50) DEFAULT NULL,
+ `ORCHESTRATOR` varchar(50) DEFAULT NULL,
+ `LAST_UPDATED_BY` varchar(120) DEFAULT NULL,
+ `CREATION_TIMESTAMP` timestamp NULL DEFAULT current_timestamp(),
+ `UPDATE_TIMESTAMP` timestamp NULL DEFAULT current_timestamp(),
+ PRIMARY KEY (`ID`),
+ KEY `FK_cloud_sites_identity_services` (`IDENTITY_SERVICE_ID`),
+ CONSTRAINT `FK_cloud_sites_identity_services` FOREIGN KEY (`IDENTITY_SERVICE_ID`) REFERENCES `identity_services` (`ID`)
+) ; \ No newline at end of file