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.NetworkUtils;
19 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
20 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
21 import org.opendaylight.transportpce.tapi.connectivity.ConnectivityUtils;
22 import org.opendaylight.transportpce.tapi.connectivity.TapiConnectivityImpl;
23 import org.opendaylight.transportpce.tapi.listeners.TapiNetworkModelListenerImpl;
24 import org.opendaylight.transportpce.tapi.listeners.TapiPceListenerImpl;
25 import org.opendaylight.transportpce.tapi.listeners.TapiRendererListenerImpl;
26 import org.opendaylight.transportpce.tapi.listeners.TapiServiceHandlerListenerImpl;
27 import org.opendaylight.transportpce.tapi.topology.TapiNetconfTopologyListener;
28 import org.opendaylight.transportpce.tapi.topology.TapiOrLinkListener;
29 import org.opendaylight.transportpce.tapi.topology.TapiPortMappingListener;
30 import org.opendaylight.transportpce.tapi.topology.TapiTopologyImpl;
31 import org.opendaylight.transportpce.tapi.topology.TopologyUtils;
32 import org.opendaylight.transportpce.tapi.utils.TapiContext;
33 import org.opendaylight.transportpce.tapi.utils.TapiInitialORMapping;
34 import org.opendaylight.transportpce.tapi.utils.TapiLink;
35 import org.opendaylight.transportpce.tapi.utils.TapiListener;
36 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.TransportpcePceListener;
37 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.Network;
38 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.network.Nodes;
39 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.TransportpceRendererListener;
40 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev201125.TransportpceServicehandlerListener;
41 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.tapinetworkutils.rev210408.TransportpceTapinetworkutilsService;
42 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.OrgOpenroadmServiceService;
43 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NetworkId;
44 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.Networks;
45 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.NetworkKey;
46 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Network1;
47 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.Link;
48 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.TapiCommonService;
49 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.TapiConnectivityService;
50 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.TapiTopologyService;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.tapi.rev180928.ServiceInterfacePoints;
52 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
53 import org.opendaylight.yangtools.concepts.ListenerRegistration;
54 import org.opendaylight.yangtools.concepts.ObjectRegistration;
55 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
56 import org.slf4j.Logger;
57 import org.slf4j.LoggerFactory;
60 * Class to register TAPI interface Service and Notification.
62 * @author Gilles Thouenon (gilles.thouenon@orange.com) on behalf of Orange
65 public class TapiProvider {
67 private static final Logger LOG = LoggerFactory.getLogger(TapiProvider.class);
69 private static final InstanceIdentifier<Nodes> MAPPING_II = InstanceIdentifier.create(Network.class)
70 .child(org.opendaylight.yang.gen.v1.http
71 .org.opendaylight.transportpce.portmapping.rev220922.network.Nodes.class);
72 private static final InstanceIdentifier<Link> LINK_II = InstanceIdentifier.create(Networks.class).child(
73 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network.class,
74 new NetworkKey(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID))).augmentation(Network1.class)
76 private final DataBroker dataBroker;
77 private final RpcProviderService rpcProviderService;
78 private ObjectRegistration<TapiConnectivityService> rpcRegistration;
79 private ObjectRegistration<TransportpceTapinetworkutilsService> tapiNetworkutilsServiceRpcRegistration;
80 private ListenerRegistration<TapiNetconfTopologyListener> dataTreeChangeListenerRegistration;
81 private ListenerRegistration<TapiOrLinkListener> dataTreeChangeListenerRegistration1;
82 private ListenerRegistration<TapiPortMappingListener> mappingListenerListenerRegistration;
83 private ListenerRegistration<TransportpcePceListener> pcelistenerRegistration;
84 private ListenerRegistration<TransportpceRendererListener> rendererlistenerRegistration;
85 private ListenerRegistration<TransportpceServicehandlerListener> servicehandlerlistenerRegistration;
86 private ListenerRegistration<TapiNetworkModelListenerImpl> tapinetworkmodellistenerRegistration;
87 private final OrgOpenroadmServiceService serviceHandler;
88 private final ServiceDataStoreOperations serviceDataStoreOperations;
89 private final TapiListener tapiListener;
90 private final TapiNetconfTopologyListener topologyListener;
91 private final TapiOrLinkListener orLinkListener;
92 private TapiPortMappingListener tapiPortMappingListener;
93 private final NetworkTransactionService networkTransactionService;
94 private final TransportpceTapinetworkutilsService tapiNetworkUtils;
95 private TapiPceListenerImpl pceListenerImpl;
96 private TapiRendererListenerImpl rendererListenerImpl;
97 private TapiServiceHandlerListenerImpl serviceHandlerListenerImpl;
98 private final NotificationService notificationService;
99 private TapiNetworkModelListenerImpl tapiNetworkModelListenerImpl;
101 public TapiProvider(DataBroker dataBroker, RpcProviderService rpcProviderService,
102 OrgOpenroadmServiceService serviceHandler,ServiceDataStoreOperations serviceDataStoreOperations,
103 TapiListener tapiListener, NetworkTransactionService networkTransactionService,
104 TapiNetconfTopologyListener topologyListener, TapiPortMappingListener tapiPortMappingListener,
105 TransportpceTapinetworkutilsService tapiNetworkUtils, TapiPceListenerImpl pceListenerImpl,
106 TapiRendererListenerImpl rendererListenerImpl, TapiServiceHandlerListenerImpl serviceHandlerListenerImpl,
107 NotificationService notificationService, TapiOrLinkListener orLinkListener,
108 TapiNetworkModelListenerImpl tapiNetworkModelListenerImpl) {
109 this.dataBroker = dataBroker;
110 this.rpcProviderService = rpcProviderService;
111 this.serviceHandler = serviceHandler;
112 this.serviceDataStoreOperations = serviceDataStoreOperations;
113 this.tapiListener = tapiListener;
114 this.networkTransactionService = networkTransactionService;
115 this.topologyListener = topologyListener;
116 this.tapiPortMappingListener = tapiPortMappingListener;
117 this.tapiNetworkUtils = tapiNetworkUtils;
118 this.pceListenerImpl = pceListenerImpl;
119 this.rendererListenerImpl = rendererListenerImpl;
120 this.serviceHandlerListenerImpl = serviceHandlerListenerImpl;
121 this.notificationService = notificationService;
122 this.orLinkListener = orLinkListener;
123 this.tapiNetworkModelListenerImpl = tapiNetworkModelListenerImpl;
124 //this.notificationPublishService = notificationPublishService;
128 * Method called when the blueprint container is created.
131 LOG.info("TapiProvider Session Initiated");
132 TapiContext tapiContext = new TapiContext(this.networkTransactionService);
133 LOG.info("Empty TAPI context created: {}", tapiContext.getTapiContext());
134 TapiLink tapiLink = new TapiLink(this.networkTransactionService);
135 TopologyUtils topologyUtils = new TopologyUtils(this.networkTransactionService, this.dataBroker, tapiLink);
136 ConnectivityUtils connectivityUtils = new ConnectivityUtils(this.serviceDataStoreOperations, new HashMap<>(),
137 tapiContext, this.networkTransactionService);
138 TapiInitialORMapping tapiInitialORMapping = new TapiInitialORMapping(topologyUtils, connectivityUtils,
139 tapiContext, this.serviceDataStoreOperations);
140 tapiInitialORMapping.performTopoInitialMapping();
141 tapiInitialORMapping.performServInitialMapping();
143 TapiConnectivityImpl tapi = new TapiConnectivityImpl(this.serviceHandler, tapiContext, connectivityUtils,
144 pceListenerImpl, rendererListenerImpl);
145 TapiTopologyImpl topo = new TapiTopologyImpl(this.dataBroker, tapiContext, topologyUtils, tapiLink);
147 rpcRegistration = rpcProviderService.registerRpcImplementation(TapiConnectivityService.class, tapi);
148 rpcProviderService.registerRpcImplementation(TapiTopologyService.class, topo);
149 rpcProviderService.registerRpcImplementation(TapiCommonService.class, topo);
150 dataTreeChangeListenerRegistration1 =
151 dataBroker.registerDataTreeChangeListener(DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION,
152 LINK_II), orLinkListener);
153 dataTreeChangeListenerRegistration =
154 dataBroker.registerDataTreeChangeListener(DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL,
155 InstanceIdentifiers.NETCONF_TOPOLOGY_II.child(Node.class)), topologyListener);
156 mappingListenerListenerRegistration =
157 dataBroker.registerDataTreeChangeListener(DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION,
158 MAPPING_II), tapiPortMappingListener);
159 tapiNetworkutilsServiceRpcRegistration =
160 rpcProviderService.registerRpcImplementation(TransportpceTapinetworkutilsService.class,
161 this.tapiNetworkUtils);
163 InstanceIdentifier<ServiceInterfacePoints> sipIID = InstanceIdentifier.create(ServiceInterfacePoints.class);
164 dataBroker.registerDataTreeChangeListener(DataTreeIdentifier.create(
165 LogicalDatastoreType.CONFIGURATION, sipIID), tapiListener);
166 // Notification Listener
167 pcelistenerRegistration = notificationService.registerNotificationListener(pceListenerImpl);
168 rendererlistenerRegistration = notificationService.registerNotificationListener(rendererListenerImpl);
169 servicehandlerlistenerRegistration =
170 notificationService.registerNotificationListener(serviceHandlerListenerImpl);
171 tapinetworkmodellistenerRegistration =
172 notificationService.registerNotificationListener(tapiNetworkModelListenerImpl);
176 * Method called when the blueprint container is destroyed.
178 public void close() {
179 LOG.info("TapiProvider Session Closed");
180 if (dataTreeChangeListenerRegistration != null) {
181 dataTreeChangeListenerRegistration.close();
183 if (mappingListenerListenerRegistration != null) {
184 mappingListenerListenerRegistration.close();
186 if (dataTreeChangeListenerRegistration1 != null) {
187 dataTreeChangeListenerRegistration1.close();
189 if (tapiNetworkutilsServiceRpcRegistration != null) {
190 tapiNetworkutilsServiceRpcRegistration.close();
192 pcelistenerRegistration.close();
193 rendererlistenerRegistration.close();
194 servicehandlerlistenerRegistration.close();
195 rpcRegistration.close();
196 tapinetworkmodellistenerRegistration.close();