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