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