2 * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. 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.vpnservice.itm.impl;
10 import java.math.BigInteger;
11 import java.util.List;
12 import java.util.concurrent.Future;
14 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
15 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
16 import org.opendaylight.controller.md.sal.binding.api.NotificationService;
17 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
18 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
19 import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
20 import org.opendaylight.vpnservice.interfacemgr.interfaces.IInterfaceManager;
21 import org.opendaylight.vpnservice.itm.api.IITMProvider;
22 import org.opendaylight.vpnservice.itm.listeners.TransportZoneListener;
23 import org.opendaylight.vpnservice.itm.rpc.ItmManagerRpcService;
24 import org.opendaylight.vpnservice.mdsalutil.interfaces.IMdsalApiManager;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.itm.op.rev150701.GetTunnelIdInput;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.itm.op.rev150701.GetTunnelIdOutput;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.itm.op.rev150701.ItmStateService;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.itm.op.rev150701.TunnelsState;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.itm.rev150701.transport.zones.transport.zone.*;;
30 import org.opendaylight.yangtools.yang.common.RpcResult;
31 import org.slf4j.Logger;
32 import org.slf4j.LoggerFactory;
34 public class ItmProvider implements BindingAwareProvider, AutoCloseable, IITMProvider,ItmStateService {
36 private static final Logger LOG = LoggerFactory.getLogger(ItmProvider.class);
37 private IInterfaceManager interfaceManager;
38 private ITMManager itmManager;
39 private IMdsalApiManager mdsalManager;
40 private DataBroker dataBroker;
41 private NotificationPublishService notificationPublishService;
42 private ItmManagerRpcService itmRpcService ;
43 private NotificationService notificationService;
44 private TransportZoneListener tzChangeListener;
47 public void onSessionInitiated(ProviderContext session) {
48 LOG.info("ItmProvider Session Initiated");
50 dataBroker = session.getSALService(DataBroker.class);
52 itmManager = new ITMManager(dataBroker);
53 tzChangeListener = new TransportZoneListener(dataBroker) ;
54 itmRpcService = new ItmManagerRpcService(dataBroker);
56 itmManager.setMdsalManager(mdsalManager);
57 itmManager.setNotificationPublishService(notificationPublishService);
58 itmManager.setMdsalManager(mdsalManager);
59 tzChangeListener.setItmManager(itmManager);
60 tzChangeListener.registerListener(LogicalDatastoreType.CONFIGURATION, dataBroker);
61 } catch (Exception e) {
62 LOG.error("Error initializing services", e);
66 public void setInterfaceManager(IInterfaceManager interfaceManager) {
67 this.interfaceManager = interfaceManager;
70 public void setNotificationPublishService(NotificationPublishService notificationPublishService) {
71 this.notificationPublishService = notificationPublishService;
74 public void setMdsalApiManager(IMdsalApiManager mdsalMgr) {
75 this.mdsalManager = mdsalMgr;
77 public void setNotificationService(NotificationService notificationService) {
78 this.notificationService = notificationService;
82 public void close() throws Exception {
83 if (itmManager != null) {
86 if (tzChangeListener != null) {
87 tzChangeListener.close();
90 LOG.info("ItmProvider Closed");
94 public Future<RpcResult<GetTunnelIdOutput>> getTunnelId(
95 GetTunnelIdInput input) {
96 // TODO Auto-generated method stub