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>
diff --git a/adapters/mso-adapter-utils/pom.xml b/adapters/mso-adapter-utils/pom.xml
index 093dbb7..566eef7 100644
--- a/adapters/mso-adapter-utils/pom.xml
+++ b/adapters/mso-adapter-utils/pom.xml
@@ -60,6 +60,16 @@
<dependencies>
<dependency>
+ <groupId>org.glassfish.jersey.core</groupId>
+ <artifactId>jersey-client</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>ch.vorburger.mariaDB4j</groupId>
+ <artifactId>mariaDB4j</artifactId>
+ <version>2.2.3</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.onap.so.adapters</groupId>
<artifactId>mso-adapters-rest-interface</artifactId>
<version>${project.version}</version>
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/AuthenticationType.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/AuthenticationType.java
deleted file mode 100644
index 7cb2222..0000000
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/AuthenticationType.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.so.cloud;
-
-public enum AuthenticationType {
- USERNAME_PASSWORD, RACKSPACE_APIKEY;
-}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/CloudConfig.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/CloudConfig.java
index ef5f823..5560282 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/CloudConfig.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/CloudConfig.java
@@ -20,22 +20,16 @@
package org.onap.so.cloud;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
import java.util.Optional;
-import javax.annotation.PostConstruct;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRootName;
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.context.annotation.Configuration;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
-import org.apache.commons.lang3.builder.EqualsBuilder;
+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.db.catalog.client.CatalogDbClient;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
/**
* JavaBean JSON class for a CloudConfig. This bean maps a JSON-format cloud
@@ -52,61 +46,17 @@
*
*/
-@Configuration
@JsonRootName("cloud_config")
-@ConfigurationProperties(prefix="cloud_config")
+@Component
public class CloudConfig {
private static final String CLOUD_SITE_VERSION = "2.5";
private static final String DEFAULT_CLOUD_SITE_ID = "default";
-
- @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<>();
- @PostConstruct
- private void init() {
- for (Entry<String, CloudIdentity> entry : identityServices.entrySet()) {
- entry.getValue().setId(entry.getKey());
- }
-
- for (Entry<String, CloudSite> entry : cloudSites.entrySet()) {
- entry.getValue().setId(entry.getKey());
- }
-
- for (Entry<String, CloudifyManager> entry : cloudifyManagers.entrySet()) {
- entry.getValue().setId(entry.getKey());
- }
- }
-
- /**
- * Get a map of all identity services that have been loaded.
- */
- public Map<String, CloudIdentity> getIdentityServices() {
- return identityServices;
- }
+ @Autowired
+ private CatalogDbClient catalogDbClient;
/**
- * Get a map of all cloud sites that have been loaded.
- */
- public Map<String, CloudSite> getCloudSites() {
- return cloudSites;
- }
-
- /**
- * Get a Map of all CloudifyManagers that have been loaded.
- * @return the Map
- */
- public Map<String,CloudifyManager> getCloudifyManagers() {
- return cloudifyManagers;
- }
-
- /**
* Get a specific CloudSites, based on an ID. The ID is first checked
* against the regions, and if no match is found there, then against
* individual entries to try and find one with a CLLI that matches the ID
@@ -116,39 +66,28 @@
* @return an Optional of CloudSite object.
*/
public synchronized Optional<CloudSite> getCloudSite(String id) {
- if (id == null) {
- return Optional.empty();
- }
- if (cloudSites.containsKey(id)) {
- return Optional.ofNullable(cloudSites.get(id));
- } else {
- return getCloudSiteWithClli(id);
- }
- }
-
- public String getCloudSiteId(CloudSite cloudSite) {
- for(Entry<String, CloudSite> entry : this.getCloudSites().entrySet()){
- if(entry.getValue().equals(cloudSite))
- return entry.getKey();
- }
- return null;
- }
+ if (id == null) {
+ return Optional.empty();
+ }
+ CloudSite cloudSite = catalogDbClient.getCloudSite(id);
+ if (cloudSite != null) {
+ return Optional.of(cloudSite);
+ } else {
+ return getCloudSiteWithClli(id);
+ }
+ }
+
/**
* Get a specific CloudSites, based on a CLLI and (optional) version, which
* will be matched against the aic_version field of the CloudSite.
*
* @param clli
* the CLLI to match
- * @param version
- * the version to match; may be null in which case any version
- * matches
* @return a CloudSite, or null of no match found
*/
private Optional<CloudSite> getCloudSiteWithClli(String clli) {
- Optional <CloudSite> cloudSiteOptional = cloudSites.values().stream().filter(cs ->
- cs.getClli() != null && clli.equals(cs.getClli()) && (CLOUD_SITE_VERSION.equals(cs.getAicVersion())))
- .findAny();
+ Optional <CloudSite> cloudSiteOptional = Optional.ofNullable(catalogDbClient.getCloudSiteByClliAndAicVersion(clli,CLOUD_SITE_VERSION));
if (cloudSiteOptional.isPresent()) {
return cloudSiteOptional;
} else {
@@ -157,8 +96,7 @@
}
private Optional<CloudSite> getDefaultCloudSite(String clli) {
- Optional<CloudSite> cloudSiteOpt = cloudSites.values().stream()
- .filter(cs -> cs.getId().equalsIgnoreCase(DEFAULT_CLOUD_SITE_ID)).findAny();
+ Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(catalogDbClient.getCloudSite(DEFAULT_CLOUD_SITE_ID));
if (cloudSiteOpt.isPresent()) {
CloudSite defaultCloudSite = cloudSiteOpt.get();
CloudSite clone = new CloudSite(defaultCloudSite);
@@ -178,7 +116,7 @@
* @return a CloudIdentity, or null of no match found
*/
public CloudIdentity getIdentityService(String id) {
- return identityServices.get(id);
+ return catalogDbClient.getCloudIdentity(id);
}
/**
@@ -187,30 +125,6 @@
* @return a CloudifyManager, or null of no match found
*/
public CloudifyManager getCloudifyManager (String id) {
- return cloudifyManagers.get(id);
- }
-
- @Override
- public String toString() {
- return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
- .append("identityServices", getIdentityServices()).append("cloudSites", getCloudSites()).toString();
- }
-
- @Override
- public boolean equals(final Object other) {
- if (other == null) {
- return false;
- }
- if (!getClass().equals(other.getClass())) {
- return false;
- }
- CloudConfig castOther = (CloudConfig) other;
- return new EqualsBuilder().append(getIdentityServices(), castOther.getIdentityServices())
- .append(getCloudSites(), castOther.getCloudSites()).isEquals();
- }
-
- @Override
- public int hashCode() {
- return new HashCodeBuilder(1, 31).append(getIdentityServices()).append(getCloudSites()).toHashCode();
+ return catalogDbClient.getCloudifyManager(id);
}
}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/CloudIdentity.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/CloudIdentity.java
deleted file mode 100644
index 188a930..0000000
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/CloudIdentity.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.so.cloud;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.openpojo.business.annotation.BusinessKey;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
-
-import java.util.Comparator;
-
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
-
-/**
- * JavaBean JSON class for a CloudIdentity. This bean represents a cloud identity
- * service instance (i.e. a DCP node) in the NVP/AIC cloud. It will be loaded via
- * CloudConfig object, of which it is a component (a CloudConfig JSON configuration
- * file may contain multiple CloudIdentity definitions).
- *
- * Note that this is only used to access Cloud Configurations loaded from a
- * JSON config file, so there are no explicit setters.
- *
- */
-public class CloudIdentity {
-
- @JsonProperty
- @BusinessKey
- private String id;
- @JsonProperty("identity_url")
- @BusinessKey
- private String identityUrl;
- @JsonProperty("mso_id")
- @BusinessKey
- private String msoId;
- @JsonProperty("mso_pass")
- @BusinessKey
- private String msoPass;
- @JsonProperty("admin_tenant")
- @BusinessKey
- private String adminTenant;
- @JsonProperty("member_role")
- @BusinessKey
- private String memberRole;
- @JsonProperty("tenant_metadata")
- @BusinessKey
- private Boolean tenantMetadata;
- @JsonProperty("identity_server_type")
- @BusinessKey
- private ServerType identityServerType;
- @JsonProperty("identity_authentication_type")
- @BusinessKey
- private AuthenticationType identityAuthenticationType;
-
- public CloudIdentity() {}
-
- public String getId () {
- return id;
- }
-
- public void setId (String id) {
- this.id = id;
- }
-
- public String getIdentityUrl() {
- return this.identityUrl;
- }
- public void setIdentityUrl(String url) {
- this.identityUrl = url;
- }
-
- public String getMsoId () {
- return msoId;
- }
-
- public void setMsoId (String id) {
- this.msoId = id;
- }
-
- public String getMsoPass () {
- return msoPass;
- }
-
- public void setMsoPass (String pwd) {
- this.msoPass = pwd;
- }
-
- public String getAdminTenant () {
- return adminTenant;
- }
-
- public void setAdminTenant (String tenant) {
- this.adminTenant = tenant;
- }
-
- public String getMemberRole () {
- return memberRole;
- }
-
- public void setMemberRole (String role) {
- this.memberRole = role;
- }
-
- public Boolean hasTenantMetadata () {
- return tenantMetadata;
- }
-
- public void setTenantMetadata (Boolean meta) {
- this.tenantMetadata = meta;
- }
-
- public ServerType getIdentityServerType() {
- return this.identityServerType;
- }
- public void setIdentityServerType(ServerType ist) {
- this.identityServerType = ist;
- }
- public String getIdentityServerTypeAsString() {
- return this.identityServerType.toString();
- }
- /**
- * @return the identityAuthenticationType
- */
- public AuthenticationType getIdentityAuthenticationType() {
- return identityAuthenticationType;
- }
-
- /**
- * @param identityAuthenticationType the identityAuthenticationType to set
- */
- public void setIdentityAuthenticationType(AuthenticationType identityAuthenticationType) {
- this.identityAuthenticationType = identityAuthenticationType;
- }
-
- @Override
- public CloudIdentity clone() {
- CloudIdentity cloudIdentityCopy = new CloudIdentity();
-
- cloudIdentityCopy.id = this.id;
- cloudIdentityCopy.identityUrl = this.identityUrl;
- cloudIdentityCopy.msoId = this.msoId;
- cloudIdentityCopy.msoPass = this.msoPass;
- cloudIdentityCopy.adminTenant = this.adminTenant;
- cloudIdentityCopy.memberRole = this.memberRole;
- cloudIdentityCopy.tenantMetadata = this.tenantMetadata;
- cloudIdentityCopy.identityServerType = this.identityServerType;
- cloudIdentityCopy.identityAuthenticationType = this.identityAuthenticationType;
-
- return cloudIdentityCopy;
- }
-
- @Override
- public String toString() {
- return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("id", getId())
- .append("identityUrl", getIdentityUrl()).append("msoId", getMsoId())
- .append("adminTenant", getAdminTenant()).append("memberRole", getMemberRole())
- .append("tenantMetadata", hasTenantMetadata()).append("identityServerType", getIdentityServerType())
- .append("identityAuthenticationType", getIdentityAuthenticationType()).toString();
- }
-
- @Override
- public boolean equals(final Object other) {
- if (other == null) {
- return false;
- }
- if (!getClass().equals(other.getClass())) {
- return false;
- }
- CloudIdentity castOther = (CloudIdentity) other;
- return new EqualsBuilder().append(getId(), castOther.getId())
- .append(getIdentityUrl(), castOther.getIdentityUrl()).append(getMsoId(), castOther.getMsoId())
- .append(getMsoPass(), castOther.getMsoPass()).append(getAdminTenant(), castOther.getAdminTenant())
- .append(getMemberRole(), castOther.getMemberRole())
- .append(hasTenantMetadata(), castOther.hasTenantMetadata())
- .append(getIdentityServerType(), castOther.getIdentityServerType())
- .append(getIdentityAuthenticationType(), castOther.getIdentityAuthenticationType()).isEquals();
- }
-
- @Override
- public int hashCode() {
- return new HashCodeBuilder(1, 31).append(getId()).append(getIdentityUrl()).append(getMsoId())
- .append(getMsoPass()).append(getAdminTenant()).append(getMemberRole()).append(hasTenantMetadata())
- .append(getIdentityServerType()).append(getIdentityAuthenticationType()).toHashCode();
- }
-}
\ No newline at end of file
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/CloudSite.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/CloudSite.java
deleted file mode 100644
index f38403d..0000000
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/CloudSite.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.so.cloud;
-
-
-import java.util.Comparator;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.openpojo.business.annotation.BusinessKey;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
-
-/**
- * JavaBean JSON class for a CloudSite. This bean represents a cloud location
- * (i.e. and LCP node) in the NVP/AIC cloud. It will be loaded via CloudConfig
- * object, of which it is a component (a CloudConfig JSON configuration file
- * will contain multiple CloudSite definitions).
- *
- * Note that this is only used to access Cloud Configurations loaded from a
- * JSON config file, so there are no explicit setters.
- *
- */
-public class CloudSite {
- @JsonProperty
- @BusinessKey
- private String id;
- @JsonProperty("region_id")
- @BusinessKey
- private String regionId;
- @JsonProperty("identity_service_id")
- @BusinessKey
- private String identityServiceId;
- @JsonProperty("aic_version")
- @BusinessKey
- private String aicVersion;
- @JsonProperty("clli")
- @BusinessKey
- private String clli;
- @JsonProperty("cloudify_id")
- @BusinessKey
- private String cloudifyId;
- @JsonProperty("platform")
- @BusinessKey
- private String platform;
- @JsonProperty("orchestrator")
- @BusinessKey
- private String orchestrator;
-
- // Derived property (set by CloudConfig loader based on identityServiceId)
- private CloudIdentity identityService;
- // Derived property (set by CloudConfig loader based on cloudifyId)
- private CloudifyManager cloudifyManager;
-
- public CloudSite() {
-
- }
-
- public CloudSite(CloudSite site) {
- this.aicVersion = site.getAicVersion();
- this.clli = site.getClli();
- this.cloudifyId = this.getCloudifyId();
- this.cloudifyManager = this.getCloudifyManager();
- this.id = site.getId();
- this.identityService = site.getIdentityService();
- this.identityServiceId = site.getIdentityServiceId();
- this.orchestrator = site.getOrchestrator();
- this.platform = site.getPlatform();
- this.regionId = this.getRegionId();
- }
- public String getId() {
- return this.id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public String getRegionId() {
- return regionId;
- }
-
- public void setRegionId(String regionId) {
- this.regionId = regionId;
- }
-
- public String getIdentityServiceId() {
- return identityServiceId;
- }
-
- public void setIdentityServiceId(String identityServiceId) {
- this.identityServiceId = identityServiceId;
- }
- public String getAicVersion() {
- return aicVersion;
- }
-
- public void setAicVersion(String aicVersion) {
- this.aicVersion = aicVersion;
- }
-
- public String getClli() {
- return clli;
- }
-
- public void setClli(String clli) {
- this.clli = clli;
- }
-
- public String getCloudifyId() {
- return cloudifyId;
- }
-
- public void setCloudifyId (String id) {
- this.cloudifyId = id;
- }
-
- public String getPlatform() {
- return platform;
- }
-
- public void setPlatform(String platform) {
- this.platform = platform;
- }
-
- public String getOrchestrator() {
- return orchestrator;
- }
-
- public void setOrchestrator(String orchestrator) {
- this.orchestrator = orchestrator;
- }
-
- public CloudIdentity getIdentityService () {
- return identityService;
- }
-
- public void setIdentityService (CloudIdentity identity) {
- this.identityService = identity;
- }
-
- public CloudifyManager getCloudifyManager () {
- return cloudifyManager;
- }
-
- public void setCloudifyManager (CloudifyManager cloudify) {
- this.cloudifyManager = cloudify;
- }
-
- @Override
- public String toString() {
- return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("regionId", getRegionId())
- .append("identityServiceId", getIdentityServiceId()).append("aicVersion", getAicVersion())
- .append("clli", getClli()).append("cloudifyId", getCloudifyId()).append("platform", getPlatform())
- .append("orchestrator", getOrchestrator()).toString();
- }
-
- @Override
- public boolean equals(final Object other) {
- if (other == null) {
- return false;
- }
- if (!getClass().equals(other.getClass())) {
- return false;
- }
- CloudSite castOther = (CloudSite) other;
- return new EqualsBuilder().append(getRegionId(), castOther.getRegionId())
- .append(getIdentityServiceId(), castOther.getIdentityServiceId())
- .append(getAicVersion(), castOther.getAicVersion()).append(getClli(), castOther.getClli()).isEquals();
- }
-
- @Override
- public int hashCode() {
- return new HashCodeBuilder(1, 31).append(getRegionId()).append(getIdentityServiceId()).append(getAicVersion())
- .append(getClli()).toHashCode();
- }
-}
\ No newline at end of file
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/CloudifyManager.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/CloudifyManager.java
deleted file mode 100644
index 1bf3f13..0000000
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/CloudifyManager.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.so.cloud;
-
-import java.security.GeneralSecurityException;
-import java.util.Comparator;
-
-import org.onap.so.logger.MessageEnum;
-import org.onap.so.logger.MsoLogger;
-import org.onap.so.utils.CryptoUtils;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.openpojo.business.annotation.BusinessKey;
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
-import org.apache.commons.lang3.builder.EqualsBuilder;
-
-/**
- * JavaBean JSON class for a Cloudify Manager. This bean represents a Cloudify
- * node through which TOSCA-based VNFs may be deployed. Each CloudSite in the
- * CloudConfig may have a Cloudify Manager for deployments using TOSCA blueprints.
- * Cloudify Managers may support multiple Cloud Sites, but each site will have
- * at most one Cloudify Manager.
- *
- * This does not replace the ability to use the CloudSite directly via Openstack.
- *
- * Note that this is only used to access Cloud Configurations loaded from a
- * JSON config file, so there are no explicit setters.
- *
- * @author JC1348
- */
-public class CloudifyManager {
-
- private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA, CloudifyManager.class);
-
- @BusinessKey
- @JsonProperty
- private String id;
-
- @BusinessKey
- @JsonProperty ("cloudify_url")
- private String cloudifyUrl;
-
- @BusinessKey
- @JsonProperty("username")
- private String username;
-
- @BusinessKey
- @JsonProperty("password")
- private String password;
-
- @BusinessKey
- @JsonProperty("version")
- private String version;
-
- public CloudifyManager() {}
-
- public String getId() {
- return id;
- }
- public void setId(String id) {
- this.id = id;
- }
-
- public String getCloudifyUrl() {
- return cloudifyUrl;
- }
-
- public void setCloudifyUrl(String cloudifyUrl) {
- this.cloudifyUrl = cloudifyUrl;
- }
-
- public String getUsername() {
- return username;
- }
-
- public void setUsername(String username) {
- this.username = username;
- }
-
- public String getPassword() {
- return password;
- }
-
- public void setPassword(String password) {
- this.password = password;
- }
-
- public String getVersion() {
- return version;
- }
-
- public void setVersion(String version) {
- this.version = version;
- }
-
- @Override
- public CloudifyManager clone() {
- CloudifyManager cloudifyManagerCopy = new CloudifyManager();
- cloudifyManagerCopy.id = this.id;
- cloudifyManagerCopy.cloudifyUrl = this.cloudifyUrl;
- cloudifyManagerCopy.username = this.username;
- cloudifyManagerCopy.password = this.password;
- cloudifyManagerCopy.version = this.version;
- return cloudifyManagerCopy;
- }
-
- @Override
- public String toString() {
- return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("id", getId())
- .append("cloudifyUrl", getCloudifyUrl()).append("username", getUsername())
- .append("password", getPassword()).append("version", getVersion()).toString();
- }
-
- @Override
- public boolean equals(final Object other) {
- if (other == null) {
- return false;
- }
- if (!getClass().equals(other.getClass())) {
- return false;
- }
- CloudifyManager castOther = (CloudifyManager) other;
- return new EqualsBuilder().append(getId(), castOther.getId())
- .append(getCloudifyUrl(), castOther.getCloudifyUrl()).append(getUsername(), castOther.getUsername())
- .append(getPassword(), castOther.getPassword()).append(getVersion(), castOther.getVersion()).isEquals();
- }
-
- @Override
- public int hashCode() {
- return new HashCodeBuilder(1, 31).append(getId()).append(getCloudifyUrl()).append(getUsername())
- .append(getPassword()).append(getVersion()).toHashCode();
- }
-}
\ No newline at end of file
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/ServerType.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/ServerType.java
deleted file mode 100644
index ac59018..0000000
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/ServerType.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.so.cloud;
-
-public enum ServerType {
- KEYSTONE, ORM;
-}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/AuthenticationMethodFactory.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/AuthenticationMethodFactory.java
index 5c648eb..1912cd8 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/AuthenticationMethodFactory.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/AuthenticationMethodFactory.java
@@ -20,8 +20,8 @@
package org.onap.so.cloud.authentication;
-import org.onap.so.cloud.AuthenticationType;
-import org.onap.so.cloud.CloudIdentity;
+import org.onap.so.db.catalog.beans.AuthenticationType;
+import org.onap.so.db.catalog.beans.CloudIdentity;
import org.onap.so.cloud.authentication.models.RackspaceAuthentication;
import org.onap.so.utils.CryptoUtils;
import org.springframework.stereotype.Component;
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java
index aa8e37f..59996fa 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java
@@ -42,8 +42,8 @@
import org.onap.so.adapters.vdu.VduStateType;
import org.onap.so.adapters.vdu.VduStatus;
import org.onap.so.cloud.CloudConfig;
-import org.onap.so.cloud.CloudSite;
-import org.onap.so.cloud.CloudifyManager;
+import org.onap.so.db.catalog.beans.CloudSite;
+import org.onap.so.db.catalog.beans.CloudifyManager;
import org.onap.so.cloudify.base.client.CloudifyBaseException;
import org.onap.so.cloudify.base.client.CloudifyClientTokenProvider;
import org.onap.so.cloudify.base.client.CloudifyConnectException;
@@ -898,7 +898,7 @@
{
CloudifyManager cloudifyConfig = cloudConfig.getCloudifyManager(cloudSite.getCloudifyId());
if (cloudifyConfig == null) {
- throw new MsoCloudifyManagerNotFound (cloudConfig.getCloudSiteId(cloudSite));
+ throw new MsoCloudifyManagerNotFound (cloudSite.getId());
}
// Get a Cloudify client
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java
index e5ece20..1d5b1a0 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java
@@ -41,8 +41,8 @@
import org.onap.so.adapters.vdu.VduStateType;
import org.onap.so.adapters.vdu.VduStatus;
import org.onap.so.cloud.CloudConfig;
-import org.onap.so.cloud.CloudIdentity;
-import org.onap.so.cloud.CloudSite;
+import org.onap.so.db.catalog.beans.CloudIdentity;
+import org.onap.so.db.catalog.beans.CloudSite;
import org.onap.so.cloud.authentication.AuthenticationMethodFactory;
import org.onap.so.db.catalog.beans.HeatTemplate;
import org.onap.so.db.catalog.beans.HeatTemplateParam;
@@ -949,7 +949,7 @@
* @return an authenticated Heat object
*/
public Heat getHeatClient (CloudSite cloudSite, String tenantId) throws MsoException {
- String cloudId = cloudConfig.getCloudSiteId(cloudSite);
+ String cloudId = cloudSite.getId();
// Check first in the cache of previously authorized clients
String cacheKey = cloudId + ":" + tenantId;
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtilsWithUpdate.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtilsWithUpdate.java
index 0b3f9df..e68a8e7 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtilsWithUpdate.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtilsWithUpdate.java
@@ -28,8 +28,7 @@
import java.util.List;
import java.util.Map;
-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.MessageEnum;
import org.onap.so.logger.MsoLogger;
import org.onap.so.openstack.beans.StackInfo;
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneUtils.java
index d3ec74d..2f2a457 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneUtils.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneUtils.java
@@ -27,8 +27,8 @@
import java.util.Map;
import java.util.Optional;
-import org.onap.so.cloud.CloudIdentity;
-import org.onap.so.cloud.CloudSite;
+import org.onap.so.db.catalog.beans.CloudIdentity;
+import org.onap.so.db.catalog.beans.CloudSite;
import org.onap.so.cloud.authentication.AuthenticationMethodFactory;
import org.onap.so.logger.MessageEnum;
import org.onap.so.logger.MsoAlarmLogger;
@@ -92,7 +92,7 @@
* <p>
*
* @param tenantName The tenant name to create
- * @param cloudId The cloud identifier (may be a region) in which to create the tenant.
+ * @param cloudSiteId The cloud identifier (may be a region) in which to create the tenant.
* @return the tenant ID of the newly created tenant
* @throws MsoTenantAlreadyExists Thrown if the requested tenant already exists
* @throws MsoOpenstackException Thrown if the Openstack API call returns an exception
@@ -150,7 +150,7 @@
executeAndRecordOpenstackRequest (request);
}
- if (cloudIdentity.hasTenantMetadata () && metadata != null && !metadata.isEmpty ()) {
+ if (cloudIdentity.getTenantMetadata () && metadata != null && !metadata.isEmpty ()) {
Metadata tenantMetadata = new Metadata ();
tenantMetadata.setMetadata (metadata);
@@ -221,7 +221,7 @@
}
Map <String, String> metadata = new HashMap <String, String> ();
- if (cloudConfig.getIdentityService(cloudSite.getIdentityServiceId()).hasTenantMetadata ()) {
+ if (cloudConfig.getIdentityService(cloudSite.getIdentityServiceId()).getTenantMetadata ()) {
OpenStackRequest <Metadata> request = keystoneAdminClient.tenants ().showMetadata (tenant.getId ());
Metadata tenantMetadata = executeAndRecordOpenstackRequest (request);
if (tenantMetadata != null) {
@@ -267,7 +267,7 @@
}
Map <String, String> metadata = new HashMap <String, String> ();
- if (cloudConfig.getIdentityService(cloudSite.getIdentityServiceId()).hasTenantMetadata ()) {
+ if (cloudConfig.getIdentityService(cloudSite.getIdentityServiceId()).getTenantMetadata ()) {
OpenStackRequest <Metadata> request = keystoneAdminClient.tenants ().showMetadata (tenant.getId ());
Metadata tenantMetadata = executeAndRecordOpenstackRequest (request);
if (tenantMetadata != null) {
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java
index adeb008..18ed941 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java
@@ -27,8 +27,8 @@
import java.util.Map;
import org.onap.so.cloud.CloudConfig;
-import org.onap.so.cloud.CloudIdentity;
-import org.onap.so.cloud.CloudSite;
+import org.onap.so.db.catalog.beans.CloudIdentity;
+import org.onap.so.db.catalog.beans.CloudSite;
import org.onap.so.cloud.authentication.AuthenticationMethodFactory;
import org.onap.so.logger.MessageEnum;
import org.onap.so.logger.MsoAlarmLogger;
@@ -42,7 +42,6 @@
import org.onap.so.openstack.exceptions.MsoNetworkAlreadyExists;
import org.onap.so.openstack.exceptions.MsoNetworkNotFound;
import org.onap.so.openstack.exceptions.MsoOpenstackException;
-import org.onap.so.openstack.exceptions.MsoTenantNotFound;
import org.onap.so.openstack.mappers.NetworkInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoTenantUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoTenantUtils.java
index 28911bc..383409f 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoTenantUtils.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoTenantUtils.java
@@ -24,7 +24,7 @@
import java.util.Map;
import org.onap.so.cloud.CloudConfig;
-import org.onap.so.cloud.CloudIdentity;
+import org.onap.so.db.catalog.beans.CloudIdentity;
import org.onap.so.logger.MsoLogger;
import org.onap.so.openstack.beans.MsoTenant;
import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound;
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoTenantUtilsFactory.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoTenantUtilsFactory.java
index 68d0ef2..da9f79a 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoTenantUtilsFactory.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoTenantUtilsFactory.java
@@ -21,8 +21,8 @@
package org.onap.so.openstack.utils;
import org.onap.so.cloud.CloudConfig;
-import org.onap.so.cloud.CloudSite;
-import org.onap.so.cloud.ServerType;
+import org.onap.so.db.catalog.beans.CloudSite;
+import org.onap.so.db.catalog.beans.ServerType;
import org.onap.so.logger.MsoLogger;
import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound;
import org.springframework.beans.factory.annotation.Autowired;
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/BaseTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/BaseTest.java
index 36f82e1..36a50fd 100644
--- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/BaseTest.java
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/BaseTest.java
@@ -22,14 +22,30 @@
import com.github.tomakehurst.wiremock.client.WireMock;
+import org.apache.http.HttpHeaders;
+import org.apache.http.HttpStatus;
import org.junit.After;
+import org.junit.Before;
import org.junit.runner.RunWith;
+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.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock;
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.FileReader;
+import java.io.IOException;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.*;
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
+
@RunWith(SpringRunner.class)
@SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ActiveProfiles("test")
@@ -43,4 +59,68 @@
public void after() {
WireMock.reset();
}
-}
+
+ protected static String getBody(String body, int port, String urlPath) throws IOException {
+ return body.replaceAll("port", "http://localhost:" + port + urlPath);
+ }
+
+ @Before
+ public void init() throws IOException {
+ CloudIdentity identity = getCloudIdentity();
+ CloudSite cloudSite = getCloudSite(identity);
+ mockCloud(identity, cloudSite);
+ }
+
+ private void mockCloud(CloudIdentity identity, CloudSite cloudSite) throws IOException {
+ stubFor(get(urlPathEqualTo("/cloudSite/MTN13")).willReturn(aResponse()
+ .withBody(getBody(mapper.writeValueAsString(cloudSite),wireMockPort, ""))
+ .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withStatus(HttpStatus.SC_OK)));
+ stubFor(get(urlPathEqualTo("/cloudSite/default")).willReturn(aResponse()
+ .withBody(getBody(mapper.writeValueAsString(cloudSite),wireMockPort, ""))
+ .withHeader(HttpHeaders.CONTENT_TYPE,MediaType.APPLICATION_JSON)
+ .withStatus(HttpStatus.SC_OK)));
+ stubFor(get(urlPathEqualTo("/cloudIdentity/mtn13")).willReturn(aResponse()
+ .withBody(getBody(mapper.writeValueAsString(identity),wireMockPort, ""))
+ .withHeader(HttpHeaders.CONTENT_TYPE,MediaType.APPLICATION_JSON)
+ .withStatus(HttpStatus.SC_OK)));
+ }
+
+ private CloudIdentity getCloudIdentity() {
+ CloudIdentity identity = new CloudIdentity();
+ identity.setId("mtn13");
+ identity.setMsoId("m93945");
+ identity.setMsoPass("93937EA01B94A10A49279D4572B48369");
+ identity.setAdminTenant("admin");
+ identity.setMemberRole("admin");
+ identity.setTenantMetadata(false);
+ identity.setIdentityUrl("http://localhost:"+wireMockPort+"/v2.0");
+ identity.setIdentityAuthenticationType(AuthenticationType.USERNAME_PASSWORD);
+ identity.setIdentityServerType(ServerType.KEYSTONE);
+ return identity;
+ }
+
+ private CloudSite getCloudSite(CloudIdentity identity) {
+ CloudSite cloudSite = new CloudSite();
+ cloudSite.setId("MTN13");
+ cloudSite.setCloudVersion("3.0");
+ cloudSite.setClli("MDT13");
+ cloudSite.setRegionId("mtn13");
+ cloudSite.setIdentityService(identity);
+ return cloudSite;
+ }
+
+ private static String readFile(String fileName) throws IOException {
+ try (BufferedReader br = new BufferedReader(new FileReader(fileName))) {
+ StringBuilder sb = new StringBuilder();
+ String line = br.readLine();
+
+ while (line != null) {
+ sb.append(line);
+ sb.append("\n");
+ line = br.readLine();
+ }
+ return sb.toString();
+ }
+ }
+}
\ No newline at end of file
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java
new file mode 100644
index 0000000..d7b30ed
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java
@@ -0,0 +1,42 @@
+package org.onap.so;
+
+import ch.vorburger.exec.ManagedProcessException;
+import ch.vorburger.mariadb4j.DBConfigurationBuilder;
+import ch.vorburger.mariadb4j.springframework.MariaDB4jSpringService;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Profile;
+
+import javax.sql.DataSource;
+
+@Configuration
+@Profile({"test","local"})
+public class EmbeddedMariaDbConfig {
+
+ @Bean
+ MariaDB4jSpringService mariaDB4jSpringService() {
+ return new MariaDB4jSpringService();
+ }
+
+ @Bean
+ DataSource dataSource(MariaDB4jSpringService mariaDB4jSpringService,
+ @Value("${mariaDB4j.databaseName}") String databaseName,
+ @Value("${spring.datasource.username}") String datasourceUsername,
+ @Value("${spring.datasource.password}") String datasourcePassword,
+ @Value("${spring.datasource.driver-class-name}") String datasourceDriver) throws ManagedProcessException {
+ //Create our database with default root user and no password
+ mariaDB4jSpringService.getDB().createDB(databaseName);
+
+ DBConfigurationBuilder config = mariaDB4jSpringService.getConfiguration();
+
+ return DataSourceBuilder
+ .create()
+ .username(datasourceUsername)
+ .password(datasourcePassword)
+ .url(config.getURL(databaseName))
+ .driverClassName(datasourceDriver)
+ .build();
+ }
+}
\ No newline at end of file
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/adapter_utils/tests/MsoHeatUtilsRefactorTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/adapter_utils/tests/MsoHeatUtilsRefactorTest.java
index 539e7ac..012805e 100644
--- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/adapter_utils/tests/MsoHeatUtilsRefactorTest.java
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/adapter_utils/tests/MsoHeatUtilsRefactorTest.java
@@ -21,39 +21,72 @@
package org.onap.so.adapter_utils.tests;
+import org.apache.http.HttpHeaders;
+import org.apache.http.HttpStatus;
+import org.junit.Before;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.onap.so.cloud.Application;
-import org.onap.so.openstack.utils.MsoCommonUtils;
+import org.onap.so.BaseTest;
+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.openstack.exceptions.MsoCloudSiteNotFound;
import org.onap.so.openstack.utils.MsoHeatUtils;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.junit4.SpringRunner;
+
+import javax.ws.rs.core.MediaType;
+import java.io.IOException;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.*;
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static org.junit.Assert.assertEquals;
-/**
+/**PoConfigTest
* This class implements test methods of the MsoHeatUtils
*
*
*/
-@RunWith(SpringRunner.class)
-@SpringBootTest(classes = Application.class)
-@ActiveProfiles("test")
-public class MsoHeatUtilsRefactorTest extends MsoCommonUtils {
+public class MsoHeatUtilsRefactorTest extends BaseTest {
@Autowired
private MsoHeatUtils msoHeatUtils;
+
+ @Before
+ public void init() throws IOException {
+ CloudIdentity identity = new CloudIdentity();
+
+ identity.setId("MTN13");
+ identity.setMsoId("m93945");
+ identity.setMsoPass("93937EA01B94A10A49279D4572B48369");
+ identity.setAdminTenant("admin");
+ identity.setMemberRole("admin");
+ identity.setTenantMetadata(true);
+ identity.setIdentityUrl("http://localhost:28090/v2.0");
+ identity.setIdentityAuthenticationType(AuthenticationType.USERNAME_PASSWORD);
+
+ CloudSite cloudSite = new CloudSite();
+ cloudSite.setId("MTN13");
+ cloudSite.setCloudVersion("3.0");
+ cloudSite.setClli("MDT13");
+ cloudSite.setRegionId("MTN13");
+ identity.setIdentityServerType(ServerType.KEYSTONE);
+ cloudSite.setIdentityService(identity);
+
+
+ stubFor(get(urlPathEqualTo("/cloudSite/default")).willReturn(aResponse()
+ .withBody(getBody(mapper.writeValueAsString(cloudSite),wireMockPort, ""))
+ .withHeader(HttpHeaders.CONTENT_TYPE,MediaType.APPLICATION_JSON)
+ .withStatus(HttpStatus.SC_OK)));
+ stubFor(get(urlPathEqualTo("/cloudIdentity/MTN13")).willReturn(aResponse()
+ .withBody(getBody(mapper.writeValueAsString(identity),wireMockPort, ""))
+ .withHeader(HttpHeaders.CONTENT_TYPE,MediaType.APPLICATION_JSON)
+ .withStatus(HttpStatus.SC_OK)));
+ }
@Test
- public final void testGetKeystoneUrl() {
- try {
- String keyUrl = msoHeatUtils.getCloudSiteKeystoneUrl("DAN");
- assertEquals("http://192.168.170.21:5000/v2.0",keyUrl);
- } catch (Exception e) {
-
- }
+ public final void testGetKeystoneUrl() throws MsoCloudSiteNotFound {
+ String keyUrl = msoHeatUtils.getCloudSiteKeystoneUrl("DAN");
+ assertEquals("http://localhost:28090/v2.0", keyUrl);
}
-
-
}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/adapter_utils/tests/MsoHeatUtilsWithUpdateTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/adapter_utils/tests/MsoHeatUtilsWithUpdateTest.java
index 6d96872..50fc175 100644
--- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/adapter_utils/tests/MsoHeatUtilsWithUpdateTest.java
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/adapter_utils/tests/MsoHeatUtilsWithUpdateTest.java
@@ -23,7 +23,6 @@
import static org.junit.Assert.fail;
import static org.mockito.Mockito.when;
-import java.security.GeneralSecurityException;
import java.util.HashMap;
import java.util.Map;
@@ -36,9 +35,9 @@
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.onap.so.cloud.CloudConfig;
-import org.onap.so.cloud.CloudIdentity;
-import org.onap.so.cloud.CloudSite;
-import org.onap.so.cloud.ServerType;
+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.openstack.exceptions.MsoCloudSiteNotFound;
import org.onap.so.openstack.exceptions.MsoException;
import org.onap.so.openstack.exceptions.MsoIOException;
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudConfigTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudConfigTest.java
index 668b180..c6db998 100644
--- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudConfigTest.java
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudConfigTest.java
@@ -22,86 +22,71 @@
import static org.junit.Assert.*;
-import java.util.Map;
import java.util.Optional;
import org.junit.Test;
-import org.junit.runner.RunWith;
import org.onap.so.BaseTest;
+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.openstack.exceptions.MsoException;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.junit4.SpringRunner;
/**
* This class implements test methods of the CloudConfig features.
*
*
*/
-public class CloudConfigTest extends BaseTest {
+public class CloudConfigTest extends BaseTest{
@Autowired
private CloudConfig con;
- /**
- * This method implements a test for the getCloudSites method.
- */
- @Test
- public final void testGetCloudSites () {
- Map<String,CloudSite> siteMap = con.getCloudSites();
- assertNotNull(siteMap);
+ /**
+ * This method implements a test for the getCloudSite method.
+ */
+ @Test
+ public final void testGetCloudSite () {
+ CloudSite site1 = con.getCloudSite("MTN13").get();
- CloudSite site1 = siteMap.get("regionOne");
-
- assertEquals ("regionOne", site1.getRegionId());
- assertEquals ("MT_KEYSTONE", site1.getIdentityServiceId());
- assertEquals ("MT2", site1.getClli());
- assertEquals ("2.5", site1.getAicVersion());
- }
+ assertEquals ("mtn13", site1.getRegionId());
+ assertEquals ("mtn13", site1.getIdentityServiceId());
+ assertEquals ("MDT13", site1.getClli());
+ assertEquals ("3.0", site1.getCloudVersion());
+ }
- /**
- * This method implements a test for the getIdentityServices method.
- * @throws MsoException
- */
- @Test
- public final void testGetIdentityServices () throws MsoException {
- Map<String,CloudIdentity> identityMap = con.getIdentityServices ();
- assertNotNull(identityMap);
+ /**
+ * This method implements a test for the getIdentityServices method.
+ * @throws MsoException
+ */
+ @Test
+ public final void testGetIdentityServices () throws MsoException {
- CloudIdentity identity1 = identityMap.get("MT_KEYSTONE");
+ CloudIdentity identity1 = con.getIdentityService("mtn13");
- assertEquals("john", identity1.getMsoId());
- assertEquals("313DECE408AF7759D442D7B06DD9A6AA", identity1.getMsoPass());
- assertEquals("admin", identity1.getAdminTenant());
- assertEquals("_member_", identity1.getMemberRole());
- assertEquals(false, identity1.hasTenantMetadata());
- assertEquals("http://localhost:"+wireMockPort+"/v2.0", identity1.getIdentityUrl());
- assertEquals(ServerType.KEYSTONE, identity1.getIdentityServerType());
- assertEquals(AuthenticationType.USERNAME_PASSWORD, identity1.getIdentityAuthenticationType());
+ assertEquals("m93945", identity1.getMsoId());
+ assertEquals("93937EA01B94A10A49279D4572B48369", identity1.getMsoPass());
+ assertEquals("admin", identity1.getAdminTenant());
+ assertEquals("admin", identity1.getMemberRole());
+ assertTrue(identity1.getIdentityUrl().contains("http://localhost:"));
+ assertEquals(ServerType.KEYSTONE, identity1.getIdentityServerType());
+ assertEquals(AuthenticationType.USERNAME_PASSWORD, identity1.getIdentityAuthenticationType());
- }
+ }
- /**
- * This method implements a test for the getCloudSite method.
- */
- @Test
- public final void testGetDefaultCloudSite () {
- Optional<CloudSite> site = con.getCloudSite("NotThere");
- assertTrue(site.isPresent());
- CloudSite site1 = site.get();
- assertEquals ("NotThere", site1.getRegionId());
- assertEquals("MTN6", site1.getClli());
- assertEquals("NotThere", site1.getId());
- assertEquals ("ORDM3", site1.getIdentityServiceId());
- }
-
- @Test
- public void testGetIdentityService() {
- CloudIdentity identity = con.getIdentityService("MT_KEYSTONE");
- assertEquals("john", identity.getMsoId());
- assertEquals("MT_KEYSTONE", identity.getId());
- }
-
+ /**
+ * This method implements a test for the getCloudSite method.
+ */
+ @Test
+ public final void testGetDefaultCloudSite () {
+ Optional<CloudSite> site = con.getCloudSite("NotThere");
+ assertTrue(site.isPresent());
+ CloudSite site1 = site.get();
+ assertEquals ("NotThere", site1.getRegionId());
+ assertEquals("MDT13", site1.getClli());
+ assertEquals("NotThere", site1.getId());
+ }
+
}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudIdentityTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudIdentityTest.java
deleted file mode 100644
index db2ba05..0000000
--- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudIdentityTest.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.so.cloud;
-
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.security.GeneralSecurityException;
-
-import org.junit.Test;
-import org.onap.so.utils.CryptoUtils;
-
-public class CloudIdentityTest {
-
- private CloudIdentity cloudIdentity = new CloudIdentity();
- private static final String ID = "testId";
- private static final String IDENTITY_URL = "testIdentityUrl";
- private static final String MSO_ID = "testMsoId";
- private static final String MSO_PASS = "testMsoPassword";
- private static final String ADMIN_TENANT = "testAdminTenant";
- private static final String MEMBER_ROLE = "testMemberRole";
- private static final Boolean TENANT_METADATA = true;
-
- @Test
- public final void testCloudIdentity () {
- CloudIdentity id = new CloudIdentity ();
- id.setAdminTenant ("AdminTenant");
- id.setId ("id");
-// id.setKeystoneUrl ("keystone");
- id.setIdentityUrl ("keystone");
- id.setMemberRole ("member");
- id.setMsoId ("msoId");
- id.setMsoPass (CryptoUtils.encryptCloudConfigPassword("password"));
- id.setTenantMetadata (true);
- id.setIdentityServerType(null);
- id.setIdentityAuthenticationType(null);
-
-
- assertTrue (id.getAdminTenant ().equals ("AdminTenant"));
- assertTrue (id.getId ().equals ("id"));
-// assertTrue (id.getKeystoneUrl ().equals ("keystone"));
- assertTrue (id.getMemberRole ().equals ("member"));
- assertTrue (id.getMsoId ().equals ("msoId"));
- assertTrue (CryptoUtils.decryptCloudConfigPassword(id.getMsoPass()).equals ("password"));
- assertTrue (id.hasTenantMetadata ());
-// assertTrue (id.toString ().contains ("keystone"));
- assertTrue(id.toString().contains("null"));
- }
-
- @Test
- public final void testEncryption () throws GeneralSecurityException {
- String encrypted = CryptoUtils.encryptCloudConfigPassword("password");
- assertTrue (encrypted != null);
- assertTrue (!encrypted.equals ("password"));
- }
-
- @Test
- public void cloneTest() {
- cloudIdentity = setupCloudIdentity(cloudIdentity, ID, IDENTITY_URL, MSO_ID, MSO_PASS, ADMIN_TENANT,
- MEMBER_ROLE, TENANT_METADATA, ServerType.ORM, AuthenticationType.USERNAME_PASSWORD);
- CloudIdentity cloudIdentity2 = cloudIdentity.clone();
-
- assertEquals(cloudIdentity.getClass(), cloudIdentity2.getClass());
- }
-
- private CloudIdentity setupCloudIdentity(CloudIdentity obj, String id, String identityUrl,
- String msoId, String msoPass, String adminTenant, String memberRole, Boolean tenantMetadata,
- ServerType identityServerType, AuthenticationType identityAuthenticationType) {
- obj.setId(id);
- obj.setIdentityUrl(identityUrl);
- obj.setMsoId(msoId);
- obj.setMsoPass(msoPass);
- obj.setAdminTenant(adminTenant);
- obj.setMemberRole(memberRole);
- obj.setTenantMetadata(tenantMetadata);
- obj.setIdentityServerType(identityServerType);
- obj.setIdentityAuthenticationType(identityAuthenticationType);
-
- return obj;
- }
-}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudPojoTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudPojoTest.java
index 89c15b0..096d5da 100644
--- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudPojoTest.java
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudPojoTest.java
@@ -21,7 +21,9 @@
package org.onap.so.cloud;
import org.junit.Test;
-import org.onap.so.openpojo.rules.EqualsAndHashCodeTester;
+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.openpojo.rules.ToStringTester;
import com.openpojo.reflection.PojoClass;
@@ -51,7 +53,6 @@
.with(new SetterTester())
.with(new GetterTester())
.with(new ToStringTester())
- .with(new EqualsAndHashCodeTester())
.build();
validator.validate(pojoClass);
}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudifyManagerTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudifyManagerTest.java
deleted file mode 100644
index 9a660b4..0000000
--- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudifyManagerTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.so.cloud;
-
-import static org.junit.Assert.assertEquals;
-import org.junit.Test;
-
-public class CloudifyManagerTest {
-
- private CloudifyManager cloudifyManager = new CloudifyManager();
- private static final String ID = "testId";
- private static final String CLOUDIFY_URL = "testCloudifyUrl";
- private static final String USERNAME = "testUsername";
- private static final String PASSWORD = "testPassword";
- private static final String VERSION = "testVersion";
-
- @Test
- public void cloneTest() {
- cloudifyManager.setId(ID);
- cloudifyManager.setCloudifyUrl(CLOUDIFY_URL);
- cloudifyManager.setUsername(USERNAME);
- cloudifyManager.setPassword(PASSWORD);
- cloudifyManager.setVersion(VERSION);
-
- CloudifyManager clone = cloudifyManager.clone();
- assertEquals(cloudifyManager, clone);
- }
-}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/authentication/AuthenticationMethodTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/authentication/AuthenticationMethodTest.java
index e1c5337..d676bca 100644
--- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/authentication/AuthenticationMethodTest.java
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/authentication/AuthenticationMethodTest.java
@@ -24,11 +24,11 @@
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.onap.so.BaseTest;
import org.onap.so.cloud.Application;
-import org.onap.so.cloud.AuthenticationType;
-import org.onap.so.cloud.CloudIdentity;
+import org.onap.so.db.catalog.beans.AuthenticationType;
+import org.onap.so.db.catalog.beans.CloudIdentity;
import org.onap.so.cloud.authentication.models.RackspaceAuthentication;
-import org.onap.so.openstack.exceptions.MsoException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
@@ -43,10 +43,7 @@
* only are tested.
*
*/
-@RunWith(SpringRunner.class)
-@SpringBootTest(classes = Application.class)
-@ActiveProfiles("test")
-public class AuthenticationMethodTest {
+public class AuthenticationMethodTest extends BaseTest {
@Autowired
private AuthenticationMethodFactory authenticationMethodFactory;
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/utils/MsoCloudifyUtilsTest2.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/utils/MsoCloudifyUtilsTest2.java
index e75a4ae..96202c5 100644
--- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/utils/MsoCloudifyUtilsTest2.java
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/utils/MsoCloudifyUtilsTest2.java
@@ -42,13 +42,12 @@
import org.onap.so.adapters.vdu.VduStateType;
import org.onap.so.adapters.vdu.VduStatus;
import org.onap.so.cloud.CloudConfig;
-import org.onap.so.cloud.CloudIdentity;
-import org.onap.so.cloud.CloudSite;
+import org.onap.so.db.catalog.beans.CloudIdentity;
+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.v3.client.Cloudify;
import org.onap.so.cloudify.v3.model.AzureConfig;
-import org.onap.so.cloudify.v3.model.OpenstackConfig;
import org.onap.so.openstack.exceptions.MsoException;
public class MsoCloudifyUtilsTest2 {
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/config/PoConfigTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/config/PoConfigTest.java
index d347ded..f069e9f 100644
--- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/config/PoConfigTest.java
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/config/PoConfigTest.java
@@ -24,6 +24,7 @@
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.onap.so.BaseTest;
import org.onap.so.cloud.Application;
import org.onap.so.config.beans.PoConfig;
import org.springframework.beans.factory.annotation.Autowired;
@@ -31,10 +32,7 @@
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
-@RunWith(SpringRunner.class)
-@SpringBootTest(classes = Application.class)
-@ActiveProfiles("test")
-public class PoConfigTest {
+public class PoConfigTest extends BaseTest {
@Autowired
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/beans/HeatCacheEntryTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/beans/HeatCacheEntryTest.java
index 4adf6bf..b675f48 100644
--- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/beans/HeatCacheEntryTest.java
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/beans/HeatCacheEntryTest.java
@@ -30,7 +30,7 @@
import org.junit.Test;
import org.onap.so.BaseTest;
-public class HeatCacheEntryTest extends BaseTest {
+public class HeatCacheEntryTest {
private static final String HEAT_URL = "testHeatUrl";
private static final String TOKEN = "testToken";
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/beans/NeutronCacheEntryTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/beans/NeutronCacheEntryTest.java
index 3a65204..8626e7d 100644
--- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/beans/NeutronCacheEntryTest.java
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/beans/NeutronCacheEntryTest.java
@@ -29,7 +29,7 @@
import org.junit.Test;
import org.onap.so.BaseTest;
-public class NeutronCacheEntryTest extends BaseTest {
+public class NeutronCacheEntryTest {
private static final String NEUTRON_URL = "testNeutronUrl";
private static final String TOKEN = "testToken";
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/beans/OpenstackBeansPojoTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/beans/OpenstackBeansPojoTest.java
index 522a261..94715f1 100644
--- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/beans/OpenstackBeansPojoTest.java
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/beans/OpenstackBeansPojoTest.java
@@ -30,7 +30,7 @@
import com.openpojo.validation.test.impl.GetterTester;
import com.openpojo.validation.test.impl.SetterTester;
-public class OpenstackBeansPojoTest extends BaseTest {
+public class OpenstackBeansPojoTest {
@Test
public void pojoStructure() {
test(PojoClassFactory.getPojoClass(VnfRollback.class));
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java
index 6bcb209..b304cba 100644
--- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java
@@ -47,6 +47,10 @@
import org.onap.so.adapters.vdu.VduModelInfo;
import org.onap.so.adapters.vdu.VduStateType;
import org.onap.so.adapters.vdu.VduStatus;
+import org.onap.so.cloud.CloudConfig;
+import org.onap.so.db.catalog.beans.CloudSite;
+import org.onap.so.openstack.beans.HeatStatus;
+import org.onap.so.openstack.beans.StackInfo;
import org.onap.so.openstack.exceptions.MsoException;
import org.springframework.beans.factory.annotation.Autowired;
@@ -67,7 +71,7 @@
expected.setStatus(status);
CloudInfo cloudInfo = new CloudInfo();
- cloudInfo.setCloudSiteId("regionOne");
+ cloudInfo.setCloudSiteId("MTN13");
cloudInfo.setTenantId("tenantId");
VduModelInfo vduModel = new VduModelInfo();
vduModel.setModelCustomizationUUID("blueprintId");
@@ -111,7 +115,7 @@
expected.setStatus(status);
CloudInfo cloudInfo = new CloudInfo();
- cloudInfo.setCloudSiteId("regionOne");
+ cloudInfo.setCloudSiteId("mtn13");
cloudInfo.setTenantId("tenantId");
String instanceId = "instanceId";
@@ -138,7 +142,7 @@
expected.setStatus(status);
CloudInfo cloudInfo = new CloudInfo();
- cloudInfo.setCloudSiteId("regionOne");
+ cloudInfo.setCloudSiteId("mtn13");
cloudInfo.setTenantId("tenantId");
String instanceId = "instanceId";
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsWithUpdateTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsWithUpdateTest.java
index c252f61..1a8f4fb 100644
--- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsWithUpdateTest.java
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsWithUpdateTest.java
@@ -25,7 +25,6 @@
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.isA;
import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import java.io.File;
@@ -39,13 +38,12 @@
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
-import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
import org.mockito.runners.MockitoJUnitRunner;
import org.onap.so.TestDataSetup;
import org.onap.so.cloud.CloudConfig;
-import org.onap.so.cloud.CloudSite;
+import org.onap.so.db.catalog.beans.CloudSite;
import org.onap.so.openstack.beans.HeatStatus;
import org.onap.so.openstack.beans.StackInfo;
import org.onap.so.openstack.exceptions.MsoException;
@@ -55,10 +53,7 @@
import com.fasterxml.jackson.databind.JsonMappingException;
import com.woorea.openstack.base.client.OpenStackRequest;
import com.woorea.openstack.heat.Heat;
-import com.woorea.openstack.heat.StackResource;
-import com.woorea.openstack.heat.StackResource.UpdateStack;
import com.woorea.openstack.heat.model.Stack;
-import com.woorea.openstack.heat.model.UpdateStackParam;
@RunWith(MockitoJUnitRunner.class)
public class MsoHeatUtilsWithUpdateTest extends TestDataSetup {
@@ -95,7 +90,7 @@
@Test
public void updateStackTest() throws MsoException, JsonParseException, JsonMappingException, IOException {
- CloudSite cloudSite = mapper.readValue(new File(RESOURCE_PATH + "CloudSite.json"), CloudSite.class);
+ CloudSite cloudSite = new CloudSite();
Heat heatClient = new Heat("endpoint");
Stack heatStack = mapper.readValue(new File(RESOURCE_PATH + "HeatStack.json"), Stack.class);
Stack updateStack = mapper.readValue(new File(RESOURCE_PATH + "UpdateStack.json"), Stack.class);
@@ -120,7 +115,7 @@
public void updateStackWithEnvironmentTest() throws JsonParseException, JsonMappingException, IOException, MsoException {
String environmentString = "environmentString";
- CloudSite cloudSite = mapper.readValue(new File(RESOURCE_PATH + "CloudSite.json"), CloudSite.class);
+ CloudSite cloudSite = new CloudSite();
Heat heatClient = new Heat("endpoint");
Stack heatStack = mapper.readValue(new File(RESOURCE_PATH + "HeatStack.json"), Stack.class);
Stack updateStack = mapper.readValue(new File(RESOURCE_PATH + "UpdateStack.json"), Stack.class);
@@ -147,7 +142,7 @@
Map<String, Object> files = new HashMap<>();
files.put("file1", new Object());
- CloudSite cloudSite = mapper.readValue(new File(RESOURCE_PATH + "CloudSite.json"), CloudSite.class);
+ CloudSite cloudSite = new CloudSite();
Heat heatClient = new Heat("endpoint");
Stack heatStack = mapper.readValue(new File(RESOURCE_PATH + "HeatStack.json"), Stack.class);
Stack updateStack = mapper.readValue(new File(RESOURCE_PATH + "UpdateStack.json"), Stack.class);
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoKeystoneUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoKeystoneUtilsTest.java
index 706427e..92f7738 100644
--- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoKeystoneUtilsTest.java
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoKeystoneUtilsTest.java
@@ -48,7 +48,7 @@
StubOpenStack.mockOpenStackGetUserById("john");
StubOpenStack.mockOpenStackGetRoles_200("OS-KSADM");
- String response = msoKeystoneUtils.createTenant("tenant", "regionOne", new HashMap<>(), true);
+ String response = msoKeystoneUtils.createTenant("tenant", "MTN13", new HashMap<>(), true);
Assert.assertEquals("tenantId", response);
}
@@ -59,7 +59,7 @@
StubOpenStack.mockOpenStackGetUserByName("john");
StubOpenStack.mockOpenStackGetRoles_200("OS-KSADM");
- String response = msoKeystoneUtils.createTenant("tenant", "regionOne", new HashMap<>(), true);
+ String response = msoKeystoneUtils.createTenant("tenant", "MTN13", new HashMap<>(), true);
Assert.assertEquals("tenantId", response);
}
@@ -70,14 +70,14 @@
StubOpenStack.mockOpenStackPostTenantWithBodyFile_200();
StubOpenStack.mockOpenStackGetUserByName_500("john");
StubOpenStack.mockOpenStackGetRoles_200("OS-KSADM");
- msoKeystoneUtils.createTenant("tenant", "regionOne", new HashMap<>(), true);
+ msoKeystoneUtils.createTenant("tenant", "Test", new HashMap<>(), true);
}
@Test
public void queryTenantTest() throws Exception {
StubOpenStack.mockOpenStackGetTenantById("tenantId");
- MsoTenant msoTenant = msoKeystoneUtils.queryTenant("tenantId", "regionOne");
+ MsoTenant msoTenant = msoKeystoneUtils.queryTenant("tenantId", "MTN13");
Assert.assertEquals("testingTenantName", msoTenant.getTenantName());
}
@@ -86,7 +86,7 @@
public void queryTenantByNameTest() throws Exception {
StubOpenStack.mockOpenStackGetTenantByName("tenant");
- MsoTenant msoTenant = msoKeystoneUtils.queryTenantByName("tenant", "regionOne");
+ MsoTenant msoTenant = msoKeystoneUtils.queryTenantByName("tenant", "MTN13");
Assert.assertEquals("testingTenantName", msoTenant.getTenantName());
}
@@ -95,7 +95,7 @@
public void deleteTenantTest() throws Exception {
StubOpenStack.mockOpenStackGetTenantById("tenantId");
StubOpenStack.mockOpenStackDeleteTenantById_200("tenantId");
- boolean result = msoKeystoneUtils.deleteTenant("tenantId", "regionOne");
+ boolean result = msoKeystoneUtils.deleteTenant("tenantId", "MTN13");
Assert.assertTrue(result);
}
@@ -104,7 +104,7 @@
public void deleteTenantByNameTest() throws Exception {
StubOpenStack.mockOpenStackGetTenantByName("tenant");
StubOpenStack.mockOpenStackDeleteTenantById_200("tenantId");
- boolean result = msoKeystoneUtils.deleteTenantByName("tenant", "regionOne");
+ boolean result = msoKeystoneUtils.deleteTenantByName("tenant", "MTN13");
Assert.assertTrue(result);
}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoNeutronUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoNeutronUtilsTest.java
index 9f8b51a..0442d4d 100644
--- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoNeutronUtilsTest.java
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoNeutronUtilsTest.java
@@ -50,14 +50,14 @@
@Test
public void createNetworkTest_OpenStackBaseException() throws Exception {
expectedException.expect(MsoException.class);
- msoNeutronUtils.createNetwork("regionOne", "tenantId",
+ msoNeutronUtils.createNetwork("MTN13", "tenantId",
MsoNeutronUtils.NetworkType.PROVIDER,"networkName", "PROVIDER", vlans);
}
@Test
public void createNetworkTest_NetworkTypeAsMultiProvider() throws Exception {
StubOpenStack.mockOpenstackPostNetwork("OpenstackCreateNeutronNetworkResponse.json");
- NetworkInfo networkInfo = msoNeutronUtils.createNetwork("regionOne", "tenantId",
+ NetworkInfo networkInfo = msoNeutronUtils.createNetwork("MTN13", "tenantId",
MsoNeutronUtils.NetworkType.MULTI_PROVIDER,"networkName","PROVIDER", vlans);
Assert.assertEquals("2a4017ef-31ff-496a-9294-e96ecc3bc9c9",networkInfo.getId());
@@ -66,7 +66,7 @@
@Test
public void createNetworkTest() throws Exception {
StubOpenStack.mockOpenstackPostNetwork("OpenstackCreateNeutronNetworkResponse.json");
- NetworkInfo networkInfo = msoNeutronUtils.createNetwork("regionOne", "tenantId",
+ NetworkInfo networkInfo = msoNeutronUtils.createNetwork("MTN13", "tenantId",
MsoNeutronUtils.NetworkType.PROVIDER,"networkName","PROVIDER", vlans);
Assert.assertEquals("2a4017ef-31ff-496a-9294-e96ecc3bc9c9",networkInfo.getId());
@@ -75,14 +75,14 @@
@Test
public void queryNetworkTest() throws Exception {
StubOpenStack.mockOpenStackGetNeutronNetwork("GetNeutronNetwork.json", "43173f6a-d699-414b-888f-ab243dda6dfe");
- NetworkInfo networkInfo = msoNeutronUtils.queryNetwork("43173f6a-d699-414b-888f-ab243dda6dfe", "tenantId","regionOne");
+ NetworkInfo networkInfo = msoNeutronUtils.queryNetwork("43173f6a-d699-414b-888f-ab243dda6dfe", "tenantId","MTN13");
Assert.assertEquals("net1",networkInfo.getName());
}
@Test
public void queryNetworkTest_404() throws Exception {
- NetworkInfo networkInfo = msoNeutronUtils.queryNetwork("43173f6a-d699-414b-888f-ab243dda6dfe", "tenantId","regionOne");
+ NetworkInfo networkInfo = msoNeutronUtils.queryNetwork("43173f6a-d699-414b-888f-ab243dda6dfe", "tenantId","MTN13");
Assert.assertNull(networkInfo);
}
@@ -90,7 +90,7 @@
public void queryNetworkTest_500() throws Exception {
expectedException.expect(MsoException.class);
StubOpenStack.mockOpenStackGetNeutronNetwork_500("43173f6a-d699-414b-888f-ab243dda6dfe");
- msoNeutronUtils.queryNetwork("43173f6a-d699-414b-888f-ab243dda6dfe", "tenantId","regionOne");
+ msoNeutronUtils.queryNetwork("43173f6a-d699-414b-888f-ab243dda6dfe", "tenantId","MTN13");
}
@@ -98,7 +98,7 @@
public void deleteNetworkkTest() throws Exception {
StubOpenStack.mockOpenStackGetNeutronNetwork("GetNeutronNetwork.json", "43173f6a-d699-414b-888f-ab243dda6dfe");
StubOpenStack.mockOpenStackDeleteNeutronNetwork("43173f6a-d699-414b-888f-ab243dda6dfe");
- Boolean result = msoNeutronUtils.deleteNetwork("43173f6a-d699-414b-888f-ab243dda6dfe", "tenantId","regionOne");
+ Boolean result = msoNeutronUtils.deleteNetwork("43173f6a-d699-414b-888f-ab243dda6dfe", "tenantId","MTN13");
Assert.assertTrue(result);
}
@@ -107,7 +107,7 @@
public void updateNetworkTest() throws Exception {
StubOpenStack.mockOpenStackGetNeutronNetwork("GetNeutronNetwork.json", "43173f6a-d699-414b-888f-ab243dda6dfe");
StubOpenStack.mockOpenstackPutNetwork("OpenstackCreateNeutronNetworkResponse.json", "43173f6a-d699-414b-888f-ab243dda6dfe");
- NetworkInfo networkInfo = msoNeutronUtils.updateNetwork("regionOne", "tenantId",
+ NetworkInfo networkInfo = msoNeutronUtils.updateNetwork("MTN13", "tenantId",
"43173f6a-d699-414b-888f-ab243dda6dfe",MsoNeutronUtils.NetworkType.PROVIDER,"PROVIDER", vlans);
Assert.assertEquals("2a4017ef-31ff-496a-9294-e96ecc3bc9c9",networkInfo.getId());
@@ -117,7 +117,7 @@
public void updateNetworkTest_NetworkTypeAsMultiProvider() throws Exception {
StubOpenStack.mockOpenStackGetNeutronNetwork("GetNeutronNetwork.json", "43173f6a-d699-414b-888f-ab243dda6dfe");
StubOpenStack.mockOpenstackPutNetwork("OpenstackCreateNeutronNetworkResponse.json", "43173f6a-d699-414b-888f-ab243dda6dfe");
- NetworkInfo networkInfo = msoNeutronUtils.updateNetwork("regionOne", "tenantId",
+ NetworkInfo networkInfo = msoNeutronUtils.updateNetwork("MTN13", "tenantId",
"43173f6a-d699-414b-888f-ab243dda6dfe",MsoNeutronUtils.NetworkType.MULTI_PROVIDER,"PROVIDER", vlans);
Assert.assertEquals("2a4017ef-31ff-496a-9294-e96ecc3bc9c9",networkInfo.getId());
diff --git a/adapters/mso-adapter-utils/src/test/resources/__files/OpenstackResponse_Access.json b/adapters/mso-adapter-utils/src/test/resources/__files/OpenstackResponse_Access.json
index 7153f8b..f1c08cc 100644
--- a/adapters/mso-adapter-utils/src/test/resources/__files/OpenstackResponse_Access.json
+++ b/adapters/mso-adapter-utils/src/test/resources/__files/OpenstackResponse_Access.json
@@ -12,7 +12,7 @@
"name": null,
"endpoints": [
{
- "region": "regionOne",
+ "region": "mtn13",
"publicURL": "port",
"internalURL": null,
"adminURL": null
@@ -25,7 +25,7 @@
"name": null,
"endpoints": [
{
- "region": "regionOne",
+ "region": "mtn13",
"publicURL": "port",
"internalURL": null,
"adminURL": null
@@ -38,7 +38,7 @@
"name": null,
"endpoints": [
{
- "region": "regionOne",
+ "region": "mtn13",
"publicURL": "port",
"internalURL": null,
"adminURL": null
diff --git a/adapters/mso-adapter-utils/src/test/resources/application-test.yaml b/adapters/mso-adapter-utils/src/test/resources/application-test.yaml
index b584088..f9467d3 100644
--- a/adapters/mso-adapter-utils/src/test/resources/application-test.yaml
+++ b/adapters/mso-adapter-utils/src/test/resources/application-test.yaml
@@ -1,12 +1,5 @@
# will be used as entry in DB to say SITE OFF/ON for healthcheck
# MSO Properties go here
-mso:
- catalog:
- db:
- spring:
- endpoint: "http://localhost:"
- db:
- auth: Basic YnBlbDptc28tZGItMTUwNyE=
cloud_config:
identity_services:
MT_KEYSTONE:
@@ -48,3 +41,51 @@
orm_url_replace_with_this: "7080"
quota_value: "10"
set_default_quota: "false"
+
+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
+
+mariaDB4j:
+ dataDir:
+ port: 3307
+ databaseName: catalogdb
+
+
+#Actuator
+management:
+ endpoints:
+ enabled-by-default: false
+ endpoint:
+ info:
+ enabled: true
\ No newline at end of file
diff --git a/adapters/mso-adapter-utils/src/test/resources/data.sql b/adapters/mso-adapter-utils/src/test/resources/data.sql
new file mode 100644
index 0000000..5e0e558
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/test/resources/data.sql
@@ -0,0 +1,3 @@
+INSERT INTO `cloudify_managers` (`ID`, `CLOUDIFY_URL`, `USERNAME`, `PASSWORD`, `VERSION`, `CREATION_TIMESTAMP`, `UPDATE_TIMESTAMP`) VALUES ('mtn13', 'http://localhost:28090/v2.0', 'm93945', '93937EA01B94A10A49279D4572B48369', NULL, '2018-07-17 14:05:08', '2018-07-17 14:05:08');
+
+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');
\ No newline at end of file