summaryrefslogtreecommitdiffstats
path: root/adapters/mso-adapter-utils/src
diff options
context:
space:
mode:
authorBenjamin, Max (mb388a) <mb388a@us.att.com>2018-08-23 08:55:54 -0400
committerBenjamin, Max (mb388a) <mb388a@us.att.com>2018-08-23 08:58:09 -0400
commit1dce2e1792763171edad8a5a2afbb0321c189cc7 (patch)
tree5c42972aa18faf6dfb2b97e297d4accf429d4fb6 /adapters/mso-adapter-utils/src
parentbb6310f30287b352ad941ecc97aeb278a327d595 (diff)
Changed RequestFactory for Catalog DB client
- Missed some files, the repository isn't required now that we dont fetch the identity service directly - Fixing review comments and removing the unused import - Fixing the build :) Now that cloudSite has a 1-1 relationship with cloudidentity, there shouldn't be a need to query the identity on its own unless the site is missing Refactored some code to use site to fetch identity as a composition - Changing the catalogDb client to use HttpComponentsClientHttpRequestFactory instead of SimpleClientHttpRequestFactory, the later would lead to a IOException (FileNotFoundException specifically) whenever a 40X type of a response code is returned from the spring rest endpoint. Adding some tests for the catalogDbClient which earlier got missed in handover. Also fixing another issue with cloudSite repository which was not fetching data correctly. Fixed a repository which was added initially but later the same went missing (Not sure how) Change-Id: I72506865c4c5f7fd07a6031c146a4aba1a96c2c8 Issue-ID: SO-892 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'adapters/mso-adapter-utils/src')
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/CloudConfig.java14
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java6
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java6
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneUtils.java8
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java2
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoTenantUtilsFactory.java2
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/BaseTest.java2
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/adapter_utils/tests/MsoHeatUtilsRefactorTest.java2
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudConfigTest.java20
9 files changed, 15 insertions, 47 deletions
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 5560282fda..b32ca1833f 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
@@ -24,7 +24,6 @@ import java.util.Optional;
import com.fasterxml.jackson.annotation.JsonRootName;
-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;
@@ -51,7 +50,7 @@ import org.springframework.stereotype.Component;
public class CloudConfig {
private static final String CLOUD_SITE_VERSION = "2.5";
- private static final String DEFAULT_CLOUD_SITE_ID = "default";
+ private static final String DEFAULT_CLOUD_SITE_ID = "DEFAULT";
@Autowired
private CatalogDbClient catalogDbClient;
@@ -108,17 +107,6 @@ public class CloudConfig {
}
}
- /**
- * Get a specific CloudIdentity, based on an ID.
- *
- * @param id
- * the ID to match
- * @return a CloudIdentity, or null of no match found
- */
- public CloudIdentity getIdentityService(String id) {
- return catalogDbClient.getCloudIdentity(id);
- }
-
/**
* Get a specific CloudifyManager, based on an ID.
* @param id the ID to match
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 59996fa3d1..677f6395ff 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
@@ -1376,9 +1376,9 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{
protected OpenstackConfig getOpenstackConfig (CloudSite cloudSite, String tenantId) {
OpenstackConfig openstackConfig = new OpenstackConfig();
openstackConfig.setRegion (cloudSite.getRegionId());
- openstackConfig.setAuthUrl (cloudConfig.getIdentityService(cloudSite.getIdentityServiceId()).getIdentityUrl());
- openstackConfig.setUsername (cloudConfig.getIdentityService(cloudSite.getIdentityServiceId()).getMsoId());
- openstackConfig.setPassword (CryptoUtils.decryptCloudConfigPassword(cloudConfig.getIdentityService(cloudSite.getIdentityServiceId()).getMsoPass()));
+ openstackConfig.setAuthUrl (cloudSite.getIdentityService().getIdentityUrl());
+ openstackConfig.setUsername (cloudSite.getIdentityService().getMsoId());
+ openstackConfig.setPassword (CryptoUtils.decryptCloudConfigPassword(cloudSite.getIdentityService().getMsoPass()));
openstackConfig.setTenantName (tenantId);
return openstackConfig;
}
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 1d5b1a006d..6b66970ea0 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
@@ -382,7 +382,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{
OpenStackRequest <Stack> request = heatClient.getStacks ().create (stack);
// Begin X-Auth-User
// Obtain an MSO token for the tenant
- CloudIdentity cloudIdentity = cloudConfig.getIdentityService(cloudSite.getIdentityServiceId());
+ CloudIdentity cloudIdentity = cloudSite.getIdentityService();
// cloudIdentity.getMsoId(), cloudIdentity.getMsoPass()
//req
request.header ("X-Auth-User", cloudIdentity.getMsoId ());
@@ -965,7 +965,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{
}
// Obtain an MSO token for the tenant
- CloudIdentity cloudIdentity = cloudConfig.getIdentityService(cloudSite.getIdentityServiceId());
+ CloudIdentity cloudIdentity = cloudSite.getIdentityService();
LOGGER.debug("Found: " + cloudIdentity.toString());
MsoTenantUtils tenantUtils = tenantUtilsFactory.getTenantUtilsByServerType(cloudIdentity.getIdentityServerType());
String keystoneUrl = tenantUtils.getKeystoneUrl(cloudId, cloudIdentity);
@@ -1488,7 +1488,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{
String keystone_url = null;
try {
CloudSite cloudSite = cloudConfig.getCloudSite(cloudSiteId).orElseThrow(() -> new MsoCloudSiteNotFound(cloudSiteId));
- CloudIdentity cloudIdentity = cloudConfig.getIdentityService(cloudSite.getIdentityServiceId());
+ CloudIdentity cloudIdentity = cloudSite.getIdentityService();
keystone_url = cloudIdentity.getIdentityUrl();
} catch (Exception e) {
throw new MsoCloudSiteNotFound(cloudSiteId);
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 2f2a457bed..759c116e05 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
@@ -138,7 +138,7 @@ public class MsoKeystoneUtils extends MsoTenantUtils {
// Add MSO User to the tenant as a member and
// apply tenant metadata if supported by the cloud site
try {
- CloudIdentity cloudIdentity = cloudConfig.getIdentityService(cloudSiteOpt.get().getIdentityServiceId());
+ CloudIdentity cloudIdentity = cloudSiteOpt.get().getIdentityService();
User msoUser = findUserByNameOrId (keystoneAdminClient, cloudIdentity.getMsoId ());
Role memberRole = findRoleByNameOrId (keystoneAdminClient, cloudIdentity.getMemberRole ());
@@ -221,7 +221,7 @@ public class MsoKeystoneUtils extends MsoTenantUtils {
}
Map <String, String> metadata = new HashMap <String, String> ();
- if (cloudConfig.getIdentityService(cloudSite.getIdentityServiceId()).getTenantMetadata ()) {
+ if (cloudSite.getIdentityService().getTenantMetadata ()) {
OpenStackRequest <Metadata> request = keystoneAdminClient.tenants ().showMetadata (tenant.getId ());
Metadata tenantMetadata = executeAndRecordOpenstackRequest (request);
if (tenantMetadata != null) {
@@ -267,7 +267,7 @@ public class MsoKeystoneUtils extends MsoTenantUtils {
}
Map <String, String> metadata = new HashMap <String, String> ();
- if (cloudConfig.getIdentityService(cloudSite.getIdentityServiceId()).getTenantMetadata ()) {
+ if (cloudSite.getIdentityService().getTenantMetadata ()) {
OpenStackRequest <Metadata> request = keystoneAdminClient.tenants ().showMetadata (tenant.getId ());
Metadata tenantMetadata = executeAndRecordOpenstackRequest (request);
if (tenantMetadata != null) {
@@ -401,7 +401,7 @@ public class MsoKeystoneUtils extends MsoTenantUtils {
* @return an authenticated Keystone object
*/
public Keystone getKeystoneAdminClient (CloudSite cloudSite) throws MsoException {
- CloudIdentity cloudIdentity = cloudConfig.getIdentityService(cloudSite.getIdentityServiceId());
+ CloudIdentity cloudIdentity = cloudSite.getIdentityService();
String cloudId = cloudIdentity.getId ();
String adminTenantName = cloudIdentity.getAdminTenant ();
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 18ed94112c..a9f0a39235 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
@@ -375,7 +375,7 @@ public class MsoNeutronUtils extends MsoCommonUtils
}
// Obtain an MSO token for the tenant from the identity service
- CloudIdentity cloudIdentity = cloudConfig.getIdentityService(cloudSite.getIdentityServiceId());
+ CloudIdentity cloudIdentity = cloudSite.getIdentityService();
MsoTenantUtils tenantUtils = tenantUtilsFactory.getTenantUtilsByServerType(cloudIdentity.getIdentityServerType());
final String keystoneUrl = tenantUtils.getKeystoneUrl(cloudId, cloudIdentity);
Keystone keystoneTenantClient = new Keystone(keystoneUrl);
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 da9f79aa89..79934ccd28 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
@@ -42,7 +42,7 @@ public class MsoTenantUtilsFactory {
CloudSite cloudSite = cloudConfig.getCloudSite(cloudSiteId).orElseThrow(
() -> new MsoCloudSiteNotFound(cloudSiteId));
- return getTenantUtilsByServerType(cloudConfig.getIdentityService(cloudSite.getIdentityServiceId()).getIdentityServerType());
+ return getTenantUtilsByServerType(cloudSite.getIdentityService().getIdentityServerType());
}
public MsoTenantUtils getTenantUtilsByServerType(ServerType serverType) {
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 36a50fd77e..087ac6f17b 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
@@ -76,7 +76,7 @@ public abstract class BaseTest extends TestDataSetup {
.withBody(getBody(mapper.writeValueAsString(cloudSite),wireMockPort, ""))
.withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlPathEqualTo("/cloudSite/default")).willReturn(aResponse()
+ stubFor(get(urlPathEqualTo("/cloudSite/DEFAULT")).willReturn(aResponse()
.withBody(getBody(mapper.writeValueAsString(cloudSite),wireMockPort, ""))
.withHeader(HttpHeaders.CONTENT_TYPE,MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_OK)));
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 012805e774..c3777ca810 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
@@ -74,7 +74,7 @@ public class MsoHeatUtilsRefactorTest extends BaseTest {
cloudSite.setIdentityService(identity);
- stubFor(get(urlPathEqualTo("/cloudSite/default")).willReturn(aResponse()
+ stubFor(get(urlPathEqualTo("/cloudSite/DEFAULT")).willReturn(aResponse()
.withBody(getBody(mapper.writeValueAsString(cloudSite),wireMockPort, ""))
.withHeader(HttpHeaders.CONTENT_TYPE,MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_OK)));
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 c6db998b2b..ea25fe580d 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
@@ -56,26 +56,6 @@ public class CloudConfigTest extends BaseTest{
assertEquals ("3.0", site1.getCloudVersion());
}
-
- /**
- * This method implements a test for the getIdentityServices method.
- * @throws MsoException
- */
- @Test
- public final void testGetIdentityServices () throws MsoException {
-
- CloudIdentity identity1 = con.getIdentityService("mtn13");
-
- 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.
*/