2 * Copyright (c) 2015 - 2016 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.interfacemgr;
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;
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;
77 public class InterfacemgrProvider implements BindingAwareProvider, AutoCloseable, IInterfaceManager {
79 private static final Logger LOG = LoggerFactory.getLogger(InterfacemgrProvider.class);
80 private static final InterfaceStatusMonitor interfaceStatusMonitor = InterfaceStatusMonitor.getInstance();
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;
102 public void setRpcProviderRegistry(RpcProviderRegistry rpcProviderRegistry) {
103 this.rpcProviderRegistry = rpcProviderRegistry;
104 interfaceStatusMonitor.registerMbean();
107 public void setMdsalManager(IMdsalApiManager mdsalManager) {
108 this.mdsalManager = mdsalManager;
111 public void setNotificationService(NotificationService notificationService) {
112 this.notificationService = notificationService;
116 public void onSessionInitiated(ProviderContext session) {
117 LOG.info("InterfacemgrProvider Session Initiated");
118 interfaceStatusMonitor.reportStatus("STARTING");
120 dataBroker = session.getSALService(DataBroker.class);
121 idManager = rpcProviderRegistry.getRpcService(IdManagerService.class);
124 alivenessManager = rpcProviderRegistry.getRpcService(AlivenessMonitorService.class);
125 interfaceManagerRpcService = new InterfaceManagerRpcService(dataBroker, mdsalManager);
126 rpcRegistration = getRpcProviderRegistry().addRpcImplementation(
127 OdlInterfaceRpcService.class, interfaceManagerRpcService);
129 interfaceConfigListener = new InterfaceConfigListener(dataBroker, idManager,alivenessManager, mdsalManager);
130 interfaceConfigListener.registerListener(LogicalDatastoreType.CONFIGURATION, dataBroker);
132 interfaceInventoryStateListener = new InterfaceInventoryStateListener(dataBroker, idManager, mdsalManager, alivenessManager);
133 interfaceInventoryStateListener.registerListener(LogicalDatastoreType.OPERATIONAL, dataBroker);
135 topologyStateListener = new InterfaceTopologyStateListener(dataBroker);
136 topologyStateListener.registerListener(LogicalDatastoreType.OPERATIONAL, dataBroker);
138 hwVTEPTunnelsStateListener = new HwVTEPTunnelsStateListener(dataBroker);
139 hwVTEPTunnelsStateListener.registerListener(LogicalDatastoreType.OPERATIONAL,dataBroker);
141 terminationPointStateListener = new TerminationPointStateListener(dataBroker);
142 terminationPointStateListener.registerListener(LogicalDatastoreType.OPERATIONAL, dataBroker);
144 flowBasedServicesConfigListener = new FlowBasedServicesConfigListener(dataBroker);
145 flowBasedServicesConfigListener.registerListener(LogicalDatastoreType.CONFIGURATION, dataBroker);
147 flowBasedServicesInterfaceStateListener =
148 new FlowBasedServicesInterfaceStateListener(dataBroker);
149 flowBasedServicesInterfaceStateListener.registerListener(LogicalDatastoreType.OPERATIONAL, dataBroker);
151 vlanMemberConfigListener =
152 new VlanMemberConfigListener(dataBroker, idManager, alivenessManager,mdsalManager);
153 vlanMemberConfigListener.registerListener(LogicalDatastoreType.CONFIGURATION, dataBroker);
155 hwVTEPConfigListener = new HwVTEPConfigListener(dataBroker);
156 hwVTEPConfigListener.registerListener(LogicalDatastoreType.CONFIGURATION, dataBroker);
158 alivenessMonitorListener = new org.opendaylight.vpnservice.interfacemgr.listeners.AlivenessMonitorListener(dataBroker);
159 notificationService.registerNotificationListener(alivenessMonitorListener);
161 //Initialize nodeconnectorstatsimpl
162 nodeConnectorStatsManager = new NodeConnectorStatsImpl(dataBroker, notificationService,
163 session.getRpcService(OpendaylightPortStatisticsService.class), session.getRpcService(OpendaylightFlowTableStatisticsService.class));
166 interfaceStatusMonitor.reportStatus("OPERATIONAL");
167 } catch (Exception e) {
168 LOG.error("Error initializing services", e);
169 interfaceStatusMonitor.reportStatus("ERROR");
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)
179 //TODO: Error handling
180 Future<RpcResult<Void>> result = idManager.createIdPool(createPool);
182 if ((result != null) && (result.get().isSuccessful())) {
183 LOG.debug("Created IdPool for InterfaceMgr");
185 } catch (InterruptedException | ExecutionException e) {
186 LOG.error("Failed to create idPool for InterfaceMgr",e);
191 public void close() throws Exception {
192 LOG.info("InterfacemgrProvider Closed");
193 interfaceConfigListener.close();
194 rpcRegistration.close();
197 public RpcProviderRegistry getRpcProviderRegistry() {
198 return rpcProviderRegistry;
202 public Long getPortForInterface(String ifName) {
203 GetPortFromInterfaceInput input = new GetPortFromInterfaceInputBuilder().setIntfName(ifName).build();
204 Future<RpcResult<GetPortFromInterfaceOutput>> output = interfaceManagerRpcService.getPortFromInterface(input);
206 RpcResult<GetPortFromInterfaceOutput> port = output.get();
207 if(port.isSuccessful()){
208 return port.getResult().getPortno();
210 }catch(NullPointerException | InterruptedException | ExecutionException e){
211 LOG.warn("Exception when getting port for interface",e);
217 public Long getPortForInterface(Interface intf) {
218 GetPortFromInterfaceInput input = new GetPortFromInterfaceInputBuilder().setIntfName(intf.getName()).build();
219 Future<RpcResult<GetPortFromInterfaceOutput>> output = interfaceManagerRpcService.getPortFromInterface(input);
221 RpcResult<GetPortFromInterfaceOutput> port = output.get();
222 if(port.isSuccessful()){
223 return port.getResult().getPortno();
225 }catch(NullPointerException | InterruptedException | ExecutionException e){
226 LOG.warn("Exception when getting port for interface",e);
232 public InterfaceInfo getInterfaceInfo(String interfaceName) {
233 //FIXME [ELANBE] This is not working yet, fix this
235 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface
236 ifState = InterfaceManagerCommonUtils.getInterfaceStateFromOperDS(interfaceName,dataBroker);
238 if(ifState == null) {
239 LOG.error("Interface {} is not present", interfaceName);
243 Integer lportTag = ifState.getIfIndex();
244 Interface intf = InterfaceManagerCommonUtils.getInterfaceFromConfigDS(new InterfaceKey(interfaceName), dataBroker);
246 LOG.error("Interface {} doesn't exist in config datastore", interfaceName);
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;
256 dpId = new BigInteger(IfmUtil.getDpnFromNodeConnectorId(ncId));
257 portNo = Integer.parseInt(IfmUtil.getPortNoFromNodeConnectorId(ncId));
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());
271 interfaceInfo = trunkInterfaceInfo;
272 interfaceInfo.setL2domainGroupId(IfmUtil.getGroupId(OperationalIfmUtil.getInterfaceStateByIfName(dataBroker, higherLayerIf).getIfIndex(), InterfaceType.VLAN_INTERFACE));
274 LOG.error("Type of Interface {} is unknown", interfaceName);
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);
287 return interfaceInfo;
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);
300 Integer lportTag = ifState.getIfIndex();
301 NodeConnectorId ncId = IfmUtil.getNodeConnectorIdFromInterface(ifState);
303 interfaceInfo.setDpId(new BigInteger(IfmUtil.getDpnFromNodeConnectorId(ncId)));
304 interfaceInfo.setPortNo(Integer.parseInt(IfmUtil.getPortNoFromNodeConnectorId(ncId)));
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);
314 return interfaceInfo;
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);
325 Integer lportTag = ifState.getIfIndex();
326 InterfaceInfo interfaceInfo = new InterfaceInfo(interfaceName);
327 NodeConnectorId ncId = IfmUtil.getNodeConnectorIdFromInterface(ifState);
329 interfaceInfo.setPortName(IfmUtil.getPortName(dataBroker, ncId));
330 interfaceInfo.setDpId(new BigInteger(IfmUtil.getDpnFromNodeConnectorId(ncId)));
331 interfaceInfo.setPortNo(Integer.parseInt(IfmUtil.getPortNoFromNodeConnectorId(ncId)));
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;
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);
347 l2vlanBuilder.setVlanId(new VlanId(vlanId));
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);
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);
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);
377 public BigInteger getDpnForInterface(String ifName) {
378 GetDpidFromInterfaceInput input = new GetDpidFromInterfaceInputBuilder().setIntfName(ifName).build();
379 Future<RpcResult<GetDpidFromInterfaceOutput>> output = interfaceManagerRpcService.getDpidFromInterface(input);
381 RpcResult<GetDpidFromInterfaceOutput> dpn = output.get();
382 if(dpn.isSuccessful()){
383 return dpn.getResult().getDpid();
385 }catch(NullPointerException | InterruptedException | ExecutionException e){
386 LOG.warn("Exception when getting port for interface",e);
392 public String getEndpointIpForDpn(BigInteger dpnId) {
393 GetEndpointIpForDpnInput input = new GetEndpointIpForDpnInputBuilder().setDpid(dpnId).build();
394 Future<RpcResult<GetEndpointIpForDpnOutput>> output = interfaceManagerRpcService.getEndpointIpForDpn(input);
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();
403 }catch(NullPointerException | InterruptedException | ExecutionException e){
404 LOG.warn("Exception when getting port for interface",e);
410 public List<ActionInfo> getInterfaceEgressActions(String ifName) {
411 return IfmUtil.getEgressActionInfosForInterface(ifName, 0, dataBroker);
415 public BigInteger getDpnForInterface(Interface intrf) {
416 return getDpnForInterface(intrf.getName());
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()) {
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) {
438 public List<Interface> getVxlanInterfaces() {
439 return InterfaceManagerCommonUtils.getAllTunnelInterfaces(dataBroker,
440 InterfaceInfo.InterfaceType.VXLAN_TRUNK_INTERFACE);