summaryrefslogtreecommitdiffstats
path: root/adapters
diff options
context:
space:
mode:
Diffstat (limited to 'adapters')
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java47
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneUtils.java54
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java48
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/db/migration/CloudConfig.java (renamed from adapters/mso-openstack-adapters/src/main/java/db/migration/CloudConfig.java)0
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/db/migration/R__CloudConfigMigration.java (renamed from adapters/mso-openstack-adapters/src/main/java/db/migration/R__CloudConfigMigration.java)0
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/resources/application-test.yaml41
-rw-r--r--adapters/mso-openstack-adapters/pom.xml4
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackService.java2
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackServiceData.java8
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/HeatStackAudit.java34
-rw-r--r--adapters/mso-openstack-adapters/src/main/resources/application-local.yaml5
-rw-r--r--adapters/mso-openstack-adapters/src/main/resources/application.yaml20
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/db/migration/CloudConfigMigrationTest.java127
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/HeatStackAuditTest.java44
-rw-r--r--adapters/mso-openstack-adapters/src/test/resources/GetResourcesNoServer.json25
-rw-r--r--adapters/mso-openstack-adapters/src/test/resources/application-test.yaml38
16 files changed, 127 insertions, 370 deletions
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 14aee2f4f2..20498cb694 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
@@ -103,13 +103,6 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{
protected static final String CREATE_STACK = "CreateStack";
- // Cache Heat Clients statically. Since there is just one MSO user, there is no
- // benefit to re-authentication on every request (or across different flows). The
- // token will be used until it expires.
- //
- // The cache key is "tenantId:cloudId"
- private static Map <String, HeatCacheEntry> heatClientCache = new HashMap <> ();
-
// Fetch cloud configuration each time (may be cached in CloudConfig class)
@Autowired
protected CloudConfig cloudConfig;
@@ -859,19 +852,6 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{
String cloudId = cloudSite.getId();
// For DCP/LCP, the region should be the cloudId.
String region = cloudSite.getRegionId ();
-
- // Check first in the cache of previously authorized clients
- String cacheKey = cloudId + ":" + tenantId;
- if (heatClientCache.containsKey (cacheKey)) {
- if (!heatClientCache.get (cacheKey).isExpired ()) {
- LOGGER.debug ("Using Cached HEAT Client for " + cacheKey);
- return heatClientCache.get (cacheKey).getHeatClient ();
- } else {
- // Token is expired. Remove it from cache.
- heatClientCache.remove (cacheKey);
- LOGGER.debug ("Expired Cached HEAT Client for " + cacheKey);
- }
- }
// Obtain an MSO token for the tenant
CloudIdentity cloudIdentity = cloudSite.getIdentityService();
@@ -946,38 +926,11 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{
// Catch-all
throw runtimeExceptionToMsoException (e, TOKEN_AUTH);
}
-
Heat heatClient = new Heat (heatUrl);
heatClient.token (tokenId);
-
- heatClientCache.put (cacheKey,
- new HeatCacheEntry (heatUrl,
- tokenId,
- expiration));
- LOGGER.debug ("Caching HEAT Client for " + cacheKey);
-
return heatClient;
}
- /**
- * Forcibly expire a HEAT client from the cache. This call is for use by
- * the KeystoneClient in case where a tenant is deleted. In that case,
- * all cached credentials must be purged so that fresh authentication is
- * done if a similarly named tenant is re-created.
- * <p>
- * Note: This is probably only applicable to dev/test environments where
- * the same Tenant Name is repeatedly used for creation/deletion.
- * <p>
- *
- */
- public void expireHeatClient (String tenantId, String cloudId) {
- String cacheKey = cloudId + ":" + tenantId;
- if (heatClientCache.containsKey (cacheKey)) {
- heatClientCache.remove (cacheKey);
- LOGGER.debug ("Deleted Cached HEAT Client for " + cacheKey);
- }
- }
-
/*
* Query for a Heat Stack. This function is needed in several places, so
* a common method is useful. This method takes an authenticated Heat Client
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 3936ae6496..0bd2a3931f 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
@@ -59,12 +59,6 @@ import com.woorea.openstack.keystone.utils.KeystoneUtils;
@Component
public class MsoKeystoneUtils extends MsoTenantUtils {
- // Cache the Keystone Clients statically. Since there is just one MSO user, there is no
- // benefit to re-authentication on every request (or across different flows). The
- // token will be used until it expires.
- //
- // The cache key is "cloudId"
- private static Map <String, KeystoneCacheEntry> adminClientCache = new HashMap<>();
private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA, MsoKeystoneUtils.class);
@@ -316,10 +310,6 @@ public class MsoKeystoneUtils extends MsoTenantUtils {
OpenStackRequest <Void> request = keystoneAdminClient.tenants ().delete (tenant.getId ());
executeAndRecordOpenstackRequest (request);
LOGGER.debug ("Deleted Tenant " + tenant.getId () + " (" + tenant.getName () + ")");
-
- // Clear any cached clients. Not really needed, ID will not be reused.
- msoHeatUtils.expireHeatClient (tenant.getId (), cloudSiteId);
- msoNeutronUtils.expireNeutronClient (tenant.getId (), cloudSiteId);
} catch (OpenStackBaseException e) {
// Convert Keystone OpenStackResponseException to MsoOpenstackException
throw keystoneErrorToMsoException (e, "Delete Tenant");
@@ -369,9 +359,6 @@ public class MsoKeystoneUtils extends MsoTenantUtils {
LOGGER.debug ("Deleted Tenant " + tenant.getId () + " (" + tenant.getName () + ")");
- // Clear any cached clients. Not really needed, ID will not be reused.
- msoHeatUtils.expireHeatClient (tenant.getId (), cloudSiteId);
- msoNeutronUtils.expireNeutronClient (tenant.getId (), cloudSiteId);
} catch (OpenStackBaseException e) {
// Note: It doesn't seem to matter if tenant doesn't exist, no exception is thrown.
// Convert Keystone OpenStackResponseException to MsoOpenstackException
@@ -407,16 +394,6 @@ public class MsoKeystoneUtils extends MsoTenantUtils {
String adminTenantName = cloudIdentity.getAdminTenant ();
String region = cloudSite.getRegionId ();
- // Check first in the cache of previously authorized clients
- KeystoneCacheEntry entry = adminClientCache.get (cloudId);
- if (entry != null) {
- if (!entry.isExpired ()) {
- return entry.getKeystoneClient ();
- } else {
- // Token is expired. Remove it from cache.
- adminClientCache.remove (cloudId);
- }
- }
MsoTenantUtils tenantUtils = tenantUtilsFactory.getTenantUtilsByServerType(cloudIdentity.getIdentityServerType());
final String keystoneUrl = tenantUtils.getKeystoneUrl(region, cloudIdentity);
Keystone keystone = new Keystone(keystoneUrl);
@@ -462,11 +439,6 @@ public class MsoKeystoneUtils extends MsoTenantUtils {
// Note: this doesn't go back to Openstack, it's just a local object.
keystone = new Keystone (adminUrl);
keystone.token (token);
-
- // Cache to avoid re-authentication for every call.
- KeystoneCacheEntry cacheEntry = new KeystoneCacheEntry (adminUrl, token, access.getToken ().getExpires ());
- adminClientCache.put (cloudId, cacheEntry);
-
return keystone;
}
@@ -636,32 +608,6 @@ public class MsoKeystoneUtils extends MsoTenantUtils {
return null;
}
- private static class KeystoneCacheEntry implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- private String keystoneUrl;
- private String token;
- private Calendar expires;
-
- public KeystoneCacheEntry (String url, String token, Calendar expires) {
- this.keystoneUrl = url;
- this.token = token;
- this.expires = expires;
- }
-
- public Keystone getKeystoneClient () {
- Keystone keystone = new Keystone (keystoneUrl);
- keystone.token (token);
- return keystone;
- }
-
- public boolean isExpired () {
- // adding arbitrary guard timer of 5 minutes
- return expires == null || System.currentTimeMillis() > (expires.getTimeInMillis() - 1800000);
- }
- }
-
@Override
public String getKeystoneUrl(String regionId, CloudIdentity cloudIdentity) throws MsoException {
return cloudIdentity.getIdentityUrl();
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 7b82ad62ff..785e8606d3 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
@@ -67,12 +67,6 @@ import com.woorea.openstack.quantum.model.Segment;
@Component
public class MsoNeutronUtils extends MsoCommonUtils
{
- // Cache Neutron Clients statically. Since there is just one MSO user, there is no
- // benefit to re-authentication on every request (or across different flows). The
- // token will be used until it expires.
- //
- // The cache key is "tenantId:cloudId"
- private static Map<String,NeutronCacheEntry> neutronClientCache = new HashMap<>();
// Fetch cloud configuration each time (may be cached in CloudConfig class)
@Autowired
@@ -364,24 +358,8 @@ public class MsoNeutronUtils extends MsoCommonUtils
private Quantum getNeutronClient(CloudSite cloudSite, String tenantId) throws MsoException
{
String cloudId = cloudSite.getId();
- String region = cloudSite.getRegionId();
-
- // Check first in the cache of previously authorized clients
- String cacheKey = cloudId + ":" + tenantId;
- if (neutronClientCache.containsKey(cacheKey)) {
- if (! neutronClientCache.get(cacheKey).isExpired()) {
- LOGGER.debug ("Using Cached HEAT Client for " + cacheKey);
- NeutronCacheEntry cacheEntry = neutronClientCache.get(cacheKey);
- Quantum neutronClient = new Quantum(cacheEntry.getNeutronUrl());
- neutronClient.token(cacheEntry.getToken());
- return neutronClient;
- }
- else {
- // Token is expired. Remove it from cache.
- neutronClientCache.remove(cacheKey);
- LOGGER.debug ("Expired Cached Neutron Client for " + cacheKey);
- }
- }
+ String region = cloudSite.getRegionId();
+
// Obtain an MSO token for the tenant from the identity service
CloudIdentity cloudIdentity = cloudSite.getIdentityService();
@@ -454,31 +432,9 @@ public class MsoNeutronUtils extends MsoCommonUtils
Quantum neutronClient = new Quantum(neutronUrl);
neutronClient.token(tokenId);
-
- neutronClientCache.put(cacheKey, new NeutronCacheEntry(neutronUrl, tokenId, expiration));
- LOGGER.debug ("Caching Neutron Client for " + cacheKey);
-
return neutronClient;
}
- /**
- * Forcibly expire a Neutron client from the cache. This call is for use by
- * the KeystoneClient in case where a tenant is deleted. In that case,
- * all cached credentials must be purged so that fresh authentication is
- * done on subsequent calls.
- * <p>
- * @param tenantName
- * @param cloudId
- */
- public void expireNeutronClient (String tenantId, String cloudId) {
- String cacheKey = cloudId + ":" + tenantId;
- if (neutronClientCache.containsKey(cacheKey)) {
- neutronClientCache.remove(cacheKey);
- LOGGER.debug ("Deleted Cached Neutron Client for " + cacheKey);
- }
- }
-
-
/*
* Find a tenant (or query its existence) by its Name or Id. Check first against the
* ID. If that fails, then try by name.
diff --git a/adapters/mso-openstack-adapters/src/main/java/db/migration/CloudConfig.java b/adapters/mso-catalog-db-adapter/src/main/java/db/migration/CloudConfig.java
index 82139f21af..82139f21af 100644
--- a/adapters/mso-openstack-adapters/src/main/java/db/migration/CloudConfig.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/db/migration/CloudConfig.java
diff --git a/adapters/mso-openstack-adapters/src/main/java/db/migration/R__CloudConfigMigration.java b/adapters/mso-catalog-db-adapter/src/main/java/db/migration/R__CloudConfigMigration.java
index 5acd8359ec..5acd8359ec 100644
--- a/adapters/mso-openstack-adapters/src/main/java/db/migration/R__CloudConfigMigration.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/db/migration/R__CloudConfigMigration.java
diff --git a/adapters/mso-catalog-db-adapter/src/test/resources/application-test.yaml b/adapters/mso-catalog-db-adapter/src/test/resources/application-test.yaml
index f84e194962..954e41aa68 100644
--- a/adapters/mso-catalog-db-adapter/src/test/resources/application-test.yaml
+++ b/adapters/mso-catalog-db-adapter/src/test/resources/application-test.yaml
@@ -20,6 +20,11 @@ spring:
driver-class-name: org.mariadb.jdbc.Driver
initialization-mode: always
data: classpath*:data.sql
+ flyway:
+ baseline-on-migrate: false
+ url: jdbc:mariadb://localhost:3307/catalogdb
+ user: root
+ password: password
jpa:
generate-ddl: false
show-sql: false
@@ -69,9 +74,33 @@ management:
enabled: true # Whether exporting of metrics to Prometheus is enabled.
step: 1m # Step size (i.e. reporting frequency) to use.
-
-flyway:
- baseline-on-migrate: false
- jdbc-url: jdbc:mariadb://localhost:3307/catalogdb
- user: root
- password: password
+cloud_config:
+ identity_services:
+ MTKEYSTONE:
+ identity_url: "http://localhost:5000/v2.0"
+ mso_id: "john"
+ mso_pass: "313DECE408AF7759D442D7B06DD9A6AA"
+ admin_tenant: "admin"
+ member_role: "_member_"
+ tenant_metadata: false
+ identity_server_type: "KEYSTONE"
+ identity_authentication_type: "USERNAME_PASSWORD"
+ cloud_sites:
+ mtn13:
+ region_id: "mtn13"
+ clli: "MDT13"
+ aic_version: "3.0"
+ identity_service_id: "MTN13"
+ orchestrator: "orchestrator"
+ cloudify_id: "mtn13"
+ regionOne:
+ region_id: "regionOne"
+ clli: "MT2"
+ aic_version: "2.5"
+ identity_service_id: "MTKEYSTONE"
+ cloudify_managers:
+ manager:
+ cloudify_url: "http://localhost:8080"
+ username: "user"
+ password: "password"
+ version: "2.0"
diff --git a/adapters/mso-openstack-adapters/pom.xml b/adapters/mso-openstack-adapters/pom.xml
index 8d4f30b631..46e73246a0 100644
--- a/adapters/mso-openstack-adapters/pom.xml
+++ b/adapters/mso-openstack-adapters/pom.xml
@@ -261,10 +261,6 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.flywaydb</groupId>
- <artifactId>flyway-core</artifactId>
- </dependency>
- <dependency>
<groupId>org.onap.so</groupId>
<artifactId>cxf-logging</artifactId>
<version>${project.version}</version>
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackService.java
index 38b00688a7..aace75ff99 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackService.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackService.java
@@ -60,7 +60,7 @@ public class AuditStackService {
auth);
ExternalTaskClient client = ExternalTaskClient.create()
.baseUrl(env.getRequiredProperty("mso.workflow.endpoint")).maxTasks(5).addInterceptor(interceptor)
- .asyncResponseTimeout(120000).backoffStrategy(new ExponentialBackoffStrategy(0, 0, 0)).build();
+ .asyncResponseTimeout(120000).backoffStrategy(new ExponentialBackoffStrategy(5000, 2, 30000)).build();
client.subscribe("InventoryAudit").lockDuration(5000)
.handler(auditStack::executeExternalTask).open();
}
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackServiceData.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackServiceData.java
index b0369395ed..ffbe1b4c46 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackServiceData.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackServiceData.java
@@ -24,9 +24,11 @@ import java.util.Collections;
import org.camunda.bpm.client.task.ExternalTask;
import org.camunda.bpm.client.task.ExternalTaskService;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.onap.so.audit.beans.AuditInventory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
@@ -49,6 +51,7 @@ public class AuditStackServiceData {
protected void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService){
AuditInventory auditInventory = externalTask.getVariable("auditInventory");
+ setupMDC(externalTask);
boolean success = false;
try {
logger.info("Executing External Task Audit Inventory, Retry Number: {} \n {}", auditInventory,externalTask.getRetries());
@@ -78,6 +81,11 @@ public class AuditStackServiceData {
}
+ private void setupMDC(ExternalTask externalTask) {
+ String msoRequestId = (String)externalTask.getVariable("mso-request-id");
+ if(msoRequestId != null && !msoRequestId.isEmpty())
+ MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, msoRequestId);
+ }
protected long calculateRetryDelay(int currentRetries){
int retrySequence = RETRY_SEQUENCE.length - currentRetries;
long retryMultiplier = Long.parseLong(env.getProperty("mso.workflow.topics.retryMultiplier","6000"));
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/HeatStackAudit.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/HeatStackAudit.java
index 974315374a..da833c7b07 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/HeatStackAudit.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/HeatStackAudit.java
@@ -25,6 +25,8 @@ import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -63,10 +65,14 @@ public class HeatStackAudit {
.filter(p -> "OS::Nova::Server".equals(p.getType())).collect(Collectors.toList());
List<Resource> resourceGroups = resources.getList().stream()
.filter(p -> "OS::Heat::ResourceGroup".equals(p.getType()) && p.getName().contains("subinterfaces")).collect(Collectors.toList());
- Set<Vserver> vserversToAudit = createVserverSet(resources, novaResources);
- Set<Vserver> vserversWithSubInterfaces = processSubInterfaces(cloudRegion, tenantId, resourceGroups,
- vserversToAudit);
- return auditVservers.auditVservers(vserversWithSubInterfaces, tenantId, cloudOwner, cloudRegion);
+ if(novaResources.isEmpty())
+ return true;
+ else{
+ Set<Vserver> vserversToAudit = createVserverSet(resources, novaResources);
+ Set<Vserver> vserversWithSubInterfaces = processSubInterfaces(cloudRegion, tenantId, resourceGroups,
+ vserversToAudit);
+ return auditVservers.auditVservers(vserversWithSubInterfaces, tenantId, cloudOwner, cloudRegion);
+ }
} catch (Exception e) {
logger.error("Error during auditing stack resources", e);
return false;
@@ -174,11 +180,13 @@ public class HeatStackAudit {
return vserversToAudit;
}
- protected Optional<String> extractResourcePathFromHref(String href) {
- URI uri;
+ protected Optional<String> extractResourcePathFromHref(String href) {
try {
- uri = new URI(href);
- return Optional.of(uri.getPath().replaceFirst("/v\\d+", "")+RESOURCES);
+ Optional<String> stackPath = extractStackPathFromHref(href);
+ if (stackPath.isPresent()){
+ return Optional.of(stackPath.get()+RESOURCES);
+ }else
+ return Optional.empty();
} catch (Exception e) {
logger.error("Error parsing URI", e);
}
@@ -186,10 +194,14 @@ public class HeatStackAudit {
}
protected Optional<String> extractStackPathFromHref(String href) {
- URI uri;
try {
- uri = new URI(href);
- return Optional.of(uri.getPath().replaceFirst("/v\\d+", ""));
+ URI uri = new URI(href);
+ Pattern p = Pattern.compile("/stacks.*");
+ Matcher m = p.matcher(uri.getPath());
+ if (m.find()){
+ return Optional.of(m.group());
+ }else
+ return Optional.empty();
} catch (Exception e) {
logger.error("Error parsing URI", e);
}
diff --git a/adapters/mso-openstack-adapters/src/main/resources/application-local.yaml b/adapters/mso-openstack-adapters/src/main/resources/application-local.yaml
index 67c4dd3c22..ef9b113e70 100644
--- a/adapters/mso-openstack-adapters/src/main/resources/application-local.yaml
+++ b/adapters/mso-openstack-adapters/src/main/resources/application-local.yaml
@@ -108,8 +108,3 @@ spring:
password: '$2a$12$tidKuu.h88E2nuL95pTVY.ZOYMN/1dp29A9b1o.0GFDsVVSYlMkHa'
role: ACTUATOR
-
-flyway:
- outOfOrder: true
- ignoreMissingMigrations: true
-
diff --git a/adapters/mso-openstack-adapters/src/main/resources/application.yaml b/adapters/mso-openstack-adapters/src/main/resources/application.yaml
index 18084ced8d..e682060c74 100644
--- a/adapters/mso-openstack-adapters/src/main/resources/application.yaml
+++ b/adapters/mso-openstack-adapters/src/main/resources/application.yaml
@@ -18,10 +18,12 @@ mso:
retryMultiplier: 60000
spring:
datasource:
- jdbc-url: jdbc:mariadb://${DB_HOST}:${DB_PORT}/catalogdb
+ type: com.zaxxer.hikari.HikariDataSource
+ url: jdbc:mariadb://${DB_HOST}:${DB_PORT}/catalogdb
username: ${DB_USERNAME}
password: ${DB_PASSWORD}
driver-class-name: org.mariadb.jdbc.Driver
+ initialization-mode: never
jpa:
show-sql: true
hibernate:
@@ -43,18 +45,4 @@ management:
export:
prometheus:
enabled: true # Whether exporting of metrics to Prometheus is enabled.
- step: 1m # Step size (i.e. reporting frequency) to use.
-
-
-flyway:
- outOfOrder: true
- ignoreMissingMigrations: true
- baseline-on-migrate: true
- validate-on-migrate: false
-
-org:
- onap:
- so:
- adapters:
- network:
- encryptionKey: aa3871669d893c7fb8abbcda31b88b4f
+ step: 1m # Step size (i.e. reporting frequency) to use.
diff --git a/adapters/mso-openstack-adapters/src/test/java/db/migration/CloudConfigMigrationTest.java b/adapters/mso-openstack-adapters/src/test/java/db/migration/CloudConfigMigrationTest.java
deleted file mode 100644
index d83e929d6e..0000000000
--- a/adapters/mso-openstack-adapters/src/test/java/db/migration/CloudConfigMigrationTest.java
+++ /dev/null
@@ -1,127 +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 db.migration;
-
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.so.adapters.vnf.BaseRestTestUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-
-import javax.sql.DataSource;
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.Statement;
-
-public class CloudConfigMigrationTest extends BaseRestTestUtils {
-
- @Qualifier("dataSource")
- @Autowired
- DataSource dataSource;
-
- R__CloudConfigMigration cloudConfigMigration;
-
- @Before
- public void setup() {
- cloudConfigMigration = new R__CloudConfigMigration();
- }
-
- @Test
- public void testMigrate() throws Exception {
- System.setProperty("spring.profiles.active", "test");
- cloudConfigMigration.migrate(dataSource.getConnection());
- assertMigratedIdentityServiceData();
- assertMigratedCloudSiteData();
- assertMigratedCloudManagerData();
- }
-
- @Test
- public void testMigrateNoData() throws Exception {
- System.setProperty("spring.profiles.active", "nomigrate");
- int identityCount = getDataCount("identity_services");
- int cloudSiteCount = getDataCount("cloud_sites");
- int cloudManagerCount = getDataCount("cloudify_managers");
-
- cloudConfigMigration.migrate(dataSource.getConnection());
-
- Assert.assertEquals(identityCount, getDataCount("identity_services"));
- Assert.assertEquals(cloudSiteCount, getDataCount("cloud_sites"));
- Assert.assertEquals(cloudManagerCount, getDataCount("cloudify_managers"));
- }
-
-
- private int getDataCount(String tableName) throws Exception {
- try (Connection con = dataSource.getConnection(); Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("select count(1) from " + tableName)) {
- while (rs.next()) {
- return rs.getInt(1);
- }
- }
- return 0;
- }
-
- private void assertMigratedIdentityServiceData() throws Exception {
- try (Connection con = dataSource.getConnection(); Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("select * from identity_services where id='MTKEYSTONE'")) {
- boolean dataAvailable = false;
- while (rs.next()) {
- dataAvailable = true;
- Assert.assertEquals("MTKEYSTONE", rs.getString("id"));
- Assert.assertEquals("http://localhost:5000/v2.0", rs.getString("identity_url"));
- Assert.assertEquals("john", rs.getString("mso_id"));
- Assert.assertEquals("313DECE408AF7759D442D7B06DD9A6AA", rs.getString("mso_pass"));
- Assert.assertEquals("admin", rs.getString("admin_tenant"));
- Assert.assertEquals("_member_", rs.getString("member_role"));
- Assert.assertEquals("KEYSTONE", rs.getString("identity_server_type"));
- Assert.assertEquals("USERNAME_PASSWORD", rs.getString("identity_authentication_type"));
- }
- Assert.assertTrue("Expected data in identity_services table post migration but didnt find any!!!", dataAvailable);
- }
- }
-
- private void assertMigratedCloudSiteData() throws Exception {
- try (Connection con = dataSource.getConnection(); Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("select * from cloud_sites where id='regionOne'")) {
- boolean dataAvailable = false;
- while (rs.next()) {
- dataAvailable = true;
- Assert.assertEquals("regionOne", rs.getString("id"));
- Assert.assertEquals("regionOne", rs.getString("region_id"));
- Assert.assertEquals("MT2", rs.getString("clli"));
- Assert.assertEquals("2.5", rs.getString("cloud_version"));
- Assert.assertEquals("MTKEYSTONE", rs.getString("identity_service_id"));
- }
- Assert.assertTrue("Expected data in identity_services table post migration but didnt find any!!!", dataAvailable);
- }
- }
-
- private void assertMigratedCloudManagerData() throws Exception {
- try (Connection con = dataSource.getConnection(); Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("select * from cloudify_managers where id='manager'")) {
- boolean dataAvailable = false;
- while (rs.next()) {
- dataAvailable = true;
- Assert.assertEquals("http://localhost:8080", rs.getString("cloudify_url"));
- Assert.assertEquals("user", rs.getString("username"));
- Assert.assertEquals("password", rs.getString("password"));
- Assert.assertEquals("2.0", rs.getString("version"));
- }
- Assert.assertTrue("Expected data in identity_services table post migration but didnt find any!!!", dataAvailable);
- }
- }
-}
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/HeatStackAuditTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/HeatStackAuditTest.java
index c5b93a7cb9..696784110b 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/HeatStackAuditTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/HeatStackAuditTest.java
@@ -80,19 +80,19 @@ public class HeatStackAuditTest extends HeatStackAudit {
@Test
public void extract_proper_path_Test(){
- Optional<String> actualResult = extractStackPathFromHref("https://orchestration.com:8004/v1/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/test_stack/f711be16-2654-4a09-b89d-0511fda20e81");
- assertEquals("/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/test_stack/f711be16-2654-4a09-b89d-0511fda20e81", actualResult.get());
+ Optional<String> actualResult = extractStackPathFromHref("https://orchestration.com:8004/v1/stacks/test_stack/f711be16-2654-4a09-b89d-0511fda20e81");
+ assertEquals("/stacks/test_stack/f711be16-2654-4a09-b89d-0511fda20e81", actualResult.get());
}
@Test
public void extract_proper_resources_path_Test(){
- Optional<String> actualResult = extractResourcePathFromHref("https://orchestration.com:8004/v1/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/test_stack/f711be16-2654-4a09-b89d-0511fda20e81");
- assertEquals("/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/test_stack/f711be16-2654-4a09-b89d-0511fda20e81/resources", actualResult.get());
+ Optional<String> actualResult = extractResourcePathFromHref("https://orchestration.com:8004/v1/stacks/test_stack/f711be16-2654-4a09-b89d-0511fda20e81");
+ assertEquals("/stacks/test_stack/f711be16-2654-4a09-b89d-0511fda20e81/resources", actualResult.get());
}
@Test
public void extract_invalid_uri_Test(){
- Optional<String> actualResult = extractStackPathFromHref("orchestrn.com:8004/v18b44d60a6f94bdcb2738f9e/stacks/test_stack/f711be16-2654-4a09-b89d-0511fda20e81");
+ Optional<String> actualResult = extractStackPathFromHref("orchestrn.com:8004/v18b44d60a6f94bdcb2738f9e//stacks/test_stack/f711be16-2654-4a09-b89d-0511fda20e81");
assertEquals(false, actualResult.isPresent());
}
@@ -114,6 +114,8 @@ public class HeatStackAuditTest extends HeatStackAudit {
ssc_1_trusted_port_0.setInterfaceId("d2f51f82-0ec2-4581-bd1a-d2a82073e52b");
vServer1.getLInterfaces().getLInterface().add(ssc_1_trusted_port_0);
+
+
LInterface ssc_1_mgmt_port_1 = new LInterface();
ssc_1_mgmt_port_1.setInterfaceId("07f5b14c-147a-4d14-8c94-a9e94dbc097b");
vServer1.getLInterfaces().getLInterface().add(ssc_1_mgmt_port_1);
@@ -156,33 +158,34 @@ public class HeatStackAuditTest extends HeatStackAudit {
expectedVservers.add(vServer1);
+
Resources service1QueryResponse = objectMapper.readValue(new File("src/test/resources/Service1ResourceGroupResponse.json"), Resources.class);
- doReturn(service1QueryResponse).when(msoHeatUtilsMock).executeHeatClientRequest("/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service1_port_0_subinterfaces-dtmxjmny7yjz/31d0647a-6043-49a4-81b6-ccab29380672/resources", cloudRegion, tenantId, Resources.class);
+ doReturn(service1QueryResponse).when(msoHeatUtilsMock).executeHeatClientRequest("/stacks/tsbc0005vm002ssc001-ssc_1_subint_service1_port_0_subinterfaces-dtmxjmny7yjz/31d0647a-6043-49a4-81b6-ccab29380672/resources", cloudRegion, tenantId, Resources.class);
Resources service2QueryResponse =objectMapper.readValue(new File("src/test/resources/Service2ResourceGroupResponse.json"), Resources.class);
- doReturn(service2QueryResponse).when(msoHeatUtilsMock).executeHeatClientRequest("/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service2_port_0_subinterfaces-hlzdigtimzst/447a9b41-714e-434b-b1d0-6cce8d9f0f0c/resources", cloudRegion, tenantId, Resources.class);
+ doReturn(service2QueryResponse).when(msoHeatUtilsMock).executeHeatClientRequest("/stacks/tsbc0005vm002ssc001-ssc_1_subint_service2_port_0_subinterfaces-hlzdigtimzst/447a9b41-714e-434b-b1d0-6cce8d9f0f0c/resources", cloudRegion, tenantId, Resources.class);
Stack service2StackQuerySubInt = stackObjectMapper.readValue(new File("src/test/resources/Service2SubInterface0.json"), Stack.class);
- doReturn(service2StackQuerySubInt).when(msoHeatUtilsMock).executeHeatClientRequest("/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service2_port_0_subinterfaces-hlzdigtimzst-0-upfi5nhurk7y/f711be16-2654-4a09-b89d-0511fda20e81", cloudRegion,tenantId, Stack.class);
+ doReturn(service2StackQuerySubInt).when(msoHeatUtilsMock).executeHeatClientRequest("/stacks/tsbc0005vm002ssc001-ssc_1_subint_service2_port_0_subinterfaces-hlzdigtimzst-0-upfi5nhurk7y/f711be16-2654-4a09-b89d-0511fda20e81", cloudRegion,tenantId, Stack.class);
Resources service2ResourceQuerySubInt = objectMapper.readValue(new File("src/test/resources/Service2SubInterface1Resources.json"), Resources.class);
- doReturn(service2ResourceQuerySubInt).when(msoHeatUtilsMock).executeHeatClientRequest("/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service2_port_0_subinterfaces-hlzdigtimzst-0-upfi5nhurk7y/f711be16-2654-4a09-b89d-0511fda20e81/resources", cloudRegion,tenantId, Resources.class);
+ doReturn(service2ResourceQuerySubInt).when(msoHeatUtilsMock).executeHeatClientRequest("/stacks/tsbc0005vm002ssc001-ssc_1_subint_service2_port_0_subinterfaces-hlzdigtimzst-0-upfi5nhurk7y/f711be16-2654-4a09-b89d-0511fda20e81/resources", cloudRegion,tenantId, Resources.class);
Stack service1StackQuerySubInt1 =stackObjectMapper.readValue(new File("src/test/resources/Service1SubInterface0.json"), Stack.class);
- doReturn(service1StackQuerySubInt1).when(msoHeatUtilsMock).executeHeatClientRequest("/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service1_port_0_subinterfaces-dtmxjmny7yjz-1-fmn5laetg5cs/0d9cd813-2ae1-46c0-9ebb-48081f6cffbb", cloudRegion,tenantId, Stack.class);
+ doReturn(service1StackQuerySubInt1).when(msoHeatUtilsMock).executeHeatClientRequest("/stacks/tsbc0005vm002ssc001-ssc_1_subint_service1_port_0_subinterfaces-dtmxjmny7yjz-1-fmn5laetg5cs/0d9cd813-2ae1-46c0-9ebb-48081f6cffbb", cloudRegion,tenantId, Stack.class);
Resources service1ResourceQuerySubInt1 = objectMapper.readValue(new File("src/test/resources/Service1SubInterface0Resources.json"), Resources.class);
- doReturn(service1ResourceQuerySubInt1).when(msoHeatUtilsMock).executeHeatClientRequest("/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service1_port_0_subinterfaces-dtmxjmny7yjz-1-fmn5laetg5cs/0d9cd813-2ae1-46c0-9ebb-48081f6cffbb/resources", cloudRegion,tenantId, Resources.class);
+ doReturn(service1ResourceQuerySubInt1).when(msoHeatUtilsMock).executeHeatClientRequest("/stacks/tsbc0005vm002ssc001-ssc_1_subint_service1_port_0_subinterfaces-dtmxjmny7yjz-1-fmn5laetg5cs/0d9cd813-2ae1-46c0-9ebb-48081f6cffbb/resources", cloudRegion,tenantId, Resources.class);
Stack service1StackQuerySubInt2 =stackObjectMapper.readValue(new File("src/test/resources/Service1SubInterface1.json"), Stack.class);
- doReturn(service1StackQuerySubInt2).when(msoHeatUtilsMock).executeHeatClientRequest("/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service1_port_0_subinterfaces-dtmxjmny7yjz-0-yghihziaf36m/b7019dd0-2ee9-4447-bdef-ac25676b205a", cloudRegion,tenantId, Stack.class);
+ doReturn(service1StackQuerySubInt2).when(msoHeatUtilsMock).executeHeatClientRequest("/stacks/tsbc0005vm002ssc001-ssc_1_subint_service1_port_0_subinterfaces-dtmxjmny7yjz-0-yghihziaf36m/b7019dd0-2ee9-4447-bdef-ac25676b205a", cloudRegion,tenantId, Stack.class);
Resources service1ResourceQuerySubInt2 = objectMapper.readValue(new File("src/test/resources/Service1SubInterface1Resources.json"), Resources.class);
- doReturn(service1ResourceQuerySubInt2).when(msoHeatUtilsMock).executeHeatClientRequest("/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service1_port_0_subinterfaces-dtmxjmny7yjz-0-yghihziaf36m/b7019dd0-2ee9-4447-bdef-ac25676b205a/resources", cloudRegion,tenantId, Resources.class);
+ doReturn(service1ResourceQuerySubInt2).when(msoHeatUtilsMock).executeHeatClientRequest("/stacks/tsbc0005vm002ssc001-ssc_1_subint_service1_port_0_subinterfaces-dtmxjmny7yjz-0-yghihziaf36m/b7019dd0-2ee9-4447-bdef-ac25676b205a/resources", cloudRegion,tenantId, Resources.class);
Stack service1StackQuerySubInt3 =stackObjectMapper.readValue(new File("src/test/resources/Service1SubInterface2.json"), Stack.class);
- doReturn(service1StackQuerySubInt3).when(msoHeatUtilsMock).executeHeatClientRequest("/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service1_port_0_subinterfaces-dtmxjmny7yjz-2-y3ndsavmsymv/bd0fc728-cbde-4301-a581-db56f494675c", cloudRegion,tenantId, Stack.class);
+ doReturn(service1StackQuerySubInt3).when(msoHeatUtilsMock).executeHeatClientRequest("/stacks/tsbc0005vm002ssc001-ssc_1_subint_service1_port_0_subinterfaces-dtmxjmny7yjz-2-y3ndsavmsymv/bd0fc728-cbde-4301-a581-db56f494675c", cloudRegion,tenantId, Stack.class);
Resources service1ResourceQuerySubInt3 = objectMapper.readValue(new File("src/test/resources/Service1SubInterface2Resources.json"), Resources.class);
- doReturn(service1ResourceQuerySubInt3).when(msoHeatUtilsMock).executeHeatClientRequest("/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service1_port_0_subinterfaces-dtmxjmny7yjz-2-y3ndsavmsymv/bd0fc728-cbde-4301-a581-db56f494675c/resources", cloudRegion,tenantId, Resources.class);
+ doReturn(service1ResourceQuerySubInt3).when(msoHeatUtilsMock).executeHeatClientRequest("/stacks/tsbc0005vm002ssc001-ssc_1_subint_service1_port_0_subinterfaces-dtmxjmny7yjz-2-y3ndsavmsymv/bd0fc728-cbde-4301-a581-db56f494675c/resources", cloudRegion,tenantId, Resources.class);
Set<Vserver> vServersToAudit = heatStackAudit.createVserverSet(resources, novaResources);
Set<Vserver> vserversWithSubInterfaces = heatStackAudit.processSubInterfaces(cloudRegion,tenantId,resourceGroups, vServersToAudit);
@@ -193,6 +196,17 @@ public class HeatStackAuditTest extends HeatStackAudit {
JSONAssert.assertEquals(expectedValue, actualValue, false);
}
+ @Test
+ public void auditHeatStackNoServers_Test() throws Exception{
+
+
+ Resources getResource = objectMapper.readValue(new File("src/test/resources/Service1ResourceGroupResponse.json"), Resources.class);
+ doReturn(getResource).when(msoHeatUtilsMock).queryStackResources(cloudRegion, tenantId, "heatStackName");
+
+ boolean actual = heatStackAudit.auditHeatStack(cloudRegion, "cloudOwner", tenantId, "heatStackName");
+ assertEquals(true, actual);
+ }
+
@Test
public void findInterfaceInformation_Test(){
diff --git a/adapters/mso-openstack-adapters/src/test/resources/GetResourcesNoServer.json b/adapters/mso-openstack-adapters/src/test/resources/GetResourcesNoServer.json
new file mode 100644
index 0000000000..cfc9e5a0f1
--- /dev/null
+++ b/adapters/mso-openstack-adapters/src/test/resources/GetResourcesNoServer.json
@@ -0,0 +1,25 @@
+{
+ "resources": [
+ {
+ "resource_name": "OAMFW_SECURITY_GROUP",
+ "links": [
+ {
+ "href": "http://orchestration.com:443/v1/872f331350c54e59991a8de2cbffb40c/stacks/zauk51bfrwl03_base_NC_01/08c898a4-ba71-4365-9681-993d4129164a/resources/OAMFW_SECURITY_GROUP",
+ "rel": "self"
+ },
+ {
+ "href": "http://orchestration.com:443/v1/872f331350c54e59991a8de2cbffb40c/stacks/zauk51bfrwl03_base_NC_01/08c898a4-ba71-4365-9681-993d4129164a",
+ "rel": "stack"
+ }
+ ],
+ "logical_resource_id": "OAMFW_SECURITY_GROUP",
+ "creation_time": "2019-02-13T21:17:03Z",
+ "resource_status": "CREATE_COMPLETE",
+ "updated_time": "2019-02-13T21:17:03Z",
+ "required_by": [],
+ "resource_status_reason": "state changed",
+ "physical_resource_id": "420833ff-2733-4043-868c-2f2d5bee8f93",
+ "resource_type": "OS::Neutron::SecurityGroup"
+ }
+ ]
+} \ No newline at end of file
diff --git a/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml b/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml
index 175b08f747..781d49f908 100644
--- a/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml
+++ b/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml
@@ -88,10 +88,6 @@ spring:
hibernate:
ddl-auto: none
database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
- flyway:
- baseline-on-migrate: true
- out-of-order: true
- ignore-missing-migrations: true
security:
usercredentials:
-
@@ -119,37 +115,3 @@ management:
prometheus:
enabled: true # Whether exporting of metrics to Prometheus is enabled.
step: 1m # Step size (i.e. reporting frequency) to use.
-
-
-cloud_config:
- identity_services:
- MTKEYSTONE:
- identity_url: "http://localhost:5000/v2.0"
- mso_id: "john"
- mso_pass: "313DECE408AF7759D442D7B06DD9A6AA"
- admin_tenant: "admin"
- member_role: "_member_"
- tenant_metadata: false
- identity_server_type: "KEYSTONE"
- identity_authentication_type: "USERNAME_PASSWORD"
- cloud_sites:
- mtn13:
- region_id: "mtn13"
- clli: "MDT13"
- aic_version: "3.0"
- identity_service_id: "MTN13"
- orchestrator: "orchestrator"
- cloudify_id: "mtn13"
- regionOne:
- region_id: "regionOne"
- clli: "MT2"
- aic_version: "2.5"
- identity_service_id: "MTKEYSTONE"
- cloudify_managers:
- manager:
- cloudify_url: "http://localhost:8080"
- username: "user"
- password: "password"
- version: "2.0"
-
-