- protected A1Client createSdnrOnapA1Client(Ric ric) {
- return new SdnrOnapA1Client(ric.getConfig(), appConfig.getA1ControllerBaseUrl(),
- appConfig.getA1ControllerUsername(), appConfig.getA1ControllerPassword());
+ private Mono<A1Client.A1ProtocolType> getProtocolVersion(Ric ric) {
+ if (ric.getProtocolVersion() == A1ProtocolType.UNKNOWN) {
+ return fetchVersion(ric, A1ProtocolType.STD_V1_1) //
+ .onErrorResume(notUsed -> fetchVersion(ric, A1ProtocolType.OSC_V1)) //
+ .onErrorResume(notUsed -> fetchVersion(ric, A1ProtocolType.SDNC_OSC_STD_V1_1)) //
+ .onErrorResume(notUsed -> fetchVersion(ric, A1ProtocolType.SDNC_ONAP)) //
+ .doOnNext(ric::setProtocolVersion)
+ .doOnNext(version -> logger.debug("Established protocol version:{} for Ric: {}", version, ric.name())) //
+ .doOnError(notUsed -> logger.warn("Could not get protocol version from RIC: {}", ric.name())) //
+ .onErrorResume(
+ notUsed -> Mono.error(new ServiceException("Protocol negotiation failed for " + ric.name())));
+ } else {
+ return Mono.just(ric.getProtocolVersion());
+ }