Merge "L2 Gw create changes related to ITM Tunnels creation in neutronvpn module"
[vpnservice.git] / interfacemgr / interfacemgr-impl / src / main / java / org / opendaylight / vpnservice / interfacemgr / InterfacemgrProvider.java
1 /*
2  * Copyright (c) 2015 - 2016 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.interfacemgr;
9
10
11 import com.google.common.base.Optional;
12 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
13 import org.opendaylight.controller.md.sal.binding.api.NotificationService;
14 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
15 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
16 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
17 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
18 import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
19 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
20 import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceManagerCommonUtils;
21 import org.opendaylight.vpnservice.interfacemgr.globals.InterfaceInfo;
22 import org.opendaylight.vpnservice.interfacemgr.globals.InterfaceInfo.InterfaceAdminState;
23 import org.opendaylight.vpnservice.interfacemgr.interfaces.IInterfaceManager;
24 import org.opendaylight.vpnservice.interfacemgr.listeners.AlivenessMonitorListener;
25 import org.opendaylight.vpnservice.interfacemgr.listeners.InterfaceConfigListener;
26 import org.opendaylight.vpnservice.interfacemgr.listeners.HwVTEPConfigListener;
27 import org.opendaylight.vpnservice.interfacemgr.listeners.HwVTEPTunnelsStateListener;
28 import org.opendaylight.vpnservice.interfacemgr.listeners.InterfaceInventoryStateListener;
29 import org.opendaylight.vpnservice.interfacemgr.listeners.TerminationPointStateListener;
30 import org.opendaylight.vpnservice.interfacemgr.listeners.InterfaceTopologyStateListener;
31 import org.opendaylight.vpnservice.interfacemgr.listeners.VlanMemberConfigListener;
32 import org.opendaylight.vpnservice.interfacemgr.pmcounters.NodeConnectorStatsImpl;
33 import org.opendaylight.vpnservice.interfacemgr.rpcservice.InterfaceManagerRpcService;
34 import org.opendaylight.vpnservice.interfacemgr.servicebindings.flowbased.listeners.FlowBasedServicesConfigListener;
35 import org.opendaylight.vpnservice.interfacemgr.servicebindings.flowbased.listeners.FlowBasedServicesInterfaceStateListener;
36 import org.opendaylight.vpnservice.interfacemgr.statusanddiag.InterfaceStatusMonitor;
37 import org.opendaylight.vpnservice.mdsalutil.ActionInfo;
38 import org.opendaylight.vpnservice.mdsalutil.interfaces.IMdsalApiManager;
39 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.L2vlan;
40 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
41 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces;
42 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
43 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder;
44 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey;
45 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.AdminStatus;
46 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.OpendaylightFlowTableStatisticsService;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.servicebinding.rev151015.ServiceBindings;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.servicebinding.rev151015.service.bindings.ServicesInfo;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.servicebinding.rev151015.service.bindings.ServicesInfoKey;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.servicebinding.rev151015.service.bindings.services.info.BoundServices;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.servicebinding.rev151015.service.bindings.services.info.BoundServicesKey;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.OpendaylightPortStatisticsService;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.alivenessmonitor.rev150629.AlivenessMonitorService;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.CreateIdPoolInput;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.CreateIdPoolInputBuilder;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.IdManagerService;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.IfL2vlan;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.IfL2vlanBuilder;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.ParentRefs;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.ParentRefsBuilder;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.*;
65 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
66 import org.opendaylight.yangtools.yang.common.RpcResult;
67 import org.slf4j.Logger;
68 import org.slf4j.LoggerFactory;
69
70 import java.math.BigInteger;
71 import java.util.ArrayList;
72 import java.util.List;
73 import java.util.concurrent.ExecutionException;
74 import java.util.concurrent.Future;
75
76
77 public class InterfacemgrProvider implements BindingAwareProvider, AutoCloseable, IInterfaceManager {
78
79     private static final Logger LOG = LoggerFactory.getLogger(InterfacemgrProvider.class);
80     private static final InterfaceStatusMonitor interfaceStatusMonitor = InterfaceStatusMonitor.getInstance();
81
82     private RpcProviderRegistry rpcProviderRegistry;
83     private IdManagerService idManager;
84     private NotificationService notificationService;
85     private AlivenessMonitorService alivenessManager;
86     private IMdsalApiManager mdsalManager;
87     private InterfaceConfigListener interfaceConfigListener;
88     private InterfaceTopologyStateListener topologyStateListener;
89     private TerminationPointStateListener terminationPointStateListener;
90     private HwVTEPTunnelsStateListener hwVTEPTunnelsStateListener;
91     private InterfaceInventoryStateListener interfaceInventoryStateListener;
92     private FlowBasedServicesInterfaceStateListener flowBasedServicesInterfaceStateListener;
93     private FlowBasedServicesConfigListener flowBasedServicesConfigListener;
94     private VlanMemberConfigListener vlanMemberConfigListener;
95     private HwVTEPConfigListener hwVTEPConfigListener;
96     private AlivenessMonitorListener alivenessMonitorListener;
97     private DataBroker dataBroker;
98     private InterfaceManagerRpcService interfaceManagerRpcService;
99     private BindingAwareBroker.RpcRegistration<OdlInterfaceRpcService> rpcRegistration;
100     private NodeConnectorStatsImpl nodeConnectorStatsManager;
101
102     public void setRpcProviderRegistry(RpcProviderRegistry rpcProviderRegistry) {
103         this.rpcProviderRegistry = rpcProviderRegistry;
104         interfaceStatusMonitor.registerMbean();
105     }
106
107     public void setMdsalManager(IMdsalApiManager mdsalManager) {
108         this.mdsalManager = mdsalManager;
109     }
110
111     public void setNotificationService(NotificationService notificationService) {
112         this.notificationService = notificationService;
113     }
114
115     @Override
116     public void onSessionInitiated(ProviderContext session) {
117         LOG.info("InterfacemgrProvider Session Initiated");
118         interfaceStatusMonitor.reportStatus("STARTING");
119         try {
120             dataBroker = session.getSALService(DataBroker.class);
121             idManager = rpcProviderRegistry.getRpcService(IdManagerService.class);
122             createIdPool();
123
124             alivenessManager = rpcProviderRegistry.getRpcService(AlivenessMonitorService.class);
125             interfaceManagerRpcService = new InterfaceManagerRpcService(dataBroker, mdsalManager);
126             rpcRegistration = getRpcProviderRegistry().addRpcImplementation(
127                     OdlInterfaceRpcService.class, interfaceManagerRpcService);
128
129             interfaceConfigListener = new InterfaceConfigListener(dataBroker, idManager,alivenessManager, mdsalManager);
130             interfaceConfigListener.registerListener(LogicalDatastoreType.CONFIGURATION, dataBroker);
131
132             interfaceInventoryStateListener = new InterfaceInventoryStateListener(dataBroker, idManager, mdsalManager, alivenessManager);
133             interfaceInventoryStateListener.registerListener(LogicalDatastoreType.OPERATIONAL, dataBroker);
134
135             topologyStateListener = new InterfaceTopologyStateListener(dataBroker);
136             topologyStateListener.registerListener(LogicalDatastoreType.OPERATIONAL, dataBroker);
137
138             hwVTEPTunnelsStateListener = new HwVTEPTunnelsStateListener(dataBroker);
139             hwVTEPTunnelsStateListener.registerListener(LogicalDatastoreType.OPERATIONAL,dataBroker);
140
141             //terminationPointStateListener = new TerminationPointStateListener(dataBroker);
142             //terminationPointStateListener.registerListener(LogicalDatastoreType.OPERATIONAL, dataBroker);
143
144             flowBasedServicesConfigListener = new FlowBasedServicesConfigListener(dataBroker);
145             flowBasedServicesConfigListener.registerListener(LogicalDatastoreType.CONFIGURATION, dataBroker);
146
147             flowBasedServicesInterfaceStateListener =
148                     new FlowBasedServicesInterfaceStateListener(dataBroker);
149             flowBasedServicesInterfaceStateListener.registerListener(LogicalDatastoreType.OPERATIONAL, dataBroker);
150
151             vlanMemberConfigListener =
152                     new VlanMemberConfigListener(dataBroker, idManager, alivenessManager,mdsalManager);
153             vlanMemberConfigListener.registerListener(LogicalDatastoreType.CONFIGURATION, dataBroker);
154
155             hwVTEPConfigListener = new HwVTEPConfigListener(dataBroker);
156             hwVTEPConfigListener.registerListener(LogicalDatastoreType.CONFIGURATION, dataBroker);
157
158             alivenessMonitorListener = new org.opendaylight.vpnservice.interfacemgr.listeners.AlivenessMonitorListener(dataBroker);
159             notificationService.registerNotificationListener(alivenessMonitorListener);
160
161             //Initialize nodeconnectorstatsimpl
162             nodeConnectorStatsManager = new NodeConnectorStatsImpl(dataBroker, notificationService,
163                     session.getRpcService(OpendaylightPortStatisticsService.class), session.getRpcService(OpendaylightFlowTableStatisticsService.class));
164
165
166             interfaceStatusMonitor.reportStatus("OPERATIONAL");
167         } catch (Exception e) {
168             LOG.error("Error initializing services", e);
169             interfaceStatusMonitor.reportStatus("ERROR");
170         }
171     }
172
173     private void createIdPool() {
174         CreateIdPoolInput createPool = new CreateIdPoolInputBuilder()
175                 .setPoolName(IfmConstants.IFM_IDPOOL_NAME)
176                 .setLow(IfmConstants.IFM_ID_POOL_START)
177                 .setHigh(IfmConstants.IFM_ID_POOL_END)
178                 .build();
179         //TODO: Error handling
180         Future<RpcResult<Void>> result = idManager.createIdPool(createPool);
181         try {
182             if ((result != null) && (result.get().isSuccessful())) {
183                 LOG.debug("Created IdPool for InterfaceMgr");
184             }
185         } catch (InterruptedException | ExecutionException e) {
186             LOG.error("Failed to create idPool for InterfaceMgr",e);
187         }
188     }
189
190     @Override
191     public void close() throws Exception {
192         LOG.info("InterfacemgrProvider Closed");
193         interfaceConfigListener.close();
194         rpcRegistration.close();
195     }
196
197     public RpcProviderRegistry getRpcProviderRegistry() {
198         return rpcProviderRegistry;
199     }
200
201     @Override
202     public Long getPortForInterface(String ifName) {
203         GetPortFromInterfaceInput input = new GetPortFromInterfaceInputBuilder().setIntfName(ifName).build();
204         Future<RpcResult<GetPortFromInterfaceOutput>> output = interfaceManagerRpcService.getPortFromInterface(input);
205         try {
206             RpcResult<GetPortFromInterfaceOutput> port = output.get();
207             if(port.isSuccessful()){
208                 return port.getResult().getPortno();
209             }
210         }catch(NullPointerException | InterruptedException | ExecutionException e){
211             LOG.warn("Exception when getting port for interface",e);
212         }
213         return null;
214     }
215
216     @Override
217     public Long getPortForInterface(Interface intf) {
218         GetPortFromInterfaceInput input = new GetPortFromInterfaceInputBuilder().setIntfName(intf.getName()).build();
219         Future<RpcResult<GetPortFromInterfaceOutput>> output = interfaceManagerRpcService.getPortFromInterface(input);
220         try {
221             RpcResult<GetPortFromInterfaceOutput> port = output.get();
222             if(port.isSuccessful()){
223                 return port.getResult().getPortno();
224             }
225         }catch(NullPointerException | InterruptedException | ExecutionException e){
226             LOG.warn("Exception when getting port for interface",e);
227         }
228         return null;
229     }
230
231     @Override
232     public InterfaceInfo getInterfaceInfo(String interfaceName) {
233         //FIXME [ELANBE] This is not working yet, fix this
234
235         org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface
236                 ifState = InterfaceManagerCommonUtils.getInterfaceStateFromOperDS(interfaceName,dataBroker);
237
238         if(ifState == null) {
239             LOG.error("Interface {} is not present", interfaceName);
240             return null;
241         }
242
243         Integer lportTag = ifState.getIfIndex();
244         Interface intf = InterfaceManagerCommonUtils.getInterfaceFromConfigDS(new InterfaceKey(interfaceName), dataBroker);
245         if (intf == null) {
246             LOG.error("Interface {} doesn't exist in config datastore", interfaceName);
247             return null;
248         }
249
250         NodeConnectorId ncId = IfmUtil.getNodeConnectorIdFromInterface(intf, dataBroker);
251         InterfaceInfo.InterfaceType interfaceType = IfmUtil.getInterfaceType(intf);
252         InterfaceInfo interfaceInfo = null;
253         BigInteger dpId = org.opendaylight.vpnservice.interfacemgr.globals.IfmConstants.INVALID_DPID;
254         Integer portNo = org.opendaylight.vpnservice.interfacemgr.globals.IfmConstants.INVALID_PORT_NO;
255         if (ncId !=null ) {
256             dpId = new BigInteger(IfmUtil.getDpnFromNodeConnectorId(ncId));
257             portNo = Integer.parseInt(IfmUtil.getPortNoFromNodeConnectorId(ncId));
258         }
259
260         if(interfaceType == InterfaceInfo.InterfaceType.VLAN_INTERFACE){
261             interfaceInfo = IfmUtil.getVlanInterfaceInfo(interfaceName, intf, dpId);
262         } else if (interfaceType == InterfaceInfo.InterfaceType.VXLAN_TRUNK_INTERFACE || interfaceType == InterfaceInfo.InterfaceType.GRE_TRUNK_INTERFACE) {/*
263             trunkInterfaceInfo trunkInterfaceInfo = (TrunkInterfaceInfo) ConfigIfmUtil.getTrunkInterfaceInfo(ifName, ConfigIfmUtil.getInterfaceByIfName(dataBroker, ifName));
264             String higherLayerIf = inf.getHigherLayerIf().get(0);
265             Interface vlanInterface = ConfigIfmUtil.getInterfaceByIfName(dataBroker, higherLayerIf);
266             trunkInterfaceInfo.setPortName(vlanInterface.getAugmentation(BaseConfig.class).getParentInterface());
267             trunkInterfaceManager.updateTargetMacAddressInInterfaceInfo(trunkInterfaceInfo, trunkInterface);
268             if (trunkInterface.getPhysAddress() != null) {
269                 trunkInterfaceInfo.setLocalMacAddress(trunkInterface.getPhysAddress().getValue());
270             }
271             interfaceInfo = trunkInterfaceInfo;
272             interfaceInfo.setL2domainGroupId(IfmUtil.getGroupId(OperationalIfmUtil.getInterfaceStateByIfName(dataBroker, higherLayerIf).getIfIndex(), InterfaceType.VLAN_INTERFACE));
273         */} else {
274             LOG.error("Type of Interface {} is unknown", interfaceName);
275             return null;
276         }
277         interfaceInfo.setDpId(dpId);
278         interfaceInfo.setPortNo(portNo);
279         interfaceInfo.setAdminState((intf.isEnabled() == true) ? InterfaceAdminState.ENABLED : InterfaceAdminState.DISABLED);
280         interfaceInfo.setInterfaceName(interfaceName);
281         interfaceInfo.setInterfaceTag(lportTag);
282         interfaceInfo.setInterfaceType(interfaceType);
283         interfaceInfo.setGroupId(IfmUtil.getGroupId(lportTag, interfaceType));
284         interfaceInfo.setOpState((ifState.getOperStatus() == OperStatus.Up) ? InterfaceInfo.InterfaceOpState.UP : InterfaceInfo.InterfaceOpState.DOWN);
285
286
287         return interfaceInfo;
288
289     }
290
291     @Override
292     public InterfaceInfo getInterfaceInfoFromOperationalDataStore(String interfaceName, InterfaceInfo.InterfaceType interfaceType) {
293         InterfaceInfo interfaceInfo = new InterfaceInfo(interfaceName);
294         org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState = InterfaceManagerCommonUtils
295                 .getInterfaceStateFromOperDS(interfaceName, dataBroker);
296         if (ifState == null) {
297             LOG.error("Interface {} is not present", interfaceName);
298             return null;
299         }
300         Integer lportTag = ifState.getIfIndex();
301         NodeConnectorId ncId = IfmUtil.getNodeConnectorIdFromInterface(ifState);
302         if (ncId != null) {
303             interfaceInfo.setDpId(new BigInteger(IfmUtil.getDpnFromNodeConnectorId(ncId)));
304             interfaceInfo.setPortNo(Integer.parseInt(IfmUtil.getPortNoFromNodeConnectorId(ncId)));
305         }
306         interfaceInfo.setAdminState((ifState.getAdminStatus() == AdminStatus.Up) ? InterfaceAdminState.ENABLED : InterfaceAdminState.DISABLED);
307         interfaceInfo.setInterfaceName(interfaceName);
308         interfaceInfo.setInterfaceTag(lportTag);
309         interfaceInfo.setInterfaceType(interfaceType);
310         interfaceInfo.setGroupId(IfmUtil.getGroupId(lportTag, interfaceType));
311         interfaceInfo.setOpState((ifState.getOperStatus() == OperStatus.Up) ? InterfaceInfo.InterfaceOpState.UP : InterfaceInfo.InterfaceOpState.DOWN);
312
313
314         return interfaceInfo;
315     }
316
317     @Override
318     public InterfaceInfo getInterfaceInfoFromOperationalDataStore(String interfaceName) {
319         org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState = InterfaceManagerCommonUtils
320                 .getInterfaceStateFromOperDS(interfaceName, dataBroker);
321         if (ifState == null) {
322             LOG.error("Interface {} is not present", interfaceName);
323             return null;
324         }
325         Integer lportTag = ifState.getIfIndex();
326         InterfaceInfo interfaceInfo = new InterfaceInfo(interfaceName);
327         NodeConnectorId ncId = IfmUtil.getNodeConnectorIdFromInterface(ifState);
328         if (ncId != null) {
329             interfaceInfo.setPortName(IfmUtil.getPortName(dataBroker, ncId));
330             interfaceInfo.setDpId(new BigInteger(IfmUtil.getDpnFromNodeConnectorId(ncId)));
331             interfaceInfo.setPortNo(Integer.parseInt(IfmUtil.getPortNoFromNodeConnectorId(ncId)));
332         }
333         interfaceInfo.setAdminState((ifState.getAdminStatus() == AdminStatus.Up) ? InterfaceAdminState.ENABLED : InterfaceAdminState.DISABLED);
334         interfaceInfo.setInterfaceName(interfaceName);
335         interfaceInfo.setInterfaceTag(lportTag);
336         interfaceInfo.setOpState((ifState.getOperStatus() == OperStatus.Up) ? InterfaceInfo.InterfaceOpState.UP : InterfaceInfo.InterfaceOpState.DOWN);
337         return interfaceInfo;
338     }
339
340     public void createVLANInterface(String interfaceName, String portName, BigInteger dpId,  Integer vlanId,
341                              String description, IfL2vlan.L2vlanMode l2vlanMode) {
342         LOG.info("Create VLAN interface : {}",interfaceName);
343         InstanceIdentifier<Interface> interfaceInstanceIdentifier = InterfaceManagerCommonUtils.
344                 getInterfaceIdentifier(new InterfaceKey(interfaceName));
345         IfL2vlanBuilder l2vlanBuilder = new IfL2vlanBuilder().setL2vlanMode(l2vlanMode);
346         if(vlanId > 0){
347             l2vlanBuilder.setVlanId(new VlanId(vlanId));
348         }
349         ParentRefs parentRefs = new ParentRefsBuilder().setParentInterface(portName).build();
350         Interface inf = new InterfaceBuilder().setEnabled(true).setName(interfaceName).setType(L2vlan.class).
351                 addAugmentation(IfL2vlan.class, l2vlanBuilder.build()).addAugmentation(ParentRefs.class, parentRefs).
352                 setDescription(description).build();
353         WriteTransaction t = dataBroker.newWriteOnlyTransaction();
354         t.put(LogicalDatastoreType.CONFIGURATION, interfaceInstanceIdentifier, inf, true);
355     }
356
357     public void bindService(String interfaceName, BoundServices serviceInfo){
358         LOG.info("Binding Service : {}",interfaceName);
359         WriteTransaction t = dataBroker.newWriteOnlyTransaction();
360         InstanceIdentifier<BoundServices> boundServicesInstanceIdentifier = InstanceIdentifier.builder(ServiceBindings.class).child(ServicesInfo.class, new ServicesInfoKey(interfaceName))
361                 .child(BoundServices.class, new BoundServicesKey(serviceInfo.getServicePriority())).build();
362        // List<BoundServices> services = (List<BoundServices>)serviceInfo.getBoundServices();
363         t.put(LogicalDatastoreType.CONFIGURATION, boundServicesInstanceIdentifier, serviceInfo, true);
364         t.submit();
365     }
366
367     public void unbindService(String interfaceName, BoundServices serviceInfo){
368         LOG.info("Unbinding Service  : {}",interfaceName);
369         WriteTransaction t = dataBroker.newWriteOnlyTransaction();
370         InstanceIdentifier<BoundServices> boundServicesInstanceIdentifier = InstanceIdentifier.builder(ServiceBindings.class).child(ServicesInfo.class, new ServicesInfoKey(interfaceName))
371                 .child(BoundServices.class, new BoundServicesKey(serviceInfo.getServicePriority())).build();
372         t.delete(LogicalDatastoreType.CONFIGURATION, boundServicesInstanceIdentifier);
373         t.submit();
374     }
375
376     @Override
377     public BigInteger getDpnForInterface(String ifName) {
378         GetDpidFromInterfaceInput input = new GetDpidFromInterfaceInputBuilder().setIntfName(ifName).build();
379         Future<RpcResult<GetDpidFromInterfaceOutput>> output = interfaceManagerRpcService.getDpidFromInterface(input);
380         try {
381             RpcResult<GetDpidFromInterfaceOutput> dpn = output.get();
382             if(dpn.isSuccessful()){
383                 return dpn.getResult().getDpid();
384             }
385         }catch(NullPointerException | InterruptedException | ExecutionException e){
386             LOG.warn("Exception when getting port for interface",e);
387         }
388         return null;
389     }
390
391     @Override
392     public String getEndpointIpForDpn(BigInteger dpnId) {
393         GetEndpointIpForDpnInput input = new GetEndpointIpForDpnInputBuilder().setDpid(dpnId).build();
394         Future<RpcResult<GetEndpointIpForDpnOutput>> output = interfaceManagerRpcService.getEndpointIpForDpn(input);
395         try {
396             RpcResult<GetEndpointIpForDpnOutput> ipForDpnOutputRpcResult = output.get();
397             if(ipForDpnOutputRpcResult.isSuccessful()){
398                 List<IpAddress> localIps = ipForDpnOutputRpcResult.getResult().getLocalIps();
399                 if(!localIps.isEmpty()) {
400                     return localIps.get(0).getIpv4Address().getValue();
401                 }
402             }
403         }catch(NullPointerException | InterruptedException | ExecutionException e){
404             LOG.warn("Exception when getting port for interface",e);
405         }
406         return null;
407     }
408
409     @Override
410     public List<ActionInfo> getInterfaceEgressActions(String ifName) {
411         return IfmUtil.getEgressActionInfosForInterface(ifName, 0, dataBroker);
412     }
413
414     @Override
415     public BigInteger getDpnForInterface(Interface intrf) {
416         return getDpnForInterface(intrf.getName());
417     }
418
419     @Override
420     public List<Interface> getVlanInterfaces() {
421         List<Interface> vlanList = new ArrayList<Interface>();
422         InstanceIdentifier<Interfaces> interfacesInstanceIdentifier =  InstanceIdentifier.builder(Interfaces.class).build();
423         Optional<Interfaces> interfacesOptional  = IfmUtil.read(LogicalDatastoreType.CONFIGURATION, interfacesInstanceIdentifier, dataBroker);
424         if (!interfacesOptional.isPresent()) {
425             return vlanList;
426         }
427         Interfaces interfaces = interfacesOptional.get();
428         List<Interface> interfacesList = interfaces.getInterface();
429         for (Interface iface : interfacesList) {
430             if (IfmUtil.getInterfaceType(iface) == InterfaceInfo.InterfaceType.VLAN_INTERFACE) {
431                 vlanList.add(iface);
432             }
433         }
434         return vlanList;
435     }
436
437     @Override
438     public List<Interface> getVxlanInterfaces() {
439         return InterfaceManagerCommonUtils.getAllTunnelInterfaces(dataBroker,
440                 InterfaceInfo.InterfaceType.VXLAN_TRUNK_INTERFACE);
441     }
442 }