diff options
author | Grzegorz Wielgosinski <g.wielgosins@samsung.com> | 2021-09-08 14:46:29 +0200 |
---|---|---|
committer | Grzegorz Wielgosinski <g.wielgosins@samsung.com> | 2021-09-13 10:14:19 +0200 |
commit | e71ed345425a2cb734ec89ad1ec19953fde33023 (patch) | |
tree | 645693c024aaab9db53e7e981803d71c7f481e0f /so-cnf-adapter-application/src/main/java/org/onap | |
parent | f0924be187a9058bf1c024f885ac2ba7a8a90c74 (diff) |
Add aai.enabled and remove aai client without version1.9.0
Issue-ID: SO-3747
Signed-off-by: Grzegorz Wielgosinski <g.wielgosins@samsung.com>
Change-Id: I5ec30cd4a3ab2efb0bea5377e2d75ce4a2c10a4a
Diffstat (limited to 'so-cnf-adapter-application/src/main/java/org/onap')
2 files changed, 38 insertions, 7 deletions
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 { |