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";
"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";
}
}
+ 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";
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 {
}
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;
+ }
}
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;
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;
@Override
public void onPublishNotificationAlarmService(PublishNotificationAlarmService notification) {
-
}
+ @Override
+ public void onPublishTapiNotificationService(PublishTapiNotificationService notification) {
+ }
}
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 {
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
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
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
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
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;
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());
TapiPortMappingListener tapiPortMappingListener =
new TapiPortMappingListener(tapiNetworkModelService);
TapiNetworkModelListenerImpl tapiNetworkModelListenerImpl =
- new TapiNetworkModelListenerImpl(networkTransaction);
+ new TapiNetworkModelListenerImpl(networkTransaction,
+ lightyServices.getBindingNotificationPublishService());
tapiProvider = initTapi(lightyServices, servicehandler, networkTransaction, serviceDataStoreOperations,
tapiNetConfTopologyListener, tapiPortMappingListener, tapiNetworkutilsServiceImpl,
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);
}
}
.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<YangModuleInfo> TPCE_YANG_MODEL = Stream.concat(
<artifactId>transportpce-api</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>transportpce-tapimodels</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>transportpce-common</artifactId>
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<NotificationProcessService> converterService;
private final JsonStringConverter<NotificationAlarmService> converterAlarmService;
private final String server;
+ private final NetworkTransactionService networkTransactionService;
+ private final TopicManager topicManager;
public NbiNotificationsImpl(JsonStringConverter<NotificationProcessService> converterService,
- JsonStringConverter<NotificationAlarmService> converterAlarmService, String server) {
+ JsonStringConverter<NotificationAlarmService> converterAlarmService, String server,
+ NetworkTransactionService networkTransactionService, TopicManager topicManager) {
this.converterService = converterService;
this.converterAlarmService = converterAlarmService;
this.server = server;
+ this.networkTransactionService = networkTransactionService;
+ this.topicManager = topicManager;
}
@Override
return RpcResultBuilder.success(new GetNotificationsAlarmServiceOutputBuilder()
.setNotificationsAlarmService(notificationAlarmServiceList).build()).buildFuture();
}
+
+ @Override
+ public ListenableFuture<RpcResult<GetSupportedNotificationTypesOutput>>
+ getSupportedNotificationTypes(GetSupportedNotificationTypesInput input) {
+ return null;
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<CreateNotificationSubscriptionServiceOutput>>
+ 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<NotificationContext> 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<NotificationContext> notificationContextOptional
+ = this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, notificationcontextIID).get();
+ if (notificationContextOptional.isEmpty()) {
+ LOG.error("Could not create TAPI notification subscription service");
+ return RpcResultBuilder.<CreateNotificationSubscriptionServiceOutput>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<NotificationType> notificationTypes = (subscriptionFilter.getRequestedNotificationTypes() != null)
+ ? subscriptionFilter.getRequestedNotificationTypes()
+ : new HashSet<>(List.of(NotificationType.ALARMEVENT));
+ Set<ObjectType> 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<NotifSubscriptionKey, NotifSubscription> 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.<CreateNotificationSubscriptionServiceOutput>failed()
+ .withError(ErrorType.RPC, "Could not read notification context").buildFuture();
+ }
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<UpdateNotificationSubscriptionServiceOutput>>
+ updateNotificationSubscriptionService(UpdateNotificationSubscriptionServiceInput input) {
+ return null;
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<DeleteNotificationSubscriptionServiceOutput>>
+ deleteNotificationSubscriptionService(DeleteNotificationSubscriptionServiceInput input) {
+ return null;
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<GetNotificationSubscriptionServiceDetailsOutput>>
+ getNotificationSubscriptionServiceDetails(GetNotificationSubscriptionServiceDetailsInput input) {
+ return null;
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<GetNotificationSubscriptionServiceListOutput>>
+ getNotificationSubscriptionServiceList(GetNotificationSubscriptionServiceListInput input) {
+ return null;
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<GetNotificationListOutput>> getNotificationList(GetNotificationListInput input) {
+ return null;
+ }
}
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;
private final NotificationService notificationService;
private final JsonStringConverter<NotificationProcessService> converterService;
private final JsonStringConverter<NotificationAlarmService> converterAlarmService;
+ private final JsonStringConverter<NotificationTapiService> converterTapiService;
private final String subscriberServer;
private ObjectRegistration<NbiNotificationsService> rpcRegistration;
private ListenerRegistration<NbiNotificationsListener> listenerRegistration;
+ private TopicManager topicManager = TopicManager.getInstance();
+ private final NetworkTransactionService networkTransactionService;
public NbiNotificationsProvider(List<String> publishersService, List<String> 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;
}
/**
*/
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);
}
/**
*/
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<String, Publisher<NotificationProcessService>> publishersServiceMap;
- private final Map<String, Publisher<NotificationAlarmService>> publishersAlarmMap;
+ private Map<String, Publisher<NotificationProcessService>> publishersServiceMap;
+ private Map<String, Publisher<NotificationAlarmService>> publishersAlarmMap;
+ private Map<String, Publisher<NotificationTapiService>> tapiPublisherMap;
public NbiNotificationsListenerImpl(Map<String, Publisher<NotificationProcessService>> publishersServiceMap,
- Map<String, Publisher<NotificationAlarmService>> publishersAlarmMap) {
+ Map<String, Publisher<NotificationAlarmService>> publishersAlarmMap,
+ Map<String, Publisher<NotificationTapiService>> tapiPublisherMap) {
this.publishersServiceMap = publishersServiceMap;
this.publishersAlarmMap = publishersAlarmMap;
+ this.tapiPublisherMap = tapiPublisherMap;
}
@Override
.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<NotificationTapiService> publisher = tapiPublisherMap.get(topic);
+ publisher.sendEvent(new NotificationTapiServiceBuilder(transformTapiNotification(notification))
+ .build(), topic);
+ }
+
+ private NotificationTapiService transformTapiNotification(PublishTapiNotificationService notification) {
+ Map<AdditionalInfoKey, AdditionalInfo> 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<ChangedAttributesKey, ChangedAttributes> 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<NameKey, Name> 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<TargetObjectNameKey, TargetObjectName> 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<String, Publisher<NotificationProcessService>> publishersServiceMap) {
+ this.publishersServiceMap = publishersServiceMap;
+ }
+
+ public void setPublishersAlarmMap(Map<String, Publisher<NotificationAlarmService>> publishersAlarmMap) {
+ this.publishersAlarmMap = publishersAlarmMap;
+ }
+
+ public void setTapiPublishersMap(Map<String, Publisher<NotificationTapiService>> tapiPublishersMap) {
+ this.tapiPublisherMap = tapiPublishersMap;
+ }
}
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;
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;
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;
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;
--- /dev/null
+/*
+ * 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<NotificationTapiService> {
+ private static final Logger LOG = LoggerFactory.getLogger(TapiNotificationSerializer.class);
+ private JsonStringConverter<NotificationTapiService> converter;
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void configure(Map<String, ?> configs, boolean isKey) {
+ LOG.info("Deserializer configuration {}", configs);
+ if (configs.containsKey(ConfigConstants.CONVERTER)
+ && configs.get(ConfigConstants.CONVERTER) instanceof JsonStringConverter<?>) {
+ converter = (JsonStringConverter<NotificationTapiService>) 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<NotificationTapiService> 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];
+ }
+ }
+}
--- /dev/null
+/*
+ * 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<String, Publisher<NotificationTapiService>> tapiPublisherMap = new HashMap<>();
+ private String publisherServer;
+ private JsonStringConverter<NotificationTapiService> tapiConverter;
+ private NbiNotificationsListenerImpl nbiNotificationsListener;
+ private Map<String, Publisher<NotificationAlarmService>> alarmPublisherMap = new HashMap<>();
+ private Map<String, Publisher<NotificationProcessService>> processPublisherMap = new HashMap<>();
+ private JsonStringConverter<NotificationProcessService> processConverter;
+ private JsonStringConverter<NotificationAlarmService> 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<NotificationProcessService> processConverter) {
+ this.processConverter = processConverter;
+ }
+
+ public void setAlarmConverter(JsonStringConverter<NotificationAlarmService> alarmConverter) {
+ this.alarmConverter = alarmConverter;
+ }
+
+ public void setTapiConverter(JsonStringConverter<NotificationTapiService> 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<String, Publisher<NotificationTapiService>> getTapiTopicMap() {
+ return this.tapiPublisherMap;
+ }
+
+ public Map<String, Publisher<NotificationAlarmService>> getAlarmTopicMap() {
+ return this.alarmPublisherMap;
+ }
+
+ public Map<String, Publisher<NotificationProcessService>> getProcessTopicMap() {
+ return this.processPublisherMap;
+ }
+}
<reference id="rpcService" interface="org.opendaylight.mdsal.binding.api.RpcProviderService"/>
<reference id="notificationService" interface="org.opendaylight.mdsal.binding.api.NotificationService"/>
<reference id="bindingDOMCodecServices" interface="org.opendaylight.mdsal.binding.dom.codec.spi.BindingDOMCodecServices" />
+ <reference id="networkTransactionImpl"
+ interface="org.opendaylight.transportpce.common.network.NetworkTransactionService" />
<bean id="provider"
class="org.opendaylight.transportpce.nbinotifications.impl.NbiNotificationsProvider"
init-method="init" destroy-method="close">
<argument ref="rpcService" />
<argument ref="notificationService" />
<argument ref="bindingDOMCodecServices" />
+ <argument ref="networkTransactionImpl" />
</bean>
</blueprint>
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";
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<NotificationProcessService> converter = new JsonStringConverter<>(
getDataStoreContextUtil().getBindingDOMCodecServices());
JsonStringConverter<NotificationAlarmService> converterAlarm = new JsonStringConverter<>(
getDataStoreContextUtil().getBindingDOMCodecServices());
- nbiNotificationsImpl = new NbiNotificationsImpl(converter, converterAlarm,"localhost:8080");
+ nbiNotificationsImpl = new NbiNotificationsImpl(converter, converterAlarm,"localhost:8080",
+ networkTransactionService, topicManager);
}
@Test
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;
@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));
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;
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
@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")
@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")
@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)
@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)
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;
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 {
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;
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 {
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;
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;
{
"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
{
"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
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;
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;
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;
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;
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;
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;
this.notificationService = notificationService;
this.orLinkListener = orLinkListener;
this.tapiNetworkModelListenerImpl = tapiNetworkModelListenerImpl;
+ //this.notificationPublishService = notificationPublishService;
}
/**
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);
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;
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;
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;
private final Uuid tapiTopoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
.getBytes(StandardCharsets.UTF_8)).toString());
private final List<LayerProtocolName> 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
.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<ChangedAttributesKey, ChangedAttributes> 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<TargetObjectNameKey, TargetObjectName> targetObjectNames = new HashMap<>();
+ if (connService.getName() != null) {
+ for (Map.Entry<NameKey, Name> 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();
}
}
OperationalState operState = (OperationalState) states.get(connService.getUuid())[1];
InstanceIdentifier<ConnectivityService> 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();
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;
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;
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
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)
updateConnectionState(connection.getConnectionUuid());
}
updateConnectivityService(updtConnServ);
+ // TODO: need to send notification to kafka in case the topic exists!!
+ sendNbiNotification(createNbiNotification(updtConnServ));
}
/**
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
}
}
+ 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<ChangedAttributesKey, ChangedAttributes> 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<ChangedAttributesKey, ChangedAttributes> 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<TargetObjectNameKey, TargetObjectName> targetObjectNames = new HashMap<>();
+ if (connService.getName() != null) {
+ for (Map.Entry<NameKey, Name> 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;
}
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;
.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<Context> contextIID = InstanceIdentifier.builder(Context.class).build();
<bean id="tapiRendererListener" class="org.opendaylight.transportpce.tapi.listeners.TapiRendererListenerImpl">
<argument ref="dataBroker" />
+ <argument ref="notificationPublishService" />
</bean>
<bean id="tapiServiceHandlerListener" class="org.opendaylight.transportpce.tapi.listeners.TapiServiceHandlerListenerImpl">
<bean id="tapiNetworkModelListenerImpl" class="org.opendaylight.transportpce.tapi.listeners.TapiNetworkModelListenerImpl">
<argument ref="networkTransactionImpl" />
+ <argument ref="notificationPublishService" />
</bean>
<bean id="tapiNetworkModelService" class="org.opendaylight.transportpce.tapi.topology.TapiNetworkModelServiceImpl">