summaryrefslogtreecommitdiffstats
path: root/adapters
diff options
context:
space:
mode:
Diffstat (limited to 'adapters')
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryGroups.java4
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java16
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackService.java44
-rw-r--r--adapters/mso-openstack-adapters/src/main/resources/application.yaml2
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditStackServiceTest.java71
5 files changed, 117 insertions, 20 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryGroups.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryGroups.java
index c15b0d9df1..facdd2f4ca 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryGroups.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryGroups.java
@@ -77,9 +77,9 @@ public class QueryGroups extends CatalogQuery {
if (instanceGroup != null) {
put(valueMap, "MODEL_NAME", instanceGroup.getModelName());
- put(valueMap, "MODEL_UUID", instanceGroup.getModelInvariantUUID());
+ put(valueMap, "MODEL_UUID", instanceGroup.getModelUUID());
put(valueMap, "MODEL_INVARIANT_ID", instanceGroup.getModelInvariantUUID());
- put(valueMap, "MODEL_VERSION", instanceGroup.getModelUUID());
+ put(valueMap, "MODEL_VERSION", instanceGroup.getModelVersion());
}
String subItem = new QueryVnfcs(vnfcCustomizationNull ? null : o.getVnfcCustomizations()).JSON2(true, true);
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java
index 589f119337..f2e0762a79 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java
@@ -48,6 +48,7 @@ import org.onap.so.adapters.catalogdb.catalogrest.QueryServiceVnfs;
import org.onap.so.adapters.catalogdb.catalogrest.QueryVfModule;
import org.onap.so.db.catalog.beans.AllottedResource;
import org.onap.so.db.catalog.beans.AllottedResourceCustomization;
+import org.onap.so.db.catalog.beans.InstanceGroup;
import org.onap.so.db.catalog.beans.NetworkResource;
import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
import org.onap.so.db.catalog.beans.Recipe;
@@ -55,11 +56,13 @@ import org.onap.so.db.catalog.beans.Service;
import org.onap.so.db.catalog.beans.ToscaCsar;
import org.onap.so.db.catalog.beans.VfModule;
import org.onap.so.db.catalog.beans.VfModuleCustomization;
+import org.onap.so.db.catalog.beans.VnfRecipe;
import org.onap.so.db.catalog.beans.VnfResource;
import org.onap.so.db.catalog.beans.VnfResourceCustomization;
import org.onap.so.db.catalog.data.repository.AllottedResourceCustomizationRepository;
import org.onap.so.db.catalog.data.repository.AllottedResourceRepository;
import org.onap.so.db.catalog.data.repository.ArRecipeRepository;
+import org.onap.so.db.catalog.data.repository.InstanceGroupRepository;
import org.onap.so.db.catalog.data.repository.NetworkRecipeRepository;
import org.onap.so.db.catalog.data.repository.NetworkResourceCustomizationRepository;
import org.onap.so.db.catalog.data.repository.NetworkResourceRepository;
@@ -120,6 +123,9 @@ public class CatalogDbAdapterRest {
@Autowired
private AllottedResourceRepository arResourceRepo;
+ @Autowired
+ private InstanceGroupRepository instanceGroupRepository;
+
private static final String NO_MATCHING_PARAMETERS = "no matching parameters";
public Response respond(String version, int respStatus, boolean isArray, CatalogQuery qryResp) {
@@ -536,6 +542,16 @@ public class CatalogDbAdapterRest {
arResource.getModelVersion());
}
}
+
+ if (null == recipe) {
+ InstanceGroup grpResource = instanceGroupRepository.findByModelUUID(rmUuid);
+ if (grpResource != null) {
+ recipe = vnfRecipeRepo.findFirstVnfRecipeByNfRoleAndActionAndVersionStr(
+ grpResource.getModelName(), action, grpResource.getModelVersion());
+ }
+
+ }
+
if (recipe != null) {
QueryResourceRecipe resourceRecipe = new QueryResourceRecipe(recipe);
entity = resourceRecipe.JSON2(false, false);
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 3508810e04..57d31bf308 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
@@ -50,23 +50,32 @@ public class AuditStackService {
private AuditDeleteStackService auditDeleteStack;
@PostConstruct
- public void auditAddAAIInventory() {
- String auth = "";
- try {
- auth = CryptoUtils.decrypt(env.getRequiredProperty("mso.auth"), env.getRequiredProperty("mso.msoKey"));
- } catch (IllegalStateException | GeneralSecurityException e) {
- logger.error("Error Decrypting Password", e);
+ public void auditAddAAIInventory() throws Exception {
+ for (int i = 0; i < getMaxClients(); i++) {
+ ExternalTaskClient client = createExternalTaskClient();
+ client.subscribe("InventoryAddAudit").lockDuration(60000).handler(auditCreateStack::executeExternalTask)
+ .open();
}
- ClientRequestInterceptor interceptor =
- new BasicAuthProvider(env.getRequiredProperty("mso.config.cadi.aafId"), auth);
+ }
+
+ @PostConstruct
+ public void auditDeleteAAIInventory() throws Exception {
+ for (int i = 0; i < getMaxClients(); i++) {
+ ExternalTaskClient client = createExternalTaskClient();
+ client.subscribe("InventoryDeleteAudit").lockDuration(60000).handler(auditDeleteStack::executeExternalTask)
+ .open();
+ }
+ }
+
+ protected ExternalTaskClient createExternalTaskClient() throws Exception {
+ ClientRequestInterceptor interceptor = createClientRequestInterceptor();
ExternalTaskClient client = ExternalTaskClient.create()
.baseUrl(env.getRequiredProperty("mso.workflow.endpoint")).maxTasks(1).addInterceptor(interceptor)
- .asyncResponseTimeout(120000).backoffStrategy(new ExponentialBackoffStrategy(0, 0, 0)).build();
- client.subscribe("InventoryAddAudit").lockDuration(60000).handler(auditCreateStack::executeExternalTask).open();
+ .asyncResponseTimeout(120000).backoffStrategy(new ExponentialBackoffStrategy(10000, 2, 120000)).build();
+ return client;
}
- @PostConstruct
- public void auditDeleteAAIInventory() {
+ protected ClientRequestInterceptor createClientRequestInterceptor() {
String auth = "";
try {
auth = CryptoUtils.decrypt(env.getRequiredProperty("mso.auth"), env.getRequiredProperty("mso.msoKey"));
@@ -75,11 +84,12 @@ public class AuditStackService {
}
ClientRequestInterceptor interceptor =
new BasicAuthProvider(env.getRequiredProperty("mso.config.cadi.aafId"), auth);
- ExternalTaskClient client = ExternalTaskClient.create()
- .baseUrl(env.getRequiredProperty("mso.workflow.endpoint")).maxTasks(1).addInterceptor(interceptor)
- .asyncResponseTimeout(120000).backoffStrategy(new ExponentialBackoffStrategy(0, 0, 0)).build();
- client.subscribe("InventoryDeleteAudit").lockDuration(60000).handler(auditDeleteStack::executeExternalTask)
- .open();
+ return interceptor;
+ }
+
+ protected int getMaxClients() {
+ return Integer.parseInt(env.getProperty("workflow.topics.maxClients", "10"));
}
+
}
diff --git a/adapters/mso-openstack-adapters/src/main/resources/application.yaml b/adapters/mso-openstack-adapters/src/main/resources/application.yaml
index 1982961ae7..470bb31b19 100644
--- a/adapters/mso-openstack-adapters/src/main/resources/application.yaml
+++ b/adapters/mso-openstack-adapters/src/main/resources/application.yaml
@@ -4,7 +4,7 @@
server:
port: 8080
tomcat:
- max-threads: 50
+ max-threads: 75
mso:
logPath: ./logs/openstack
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditStackServiceTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditStackServiceTest.java
new file mode 100644
index 0000000000..2eb8d8ef39
--- /dev/null
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditStackServiceTest.java
@@ -0,0 +1,71 @@
+package org.onap.so.adapters.audit;
+
+import static com.shazam.shazamcrest.MatcherAssert.assertThat;
+import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import org.camunda.bpm.client.ExternalTaskClient;
+import org.camunda.bpm.client.interceptor.ClientRequestInterceptor;
+import org.camunda.bpm.client.interceptor.auth.BasicAuthProvider;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.Spy;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.so.utils.CryptoUtils;
+import org.springframework.core.env.Environment;
+
+@RunWith(MockitoJUnitRunner.class)
+public class AuditStackServiceTest {
+
+ @Spy
+ @InjectMocks
+ AuditStackService auditStackService;
+
+ @Mock
+ Environment mockEnvironment;
+
+
+ @Before
+ public void before() {
+ Mockito.doReturn("5").when(mockEnvironment).getProperty("workflow.topics.maxClients", "10");
+ Mockito.doReturn("6B466C603A260F3655DBF91E53CE54667041C01406D10E8CAF9CC24D8FA5388D06F90BFE4C852052B436")
+ .when(mockEnvironment).getRequiredProperty("mso.auth");
+ Mockito.doReturn("07a7159d3bf51a0e53be7a8f89699be7").when(mockEnvironment).getRequiredProperty("mso.msoKey");
+ Mockito.doReturn("something").when(mockEnvironment).getRequiredProperty("mso.config.cadi.aafId");
+ Mockito.doReturn("host.com").when(mockEnvironment).getRequiredProperty("mso.workflow.endpoint");
+ }
+
+ @Test
+ public void testGetMaxClients() throws Exception {
+ int actual = auditStackService.getMaxClients();
+ assertEquals(5, actual);
+ }
+
+ @Test
+ public void testCreateClientRequestInterceptor() throws Exception {
+ String auth = CryptoUtils.decrypt(
+ "6B466C603A260F3655DBF91E53CE54667041C01406D10E8CAF9CC24D8FA5388D06F90BFE4C852052B436",
+ "07a7159d3bf51a0e53be7a8f89699be7");
+ ClientRequestInterceptor expected = new BasicAuthProvider("something", auth);
+ ClientRequestInterceptor actual = auditStackService.createClientRequestInterceptor();
+ assertThat(actual, sameBeanAs(expected));
+
+ }
+
+ @Test
+ public void testCreateExternalTaskClient() throws Exception {
+ String auth = CryptoUtils.decrypt(
+ "6B466C603A260F3655DBF91E53CE54667041C01406D10E8CAF9CC24D8FA5388D06F90BFE4C852052B436",
+ "07a7159d3bf51a0e53be7a8f89699be7");
+ ClientRequestInterceptor inter = new BasicAuthProvider("something", auth);
+ Mockito.doReturn(inter).when(auditStackService).createClientRequestInterceptor();
+ ExternalTaskClient actual = auditStackService.createExternalTaskClient();
+ assertNotNull(actual);
+ Mockito.verify(auditStackService, Mockito.times(1)).createClientRequestInterceptor();
+
+ }
+}