*/
package org.opendaylight.transportpce.tapi.impl;
+import java.util.HashMap;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
import org.opendaylight.mdsal.binding.api.RpcProviderService;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.transportpce.common.InstanceIdentifiers;
import org.opendaylight.transportpce.common.network.NetworkTransactionService;
+import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
+import org.opendaylight.transportpce.tapi.connectivity.ConnectivityUtils;
import org.opendaylight.transportpce.tapi.connectivity.TapiConnectivityImpl;
+import org.opendaylight.transportpce.tapi.topology.TapiNetconfTopologyListener;
+import org.opendaylight.transportpce.tapi.topology.TapiPortMappingListener;
import org.opendaylight.transportpce.tapi.topology.TapiTopologyImpl;
import org.opendaylight.transportpce.tapi.topology.TopologyUtils;
import org.opendaylight.transportpce.tapi.utils.TapiContext;
import org.opendaylight.transportpce.tapi.utils.TapiInitialORMapping;
import org.opendaylight.transportpce.tapi.utils.TapiListener;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210315.Network;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210315.network.Nodes;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.tapinetworkutils.rev210408.TransportpceTapinetworkutilsService;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.OrgOpenroadmServiceService;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.TapiConnectivityService;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.TapiTopologyService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.tapi.rev180928.ServiceInterfacePoints;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.concepts.ObjectRegistration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
private static final Logger LOG = LoggerFactory.getLogger(TapiProvider.class);
+ private static final InstanceIdentifier<Nodes> MAPPING_II = InstanceIdentifier.create(Network.class)
+ .child(org.opendaylight.yang.gen.v1.http
+ .org.opendaylight.transportpce.portmapping.rev210315.network.Nodes.class);
private final DataBroker dataBroker;
private final RpcProviderService rpcProviderService;
private ObjectRegistration<TapiConnectivityService> rpcRegistration;
+ private ObjectRegistration<TransportpceTapinetworkutilsService> tapiNetworkutilsServiceRpcRegistration;
+ private ListenerRegistration<TapiNetconfTopologyListener> dataTreeChangeListenerRegistration;
+ private ListenerRegistration<TapiPortMappingListener> mappingListenerListenerRegistration;
private final OrgOpenroadmServiceService serviceHandler;
+ private final ServiceDataStoreOperations serviceDataStoreOperations;
private final TapiListener tapiListener;
+ private final TapiNetconfTopologyListener topologyListener;
+ private TapiPortMappingListener tapiPortMappingListener;
private final NetworkTransactionService networkTransactionService;
+ private final TransportpceTapinetworkutilsService tapiNetworkUtils;
public TapiProvider(DataBroker dataBroker, RpcProviderService rpcProviderService,
- OrgOpenroadmServiceService serviceHandler, TapiListener tapiListener,
- NetworkTransactionService networkTransactionService) {
+ OrgOpenroadmServiceService serviceHandler, ServiceDataStoreOperations serviceDataStoreOperations,
+ TapiListener tapiListener, NetworkTransactionService networkTransactionService,
+ TapiNetconfTopologyListener topologyListener, TapiPortMappingListener tapiPortMappingListener,
+ TransportpceTapinetworkutilsService tapiNetworkUtils) {
this.dataBroker = dataBroker;
this.rpcProviderService = rpcProviderService;
this.serviceHandler = serviceHandler;
+ this.serviceDataStoreOperations = serviceDataStoreOperations;
this.tapiListener = tapiListener;
this.networkTransactionService = networkTransactionService;
+ this.topologyListener = topologyListener;
+ this.tapiPortMappingListener = tapiPortMappingListener;
+ this.tapiNetworkUtils = tapiNetworkUtils;
}
/**
LOG.info("Empty TAPI context created: {}", tapiContext.getTapiContext());
TopologyUtils topologyUtils = new TopologyUtils(this.networkTransactionService, this.dataBroker);
- TapiInitialORMapping tapiInitialORMapping = new TapiInitialORMapping(topologyUtils, tapiContext);
+ ConnectivityUtils connectivityUtils = new ConnectivityUtils(this.serviceDataStoreOperations, new HashMap<>(),
+ tapiContext);
+ TapiInitialORMapping tapiInitialORMapping = new TapiInitialORMapping(topologyUtils, connectivityUtils,
+ tapiContext, this.serviceDataStoreOperations);
tapiInitialORMapping.performTopoInitialMapping();
+ tapiInitialORMapping.performServInitialMapping();
TapiConnectivityImpl tapi = new TapiConnectivityImpl(this.serviceHandler);
TapiTopologyImpl topo = new TapiTopologyImpl(this.dataBroker, tapiContext, topologyUtils);
rpcRegistration = rpcProviderService.registerRpcImplementation(TapiConnectivityService.class, tapi);
rpcProviderService.registerRpcImplementation(TapiTopologyService.class, topo);
+ dataTreeChangeListenerRegistration =
+ dataBroker.registerDataTreeChangeListener(DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL,
+ InstanceIdentifiers.NETCONF_TOPOLOGY_II.child(Node.class)), topologyListener);
+ mappingListenerListenerRegistration =
+ dataBroker.registerDataTreeChangeListener(DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION,
+ MAPPING_II), tapiPortMappingListener);
+ tapiNetworkutilsServiceRpcRegistration =
+ rpcProviderService.registerRpcImplementation(TransportpceTapinetworkutilsService.class,
+ this.tapiNetworkUtils);
@NonNull
InstanceIdentifier<ServiceInterfacePoints> sipIID = InstanceIdentifier.create(ServiceInterfacePoints.class);
dataBroker.registerDataTreeChangeListener(DataTreeIdentifier.create(
*/
public void close() {
LOG.info("TapiProvider Session Closed");
+ if (dataTreeChangeListenerRegistration != null) {
+ dataTreeChangeListenerRegistration.close();
+ }
+ if (mappingListenerListenerRegistration != null) {
+ mappingListenerListenerRegistration.close();
+ }
+ if (tapiNetworkutilsServiceRpcRegistration != null) {
+ tapiNetworkutilsServiceRpcRegistration.close();
+ }
rpcRegistration.close();
}
}