summaryrefslogtreecommitdiffstats
path: root/so-cnf-adapter-application
diff options
context:
space:
mode:
Diffstat (limited to 'so-cnf-adapter-application')
-rwxr-xr-xso-cnf-adapter-application/pom.xml5
-rw-r--r--so-cnf-adapter-application/src/main/java/org/onap/so/adapters/cnf/AaiConfiguration.java15
-rw-r--r--so-cnf-adapter-application/src/main/java/org/onap/so/adapters/cnf/service/aai/AaiService.java30
-rw-r--r--so-cnf-adapter-application/src/main/resources/application.yaml3
-rw-r--r--so-cnf-adapter-application/src/test/java/org/onap/so/adapters/cnf/service/aai/AaiServiceTest.java5
5 files changed, 46 insertions, 12 deletions
diff --git a/so-cnf-adapter-application/pom.xml b/so-cnf-adapter-application/pom.xml
index e51144d..504d994 100755
--- a/so-cnf-adapter-application/pom.xml
+++ b/so-cnf-adapter-application/pom.xml
@@ -96,11 +96,6 @@
</build>
<dependencies>
<dependency>
- <groupId>org.onap.so</groupId>
- <artifactId>aai-client</artifactId>
- <version>1.9.0</version>
- </dependency>
- <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
diff --git a/so-cnf-adapter-application/src/main/java/org/onap/so/adapters/cnf/AaiConfiguration.java b/so-cnf-adapter-application/src/main/java/org/onap/so/adapters/cnf/AaiConfiguration.java
new file mode 100644
index 0000000..49f95a6
--- /dev/null
+++ b/so-cnf-adapter-application/src/main/java/org/onap/so/adapters/cnf/AaiConfiguration.java
@@ -0,0 +1,15 @@
+package org.onap.so.adapters.cnf;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class AaiConfiguration {
+
+ @Value("${aai.enabled:false}")
+ private boolean enabled;
+
+ public boolean isEnabled() {
+ return enabled;
+ }
+}
diff --git a/so-cnf-adapter-application/src/main/java/org/onap/so/adapters/cnf/service/aai/AaiService.java b/so-cnf-adapter-application/src/main/java/org/onap/so/adapters/cnf/service/aai/AaiService.java
index 4827578..71d34a3 100644
--- a/so-cnf-adapter-application/src/main/java/org/onap/so/adapters/cnf/service/aai/AaiService.java
+++ b/so-cnf-adapter-application/src/main/java/org/onap/so/adapters/cnf/service/aai/AaiService.java
@@ -1,10 +1,13 @@
package org.onap.so.adapters.cnf.service.aai;
+import org.onap.so.adapters.cnf.AaiConfiguration;
import org.onap.so.adapters.cnf.client.MulticloudClient;
import org.onap.so.adapters.cnf.model.instantiation.AaiRequest;
import org.onap.so.adapters.cnf.model.statuscheck.K8sRbInstanceResourceStatus;
import org.onap.so.adapters.cnf.model.statuscheck.K8sRbInstanceStatus;
import org.onap.so.client.exception.BadResponseException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import java.util.List;
@@ -13,26 +16,39 @@ import java.util.stream.Collectors;
@Service
public class AaiService {
+ private final static Logger log = LoggerFactory.getLogger(AaiService.class);
+
private final MulticloudClient multicloudClient;
private final AaiRequestSender aaiRequestSender;
private final AaiResponseParser responseParser;
+ private final AaiConfiguration aaiConfiguration;
- public AaiService(MulticloudClient multicloudClient, AaiRequestSender aaiRequestSender, AaiResponseParser responseParser) {
+ public AaiService(MulticloudClient multicloudClient,
+ AaiRequestSender aaiRequestSender,
+ AaiResponseParser responseParser,
+ AaiConfiguration aaiConfiguration) {
this.multicloudClient = multicloudClient;
this.aaiRequestSender = aaiRequestSender;
this.responseParser = responseParser;
+ this.aaiConfiguration = aaiConfiguration;
}
public void aaiUpdate(AaiRequest aaiRequest) throws BadResponseException {
- List<ParseResult> parseStatus = parseStatus(aaiRequest);
-
- parseStatus.forEach(status -> aaiRequestSender.sendUpdateRequestToAai(status, aaiRequest));
+ if (aaiConfiguration.isEnabled()) {
+ List<ParseResult> parseStatus = parseStatus(aaiRequest);
+ parseStatus.forEach(status -> aaiRequestSender.sendUpdateRequestToAai(status, aaiRequest));
+ } else {
+ log.info("aai.enabled=false, do not execute aaiUpdate flow");
+ }
}
public void aaiDelete(AaiRequest aaiRequest) throws BadResponseException {
- List<ParseResult> parseStatus = parseStatus(aaiRequest);
-
- parseStatus.forEach(status -> aaiRequestSender.sendDeleteRequestToAai(aaiRequest));
+ if (aaiConfiguration.isEnabled()) {
+ List<ParseResult> parseStatus = parseStatus(aaiRequest);
+ parseStatus.forEach(status -> aaiRequestSender.sendDeleteRequestToAai(aaiRequest));
+ } else {
+ log.info("aai.enabled=false, do not execute aaiDelete flow");
+ }
}
private List<ParseResult> parseStatus(AaiRequest aaiRequest) throws BadResponseException {
diff --git a/so-cnf-adapter-application/src/main/resources/application.yaml b/so-cnf-adapter-application/src/main/resources/application.yaml
index a0e00a7..098ca64 100644
--- a/so-cnf-adapter-application/src/main/resources/application.yaml
+++ b/so-cnf-adapter-application/src/main/resources/application.yaml
@@ -23,6 +23,9 @@
#logging:
# path: logs
+aai:
+ enabled: false
+
spring:
security:
usercredentials:
diff --git a/so-cnf-adapter-application/src/test/java/org/onap/so/adapters/cnf/service/aai/AaiServiceTest.java b/so-cnf-adapter-application/src/test/java/org/onap/so/adapters/cnf/service/aai/AaiServiceTest.java
index 976fc52..f8f9597 100644
--- a/so-cnf-adapter-application/src/test/java/org/onap/so/adapters/cnf/service/aai/AaiServiceTest.java
+++ b/so-cnf-adapter-application/src/test/java/org/onap/so/adapters/cnf/service/aai/AaiServiceTest.java
@@ -4,6 +4,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
+import org.onap.so.adapters.cnf.AaiConfiguration;
import org.onap.so.adapters.cnf.client.MulticloudClient;
import org.onap.so.adapters.cnf.model.instantiation.AaiRequest;
import org.onap.so.adapters.cnf.model.statuscheck.K8sRbInstanceResourceStatus;
@@ -32,6 +33,8 @@ public class AaiServiceTest {
private AaiRequestSender aaiRequestSender;
@Mock
private AaiResponseParser responseParser;
+ @Mock
+ private AaiConfiguration aaiConfiguration;
@Test
public void shouldTestAaiUpdate() throws BadResponseException {
@@ -51,6 +54,7 @@ public class AaiServiceTest {
when(multicloudClient.getInstanceStatus(instanceId)).thenReturn(instanceStatus);
when(instanceStatus.getResourcesStatus()).thenReturn(resourcesStatus);
when(responseParser.parse(status, aaiRequest)).thenReturn(parseResult);
+ when(aaiConfiguration.isEnabled()).thenReturn(true);
doNothing().when(aaiRequestSender).sendUpdateRequestToAai(parseResult, aaiRequest);
// then
@@ -79,6 +83,7 @@ public class AaiServiceTest {
when(multicloudClient.getInstanceStatus(instanceId)).thenReturn(instanceStatus);
when(instanceStatus.getResourcesStatus()).thenReturn(resourcesStatus);
when(responseParser.parse(status, aaiRequest)).thenReturn(parseResult);
+ when(aaiConfiguration.isEnabled()).thenReturn(true);
doNothing().when(aaiRequestSender).sendUpdateRequestToAai(parseResult, aaiRequest);
// then