*/
package org.opendaylight.netvirt.elan.utils;
-import java.math.BigInteger;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import javax.inject.Inject;
import javax.inject.Singleton;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
+import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.netvirt.elan.l2gw.utils.ElanL2GatewayUtils;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.ItmRpcService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.Uint64;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
* Vni to be stamped on the VxLAN Header.
* @return the external itm egress action
*/
- public List<Action> getExternalTunnelItmEgressAction(BigInteger srcDpnId, NodeId torNode, long vni) {
+ public List<Action> getExternalTunnelItmEgressAction(Uint64 srcDpnId, NodeId torNode, long vni) {
List<Action> result = Collections.emptyList();
GetExternalTunnelInterfaceNameInput input = new GetExternalTunnelInterfaceNameInputBuilder()
String tunnelIfaceName = tunnelInterfaceNameOutput.getInterfaceName();
LOG.debug("Received tunnelInterfaceName from getTunnelInterfaceName RPC {}", tunnelIfaceName);
- result = buildTunnelItmEgressActions(tunnelIfaceName, vni);
+ result = buildTunnelItmEgressActions(tunnelIfaceName, vni, false);
}
} catch (InterruptedException | ExecutionException e) {
- LOG.error("Error in RPC call getTunnelInterfaceName {}", e);
+ LOG.error("Error in RPC call getTunnelInterfaceName", e);
}
return result;
}
- public List<Action> getExternalTunnelItmEgressAction(BigInteger srcDpnId, String nexthopIP, long vni) {
+ public List<Action> getExternalTunnelItmEgressAction(Uint64 srcDpnId, String nexthopIP, long vni) {
List<Action> result = Collections.emptyList();
GetExternalTunnelInterfaceNameInput input = new GetExternalTunnelInterfaceNameInputBuilder()
String tunnelIfaceName = tunnelInterfaceNameOutput.getInterfaceName();
LOG.debug("Received tunnelInterfaceName from getTunnelInterfaceName RPC {}", tunnelIfaceName);
- result = buildTunnelItmEgressActions(tunnelIfaceName, vni);
+ result = buildTunnelItmEgressActions(tunnelIfaceName, vni, false);
}
} catch (InterruptedException | ExecutionException e) {
- LOG.error("Error in RPC call getTunnelInterfaceName {}", e);
+ LOG.error("Error in RPC call getTunnelInterfaceName", e);
}
return result;
* Tunnel key to be sent on the VxLAN header.
* @return the internal itm egress action
*/
- public List<Action> getInternalTunnelItmEgressAction(BigInteger sourceDpnId, BigInteger destinationDpnId, long
+ public List<Action> getInternalTunnelItmEgressAction(Uint64 sourceDpnId, Uint64 destinationDpnId, long
tunnelKey) {
List<Action> result = Collections.emptyList();
LOG.trace("In getInternalItmEgressAction Action source {}, destination {}, serviceTag/Vni {}", sourceDpnId,
GetTunnelInterfaceNameOutput tunnelInterfaceNameOutput = output.get().getResult();
String tunnelIfaceName = tunnelInterfaceNameOutput.getInterfaceName();
LOG.info("Received tunnelInterfaceName from getTunnelInterfaceName RPC {}", tunnelIfaceName);
- result = buildTunnelItmEgressActions(tunnelIfaceName, tunnelKey);
+ result = buildTunnelItmEgressActions(tunnelIfaceName, tunnelKey, true);
} else {
LOG.trace("Tunnel interface doesn't exist between srcDpId {} dstDpId {}", sourceDpnId,
destinationDpnId);
}
} catch (InterruptedException | ExecutionException e) {
- LOG.error("Error in RPC call getTunnelInterfaceName {}", e);
+ LOG.error("Error in RPC call getTunnelInterfaceName", e);
}
return result;
}
* the tunnel key
* @return the list
*/
- public List<Action> buildTunnelItmEgressActions(String tunnelIfaceName, Long tunnelKey) {
+ public List<Action> buildTunnelItmEgressActions(String tunnelIfaceName, Long tunnelKey, boolean ineternal) {
if (tunnelIfaceName != null && !tunnelIfaceName.isEmpty()) {
- return buildItmEgressActions(tunnelIfaceName, tunnelKey);
+ return buildItmEgressActions(tunnelIfaceName, tunnelKey, ineternal);
}
-
return Collections.emptyList();
}
* @return the external port itm egress actions
*/
public List<Action> getExternalPortItmEgressAction(String interfaceName) {
- return buildItmEgressActions(interfaceName, null);
+ return buildItmEgressActions(interfaceName, null, false);
}
/**
* @return the list
*/
@SuppressWarnings("checkstyle:IllegalCatch")
- public List<Action> buildItmEgressActions(String interfaceName, Long tunnelKey) {
+ public List<Action> buildItmEgressActions(String interfaceName, @Nullable Long tunnelKey, boolean internal) {
try {
- GetEgressActionsForInterfaceInput getEgressActInput = new GetEgressActionsForInterfaceInputBuilder()
- .setIntfName(interfaceName).setTunnelKey(tunnelKey).build();
-
- Future<RpcResult<GetEgressActionsForInterfaceOutput>> egressActionsOutputFuture = interfaceManagerRpcService
- .getEgressActionsForInterface(getEgressActInput);
-
- GetEgressActionsForTunnelInput getEgressActInputItm = new GetEgressActionsForTunnelInputBuilder()
- .setIntfName(interfaceName).setTunnelKey(tunnelKey).build();
-
- Future<RpcResult<GetEgressActionsForTunnelOutput>> egressActionsOutputItm =
- itmRpcService.getEgressActionsForTunnel(getEgressActInputItm);
- if (egressActionsOutputFuture.get().isSuccessful() && !interfaceManager.isItmDirectTunnelsEnabled()) {
- return egressActionsOutputFuture.get().getResult().getAction();
- } else if (egressActionsOutputItm.get().isSuccessful() && interfaceManager.isItmDirectTunnelsEnabled()) {
- return egressActionsOutputItm.get().getResult().getAction();
+ if (internal && interfaceManager.isItmDirectTunnelsEnabled()) {
+ GetEgressActionsForTunnelInput getEgressActInputItm = new GetEgressActionsForTunnelInputBuilder()
+ .setIntfName(interfaceName).setTunnelKey(tunnelKey).build();
+ Future<RpcResult<GetEgressActionsForTunnelOutput>> egressActionsOutputItm =
+ itmRpcService.getEgressActionsForTunnel(getEgressActInputItm);
+ if (egressActionsOutputItm.get().isSuccessful()) {
+ return new ArrayList<Action>(egressActionsOutputItm.get().getResult().getAction().values());
+ }
+ } else {
+ GetEgressActionsForInterfaceInput getEgressActInput = new GetEgressActionsForInterfaceInputBuilder()
+ .setIntfName(interfaceName).setTunnelKey(tunnelKey).build();
+ Future<RpcResult<GetEgressActionsForInterfaceOutput>> egressActionsOutputFuture =
+ interfaceManagerRpcService.getEgressActionsForInterface(getEgressActInput);
+ if (egressActionsOutputFuture.get().isSuccessful()) {
+ return new ArrayList<Action>(egressActionsOutputFuture.get().getResult().getAction().values());
+ }
}
} catch (Exception e) {
- LOG.error("Error in RPC call getEgressActionsForInterface {}", e);
+ LOG.error("Error in RPC call getEgressActionsForInterface", e);
}
LOG.warn("Could not build Egress actions for interface {} and tunnelId {}", interfaceName, tunnelKey);
return Collections.emptyList();
* the dst hw vtep node id
* @return the dpn tep ip
*/
- public IpAddress getSourceDpnTepIp(BigInteger srcDpnId,
+ public IpAddress getSourceDpnTepIp(Uint64 srcDpnId,
org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId dstHwVtepNodeId) {
IpAddress dpnTepIp = null;
- String tunnelInterfaceName = getExternalTunnelInterfaceName(String.valueOf(srcDpnId),
+ String tunnelInterfaceName = getExternalTunnelInterfaceName(srcDpnId.toString(),
dstHwVtepNodeId.getValue());
if (tunnelInterfaceName != null) {
Interface tunnelInterface =
ElanL2GatewayUtils.getInterfaceFromConfigDS(new InterfaceKey(tunnelInterfaceName), broker);
if (tunnelInterface != null) {
- dpnTepIp = tunnelInterface.getAugmentation(IfTunnel.class).getTunnelSource();
+ dpnTepIp = tunnelInterface.augmentation(IfTunnel.class).getTunnelSource();
} else {
LOG.warn("Tunnel interface not found for tunnelInterfaceName {}", tunnelInterfaceName);
}