use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.Result in project netvirt by opendaylight.
the class ElanItmUtils method getInternalTunnelItmEgressAction.
/**
* Builds the list of actions to be taken when sending the packet over an internal VxLAN tunnel interface, such
* as setting the serviceTag/segmentationID on the VNI field of the VxLAN header, setting the vlanId if it proceeds
* and output the packet over the right port.
*
* @param sourceDpnId
* Dpn where the tunnelInterface is located
* @param destinationDpnId
* Dpn where the packet must be sent to. It is used here in order
* to select the right tunnel interface.
* @param tunnelKey
* Tunnel key to be sent on the VxLAN header.
* @return the internal itm egress action
*/
public List<Action> getInternalTunnelItmEgressAction(BigInteger sourceDpnId, BigInteger destinationDpnId, long tunnelKey) {
List<Action> result = Collections.emptyList();
LOG.trace("In getInternalItmEgressAction Action source {}, destination {}, serviceTag/Vni {}", sourceDpnId, destinationDpnId, tunnelKey);
Class<? extends TunnelTypeBase> tunType = TunnelTypeVxlan.class;
GetTunnelInterfaceNameInput input = new GetTunnelInterfaceNameInputBuilder().setDestinationDpid(destinationDpnId).setSourceDpid(sourceDpnId).setTunnelType(tunType).build();
Future<RpcResult<GetTunnelInterfaceNameOutput>> output = itmRpcService.getTunnelInterfaceName(input);
try {
if (output.get().isSuccessful()) {
GetTunnelInterfaceNameOutput tunnelInterfaceNameOutput = output.get().getResult();
String tunnelIfaceName = tunnelInterfaceNameOutput.getInterfaceName();
LOG.info("Received tunnelInterfaceName from getTunnelInterfaceName RPC {}", tunnelIfaceName);
result = buildTunnelItmEgressActions(tunnelIfaceName, tunnelKey);
} 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);
}
return result;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.Result in project netvirt by opendaylight.
the class BaseVrfEntryHandler method addTunnelInterfaceActions.
protected void addTunnelInterfaceActions(AdjacencyResult adjacencyResult, long vpnId, VrfEntry vrfEntry, List<ActionInfo> actionInfos, String rd) {
Class<? extends TunnelTypeBase> tunnelType = VpnExtraRouteHelper.getTunnelType(nextHopManager.getInterfaceManager(), adjacencyResult.getInterfaceName());
if (tunnelType == null) {
LOG.debug("Tunnel type not found for vrfEntry {}", vrfEntry);
return;
}
// TODO - For now have added routePath into adjacencyResult so that we know for which
// routePath this result is built for. If this is not possible construct a map which does
// the same.
String nextHopIp = adjacencyResult.getNextHopIp();
java.util.Optional<Long> optionalLabel = FibUtil.getLabelForNextHop(vrfEntry, nextHopIp);
if (!optionalLabel.isPresent()) {
LOG.warn("NextHopIp {} not found in vrfEntry {}", nextHopIp, vrfEntry);
return;
}
long label = optionalLabel.get();
BigInteger tunnelId = null;
Prefixes prefixInfo = null;
// revisit
if (tunnelType.equals(TunnelTypeVxlan.class)) {
prefixInfo = fibUtil.getPrefixToInterface(vpnId, vrfEntry.getDestPrefix());
// For extra route, the prefixInfo is fetched from the primary adjacency
if (prefixInfo == null) {
prefixInfo = fibUtil.getPrefixToInterface(vpnId, adjacencyResult.getPrefix());
}
// Internet VPN VNI will be used as tun_id for NAT use-cases
if (Prefixes.PrefixCue.Nat.equals(prefixInfo.getPrefixCue())) {
if (vrfEntry.getL3vni() != null && vrfEntry.getL3vni() != 0) {
tunnelId = BigInteger.valueOf(vrfEntry.getL3vni());
}
} else {
if (fibUtil.enforceVxlanDatapathSemanticsforInternalRouterVpn(prefixInfo.getSubnetId(), vpnId, rd)) {
java.util.Optional<Long> optionalVni = fibUtil.getVniForVxlanNetwork(prefixInfo.getSubnetId());
if (!optionalVni.isPresent()) {
LOG.error("VNI not found for nexthop {} vrfEntry {} with subnetId {}", nextHopIp, vrfEntry, prefixInfo.getSubnetId());
return;
}
tunnelId = BigInteger.valueOf(optionalVni.get());
} else {
tunnelId = BigInteger.valueOf(label);
}
}
} else {
tunnelId = BigInteger.valueOf(label);
}
LOG.debug("adding set tunnel id action for label {}", label);
actionInfos.add(new ActionSetFieldTunnelId(tunnelId));
addRewriteDstMacAction(vpnId, vrfEntry, prefixInfo, actionInfos);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.Result in project netvirt by opendaylight.
the class VpnUtil method lockSubnet.
public static void lockSubnet(LockManagerService lockManager, String subnetId) {
TryLockInput input = new TryLockInputBuilder().setLockName(subnetId).setTime(3000L).setTimeUnit(TimeUnits.Milliseconds).build();
Future<RpcResult<Void>> result = lockManager.tryLock(input);
try {
if (result != null && result.get().isSuccessful()) {
LOG.debug("lockSubnet: Acquired lock for {}", subnetId);
} else {
LOG.error("Unable to get lock for subnet {}", subnetId);
throw new RuntimeException("Unable to get lock for subnet " + subnetId);
}
} catch (InterruptedException | ExecutionException e) {
LOG.error("Unable to get lock for subnet {}", subnetId, e);
throw new RuntimeException("Unable to get lock for subnet " + subnetId, e);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.Result in project netvirt by opendaylight.
the class VpnUtil method getDpnsOnVpn.
@Nonnull
public static List<BigInteger> getDpnsOnVpn(DataBroker dataBroker, String vpnInstanceName) {
List<BigInteger> result = new ArrayList<>();
String rd = getVpnRd(dataBroker, vpnInstanceName);
if (rd == null) {
LOG.debug("getDpnsOnVpn: Could not find Route-Distinguisher for VpnName={}", vpnInstanceName);
return result;
}
VpnInstanceOpDataEntry vpnInstanceOpData = getVpnInstanceOpData(dataBroker, rd);
if (vpnInstanceOpData == null) {
LOG.debug("getDpnsOnVpn: Could not find OpState for VpnName={}", vpnInstanceName);
return result;
}
List<VpnToDpnList> vpnToDpnList = vpnInstanceOpData.getVpnToDpnList();
if (vpnToDpnList == null) {
LOG.debug("getDpnsOnVpn: Could not find DPN footprint for VpnName={}", vpnInstanceName);
return result;
}
for (VpnToDpnList vpnToDpn : vpnToDpnList) {
result.add(vpnToDpn.getDpnId());
}
return result;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.Result in project netvirt by opendaylight.
the class DhcpPktHandler method getEgressAction.
private List<Action> getEgressAction(String interfaceName, BigInteger tunnelId) {
List<Action> actions = null;
try {
GetEgressActionsForInterfaceInputBuilder egressAction = new GetEgressActionsForInterfaceInputBuilder().setIntfName(interfaceName);
if (tunnelId != null) {
egressAction.setTunnelKey(tunnelId.longValue());
}
Future<RpcResult<GetEgressActionsForInterfaceOutput>> result = interfaceManagerRpc.getEgressActionsForInterface(egressAction.build());
RpcResult<GetEgressActionsForInterfaceOutput> rpcResult = result.get();
if (!rpcResult.isSuccessful()) {
LOG.warn("RPC Call to Get egress actions for interface {} returned with Errors {}", interfaceName, rpcResult.getErrors());
} else {
actions = rpcResult.getResult().getAction();
}
} catch (InterruptedException | ExecutionException e) {
LOG.warn("Exception when egress actions for interface {}", interfaceName, e);
}
return actions;
}
Aggregations