2 * Copyright © 2018 Orange, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.transportpce.tapi.impl;
10 import java.util.HashMap;
11 import org.eclipse.jdt.annotation.NonNull;
12 import org.opendaylight.mdsal.binding.api.DataBroker;
13 import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
14 import org.opendaylight.mdsal.binding.api.NotificationService;
15 import org.opendaylight.mdsal.binding.api.RpcProviderService;
16 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
17 import org.opendaylight.transportpce.common.InstanceIdentifiers;
18 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
19 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
20 import org.opendaylight.transportpce.tapi.connectivity.ConnectivityUtils;
21 import org.opendaylight.transportpce.tapi.connectivity.TapiConnectivityImpl;
22 import org.opendaylight.transportpce.tapi.listeners.TapiPceListenerImpl;
23 import org.opendaylight.transportpce.tapi.listeners.TapiRendererListenerImpl;
24 import org.opendaylight.transportpce.tapi.listeners.TapiServiceHandlerListenerImpl;
25 import org.opendaylight.transportpce.tapi.topology.TapiNetconfTopologyListener;
26 import org.opendaylight.transportpce.tapi.topology.TapiPortMappingListener;
27 import org.opendaylight.transportpce.tapi.topology.TapiTopologyImpl;
28 import org.opendaylight.transportpce.tapi.topology.TopologyUtils;
29 import org.opendaylight.transportpce.tapi.utils.TapiContext;
30 import org.opendaylight.transportpce.tapi.utils.TapiInitialORMapping;
31 import org.opendaylight.transportpce.tapi.utils.TapiListener;
32 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev210701.TransportpcePceListener;
33 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210426.Network;
34 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210426.network.Nodes;
35 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev201125.TransportpceRendererListener;
36 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev201125.TransportpceServicehandlerListener;
37 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.tapinetworkutils.rev210408.TransportpceTapinetworkutilsService;
38 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.OrgOpenroadmServiceService;
39 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.TapiCommonService;
40 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.TapiConnectivityService;
41 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.TapiTopologyService;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.tapi.rev180928.ServiceInterfacePoints;
43 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
44 import org.opendaylight.yangtools.concepts.ListenerRegistration;
45 import org.opendaylight.yangtools.concepts.ObjectRegistration;
46 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
47 import org.slf4j.Logger;
48 import org.slf4j.LoggerFactory;
51 * Class to register TAPI interface Service and Notification.
53 * @author Gilles Thouenon (gilles.thouenon@orange.com) on behalf of Orange
56 public class TapiProvider {
58 private static final Logger LOG = LoggerFactory.getLogger(TapiProvider.class);
60 private static final InstanceIdentifier<Nodes> MAPPING_II = InstanceIdentifier.create(Network.class)
61 .child(org.opendaylight.yang.gen.v1.http
62 .org.opendaylight.transportpce.portmapping.rev210426.network.Nodes.class);
63 private final DataBroker dataBroker;
64 private final RpcProviderService rpcProviderService;
65 private ObjectRegistration<TapiConnectivityService> rpcRegistration;
66 private ObjectRegistration<TransportpceTapinetworkutilsService> tapiNetworkutilsServiceRpcRegistration;
67 private ListenerRegistration<TapiNetconfTopologyListener> dataTreeChangeListenerRegistration;
68 private ListenerRegistration<TapiPortMappingListener> mappingListenerListenerRegistration;
69 private ListenerRegistration<TransportpcePceListener> pcelistenerRegistration;
70 private ListenerRegistration<TransportpceRendererListener> rendererlistenerRegistration;
71 private ListenerRegistration<TransportpceServicehandlerListener> servicehandlerlistenerRegistration;
72 private final OrgOpenroadmServiceService serviceHandler;
73 private final ServiceDataStoreOperations serviceDataStoreOperations;
74 private final TapiListener tapiListener;
75 private final TapiNetconfTopologyListener topologyListener;
76 private TapiPortMappingListener tapiPortMappingListener;
77 private final NetworkTransactionService networkTransactionService;
78 private final TransportpceTapinetworkutilsService tapiNetworkUtils;
79 private TapiPceListenerImpl pceListenerImpl;
80 private TapiRendererListenerImpl rendererListenerImpl;
81 private TapiServiceHandlerListenerImpl serviceHandlerListenerImpl;
82 private final NotificationService notificationService;
84 public TapiProvider(DataBroker dataBroker, RpcProviderService rpcProviderService,
85 OrgOpenroadmServiceService serviceHandler, ServiceDataStoreOperations serviceDataStoreOperations,
86 TapiListener tapiListener, NetworkTransactionService networkTransactionService,
87 TapiNetconfTopologyListener topologyListener, TapiPortMappingListener tapiPortMappingListener,
88 TransportpceTapinetworkutilsService tapiNetworkUtils, TapiPceListenerImpl pceListenerImpl,
89 TapiRendererListenerImpl rendererListenerImpl, TapiServiceHandlerListenerImpl serviceHandlerListenerImpl,
90 NotificationService notificationService) {
91 this.dataBroker = dataBroker;
92 this.rpcProviderService = rpcProviderService;
93 this.serviceHandler = serviceHandler;
94 this.serviceDataStoreOperations = serviceDataStoreOperations;
95 this.tapiListener = tapiListener;
96 this.networkTransactionService = networkTransactionService;
97 this.topologyListener = topologyListener;
98 this.tapiPortMappingListener = tapiPortMappingListener;
99 this.tapiNetworkUtils = tapiNetworkUtils;
100 this.pceListenerImpl = pceListenerImpl;
101 this.rendererListenerImpl = rendererListenerImpl;
102 this.serviceHandlerListenerImpl = serviceHandlerListenerImpl;
103 this.notificationService = notificationService;
107 * Method called when the blueprint container is created.
110 LOG.info("TapiProvider Session Initiated");
111 TapiContext tapiContext = new TapiContext(this.networkTransactionService);
112 LOG.info("Empty TAPI context created: {}", tapiContext.getTapiContext());
114 TopologyUtils topologyUtils = new TopologyUtils(this.networkTransactionService, this.dataBroker);
115 ConnectivityUtils connectivityUtils = new ConnectivityUtils(this.serviceDataStoreOperations, new HashMap<>(),
117 TapiInitialORMapping tapiInitialORMapping = new TapiInitialORMapping(topologyUtils, connectivityUtils,
118 tapiContext, this.serviceDataStoreOperations);
119 tapiInitialORMapping.performTopoInitialMapping();
120 tapiInitialORMapping.performServInitialMapping();
122 TapiConnectivityImpl tapi = new TapiConnectivityImpl(this.serviceHandler, tapiContext, connectivityUtils,
123 pceListenerImpl, rendererListenerImpl, serviceHandlerListenerImpl);
124 TapiTopologyImpl topo = new TapiTopologyImpl(this.dataBroker, tapiContext, topologyUtils);
125 rpcRegistration = rpcProviderService.registerRpcImplementation(TapiConnectivityService.class, tapi);
126 rpcProviderService.registerRpcImplementation(TapiTopologyService.class, topo);
127 rpcProviderService.registerRpcImplementation(TapiCommonService.class, topo);
128 dataTreeChangeListenerRegistration =
129 dataBroker.registerDataTreeChangeListener(DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL,
130 InstanceIdentifiers.NETCONF_TOPOLOGY_II.child(Node.class)), topologyListener);
131 mappingListenerListenerRegistration =
132 dataBroker.registerDataTreeChangeListener(DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION,
133 MAPPING_II), tapiPortMappingListener);
134 tapiNetworkutilsServiceRpcRegistration =
135 rpcProviderService.registerRpcImplementation(TransportpceTapinetworkutilsService.class,
136 this.tapiNetworkUtils);
138 InstanceIdentifier<ServiceInterfacePoints> sipIID = InstanceIdentifier.create(ServiceInterfacePoints.class);
139 dataBroker.registerDataTreeChangeListener(DataTreeIdentifier.create(
140 LogicalDatastoreType.CONFIGURATION, sipIID), tapiListener);
141 // Notification Listener
142 pcelistenerRegistration = notificationService.registerNotificationListener(pceListenerImpl);
143 rendererlistenerRegistration = notificationService.registerNotificationListener(rendererListenerImpl);
144 servicehandlerlistenerRegistration =
145 notificationService.registerNotificationListener(serviceHandlerListenerImpl);
149 * Method called when the blueprint container is destroyed.
151 public void close() {
152 LOG.info("TapiProvider Session Closed");
153 if (dataTreeChangeListenerRegistration != null) {
154 dataTreeChangeListenerRegistration.close();
156 if (mappingListenerListenerRegistration != null) {
157 mappingListenerListenerRegistration.close();
159 if (tapiNetworkutilsServiceRpcRegistration != null) {
160 tapiNetworkutilsServiceRpcRegistration.close();
162 pcelistenerRegistration.close();
163 rendererlistenerRegistration.close();
164 servicehandlerlistenerRegistration.close();
165 rpcRegistration.close();