a53b760e284fe7d3745ee991e0a2f5cc7fe584a2
[vpnservice.git] / itm / itm-impl / src / main / java / org / opendaylight / vpnservice / itm / impl / ItmProvider.java
1 /*
2  * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.vpnservice.itm.impl;
9
10 import java.math.BigInteger;
11 import java.util.List;
12 import java.util.concurrent.Future;
13
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
23 import org.opendaylight.vpnservice.mdsalutil.interfaces.IMdsalApiManager;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.itm.op.rev150701.GetTunnelIdInput;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.itm.op.rev150701.GetTunnelIdOutput;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.itm.op.rev150701.ItmStateService;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.itm.op.rev150701.TunnelsState;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.itm.rev150701.TransportZones;
29 import org.opendaylight.yangtools.yang.common.RpcResult;
30 import org.slf4j.Logger;
31 import org.slf4j.LoggerFactory;
32
33 public class ItmProvider implements BindingAwareProvider, AutoCloseable, IITMProvider,ItmStateService {
34
35     private static final Logger LOG = LoggerFactory.getLogger(ItmProvider.class);
36     private IInterfaceManager interfaceManager;
37     private ITMManager itmManager;
38     private IMdsalApiManager mdsalManager;
39     private DataBroker dataBroker;
40     private NotificationPublishService notificationPublishService;
41     private NotificationService notificationService;
42         
43     @Override
44     public void onSessionInitiated(ProviderContext session) {
45         LOG.info("ItmProvider Session Initiated");
46         try {
47             dataBroker = session.getSALService(DataBroker.class);
48            
49             itmManager = new ITMManager(dataBroker);
50             
51             itmManager.setMdsalManager(mdsalManager);
52             itmManager.setNotificationPublishService(notificationPublishService);
53             itmManager.setMdsalManager(mdsalManager);
54                        
55         } catch (Exception e) {
56             LOG.error("Error initializing services", e);
57         }
58     }
59
60     public void setInterfaceManager(IInterfaceManager interfaceManager) {
61         this.interfaceManager = interfaceManager;
62     }
63
64     public void setNotificationPublishService(NotificationPublishService notificationPublishService) {
65         this.notificationPublishService = notificationPublishService;
66     }
67     
68     public void setMdsalApiManager(IMdsalApiManager mdsalMgr) {
69         this.mdsalManager = mdsalMgr;
70     }
71     public void setNotificationService(NotificationService notificationService) {
72         this.notificationService = notificationService;
73     }
74
75     @Override
76     public void close() throws Exception {
77         if (itmManager != null) {
78             itmManager.close();
79         }
80                 
81         LOG.info("ItmProvider Closed");
82     }
83
84         @Override
85         public Future<RpcResult<GetTunnelIdOutput>> getTunnelId(
86                         GetTunnelIdInput input) {
87                 // TODO Auto-generated method stub
88                 return null;
89         }
90
91 }