From 4629e64c30400e7d4ee57d046ef4a4f9cb64c31a Mon Sep 17 00:00:00 2001 From: Javier Errea Date: Wed, 11 Aug 2021 15:06:54 +0200 Subject: [PATCH] Initial tapi notification implementation - Tapi notification to nbi module - Create notification subscription service rpc - Create tapi topic in kafka server and send tapi notifications - Service state change use case - Extension of nbi module to support tapi notification service - Update nbinotification revision date - TapiRendererListener sends a notification when TAPI service is implemented JIRA: TRNSPRTPCE-387 Change-Id: I32ebbf62570474b5f18787ad0c1c422f3e5e8d68 Signed-off-by: errea --- ...yang => nbi-notifications@2021-10-13.yang} | 93 +++++++++ .../client/impl/DmaapClientProvider.java | 2 +- .../NbiNotificationsListenerImpl.java | 11 +- .../dmaap/client/resource/EventsApi.java | 2 +- ...blishNotificationProcessServiceModule.java | 6 +- ...hNotificationProcessServiceSerializer.java | 2 +- .../config/ServiceAEndSerializer.java | 2 +- .../config/ServiceZEndSerializer.java | 2 +- .../NbiNotificationsListenerImplTest.java | 10 +- .../tpce/module/TransportPCEImpl.java | 10 +- .../controllers/tpce/utils/TPCEUtils.java | 2 +- nbinotifications/pom.xml | 5 + .../impl/NbiNotificationsImpl.java | 183 ++++++++++++++++-- .../impl/NbiNotificationsProvider.java | 50 +++-- .../NbiNotificationsListenerImpl.java | 122 +++++++++++- .../NotificationAlarmServiceDeserializer.java | 6 +- .../NotificationAlarmServiceSerializer.java | 2 +- .../NotificationServiceDeserializer.java | 6 +- .../NotificationServiceSerializer.java | 2 +- .../TapiNotificationSerializer.java | 56 ++++++ .../nbinotifications/utils/TopicManager.java | 109 +++++++++++ .../blueprint/nobinotifications-blueprint.xml | 3 + .../consumer/SubscriberTest.java | 8 +- .../impl/NbiNotificationsImplTest.java | 26 ++- .../impl/NbiNotificationsProviderTest.java | 10 +- .../NbiNotificationsListenerImplTest.java | 21 +- .../producer/PublisherTest.java | 4 +- ...ificationAlarmServiceDeserializerTest.java | 4 +- ...otificationAlarmServiceSerializerTest.java | 2 +- .../NotificationServiceDeserializerTest.java | 4 +- .../NotificationServiceSerializerTest.java | 2 +- .../utils/NotificationServiceDataUtils.java | 16 +- .../src/test/resources/expected_event.json | 126 ++++++------ .../expected_event_alarm_service.json | 4 +- .../impl/ServicehandlerImpl.java | 8 +- .../listeners/PceListenerImpl.java | 8 +- .../listeners/RendererListenerImpl.java | 8 +- .../listeners/ServiceListener.java | 4 +- .../listeners/ServiceListenerTest.java | 4 +- .../transportpce/tapi/impl/TapiProvider.java | 6 +- .../TapiNetworkModelListenerImpl.java | 84 +++++++- .../listeners/TapiRendererListenerImpl.java | 91 ++++++++- .../transportpce/tapi/utils/TapiContext.java | 12 +- .../OSGI-INF/blueprint/tapi-blueprint.xml | 2 + 44 files changed, 938 insertions(+), 202 deletions(-) rename api/src/main/yang/{nbi-notifications@2021-08-13.yang => nbi-notifications@2021-10-13.yang} (67%) create mode 100644 nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/serialization/TapiNotificationSerializer.java create mode 100644 nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/utils/TopicManager.java diff --git a/api/src/main/yang/nbi-notifications@2021-08-13.yang b/api/src/main/yang/nbi-notifications@2021-10-13.yang similarity index 67% rename from api/src/main/yang/nbi-notifications@2021-08-13.yang rename to api/src/main/yang/nbi-notifications@2021-10-13.yang index b90e196a3..e55b7816b 100644 --- a/api/src/main/yang/nbi-notifications@2021-08-13.yang +++ b/api/src/main/yang/nbi-notifications@2021-10-13.yang @@ -12,6 +12,14 @@ module nbi-notifications { import org-openroadm-common-state-types { prefix org-openroadm-common-state-types; } + import tapi-common { + prefix tapi-common; + revision-date 2018-12-10; + } + import tapi-notification { + prefix tapi-notification; + revision-date 2018-12-10; + } organization "transportPCE"; @@ -21,6 +29,11 @@ module nbi-notifications { "YANG definitions for using REST API in NBI notifications module. Copyright (c) 2020 ORANGE and others. All rights reserved."; + revision 2021-10-13 { + description + "Implement new models, RPC for TAPI service notification"; + } + revision 2021-08-13 { description "Rename the groupings, containers and RPCs"; @@ -105,6 +118,69 @@ module nbi-notifications { } } + grouping notification-tapi-service { + leaf notification-type { + type tapi-notification:notification-type; + description "none"; + } + leaf target-object-type { + type tapi-notification:object-type; + description "none"; + } + leaf target-object-identifier { + type tapi-common:uuid; + description "none"; + } + list target-object-name { + key 'value-name'; + min-elements 1; + uses tapi-common:name-and-value; + description "none"; + } + leaf event-time-stamp { + type tapi-common:date-and-time; + description "none"; + } + leaf sequence-number { + type uint64; + config false; + description "A monotonous increasing sequence number associated with the notification. + The exact semantics of how this sequence number is assigned (per channel or subscription or source or system) is left undefined."; + } + leaf source-indicator { + type tapi-notification:source-indicator; + description "none"; + } + leaf layer-protocol-name { + type tapi-common:layer-protocol-name; + description "none"; + } + list changed-attributes { + key 'value-name'; + uses tapi-notification:name-and-value-change; + description "none"; + } + list additional-info { + key 'value-name'; + uses tapi-common:name-and-value; + description "none"; + } + leaf additional-text { + type string; + description "none"; + } + container tca-info { + uses tapi-notification:tca-info; + description "none"; + } + container alarm-info { + uses tapi-notification:alarm-info; + description "none"; + } + uses tapi-common:resource-spec; + description "none"; + } + container notification-process-service { description "Model used to send a notification from a service request"; @@ -117,6 +193,12 @@ module nbi-notifications { uses notification-alarm-service; } + container notification-tapi-service { + description + "Model used to send a tapi notification"; + uses notification-tapi-service; + } + rpc get-notifications-process-service { description "Get the notifications service sent by ServiceHandler through filtering connection type"; input { @@ -196,4 +278,15 @@ module nbi-notifications { } uses notification-alarm-service; } + + notification publish-tapi-notification-service { + description "Publish the TAPI notifications service for topic"; + leaf topic { + type string; + mandatory true; + description + "Topic where to send the notification service"; + } + uses tapi-notification:notification; + } } diff --git a/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/impl/DmaapClientProvider.java b/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/impl/DmaapClientProvider.java index 63bee5357..482a46b78 100644 --- a/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/impl/DmaapClientProvider.java +++ b/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/impl/DmaapClientProvider.java @@ -9,7 +9,7 @@ package org.opendaylight.transportpce.dmaap.client.impl; import org.opendaylight.mdsal.binding.api.NotificationService; import org.opendaylight.transportpce.dmaap.client.listener.NbiNotificationsListenerImpl; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NbiNotificationsListener; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NbiNotificationsListener; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/listener/NbiNotificationsListenerImpl.java b/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/listener/NbiNotificationsListenerImpl.java index 4a91e6a4c..fcf0b000d 100644 --- a/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/listener/NbiNotificationsListenerImpl.java +++ b/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/listener/NbiNotificationsListenerImpl.java @@ -17,9 +17,10 @@ import org.glassfish.jersey.logging.LoggingFeature; import org.opendaylight.transportpce.dmaap.client.resource.EventsApi; import org.opendaylight.transportpce.dmaap.client.resource.config.JsonConfigurator; import org.opendaylight.transportpce.dmaap.client.resource.model.CreatedEvent; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NbiNotificationsListener; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.PublishNotificationAlarmService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.PublishNotificationProcessService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NbiNotificationsListener; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishNotificationAlarmService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishNotificationProcessService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishTapiNotificationService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -55,7 +56,9 @@ public class NbiNotificationsListenerImpl implements NbiNotificationsListener { @Override public void onPublishNotificationAlarmService(PublishNotificationAlarmService notification) { - } + @Override + public void onPublishTapiNotificationService(PublishTapiNotificationService notification) { + } } diff --git a/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/EventsApi.java b/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/EventsApi.java index e6f167824..4284f8656 100644 --- a/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/EventsApi.java +++ b/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/EventsApi.java @@ -14,7 +14,7 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import org.opendaylight.transportpce.dmaap.client.resource.model.CreatedEvent; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.PublishNotificationProcessService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishNotificationProcessService; @Path("/events") public interface EventsApi { diff --git a/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/PublishNotificationProcessServiceModule.java b/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/PublishNotificationProcessServiceModule.java index 9fcbf9f2a..5ae404b15 100644 --- a/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/PublishNotificationProcessServiceModule.java +++ b/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/PublishNotificationProcessServiceModule.java @@ -13,9 +13,9 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev2 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.service.endpoint.TxDirection; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.service.lgx.Lgx; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.service.port.Port; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.PublishNotificationProcessService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.notification.process.service.ServiceAEnd; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.notification.process.service.ServiceZEnd; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishNotificationProcessService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.process.service.ServiceAEnd; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.process.service.ServiceZEnd; //This class is a temporary workaround while waiting jackson //support in yang tools https://git.opendaylight.org/gerrit/c/yangtools/+/94852 diff --git a/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/PublishNotificationProcessServiceSerializer.java b/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/PublishNotificationProcessServiceSerializer.java index b9b650ce0..5361e3fa0 100644 --- a/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/PublishNotificationProcessServiceSerializer.java +++ b/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/PublishNotificationProcessServiceSerializer.java @@ -11,7 +11,7 @@ import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.ser.std.StdSerializer; import java.io.IOException; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.PublishNotificationProcessService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishNotificationProcessService; // This class is a temporary workaround while waiting jackson // support in yang tools https://git.opendaylight.org/gerrit/c/yangtools/+/94852 diff --git a/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/ServiceAEndSerializer.java b/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/ServiceAEndSerializer.java index e05e0fcbb..3d48bf57e 100644 --- a/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/ServiceAEndSerializer.java +++ b/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/ServiceAEndSerializer.java @@ -11,7 +11,7 @@ import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.ser.std.StdSerializer; import java.io.IOException; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.notification.process.service.ServiceAEnd; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.process.service.ServiceAEnd; // This class is a temporary workaround while waiting jackson // support in yang tools https://git.opendaylight.org/gerrit/c/yangtools/+/94852 diff --git a/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/ServiceZEndSerializer.java b/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/ServiceZEndSerializer.java index 2e1ae2835..b31bf5db6 100644 --- a/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/ServiceZEndSerializer.java +++ b/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/ServiceZEndSerializer.java @@ -11,7 +11,7 @@ import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.ser.std.StdSerializer; import java.io.IOException; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.notification.process.service.ServiceZEnd; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.process.service.ServiceZEnd; // This class is a temporary workaround while waiting jackson // support in yang tools https://git.opendaylight.org/gerrit/c/yangtools/+/94852 diff --git a/dmaap-client/src/test/java/org/opendaylight/transportpce/dmaap/client/listener/NbiNotificationsListenerImplTest.java b/dmaap-client/src/test/java/org/opendaylight/transportpce/dmaap/client/listener/NbiNotificationsListenerImplTest.java index 363653b2a..f3df78362 100644 --- a/dmaap-client/src/test/java/org/opendaylight/transportpce/dmaap/client/listener/NbiNotificationsListenerImplTest.java +++ b/dmaap-client/src/test/java/org/opendaylight/transportpce/dmaap/client/listener/NbiNotificationsListenerImplTest.java @@ -28,11 +28,11 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev2 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.service.endpoint.TxDirectionKey; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.format.rev191129.ServiceFormat; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NbiNotificationsListener; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.PublishNotificationProcessService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.PublishNotificationProcessServiceBuilder; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.notification.process.service.ServiceAEndBuilder; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.notification.process.service.ServiceZEndBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NbiNotificationsListener; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishNotificationProcessService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishNotificationProcessServiceBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.process.service.ServiceAEndBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.process.service.ServiceZEndBuilder; import org.opendaylight.yangtools.yang.common.Uint32; import org.opendaylight.yangtools.yang.common.Uint8; import org.slf4j.LoggerFactory; diff --git a/lighty/src/main/java/io/lighty/controllers/tpce/module/TransportPCEImpl.java b/lighty/src/main/java/io/lighty/controllers/tpce/module/TransportPCEImpl.java index fb3a8f828..b85554ee2 100644 --- a/lighty/src/main/java/io/lighty/controllers/tpce/module/TransportPCEImpl.java +++ b/lighty/src/main/java/io/lighty/controllers/tpce/module/TransportPCEImpl.java @@ -215,7 +215,7 @@ public class TransportPCEImpl extends AbstractLightyModule implements TransportP R2RTapiLinkDiscovery tapilinkDiscoveryImpl = new R2RTapiLinkDiscovery(networkTransaction, deviceTransactionManager, tapiLink); TapiRendererListenerImpl tapiRendererListenerImpl = new TapiRendererListenerImpl(lightyServices - .getBindingDataBroker()); + .getBindingDataBroker(), lightyServices.getBindingNotificationPublishService()); TapiPceListenerImpl tapiPceListenerImpl = new TapiPceListenerImpl(lightyServices.getBindingDataBroker()); TapiServiceHandlerListenerImpl tapiServiceHandlerListener = new TapiServiceHandlerListenerImpl( lightyServices.getBindingDataBroker()); @@ -230,7 +230,8 @@ public class TransportPCEImpl extends AbstractLightyModule implements TransportP TapiPortMappingListener tapiPortMappingListener = new TapiPortMappingListener(tapiNetworkModelService); TapiNetworkModelListenerImpl tapiNetworkModelListenerImpl = - new TapiNetworkModelListenerImpl(networkTransaction); + new TapiNetworkModelListenerImpl(networkTransaction, + lightyServices.getBindingNotificationPublishService()); tapiProvider = initTapi(lightyServices, servicehandler, networkTransaction, serviceDataStoreOperations, tapiNetConfTopologyListener, tapiPortMappingListener, tapiNetworkutilsServiceImpl, @@ -240,8 +241,9 @@ public class TransportPCEImpl extends AbstractLightyModule implements TransportP if (activateNbiNotification) { LOG.info("Creating nbi-notifications beans ..."); nbiNotificationsProvider = new NbiNotificationsProvider( - publisherServiceList, publisherAlarmList, null, null, lightyServices.getRpcProviderService(), - lightyServices.getNotificationService(), lightyServices.getAdapterContext().currentSerializer()); + publisherServiceList, publisherAlarmList, null, null, lightyServices.getRpcProviderService(), + lightyServices.getNotificationService(), lightyServices.getAdapterContext().currentSerializer(), + networkTransaction); } } diff --git a/lighty/src/main/java/io/lighty/controllers/tpce/utils/TPCEUtils.java b/lighty/src/main/java/io/lighty/controllers/tpce/utils/TPCEUtils.java index ab28ae2d8..f8cc33196 100644 --- a/lighty/src/main/java/io/lighty/controllers/tpce/utils/TPCEUtils.java +++ b/lighty/src/main/java/io/lighty/controllers/tpce/utils/TPCEUtils.java @@ -365,7 +365,7 @@ public final class TPCEUtils { .getInstance(), org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.tapi.rev180928.$YangModuleInfoImpl .getInstance(), - org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.$YangModuleInfoImpl + org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.$YangModuleInfoImpl .getInstance()); private static final Set TPCE_YANG_MODEL = Stream.concat( diff --git a/nbinotifications/pom.xml b/nbinotifications/pom.xml index 96ff011b6..552c3c2b0 100644 --- a/nbinotifications/pom.xml +++ b/nbinotifications/pom.xml @@ -41,6 +41,11 @@ transportpce-api ${project.version} + + ${project.groupId} + transportpce-tapimodels + ${project.version} + ${project.groupId} transportpce-common diff --git a/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsImpl.java b/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsImpl.java index 77f6f8552..ea5715f7d 100644 --- a/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsImpl.java +++ b/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsImpl.java @@ -8,38 +8,85 @@ package org.opendaylight.transportpce.nbinotifications.impl; import com.google.common.util.concurrent.ListenableFuture; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.UUID; +import java.util.concurrent.ExecutionException; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.transportpce.common.converter.JsonStringConverter; +import org.opendaylight.transportpce.common.network.NetworkTransactionService; import org.opendaylight.transportpce.nbinotifications.consumer.Subscriber; import org.opendaylight.transportpce.nbinotifications.serialization.NotificationAlarmServiceDeserializer; import org.opendaylight.transportpce.nbinotifications.serialization.NotificationServiceDeserializer; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.GetNotificationsAlarmServiceInput; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.GetNotificationsAlarmServiceOutput; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.GetNotificationsAlarmServiceOutputBuilder; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.GetNotificationsProcessServiceInput; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.GetNotificationsProcessServiceOutput; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.GetNotificationsProcessServiceOutputBuilder; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NbiNotificationsService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationAlarmService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationProcessService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.get.notifications.alarm.service.output.NotificationsAlarmService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.get.notifications.process.service.output.NotificationsProcessService; +import org.opendaylight.transportpce.nbinotifications.utils.TopicManager; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.GetNotificationsAlarmServiceInput; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.GetNotificationsAlarmServiceOutput; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.GetNotificationsAlarmServiceOutputBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.GetNotificationsProcessServiceInput; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.GetNotificationsProcessServiceOutput; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.GetNotificationsProcessServiceOutputBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NbiNotificationsService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationAlarmService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationProcessService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.get.notifications.alarm.service.output.NotificationsAlarmService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.get.notifications.process.service.output.NotificationsProcessService; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.Context; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.Uuid; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.Context1; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.CreateNotificationSubscriptionServiceInput; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.CreateNotificationSubscriptionServiceOutput; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.CreateNotificationSubscriptionServiceOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.DeleteNotificationSubscriptionServiceInput; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.DeleteNotificationSubscriptionServiceOutput; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.GetNotificationListInput; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.GetNotificationListOutput; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.GetNotificationSubscriptionServiceDetailsInput; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.GetNotificationSubscriptionServiceDetailsOutput; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.GetNotificationSubscriptionServiceListInput; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.GetNotificationSubscriptionServiceListOutput; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.GetSupportedNotificationTypesInput; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.GetSupportedNotificationTypesOutput; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.NotificationType; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.ObjectType; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.TapiNotificationService; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.UpdateNotificationSubscriptionServiceInput; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.UpdateNotificationSubscriptionServiceOutput; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.context.NotificationContext; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.context.NotificationContextBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.create.notification.subscription.service.output.SubscriptionService; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.create.notification.subscription.service.output.SubscriptionServiceBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.notification.context.NotifSubscription; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.notification.context.NotifSubscriptionBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.notification.context.NotifSubscriptionKey; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.notification.subscription.service.SubscriptionFilter; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.notification.subscription.service.SubscriptionFilterBuilder; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.yangtools.yang.common.ErrorType; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class NbiNotificationsImpl implements NbiNotificationsService { +public class NbiNotificationsImpl implements NbiNotificationsService, TapiNotificationService { private static final Logger LOG = LoggerFactory.getLogger(NbiNotificationsImpl.class); private final JsonStringConverter converterService; private final JsonStringConverter converterAlarmService; private final String server; + private final NetworkTransactionService networkTransactionService; + private final TopicManager topicManager; public NbiNotificationsImpl(JsonStringConverter converterService, - JsonStringConverter converterAlarmService, String server) { + JsonStringConverter converterAlarmService, String server, + NetworkTransactionService networkTransactionService, TopicManager topicManager) { this.converterService = converterService; this.converterAlarmService = converterAlarmService; this.server = server; + this.networkTransactionService = networkTransactionService; + this.topicManager = topicManager; } @Override @@ -75,4 +122,114 @@ public class NbiNotificationsImpl implements NbiNotificationsService { return RpcResultBuilder.success(new GetNotificationsAlarmServiceOutputBuilder() .setNotificationsAlarmService(notificationAlarmServiceList).build()).buildFuture(); } + + @Override + public ListenableFuture> + getSupportedNotificationTypes(GetSupportedNotificationTypesInput input) { + return null; + } + + @Override + public ListenableFuture> + createNotificationSubscriptionService(CreateNotificationSubscriptionServiceInput input) { + try { + for (Uuid uuid:input.getSubscriptionFilter().getRequestedObjectIdentifier()) { + LOG.info("Adding T-API topic: {} to Kafka server", uuid.getValue()); + this.topicManager.addTapiTopic(uuid.getValue()); + } + + InstanceIdentifier notificationcontextIID = + InstanceIdentifier.builder(Context.class).augmentation(Context1.class) + .child(org.opendaylight.yang.gen.v1.urn + .onf.otcc.yang.tapi.notification.rev181210.context.NotificationContext.class) + .build(); + Optional notificationContextOptional + = this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, notificationcontextIID).get(); + if (notificationContextOptional.isEmpty()) { + LOG.error("Could not create TAPI notification subscription service"); + return RpcResultBuilder.failed() + .withError(ErrorType.RPC, "Could not read notification context") + .buildFuture(); + } + SubscriptionFilter subscriptionFilter = new SubscriptionFilterBuilder() + .setName(input.getSubscriptionFilter().getName()) + .setLocalId(input.getSubscriptionFilter().getLocalId()) + .setIncludeContent(input.getSubscriptionFilter().getIncludeContent()) + .setRequestedNotificationTypes(input.getSubscriptionFilter().getRequestedNotificationTypes()) + .setRequestedLayerProtocols(input.getSubscriptionFilter().getRequestedLayerProtocols()) + .setRequestedObjectIdentifier(input.getSubscriptionFilter().getRequestedObjectIdentifier()) + .setRequestedObjectTypes(input.getSubscriptionFilter().getRequestedObjectTypes()) + .build(); + SubscriptionService subscriptionService = new SubscriptionServiceBuilder() + .setSubscriptionFilter(subscriptionFilter) + .setSubscriptionState(input.getSubscriptionState()).build(); + Uuid notifSubscriptionUuid = new Uuid(UUID.randomUUID().toString()); + NotifSubscriptionKey notifSubscriptionKey = new NotifSubscriptionKey(notifSubscriptionUuid); + Set notificationTypes = (subscriptionFilter.getRequestedNotificationTypes() != null) + ? subscriptionFilter.getRequestedNotificationTypes() + : new HashSet<>(List.of(NotificationType.ALARMEVENT)); + Set objectTypes = (subscriptionFilter.getRequestedObjectTypes() != null) + ? subscriptionFilter.getRequestedObjectTypes() + : new HashSet<>(List.of(ObjectType.CONNECTIVITYSERVICE)); + NotifSubscription notifSubscription = new NotifSubscriptionBuilder() + .setSubscriptionState(subscriptionService.getSubscriptionState()) + .setSubscriptionFilter(subscriptionService.getSubscriptionFilter()) + .setUuid(notifSubscriptionUuid) + .setSupportedNotificationTypes(notificationTypes) + .setSupportedObjectTypes(objectTypes) + .setName(subscriptionService.getName()) + .build(); + NotificationContext notificationContext = notificationContextOptional.get(); + Map notifSubscriptions = new HashMap<>(); + if (notificationContext.getNotifSubscription() != null) { + notifSubscriptions.putAll(notificationContext.getNotifSubscription()); + } + notifSubscriptions.put(notifSubscriptionKey, notifSubscription); + NotificationContext notificationContext1 = new NotificationContextBuilder() + .setNotification(notificationContext.getNotification()) + .setNotifSubscription(notifSubscriptions) + .build(); + this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, notificationcontextIID, + notificationContext1); + this.networkTransactionService.commit().get(); + CreateNotificationSubscriptionServiceOutput serviceOutput = + new CreateNotificationSubscriptionServiceOutputBuilder() + .setSubscriptionService(subscriptionService) + .build(); + return RpcResultBuilder.success(serviceOutput).buildFuture(); + } catch (InterruptedException | ExecutionException e) { + LOG.error("Could not create TAPI notification subscription service"); + return RpcResultBuilder.failed() + .withError(ErrorType.RPC, "Could not read notification context").buildFuture(); + } + } + + @Override + public ListenableFuture> + updateNotificationSubscriptionService(UpdateNotificationSubscriptionServiceInput input) { + return null; + } + + @Override + public ListenableFuture> + deleteNotificationSubscriptionService(DeleteNotificationSubscriptionServiceInput input) { + return null; + } + + @Override + public ListenableFuture> + getNotificationSubscriptionServiceDetails(GetNotificationSubscriptionServiceDetailsInput input) { + return null; + } + + @Override + public ListenableFuture> + getNotificationSubscriptionServiceList(GetNotificationSubscriptionServiceListInput input) { + return null; + } + + @Override + public ListenableFuture> getNotificationList(GetNotificationListInput input) { + return null; + } } diff --git a/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsProvider.java b/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsProvider.java index 24c0383e4..7940b1bde 100644 --- a/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsProvider.java +++ b/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsProvider.java @@ -14,14 +14,16 @@ import org.opendaylight.mdsal.binding.api.NotificationService; import org.opendaylight.mdsal.binding.api.RpcProviderService; import org.opendaylight.mdsal.binding.dom.codec.spi.BindingDOMCodecServices; import org.opendaylight.transportpce.common.converter.JsonStringConverter; +import org.opendaylight.transportpce.common.network.NetworkTransactionService; import org.opendaylight.transportpce.nbinotifications.listener.NbiNotificationsListenerImpl; import org.opendaylight.transportpce.nbinotifications.producer.Publisher; -import org.opendaylight.transportpce.nbinotifications.serialization.NotificationAlarmServiceSerializer; -import org.opendaylight.transportpce.nbinotifications.serialization.NotificationServiceSerializer; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NbiNotificationsListener; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NbiNotificationsService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationAlarmService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationProcessService; +import org.opendaylight.transportpce.nbinotifications.utils.TopicManager; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NbiNotificationsListener; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NbiNotificationsService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationAlarmService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationProcessService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationTapiService; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.TapiNotificationService; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.concepts.ObjectRegistration; import org.slf4j.Logger; @@ -36,30 +38,39 @@ public class NbiNotificationsProvider { private final NotificationService notificationService; private final JsonStringConverter converterService; private final JsonStringConverter converterAlarmService; + private final JsonStringConverter converterTapiService; private final String subscriberServer; private ObjectRegistration rpcRegistration; private ListenerRegistration listenerRegistration; + private TopicManager topicManager = TopicManager.getInstance(); + private final NetworkTransactionService networkTransactionService; public NbiNotificationsProvider(List publishersService, List publishersAlarm, - String subscriberServer, String publisherServer, - RpcProviderService rpcProviderService, NotificationService notificationService, - BindingDOMCodecServices bindingDOMCodecServices) { + String subscriberServer, String publisherServer, + RpcProviderService rpcProviderService, NotificationService notificationService, + BindingDOMCodecServices bindingDOMCodecServices, + NetworkTransactionService networkTransactionService) { this.rpcService = rpcProviderService; this.notificationService = notificationService; + this.topicManager.setPublisherServer(publisherServer); converterService = new JsonStringConverter<>(bindingDOMCodecServices); + this.topicManager.setProcessConverter(converterService); for (String publisherService: publishersService) { LOG.info("Creating publisher for the following class {}", publisherService); - publishersServiceMap.put(publisherService, new Publisher<>(publisherService, publisherServer, - converterService, NotificationServiceSerializer.class)); + this.topicManager.addProcessTopic(publisherService); } converterAlarmService = new JsonStringConverter<>(bindingDOMCodecServices); + this.topicManager.setAlarmConverter(converterAlarmService); for (String publisherAlarm: publishersAlarm) { LOG.info("Creating publisher for the following class {}", publisherAlarm); - publishersAlarmMap.put(publisherAlarm, new Publisher<>(publisherAlarm, publisherServer, - converterAlarmService, NotificationAlarmServiceSerializer.class)); + this.topicManager.addAlarmTopic(publisherAlarm); } this.subscriberServer = subscriberServer; + converterTapiService = new JsonStringConverter<>(bindingDOMCodecServices); + LOG.info("baozhi tapi converter: {}", converterTapiService); + this.topicManager.setTapiConverter(converterTapiService); + this.networkTransactionService = networkTransactionService; } /** @@ -67,10 +78,15 @@ public class NbiNotificationsProvider { */ public void init() { LOG.info("NbiNotificationsProvider Session Initiated"); - rpcRegistration = rpcService.registerRpcImplementation(NbiNotificationsService.class, - new NbiNotificationsImpl(converterService, converterAlarmService, subscriberServer)); - listenerRegistration = notificationService.registerNotificationListener( - new NbiNotificationsListenerImpl(publishersServiceMap, publishersAlarmMap)); + NbiNotificationsImpl nbiImpl = new NbiNotificationsImpl(converterService, converterAlarmService, + subscriberServer, this.networkTransactionService, this.topicManager); + rpcRegistration = rpcService.registerRpcImplementation(NbiNotificationsService.class, nbiImpl); + rpcService.registerRpcImplementation(TapiNotificationService.class, nbiImpl); + NbiNotificationsListenerImpl nbiNotificationsListener = + new NbiNotificationsListenerImpl(this.topicManager.getProcessTopicMap(), + this.topicManager.getAlarmTopicMap(), this.topicManager.getTapiTopicMap()); + listenerRegistration = notificationService.registerNotificationListener(nbiNotificationsListener); + this.topicManager.setNbiNotificationsListener(nbiNotificationsListener); } /** diff --git a/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/listener/NbiNotificationsListenerImpl.java b/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/listener/NbiNotificationsListenerImpl.java index 37b4c0181..797fca719 100644 --- a/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/listener/NbiNotificationsListenerImpl.java +++ b/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/listener/NbiNotificationsListenerImpl.java @@ -7,27 +7,48 @@ */ package org.opendaylight.transportpce.nbinotifications.listener; +import java.util.HashMap; import java.util.Map; import org.opendaylight.transportpce.nbinotifications.producer.Publisher; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NbiNotificationsListener; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationAlarmService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationAlarmServiceBuilder; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationProcessService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationProcessServiceBuilder; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.PublishNotificationAlarmService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.PublishNotificationProcessService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NbiNotificationsListener; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationAlarmService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationAlarmServiceBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationProcessService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationProcessServiceBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationTapiService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationTapiServiceBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishNotificationAlarmService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishNotificationProcessService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishTapiNotificationService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.tapi.service.AdditionalInfo; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.tapi.service.AdditionalInfoBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.tapi.service.AdditionalInfoKey; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.tapi.service.AlarmInfoBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.tapi.service.ChangedAttributes; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.tapi.service.ChangedAttributesBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.tapi.service.ChangedAttributesKey; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.tapi.service.TargetObjectName; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.tapi.service.TargetObjectNameBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.tapi.service.TargetObjectNameKey; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.tapi.service.TcaInfoBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.Name; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.NameBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.NameKey; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class NbiNotificationsListenerImpl implements NbiNotificationsListener { private static final Logger LOG = LoggerFactory.getLogger(NbiNotificationsListenerImpl.class); - private final Map> publishersServiceMap; - private final Map> publishersAlarmMap; + private Map> publishersServiceMap; + private Map> publishersAlarmMap; + private Map> tapiPublisherMap; public NbiNotificationsListenerImpl(Map> publishersServiceMap, - Map> publishersAlarmMap) { + Map> publishersAlarmMap, + Map> tapiPublisherMap) { this.publishersServiceMap = publishersServiceMap; this.publishersAlarmMap = publishersAlarmMap; + this.tapiPublisherMap = tapiPublisherMap; } @Override @@ -67,4 +88,85 @@ public class NbiNotificationsListenerImpl implements NbiNotificationsListener { .setServiceName(notification.getServiceName()) .build(), "alarm" + notification.getConnectionType().getName()); } + + @Override + public void onPublishTapiNotificationService(PublishTapiNotificationService notification) { + LOG.info("Receiving request for publishing TAPI notification"); + String topic = notification.getTopic(); + if (!tapiPublisherMap.containsKey(topic)) { + LOG.error("Unknown topic {}", topic); + return; + } + Publisher publisher = tapiPublisherMap.get(topic); + publisher.sendEvent(new NotificationTapiServiceBuilder(transformTapiNotification(notification)) + .build(), topic); + } + + private NotificationTapiService transformTapiNotification(PublishTapiNotificationService notification) { + Map addInfoMap = new HashMap<>(); + if (notification.getAdditionalInfo() != null) { + for (org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.notification.AdditionalInfo + addInfo:notification.getAdditionalInfo().values()) { + AdditionalInfo transAddInfo = new AdditionalInfoBuilder(addInfo).build(); + addInfoMap.put(transAddInfo.key(), transAddInfo); + } + } + Map changedAttMap = new HashMap<>(); + if (notification.getChangedAttributes() != null) { + for (org.opendaylight.yang.gen.v1 + .urn.onf.otcc.yang.tapi.notification.rev181210.notification.ChangedAttributes + changedAtt:notification.getChangedAttributes().values()) { + ChangedAttributes transChangedAtt = new ChangedAttributesBuilder(changedAtt).build(); + changedAttMap.put(transChangedAtt.key(), transChangedAtt); + } + } + Map nameMap = new HashMap<>(); + if (notification.getName() != null) { + for (Name name:notification.getName().values()) { + Name transName = new NameBuilder(name).build(); + nameMap.put(transName.key(), transName); + } + } + Map targetObjNameMap = new HashMap<>(); + if (notification.getTargetObjectName() != null) { + for (org.opendaylight.yang.gen.v1 + .urn.onf.otcc.yang.tapi.notification.rev181210.notification.TargetObjectName + targetObjectName:notification.getTargetObjectName().values()) { + TargetObjectName transTargetObjName = new TargetObjectNameBuilder(targetObjectName).build(); + targetObjNameMap.put(transTargetObjName.key(), transTargetObjName); + } + } + LOG.info("Notification uuid = {}", notification.getUuid()); + return new NotificationTapiServiceBuilder() + .setAlarmInfo(notification.getAlarmInfo() == null ? null + : new AlarmInfoBuilder(notification.getAlarmInfo()).build()) + .setAdditionalText(notification.getAdditionalText()) + .setAdditionalInfo(addInfoMap) + .setNotificationType(notification.getNotificationType()) + .setChangedAttributes(changedAttMap) + .setEventTimeStamp(notification.getEventTimeStamp()) + .setLayerProtocolName(notification.getLayerProtocolName()) + .setName(nameMap) + .setSequenceNumber(notification.getSequenceNumber()) + .setSourceIndicator(notification.getSourceIndicator()) + .setTargetObjectIdentifier(notification.getTargetObjectIdentifier()) + .setTargetObjectName(targetObjNameMap) + .setTargetObjectType(notification.getTargetObjectType()) + .setTcaInfo(notification.getTcaInfo() == null ? null + : new TcaInfoBuilder(notification.getTcaInfo()).build()) + .setUuid(notification.getUuid()) + .build(); + } + + public void setPublishersServiceMap(Map> publishersServiceMap) { + this.publishersServiceMap = publishersServiceMap; + } + + public void setPublishersAlarmMap(Map> publishersAlarmMap) { + this.publishersAlarmMap = publishersAlarmMap; + } + + public void setTapiPublishersMap(Map> tapiPublishersMap) { + this.tapiPublisherMap = tapiPublishersMap; + } } diff --git a/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationAlarmServiceDeserializer.java b/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationAlarmServiceDeserializer.java index c08dbfb2f..4f0d19fca 100644 --- a/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationAlarmServiceDeserializer.java +++ b/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationAlarmServiceDeserializer.java @@ -11,9 +11,9 @@ import java.nio.charset.StandardCharsets; import java.util.Map; import org.apache.kafka.common.serialization.Deserializer; import org.opendaylight.transportpce.common.converter.JsonStringConverter; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationAlarmService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.get.notifications.alarm.service.output.NotificationsAlarmService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.get.notifications.alarm.service.output.NotificationsAlarmServiceBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationAlarmService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.get.notifications.alarm.service.output.NotificationsAlarmService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.get.notifications.alarm.service.output.NotificationsAlarmServiceBuilder; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactorySupplier; import org.slf4j.Logger; diff --git a/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationAlarmServiceSerializer.java b/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationAlarmServiceSerializer.java index 9d0371a12..9816d9f6f 100644 --- a/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationAlarmServiceSerializer.java +++ b/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationAlarmServiceSerializer.java @@ -12,7 +12,7 @@ import java.nio.charset.StandardCharsets; import java.util.Map; import org.apache.kafka.common.serialization.Serializer; import org.opendaylight.transportpce.common.converter.JsonStringConverter; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationAlarmService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationAlarmService; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactorySupplier; import org.slf4j.Logger; diff --git a/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationServiceDeserializer.java b/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationServiceDeserializer.java index eab7f3618..73e979310 100644 --- a/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationServiceDeserializer.java +++ b/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationServiceDeserializer.java @@ -11,9 +11,9 @@ import java.nio.charset.StandardCharsets; import java.util.Map; import org.apache.kafka.common.serialization.Deserializer; import org.opendaylight.transportpce.common.converter.JsonStringConverter; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationProcessService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.get.notifications.process.service.output.NotificationsProcessService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.get.notifications.process.service.output.NotificationsProcessServiceBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationProcessService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.get.notifications.process.service.output.NotificationsProcessService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.get.notifications.process.service.output.NotificationsProcessServiceBuilder; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactorySupplier; import org.slf4j.Logger; diff --git a/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationServiceSerializer.java b/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationServiceSerializer.java index dc2c3d775..8090ccd26 100644 --- a/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationServiceSerializer.java +++ b/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationServiceSerializer.java @@ -12,7 +12,7 @@ import java.nio.charset.StandardCharsets; import java.util.Map; import org.apache.kafka.common.serialization.Serializer; import org.opendaylight.transportpce.common.converter.JsonStringConverter; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationProcessService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationProcessService; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactorySupplier; import org.slf4j.Logger; diff --git a/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/serialization/TapiNotificationSerializer.java b/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/serialization/TapiNotificationSerializer.java new file mode 100644 index 000000000..7525fcfec --- /dev/null +++ b/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/serialization/TapiNotificationSerializer.java @@ -0,0 +1,56 @@ +/* + * Copyright © 2021 Nokia, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.transportpce.nbinotifications.serialization; + +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.Map; +import org.apache.kafka.common.serialization.Serializer; +import org.opendaylight.transportpce.common.converter.JsonStringConverter; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationTapiService; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactorySupplier; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class TapiNotificationSerializer implements Serializer { + private static final Logger LOG = LoggerFactory.getLogger(TapiNotificationSerializer.class); + private JsonStringConverter converter; + + @SuppressWarnings("unchecked") + @Override + public void configure(Map configs, boolean isKey) { + LOG.info("Deserializer configuration {}", configs); + if (configs.containsKey(ConfigConstants.CONVERTER) + && configs.get(ConfigConstants.CONVERTER) instanceof JsonStringConverter) { + converter = (JsonStringConverter) configs.get(ConfigConstants.CONVERTER); + } + } + + @Override + public byte[] serialize(String topic, NotificationTapiService data) { + if (converter == null) { + throw new IllegalArgumentException( + "Converter should be configured through configure method of serializer"); + } + if (data == null) { + LOG.error("Notification data is empty"); + return new byte[0]; + } + try { + InstanceIdentifier iid = InstanceIdentifier.builder(NotificationTapiService.class) + .build(); + String serialized = converter.createJsonStringFromDataObject(iid, data, JSONCodecFactorySupplier.RFC7951); + LOG.info("Serialized event {}", serialized); + return serialized.getBytes(StandardCharsets.UTF_8); + } catch (IOException e) { + LOG.error("Event couldnt be serialized", e); + return new byte[0]; + } + } +} diff --git a/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/utils/TopicManager.java b/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/utils/TopicManager.java new file mode 100644 index 000000000..6960ab58a --- /dev/null +++ b/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/utils/TopicManager.java @@ -0,0 +1,109 @@ +/* + * Copyright © 2021 Nokia, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.transportpce.nbinotifications.utils; + +import java.util.HashMap; +import java.util.Map; +import org.opendaylight.transportpce.common.converter.JsonStringConverter; +import org.opendaylight.transportpce.nbinotifications.listener.NbiNotificationsListenerImpl; +import org.opendaylight.transportpce.nbinotifications.producer.Publisher; +import org.opendaylight.transportpce.nbinotifications.serialization.NotificationAlarmServiceSerializer; +import org.opendaylight.transportpce.nbinotifications.serialization.NotificationServiceSerializer; +import org.opendaylight.transportpce.nbinotifications.serialization.TapiNotificationSerializer; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationAlarmService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationProcessService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationTapiService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public final class TopicManager { + + private static final Logger LOG = LoggerFactory.getLogger(TopicManager.class); + private static TopicManager instance = new TopicManager(); + + private Map> tapiPublisherMap = new HashMap<>(); + private String publisherServer; + private JsonStringConverter tapiConverter; + private NbiNotificationsListenerImpl nbiNotificationsListener; + private Map> alarmPublisherMap = new HashMap<>(); + private Map> processPublisherMap = new HashMap<>(); + private JsonStringConverter processConverter; + private JsonStringConverter alarmConverter; + private int calledSetConverter = 0; + + private TopicManager() { + } + + public static TopicManager getInstance() { + return instance; + } + + public void setNbiNotificationsListener(NbiNotificationsListenerImpl nbiNotificationsListener) { + this.nbiNotificationsListener = nbiNotificationsListener; + } + + public void setProcessConverter(JsonStringConverter processConverter) { + this.processConverter = processConverter; + } + + public void setAlarmConverter(JsonStringConverter alarmConverter) { + this.alarmConverter = alarmConverter; + } + + public void setTapiConverter(JsonStringConverter tapiConverter) { + this.tapiConverter = tapiConverter; + this.calledSetConverter++; + } + + public void setPublisherServer(String publisherServer) { + this.publisherServer = publisherServer; + } + + public void addProcessTopic(String topic) { + LOG.info("Adding process topic: {}", topic); + processPublisherMap.put(topic, new Publisher<>(topic, publisherServer, processConverter, + NotificationServiceSerializer.class)); + if (this.nbiNotificationsListener != null) { + this.nbiNotificationsListener.setPublishersServiceMap(processPublisherMap); + } + } + + public void addAlarmTopic(String topic) { + LOG.info("Adding alarm topic: {}", topic); + alarmPublisherMap.put(topic, new Publisher<>(topic, publisherServer, alarmConverter, + NotificationAlarmServiceSerializer.class)); + if (this.nbiNotificationsListener != null) { + this.nbiNotificationsListener.setPublishersAlarmMap(alarmPublisherMap); + } + } + + public void addTapiTopic(String topic) { + if (tapiPublisherMap.containsKey(topic)) { + LOG.info("Tapi topic: {} already exists", topic); + return; + } + LOG.info("Adding new tapi topic: {}", topic); + tapiPublisherMap.put(topic, new Publisher<>(topic, publisherServer, tapiConverter, + TapiNotificationSerializer.class)); + if (this.nbiNotificationsListener != null) { + this.nbiNotificationsListener.setTapiPublishersMap(tapiPublisherMap); + } + } + + public Map> getTapiTopicMap() { + return this.tapiPublisherMap; + } + + public Map> getAlarmTopicMap() { + return this.alarmPublisherMap; + } + + public Map> getProcessTopicMap() { + return this.processPublisherMap; + } +} diff --git a/nbinotifications/src/main/resources/OSGI-INF/blueprint/nobinotifications-blueprint.xml b/nbinotifications/src/main/resources/OSGI-INF/blueprint/nobinotifications-blueprint.xml index d938b9d28..39bb0c041 100644 --- a/nbinotifications/src/main/resources/OSGI-INF/blueprint/nobinotifications-blueprint.xml +++ b/nbinotifications/src/main/resources/OSGI-INF/blueprint/nobinotifications-blueprint.xml @@ -15,6 +15,8 @@ xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0" + @@ -36,5 +38,6 @@ xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0" + diff --git a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/consumer/SubscriberTest.java b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/consumer/SubscriberTest.java index 7e5fcf615..c32142f23 100644 --- a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/consumer/SubscriberTest.java +++ b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/consumer/SubscriberTest.java @@ -22,10 +22,10 @@ import org.junit.Before; import org.junit.Test; import org.opendaylight.transportpce.nbinotifications.utils.NotificationServiceDataUtils; import org.opendaylight.transportpce.test.AbstractTest; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationAlarmService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationProcessService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.get.notifications.alarm.service.output.NotificationsAlarmService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.get.notifications.process.service.output.NotificationsProcessService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationAlarmService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationProcessService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.get.notifications.alarm.service.output.NotificationsAlarmService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.get.notifications.process.service.output.NotificationsProcessService; public class SubscriberTest extends AbstractTest { private static final String TOPIC = "topic"; diff --git a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsImplTest.java b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsImplTest.java index 825193f01..3ba525824 100644 --- a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsImplTest.java +++ b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsImplTest.java @@ -13,27 +13,39 @@ import com.google.common.util.concurrent.ListenableFuture; import java.util.concurrent.ExecutionException; import org.junit.Before; import org.junit.Test; +import org.mockito.Mock; import org.opendaylight.transportpce.common.converter.JsonStringConverter; +import org.opendaylight.transportpce.common.network.NetworkTransactionImpl; +import org.opendaylight.transportpce.common.network.NetworkTransactionService; +import org.opendaylight.transportpce.common.network.RequestProcessor; +import org.opendaylight.transportpce.nbinotifications.utils.TopicManager; import org.opendaylight.transportpce.test.AbstractTest; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.ConnectionType; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.GetNotificationsAlarmServiceInputBuilder; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.GetNotificationsAlarmServiceOutput; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.GetNotificationsProcessServiceInputBuilder; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.GetNotificationsProcessServiceOutput; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationAlarmService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationProcessService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.GetNotificationsAlarmServiceInputBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.GetNotificationsAlarmServiceOutput; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.GetNotificationsProcessServiceInputBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.GetNotificationsProcessServiceOutput; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationAlarmService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationProcessService; import org.opendaylight.yangtools.yang.common.RpcResult; public class NbiNotificationsImplTest extends AbstractTest { private NbiNotificationsImpl nbiNotificationsImpl; + public static NetworkTransactionService networkTransactionService; + + @Mock + private TopicManager topicManager; @Before public void setUp() { + networkTransactionService = new NetworkTransactionImpl( + new RequestProcessor(getDataStoreContextUtil().getDataBroker())); JsonStringConverter converter = new JsonStringConverter<>( getDataStoreContextUtil().getBindingDOMCodecServices()); JsonStringConverter converterAlarm = new JsonStringConverter<>( getDataStoreContextUtil().getBindingDOMCodecServices()); - nbiNotificationsImpl = new NbiNotificationsImpl(converter, converterAlarm,"localhost:8080"); + nbiNotificationsImpl = new NbiNotificationsImpl(converter, converterAlarm,"localhost:8080", + networkTransactionService, topicManager); } @Test diff --git a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsProviderTest.java b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsProviderTest.java index 2b917aab0..93827286f 100644 --- a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsProviderTest.java +++ b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsProviderTest.java @@ -18,10 +18,14 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.opendaylight.mdsal.binding.api.NotificationService; import org.opendaylight.mdsal.binding.api.RpcProviderService; +import org.opendaylight.transportpce.common.network.NetworkTransactionImpl; +import org.opendaylight.transportpce.common.network.NetworkTransactionService; +import org.opendaylight.transportpce.common.network.RequestProcessor; import org.opendaylight.transportpce.nbinotifications.listener.NbiNotificationsListenerImpl; import org.opendaylight.transportpce.test.AbstractTest; public class NbiNotificationsProviderTest extends AbstractTest { + public static NetworkTransactionService networkTransactionService; @Mock RpcProviderService rpcProviderRegistry; @@ -37,12 +41,14 @@ public class NbiNotificationsProviderTest extends AbstractTest { @Test public void initTest() { + networkTransactionService = new NetworkTransactionImpl( + new RequestProcessor(getDataStoreContextUtil().getDataBroker())); NbiNotificationsProvider provider = new NbiNotificationsProvider( Arrays.asList("topic1", "topic2"), Arrays.asList("topic1", "topic2"), "localhost:8080", "localhost:8080", rpcProviderRegistry, notificationService, - getDataStoreContextUtil().getBindingDOMCodecServices()); + getDataStoreContextUtil().getBindingDOMCodecServices(), networkTransactionService); provider.init(); - verify(rpcProviderRegistry, times(1)) + verify(rpcProviderRegistry, times(2)) .registerRpcImplementation(any(), any(NbiNotificationsImpl.class)); verify(notificationService, times(1)) .registerNotificationListener(any(NbiNotificationsListenerImpl.class)); diff --git a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/listener/NbiNotificationsListenerImplTest.java b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/listener/NbiNotificationsListenerImplTest.java index c0fa4d1ba..1743723e6 100644 --- a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/listener/NbiNotificationsListenerImplTest.java +++ b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/listener/NbiNotificationsListenerImplTest.java @@ -12,6 +12,7 @@ import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; +import java.util.HashMap; import java.util.Map; import org.junit.Before; import org.junit.Test; @@ -21,12 +22,12 @@ import org.opendaylight.transportpce.nbinotifications.producer.Publisher; import org.opendaylight.transportpce.test.AbstractTest; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.ConnectionType; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationAlarmService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationProcessService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.PublishNotificationAlarmService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.PublishNotificationAlarmServiceBuilder; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.PublishNotificationProcessService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.PublishNotificationProcessServiceBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationAlarmService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationProcessService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishNotificationAlarmService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishNotificationAlarmServiceBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishNotificationProcessService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishNotificationProcessServiceBuilder; public class NbiNotificationsListenerImplTest extends AbstractTest { @Mock @@ -42,7 +43,7 @@ public class NbiNotificationsListenerImplTest extends AbstractTest { @Test public void onPublishNotificationServiceTest() { NbiNotificationsListenerImpl listener = new NbiNotificationsListenerImpl(Map.of("test", publisherService), - Map.of("test", publisherAlarm)); + Map.of("test", publisherAlarm), new HashMap<>()); PublishNotificationProcessService notification = new PublishNotificationProcessServiceBuilder() .setPublisherName("test") .setCommonId("commonId") @@ -58,7 +59,7 @@ public class NbiNotificationsListenerImplTest extends AbstractTest { @Test public void onPublishNotificationServiceWrongPublisherTest() { NbiNotificationsListenerImpl listener = new NbiNotificationsListenerImpl(Map.of("test", publisherService), - Map.of("test", publisherAlarm)); + Map.of("test", publisherAlarm), new HashMap<>()); PublishNotificationProcessService notification = new PublishNotificationProcessServiceBuilder() .setPublisherName("wrongPublisher") .setCommonId("commonId") @@ -74,7 +75,7 @@ public class NbiNotificationsListenerImplTest extends AbstractTest { @Test public void onPublishNotificationAlarmServiceTest() { NbiNotificationsListenerImpl listener = new NbiNotificationsListenerImpl(Map.of("test", publisherService), - Map.of("test", publisherAlarm)); + Map.of("test", publisherAlarm), new HashMap<>()); PublishNotificationAlarmService notification = new PublishNotificationAlarmServiceBuilder() .setPublisherName("test") .setConnectionType(ConnectionType.Service) @@ -89,7 +90,7 @@ public class NbiNotificationsListenerImplTest extends AbstractTest { @Test public void onPublishNotificationAlarmServiceWrongPublisherTest() { NbiNotificationsListenerImpl listener = new NbiNotificationsListenerImpl(Map.of("test", publisherService), - Map.of("test", publisherAlarm)); + Map.of("test", publisherAlarm), new HashMap<>()); PublishNotificationAlarmService notification = new PublishNotificationAlarmServiceBuilder() .setPublisherName("wrongPublisher") .setConnectionType(ConnectionType.Service) diff --git a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/producer/PublisherTest.java b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/producer/PublisherTest.java index 4b9e160f5..1d988fc0c 100644 --- a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/producer/PublisherTest.java +++ b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/producer/PublisherTest.java @@ -22,8 +22,8 @@ import org.opendaylight.transportpce.nbinotifications.serialization.ConfigConsta import org.opendaylight.transportpce.nbinotifications.serialization.NotificationAlarmServiceSerializer; import org.opendaylight.transportpce.nbinotifications.serialization.NotificationServiceSerializer; import org.opendaylight.transportpce.test.AbstractTest; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationAlarmService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationProcessService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationAlarmService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationProcessService; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactorySupplier; diff --git a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationAlarmServiceDeserializerTest.java b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationAlarmServiceDeserializerTest.java index b0d156a2a..d1c5c39a4 100755 --- a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationAlarmServiceDeserializerTest.java +++ b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationAlarmServiceDeserializerTest.java @@ -16,8 +16,8 @@ import java.util.Map; import org.junit.Test; import org.opendaylight.transportpce.common.converter.JsonStringConverter; import org.opendaylight.transportpce.test.AbstractTest; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationAlarmService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.get.notifications.alarm.service.output.NotificationsAlarmService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationAlarmService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.get.notifications.alarm.service.output.NotificationsAlarmService; public class NotificationAlarmServiceDeserializerTest extends AbstractTest { diff --git a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationAlarmServiceSerializerTest.java b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationAlarmServiceSerializerTest.java index 605c85158..b850f5b79 100755 --- a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationAlarmServiceSerializerTest.java +++ b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationAlarmServiceSerializerTest.java @@ -20,7 +20,7 @@ import java.util.Map; import org.junit.Test; import org.opendaylight.transportpce.common.converter.JsonStringConverter; import org.opendaylight.transportpce.test.AbstractTest; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationAlarmService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationAlarmService; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactorySupplier; diff --git a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationServiceDeserializerTest.java b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationServiceDeserializerTest.java index 12f7a80f3..0c47b49bc 100644 --- a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationServiceDeserializerTest.java +++ b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationServiceDeserializerTest.java @@ -16,8 +16,8 @@ import java.util.Map; import org.junit.Test; import org.opendaylight.transportpce.common.converter.JsonStringConverter; import org.opendaylight.transportpce.test.AbstractTest; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationProcessService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.get.notifications.process.service.output.NotificationsProcessService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationProcessService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.get.notifications.process.service.output.NotificationsProcessService; public class NotificationServiceDeserializerTest extends AbstractTest { diff --git a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationServiceSerializerTest.java b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationServiceSerializerTest.java index 4a4868bbd..51d83fa14 100644 --- a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationServiceSerializerTest.java +++ b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationServiceSerializerTest.java @@ -20,7 +20,7 @@ import java.util.Map; import org.junit.Test; import org.opendaylight.transportpce.common.converter.JsonStringConverter; import org.opendaylight.transportpce.test.AbstractTest; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationProcessService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationProcessService; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactorySupplier; diff --git a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/utils/NotificationServiceDataUtils.java b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/utils/NotificationServiceDataUtils.java index de4cb5f01..ea8c5496a 100644 --- a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/utils/NotificationServiceDataUtils.java +++ b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/utils/NotificationServiceDataUtils.java @@ -20,14 +20,14 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev2 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.service.port.PortBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.format.rev191129.ServiceFormat; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationProcessService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationProcessServiceBuilder; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.get.notifications.alarm.service.output.NotificationsAlarmService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.get.notifications.alarm.service.output.NotificationsAlarmServiceBuilder; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.get.notifications.process.service.output.NotificationsProcessService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.get.notifications.process.service.output.NotificationsProcessServiceBuilder; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.notification.process.service.ServiceAEndBuilder; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.notification.process.service.ServiceZEndBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationProcessService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationProcessServiceBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.get.notifications.alarm.service.output.NotificationsAlarmService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.get.notifications.alarm.service.output.NotificationsAlarmServiceBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.get.notifications.process.service.output.NotificationsProcessService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.get.notifications.process.service.output.NotificationsProcessServiceBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.process.service.ServiceAEndBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.process.service.ServiceZEndBuilder; import org.opendaylight.yangtools.yang.common.Uint32; import org.opendaylight.yangtools.yang.common.Uint8; diff --git a/nbinotifications/src/test/resources/expected_event.json b/nbinotifications/src/test/resources/expected_event.json index 47209dd7d..4e277d8a5 100644 --- a/nbinotifications/src/test/resources/expected_event.json +++ b/nbinotifications/src/test/resources/expected_event.json @@ -1,104 +1,104 @@ { "nbi-notifications:notification-process-service": { - "common-id": "commond-id", - "message": "message", - "operational-state": "inService", + "connection-type": "service", "service-z-end": { - "node-id": "XPONDER-1-2", - "service-rate": 1, - "clli": "clli", - "is-split-lambda": false, - "service-format": "OC", "tx-direction": [ { "index": 0, + "lgx": { + "lgx-port-rack": "lgx port rack", + "lgx-device-name": "lgx device name", + "lgx-port-shelf": "lgx port shelf", + "lgx-port-name": "lgx port name" + }, "port": { - "port-name": "port name", - "port-slot": "port slot", + "port-type": "port type", "port-sub-slot": "port subslot", + "port-name": "port name", + "port-rack": "port rack", "port-device-name": "device name", - "port-shelf": "port shelf", - "port-type": "port type", - "port-rack": "port rack" - }, - "lgx": { - "lgx-port-shelf": "lgx port shelf", - "lgx-port-rack": "lgx port rack", - "lgx-port-name": "lgx port name", - "lgx-device-name": "lgx device name" + "port-slot": "port slot", + "port-shelf": "port shelf" } } ], + "node-id": "XPONDER-1-2", + "service-format": "OC", + "service-rate": 1, "rx-direction": [ { "index": 0, + "lgx": { + "lgx-port-rack": "lgx port rack", + "lgx-device-name": "lgx device name", + "lgx-port-shelf": "lgx port shelf", + "lgx-port-name": "lgx port name" + }, "port": { - "port-name": "port name", - "port-slot": "port slot", + "port-type": "port type", "port-sub-slot": "port subslot", + "port-name": "port name", + "port-rack": "port rack", "port-device-name": "device name", - "port-shelf": "port shelf", - "port-type": "port type", - "port-rack": "port rack" - }, - "lgx": { - "lgx-port-shelf": "lgx port shelf", - "lgx-port-rack": "lgx port rack", - "lgx-port-name": "lgx port name", - "lgx-device-name": "lgx device name" + "port-slot": "port slot", + "port-shelf": "port shelf" } } - ] + ], + "is-split-lambda": false, + "clli": "clli" }, - "service-name": "service1", - "connection-type": "service", + "message": "message", "service-a-end": { - "node-id": "XPONDER-1-2", - "service-rate": 1, - "clli": "clli", - "is-split-lambda": false, - "service-format": "OC", "tx-direction": [ { "index": 0, + "lgx": { + "lgx-port-rack": "lgx port rack", + "lgx-device-name": "lgx device name", + "lgx-port-shelf": "lgx port shelf", + "lgx-port-name": "lgx port name" + }, "port": { - "port-name": "port name", - "port-slot": "port slot", + "port-type": "port type", "port-sub-slot": "port subslot", + "port-name": "port name", + "port-rack": "port rack", "port-device-name": "device name", - "port-shelf": "port shelf", - "port-type": "port type", - "port-rack": "port rack" - }, - "lgx": { - "lgx-port-shelf": "lgx port shelf", - "lgx-port-rack": "lgx port rack", - "lgx-port-name": "lgx port name", - "lgx-device-name": "lgx device name" + "port-slot": "port slot", + "port-shelf": "port shelf" } } ], + "node-id": "XPONDER-1-2", + "service-format": "OC", + "service-rate": 1, "rx-direction": [ { "index": 0, + "lgx": { + "lgx-port-rack": "lgx port rack", + "lgx-device-name": "lgx device name", + "lgx-port-shelf": "lgx port shelf", + "lgx-port-name": "lgx port name" + }, "port": { - "port-name": "port name", - "port-slot": "port slot", + "port-type": "port type", "port-sub-slot": "port subslot", + "port-name": "port name", + "port-rack": "port rack", "port-device-name": "device name", - "port-shelf": "port shelf", - "port-type": "port type", - "port-rack": "port rack" - }, - "lgx": { - "lgx-port-shelf": "lgx port shelf", - "lgx-port-rack": "lgx port rack", - "lgx-port-name": "lgx port name", - "lgx-device-name": "lgx device name" + "port-slot": "port slot", + "port-shelf": "port shelf" } } - ] + ], + "is-split-lambda": false, + "clli": "clli" }, - "response-failed": "" + "operational-state": "inService", + "common-id": "commond-id", + "response-failed": "", + "service-name": "service1" } -} +} \ No newline at end of file diff --git a/nbinotifications/src/test/resources/expected_event_alarm_service.json b/nbinotifications/src/test/resources/expected_event_alarm_service.json index 68480455f..4b71fd0d8 100755 --- a/nbinotifications/src/test/resources/expected_event_alarm_service.json +++ b/nbinotifications/src/test/resources/expected_event_alarm_service.json @@ -1,8 +1,8 @@ { "nbi-notifications:notification-alarm-service": { + "connection-type": "service", "message": "The service is now inService", - "operational-state": "inService", "service-name": "service1", - "connection-type": "service" + "operational-state": "inService" } } \ No newline at end of file diff --git a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImpl.java b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImpl.java index 109531e34..37e7c1a22 100644 --- a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImpl.java +++ b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImpl.java @@ -105,10 +105,10 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempSer import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.delete.input.ServiceDeleteReqInfo.TailRetention; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.delete.input.ServiceDeleteReqInfoBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.list.Services; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.PublishNotificationProcessService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.PublishNotificationProcessServiceBuilder; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.notification.process.service.ServiceAEndBuilder; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.notification.process.service.ServiceZEndBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishNotificationProcessService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishNotificationProcessServiceBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.process.service.ServiceAEndBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.process.service.ServiceZEndBuilder; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; import org.opendaylight.yangtools.yang.common.RpcResult; import org.slf4j.Logger; diff --git a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/PceListenerImpl.java b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/PceListenerImpl.java index 74d659a24..1fd4cbb39 100644 --- a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/PceListenerImpl.java +++ b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/PceListenerImpl.java @@ -26,10 +26,10 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.list.Services; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.RpcStatusEx; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.response.parameters.sp.ResponseParametersBuilder; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.PublishNotificationProcessService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.PublishNotificationProcessServiceBuilder; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.notification.process.service.ServiceAEndBuilder; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.notification.process.service.ServiceZEndBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishNotificationProcessService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishNotificationProcessServiceBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.process.service.ServiceAEndBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.process.service.ServiceZEndBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/RendererListenerImpl.java b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/RendererListenerImpl.java index a30c7d237..9eb124cad 100644 --- a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/RendererListenerImpl.java +++ b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/RendererListenerImpl.java @@ -29,10 +29,10 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191 import org.opendaylight.yang.gen.v1.http.org.openroadm.equipment.states.types.rev191129.AdminStates; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.list.Services; import org.opendaylight.yang.gen.v1.http.transportpce.topology.rev220123.OtnLinkType; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.PublishNotificationProcessService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.PublishNotificationProcessServiceBuilder; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.notification.process.service.ServiceAEndBuilder; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.notification.process.service.ServiceZEndBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishNotificationProcessService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishNotificationProcessServiceBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.process.service.ServiceAEndBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.process.service.ServiceZEndBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/ServiceListener.java b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/ServiceListener.java index 737020108..64d46b4cf 100644 --- a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/ServiceListener.java +++ b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/ServiceListener.java @@ -39,8 +39,8 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.delete.input.ServiceDeleteReqInfo; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.delete.input.ServiceDeleteReqInfoBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.list.Services; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.PublishNotificationAlarmService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.PublishNotificationAlarmServiceBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishNotificationAlarmService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishNotificationAlarmServiceBuilder; import org.opendaylight.yangtools.yang.common.RpcResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/listeners/ServiceListenerTest.java b/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/listeners/ServiceListenerTest.java index 368009f6d..b8d5290f0 100755 --- a/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/listeners/ServiceListenerTest.java +++ b/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/listeners/ServiceListenerTest.java @@ -57,8 +57,8 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.Service import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteOutputBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.list.Services; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.list.ServicesBuilder; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.PublishNotificationAlarmService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.PublishNotificationAlarmServiceBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishNotificationAlarmService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishNotificationAlarmServiceBuilder; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.opendaylight.yangtools.yang.common.Uint32; import org.opendaylight.yangtools.yang.common.Uint8; diff --git a/tapi/src/main/java/org/opendaylight/transportpce/tapi/impl/TapiProvider.java b/tapi/src/main/java/org/opendaylight/transportpce/tapi/impl/TapiProvider.java index b68f43ccf..0f8799875 100644 --- a/tapi/src/main/java/org/opendaylight/transportpce/tapi/impl/TapiProvider.java +++ b/tapi/src/main/java/org/opendaylight/transportpce/tapi/impl/TapiProvider.java @@ -99,13 +99,13 @@ public class TapiProvider { private TapiNetworkModelListenerImpl tapiNetworkModelListenerImpl; public TapiProvider(DataBroker dataBroker, RpcProviderService rpcProviderService, - OrgOpenroadmServiceService serviceHandler, ServiceDataStoreOperations serviceDataStoreOperations, + OrgOpenroadmServiceService serviceHandler,ServiceDataStoreOperations serviceDataStoreOperations, TapiListener tapiListener, NetworkTransactionService networkTransactionService, TapiNetconfTopologyListener topologyListener, TapiPortMappingListener tapiPortMappingListener, TransportpceTapinetworkutilsService tapiNetworkUtils, TapiPceListenerImpl pceListenerImpl, TapiRendererListenerImpl rendererListenerImpl, TapiServiceHandlerListenerImpl serviceHandlerListenerImpl, NotificationService notificationService, TapiOrLinkListener orLinkListener, - TapiNetworkModelListenerImpl tapiNetworkModelListenerImpl) { + TapiNetworkModelListenerImpl tapiNetworkModelListenerImpl) { this.dataBroker = dataBroker; this.rpcProviderService = rpcProviderService; this.serviceHandler = serviceHandler; @@ -121,6 +121,7 @@ public class TapiProvider { this.notificationService = notificationService; this.orLinkListener = orLinkListener; this.tapiNetworkModelListenerImpl = tapiNetworkModelListenerImpl; + //this.notificationPublishService = notificationPublishService; } /** @@ -142,6 +143,7 @@ public class TapiProvider { TapiConnectivityImpl tapi = new TapiConnectivityImpl(this.serviceHandler, tapiContext, connectivityUtils, pceListenerImpl, rendererListenerImpl); TapiTopologyImpl topo = new TapiTopologyImpl(this.dataBroker, tapiContext, topologyUtils, tapiLink); + rpcRegistration = rpcProviderService.registerRpcImplementation(TapiConnectivityService.class, tapi); rpcProviderService.registerRpcImplementation(TapiTopologyService.class, topo); rpcProviderService.registerRpcImplementation(TapiCommonService.class, topo); diff --git a/tapi/src/main/java/org/opendaylight/transportpce/tapi/listeners/TapiNetworkModelListenerImpl.java b/tapi/src/main/java/org/opendaylight/transportpce/tapi/listeners/TapiNetworkModelListenerImpl.java index 995fee80c..2d92919b9 100644 --- a/tapi/src/main/java/org/opendaylight/transportpce/tapi/listeners/TapiNetworkModelListenerImpl.java +++ b/tapi/src/main/java/org/opendaylight/transportpce/tapi/listeners/TapiNetworkModelListenerImpl.java @@ -8,6 +8,9 @@ package org.opendaylight.transportpce.tapi.listeners; import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -19,15 +22,21 @@ import java.util.Optional; import java.util.UUID; import java.util.concurrent.ExecutionException; import java.util.stream.Collectors; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.transportpce.common.network.NetworkTransactionService; import org.opendaylight.transportpce.tapi.TapiStringConstants; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishTapiNotificationService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishTapiNotificationServiceBuilder; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.AdministrativeState; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.Context; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.DateAndTime; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.LayerProtocolName; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.OperationalState; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.Uuid; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.Name; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.NameKey; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.OwnedNodeEdgePoint1; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connection.LowerConnection; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection; @@ -42,6 +51,12 @@ import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev18121 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.NotificationType; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.ObjectType; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.TapiNotificationListener; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.notification.ChangedAttributes; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.notification.ChangedAttributesBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.notification.ChangedAttributesKey; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.notification.TargetObjectName; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.notification.TargetObjectNameBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.notification.TargetObjectNameKey; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.Context1; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.NodeEdgePointRef; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.context.TopologyContext; @@ -64,12 +79,14 @@ public class TapiNetworkModelListenerImpl implements TapiNotificationListener { private final Uuid tapiTopoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER .getBytes(StandardCharsets.UTF_8)).toString()); private final List orderedServiceLayerList; + private final NotificationPublishService notificationPublishService; - - public TapiNetworkModelListenerImpl(NetworkTransactionService networkTransactionService) { + public TapiNetworkModelListenerImpl(NetworkTransactionService networkTransactionService, + NotificationPublishService notificationPublishService) { this.networkTransactionService = networkTransactionService; this.orderedServiceLayerList = List.of(LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.ODU, LayerProtocolName.DSR, LayerProtocolName.ETH); + this.notificationPublishService = notificationPublishService; } @Override @@ -88,7 +105,64 @@ public class TapiNetworkModelListenerImpl implements TapiNotificationListener { .map(NameAndValueChange::getNewValue) .collect(Collectors.toList())); updateConnectivityServices(); - // todo create NotificationPublishSerivce (Tapi) object + send Notification + // todo set attributes + for (ConnectivityService connService : this.connectivityServiceChanges) { + sendNbiNotification(createNbiNotification(connService)); + } + } + } + + private PublishTapiNotificationService createNbiNotification(ConnectivityService connService) { + if (connService == null) { + LOG.error("ConnService is null"); + return null; + } + Map changedStates = new HashMap<>(); + changedStates.put(new ChangedAttributesKey("administrativeState"), + new ChangedAttributesBuilder() + .setNewValue(connService.getAdministrativeState().getName()) + .setOldValue(connService.getAdministrativeState().equals(AdministrativeState.UNLOCKED) + ? AdministrativeState.LOCKED.getName() : AdministrativeState.UNLOCKED.getName()) + .setValueName("administrativeState").build()); + changedStates.put(new ChangedAttributesKey("operationalState"), + new ChangedAttributesBuilder() + .setNewValue(connService.getOperationalState().getName()) + .setOldValue(connService.getOperationalState().equals(OperationalState.ENABLED) + ? OperationalState.DISABLED.getName() : OperationalState.ENABLED.getName()) + .setValueName("operationalState").build()); + DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssxxx"); + OffsetDateTime offsetDateTime = OffsetDateTime.now(ZoneOffset.UTC); + DateAndTime datetime = new DateAndTime(dtf.format(offsetDateTime)); + Map targetObjectNames = new HashMap<>(); + if (connService.getName() != null) { + for (Map.Entry entry : connService.getName().entrySet()) { + targetObjectNames.put(new TargetObjectNameKey(entry.getKey().getValueName()), + new TargetObjectNameBuilder() + .setValueName(entry.getValue().getValueName()) + .setValue(entry.getValue().getValue()) + .build()); + } + } + + return new PublishTapiNotificationServiceBuilder() + .setUuid(new Uuid(UUID.randomUUID().toString())) + .setTopic(connService.getUuid().getValue()) + .setTargetObjectIdentifier(connService.getUuid()) + .setNotificationType(NotificationType.ATTRIBUTEVALUECHANGE) + .setChangedAttributes(changedStates) + .setEventTimeStamp(datetime) + .setTargetObjectName(targetObjectNames) + .setTargetObjectType(ObjectType.CONNECTIVITYSERVICE) + .setLayerProtocolName(connService.getServiceLayer()) + .build(); + } + + private void sendNbiNotification(PublishTapiNotificationService service) { + try { + this.notificationPublishService.putNotification(service); + } catch (InterruptedException e) { + LOG.warn("Cannot send notification to nbi", e); + Thread.currentThread().interrupt(); } } @@ -119,8 +193,8 @@ public class TapiNetworkModelListenerImpl implements TapiNotificationListener { OperationalState operState = (OperationalState) states.get(connService.getUuid())[1]; InstanceIdentifier connServIID = InstanceIdentifier - .builder(Context.class).augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi - .connectivity.rev181210.Context1.class) + .builder(Context.class).augmentation(org.opendaylight.yang.gen.v1 + .urn.onf.otcc.yang.tapi.connectivity.rev181210.Context1.class) .child(ConnectivityContext.class) .child(ConnectivityService.class, new ConnectivityServiceKey(connService.getUuid())) .build(); diff --git a/tapi/src/main/java/org/opendaylight/transportpce/tapi/listeners/TapiRendererListenerImpl.java b/tapi/src/main/java/org/opendaylight/transportpce/tapi/listeners/TapiRendererListenerImpl.java index 24d5e3097..0080c77c1 100644 --- a/tapi/src/main/java/org/opendaylight/transportpce/tapi/listeners/TapiRendererListenerImpl.java +++ b/tapi/src/main/java/org/opendaylight/transportpce/tapi/listeners/TapiRendererListenerImpl.java @@ -8,22 +8,33 @@ package org.opendaylight.transportpce.tapi.listeners; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.time.format.DateTimeFormatter; +import java.util.HashMap; +import java.util.Map; import java.util.Optional; import java.util.UUID; import java.util.concurrent.ExecutionException; import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.transportpce.common.network.NetworkTransactionImpl; import org.opendaylight.transportpce.common.network.NetworkTransactionService; import org.opendaylight.transportpce.common.network.RequestProcessor; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.RendererRpcResultSp; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.TransportpceRendererListener; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishTapiNotificationService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishTapiNotificationServiceBuilder; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.AdministrativeState; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.Context; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.DateAndTime; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.LifecycleState; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.OperationalState; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.Uuid; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.Name; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.NameKey; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.Context1; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectionBuilder; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectionKey; @@ -31,6 +42,14 @@ import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev18121 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectivityServiceBuilder; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectivityServiceKey; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.Connection; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.NotificationType; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.ObjectType; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.notification.ChangedAttributes; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.notification.ChangedAttributesBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.notification.ChangedAttributesKey; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.notification.TargetObjectName; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.notification.TargetObjectNameBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.notification.TargetObjectNameKey; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -42,10 +61,12 @@ public class TapiRendererListenerImpl implements TransportpceRendererListener { private Uuid serviceUuid; private RendererRpcResultSp serviceRpcResultSp; private final NetworkTransactionService networkTransactionService; + private final NotificationPublishService notificationPublishService; - public TapiRendererListenerImpl(DataBroker dataBroker) { + public TapiRendererListenerImpl(DataBroker dataBroker, NotificationPublishService notificationPublishService) { this.dataBroker = dataBroker; this.networkTransactionService = new NetworkTransactionImpl(new RequestProcessor(this.dataBroker)); + this.notificationPublishService = notificationPublishService; } @Override @@ -98,7 +119,7 @@ public class TapiRendererListenerImpl implements TransportpceRendererListener { LOG.error("Couldnt retrieve service from datastore"); return; } - LOG.info("Connectivity service = {}", connectivityService.toString()); + LOG.info("Connectivity service = {}", connectivityService); // TODO --> this throws error because the renderer goes really fast. Is this normal?? ConnectivityService updtConnServ = new ConnectivityServiceBuilder(connectivityService) .setAdministrativeState(AdministrativeState.UNLOCKED) @@ -109,6 +130,8 @@ public class TapiRendererListenerImpl implements TransportpceRendererListener { updateConnectionState(connection.getConnectionUuid()); } updateConnectivityService(updtConnServ); + // TODO: need to send notification to kafka in case the topic exists!! + sendNbiNotification(createNbiNotification(updtConnServ)); } /** @@ -118,7 +141,7 @@ public class TapiRendererListenerImpl implements TransportpceRendererListener { private void onFailedServiceImplementation(String serviceName) { LOG.error("Renderer implementation failed !"); LOG.info("PCE cancel resource done OK !"); - Uuid suuid = new Uuid(UUID.nameUUIDFromBytes(serviceName.getBytes(Charset.forName("UTF-8"))) + Uuid suuid = new Uuid(UUID.nameUUIDFromBytes(serviceName.getBytes(StandardCharsets.UTF_8)) .toString()); // get connections of connectivity service and remove them from tapi context and then remove // service from context. The CEPs are maintained as they could be reused by another service @@ -278,6 +301,66 @@ public class TapiRendererListenerImpl implements TransportpceRendererListener { } } + private void sendNbiNotification(PublishTapiNotificationService service) { + try { + this.notificationPublishService.putNotification(service); + } catch (InterruptedException e) { + LOG.warn("Cannot send notification to nbi", e); + Thread.currentThread().interrupt(); + } + } + + private PublishTapiNotificationService createNbiNotification(ConnectivityService connService) { + if (connService == null) { + LOG.error("ConnService is null"); + return null; + } + /* + Map changedStates = changedAttributesMap.entrySet() + .stream() + .filter(e -> e.getKey().getValueName().equals("administrative") + || e.getKey().getValueName().equals("operational")) + .collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue())); + + */ + Map changedStates = new HashMap<>(); + changedStates.put(new ChangedAttributesKey("administrativeState"), + new ChangedAttributesBuilder() + .setNewValue(connService.getAdministrativeState().getName()) + .setOldValue(AdministrativeState.LOCKED.getName()) + .setValueName("administrativeState").build()); + changedStates.put(new ChangedAttributesKey("operationalState"), + new ChangedAttributesBuilder() + .setNewValue(connService.getOperationalState().getName()) + .setOldValue(OperationalState.DISABLED.getName()) + .setValueName("operationalState").build()); + DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssxxx"); + OffsetDateTime offsetDateTime = OffsetDateTime.now(ZoneOffset.UTC); + DateAndTime datetime = new DateAndTime(dtf.format(offsetDateTime)); + Map targetObjectNames = new HashMap<>(); + if (connService.getName() != null) { + for (Map.Entry entry : connService.getName().entrySet()) { + targetObjectNames.put(new TargetObjectNameKey(entry.getKey().getValueName()), + new TargetObjectNameBuilder() + .setValueName(entry.getValue().getValueName()) + .setValue(entry.getValue().getValue()) + .build()); + } + } + + return new PublishTapiNotificationServiceBuilder() + .setUuid(new Uuid(UUID.randomUUID().toString())) + .setTopic(connService.getUuid().getValue()) + .setTargetObjectIdentifier(connService.getUuid()) + .setNotificationType(NotificationType.ATTRIBUTEVALUECHANGE) + .setChangedAttributes(changedStates) + .setEventTimeStamp(datetime) + .setTargetObjectName(targetObjectNames) + .setTargetObjectType(ObjectType.CONNECTIVITYSERVICE) + .setLayerProtocolName(connService.getServiceLayer()) + .build(); + } + public void setServiceUuid(Uuid serviceUuid) { this.serviceUuid = serviceUuid; } diff --git a/tapi/src/main/java/org/opendaylight/transportpce/tapi/utils/TapiContext.java b/tapi/src/main/java/org/opendaylight/transportpce/tapi/utils/TapiContext.java index 12f860175..a44e50810 100644 --- a/tapi/src/main/java/org/opendaylight/transportpce/tapi/utils/TapiContext.java +++ b/tapi/src/main/java/org/opendaylight/transportpce/tapi/utils/TapiContext.java @@ -38,6 +38,7 @@ import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev18121 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.context.ConnectivityContextBuilder; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.context.topology.context.topology.node.owned.node.edge.point.CepList; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.context.topology.context.topology.node.owned.node.edge.point.CepListBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.context.NotificationContextBuilder; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.context.TopologyContext; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.context.TopologyContextBuilder; import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.OwnedNodeEdgePoint; @@ -102,13 +103,22 @@ public class TapiContext { .build()) .build(); + org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.Context1 notificationContext + = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.Context1Builder() + .setNotificationContext(new NotificationContextBuilder() + .setNotification(new HashMap<>()) + .setNotifSubscription(new HashMap<>()) + .build()) + .build(); + ContextBuilder contextBuilder = new ContextBuilder() .setName(Map.of(contextName.key(), contextName)) .setUuid( new Uuid(UUID.nameUUIDFromBytes(TAPI_CONTEXT.getBytes(Charset.forName("UTF-8"))).toString())) .setServiceInterfacePoint(new HashMap<>()) .addAugmentation(connectivityContext) - .addAugmentation(topologyContext); + .addAugmentation(topologyContext) + .addAugmentation(notificationContext); // todo: add notification context InstanceIdentifier contextIID = InstanceIdentifier.builder(Context.class).build(); diff --git a/tapi/src/main/resources/OSGI-INF/blueprint/tapi-blueprint.xml b/tapi/src/main/resources/OSGI-INF/blueprint/tapi-blueprint.xml index 62a1d9633..419993e79 100644 --- a/tapi/src/main/resources/OSGI-INF/blueprint/tapi-blueprint.xml +++ b/tapi/src/main/resources/OSGI-INF/blueprint/tapi-blueprint.xml @@ -52,6 +52,7 @@ Author: Gilles Thouenon + @@ -60,6 +61,7 @@ Author: Gilles Thouenon + -- 2.36.6