use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Tunnel in project netvirt by opendaylight.
the class ElanTunnelInterfaceStateListener method add.
@Override
protected void add(InstanceIdentifier<StateTunnelList> key, StateTunnelList add) {
LOG.info("processing add state for StateTunnelList {}", add);
if (!isInternalTunnel(add)) {
LOG.trace("tunnel {} is not a internal vxlan tunnel", add);
return;
}
if (elanUtils.isTunnelInLogicalGroup(add.getTunnelInterfaceName())) {
LOG.trace("MULTIPLE_VxLAN_TUNNELS: ignoring the tunnel event for {}", add.getTunnelInterfaceName());
return;
}
TunnelOperStatus tunOpStatus = add.getOperState();
if (tunOpStatus != TunnelOperStatus.Down && tunOpStatus != TunnelOperStatus.Up) {
LOG.trace("Returning because unsupported tunnelOperStatus {}", tunOpStatus);
return;
}
jobCoordinator.enqueueJob(add.getTunnelInterfaceName(), () -> {
BigInteger srcDpId = new BigInteger(add.getSrcInfo().getTepDeviceId());
BigInteger dstDpId = new BigInteger(add.getDstInfo().getTepDeviceId());
LOG.info("Handling tunnel state event for srcDpId {} and dstDpId {} ", srcDpId, dstDpId);
elanInterfaceManager.handleInternalTunnelStateEvent(srcDpId, dstDpId);
return Collections.emptyList();
}, ElanConstants.JOB_MAX_RETRIES);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Tunnel in project netvirt by opendaylight.
the class TunnelEndPointChangeListener method add.
@Override
protected void add(InstanceIdentifier<TunnelEndPoints> key, TunnelEndPoints tep) {
BigInteger dpnId = key.firstIdentifierOf(DPNTEPsInfo.class).firstKeyOf(DPNTEPsInfo.class).getDPNID();
if (BigInteger.ZERO.equals(dpnId)) {
LOG.warn("add: Invalid DPN id for TEP {}", tep.getInterfaceName());
return;
}
List<VpnInstance> vpnInstances = VpnHelper.getAllVpnInstances(broker);
if (vpnInstances == null || vpnInstances.isEmpty()) {
LOG.warn("add: dpnId: {}: tep: {}: No VPN instances defined", dpnId, tep.getInterfaceName());
return;
}
for (VpnInstance vpnInstance : vpnInstances) {
final String vpnName = vpnInstance.getVpnInstanceName();
final long vpnId = VpnUtil.getVpnId(broker, vpnName);
LOG.info("add: Handling TEP {} add for VPN instance {}", tep.getInterfaceName(), vpnName);
final String primaryRd = VpnUtil.getPrimaryRd(broker, vpnName);
if (!VpnUtil.isVpnPendingDelete(broker, primaryRd)) {
List<VpnInterfaces> vpnInterfaces = VpnUtil.getDpnVpnInterfaces(broker, vpnInstance, dpnId);
if (vpnInterfaces != null) {
for (VpnInterfaces vpnInterface : vpnInterfaces) {
String vpnInterfaceName = vpnInterface.getInterfaceName();
jobCoordinator.enqueueJob("VPNINTERFACE-" + vpnInterfaceName, () -> {
final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface interfaceState = InterfaceUtils.getInterfaceStateFromOperDS(broker, vpnInterfaceName);
if (interfaceState == null) {
LOG.debug("add: Cannot retrieve interfaceState for vpnInterfaceName {}, " + "cannot generate lPortTag and process adjacencies", vpnInterfaceName);
return Collections.emptyList();
}
final int lPortTag = interfaceState.getIfIndex();
List<ListenableFuture<Void>> futures = new ArrayList<>();
futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(writeConfigTxn -> futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(writeOperTxn -> futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(writeInvTxn -> vpnInterfaceManager.processVpnInterfaceAdjacencies(dpnId, lPortTag, vpnName, primaryRd, vpnInterfaceName, vpnId, writeConfigTxn, writeOperTxn, writeInvTxn, interfaceState)))))));
LOG.trace("add: Handled TEP {} add for VPN instance {} VPN interface {}", tep.getInterfaceName(), vpnName, vpnInterfaceName);
return futures;
});
}
}
} else {
LOG.error("add: Ignoring addition of tunnel interface {} dpn {} for vpnInstance {} with primaryRd {}," + " as the VPN is already marked for deletion", tep.getInterfaceName(), dpnId, vpnName, primaryRd);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Tunnel in project netvirt by opendaylight.
the class TunnelInterfaceStateListener method add.
@Override
protected void add(InstanceIdentifier<StateTunnelList> identifier, StateTunnelList add) {
LOG.trace("add: Tunnel addition---- {}", add);
TunnelOperStatus tunOpStatus = add.getOperState();
if (tunOpStatus != TunnelOperStatus.Down && tunOpStatus != TunnelOperStatus.Up) {
LOG.info("add: Returning from unsupported tunnelOperStatus {} for tunnel interface {}", tunOpStatus, add.getTunnelInterfaceName());
return;
}
if (tunOpStatus != TunnelOperStatus.Up) {
LOG.error("add: Tunnel {} is not yet UP.", add.getTunnelInterfaceName());
}
if (isGreTunnel(add)) {
programDcGwLoadBalancingGroup(add, NwConstants.ADD_FLOW);
}
LOG.info("add: ITM Tunnel ,type {} ,added between src: {} and dest: {}", fibManager.getTransportTypeStr(add.getTransportType().toString()), add.getSrcInfo().getTepDeviceId(), add.getDstInfo().getTepDeviceId());
handleTunnelEventForDPN(add, TunnelAction.TUNNEL_EP_ADD);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Tunnel in project netvirt by opendaylight.
the class TunnelInterfaceStateListener method update.
@Override
protected void update(InstanceIdentifier<StateTunnelList> identifier, StateTunnelList original, StateTunnelList update) {
LOG.trace("update: Tunnel updation---- {}", update);
LOG.info("update: ITM Tunnel {} of type {} state event changed from :{} to :{}", update.getTunnelInterfaceName(), fibManager.getTransportTypeStr(update.getTransportType().toString()), original.getOperState(), update.getOperState());
TunnelOperStatus tunOpStatus = update.getOperState();
if (tunOpStatus != TunnelOperStatus.Down && tunOpStatus != TunnelOperStatus.Up) {
LOG.info("update: Returning from unsupported tunnelOperStatus {} for tunnel interface {}", tunOpStatus, update.getTunnelInterfaceName());
return;
}
if (isGreTunnel(update)) {
programDcGwLoadBalancingGroup(update, NwConstants.MOD_FLOW);
}
// Remove the corresponding nexthop from the routepath under extraroute in fibentries.
BigInteger srcDpnId = new BigInteger(update.getSrcInfo().getTepDeviceId());
String srcTepIp = String.valueOf(update.getSrcInfo().getTepIp().getValue());
List<VpnInstanceOpDataEntry> vpnInstanceOpData = VpnUtil.getAllVpnInstanceOpData(dataBroker);
if (vpnInstanceOpData == null) {
LOG.trace("update: No vpnInstanceOpdata present");
return;
}
WriteTransaction writeConfigTxn = dataBroker.newWriteOnlyTransaction();
if (tunOpStatus == TunnelOperStatus.Up) {
handleTunnelEventForDPN(update, TunnelAction.TUNNEL_EP_ADD);
} else {
vpnInstanceOpData.stream().filter(opData -> {
if (opData.getVpnToDpnList() == null) {
return false;
}
return opData.getVpnToDpnList().stream().anyMatch(vpnToDpn -> vpnToDpn.getDpnId().equals(srcDpnId));
}).forEach(opData -> {
List<DestPrefixes> prefixes = VpnExtraRouteHelper.getExtraRouteDestPrefixes(dataBroker, opData.getVpnId());
prefixes.forEach(destPrefix -> {
VrfEntry vrfEntry = VpnUtil.getVrfEntry(dataBroker, opData.getVrfId(), destPrefix.getDestPrefix());
if (vrfEntry == null || vrfEntry.getRoutePaths() == null) {
return;
}
List<RoutePaths> routePaths = vrfEntry.getRoutePaths();
routePaths.forEach(routePath -> {
if (routePath.getNexthopAddress().equals(srcTepIp)) {
fibManager.updateRoutePathForFibEntry(opData.getVrfId(), destPrefix.getDestPrefix(), srcTepIp, routePath.getLabel(), false, writeConfigTxn);
}
});
});
});
}
writeConfigTxn.submit();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Tunnel in project netvirt by opendaylight.
the class VpnExtraRouteHelper method getTunnelType.
public static Class<? extends TunnelTypeBase> getTunnelType(OdlInterfaceRpcService interfaceManager, String ifName) {
try {
Future<RpcResult<GetTunnelTypeOutput>> result = interfaceManager.getTunnelType(new GetTunnelTypeInputBuilder().setIntfName(ifName).build());
RpcResult<GetTunnelTypeOutput> rpcResult = result.get();
if (!rpcResult.isSuccessful()) {
LOG.warn("RPC Call to getTunnelInterfaceId returned with Errors {}", rpcResult.getErrors());
} else {
return rpcResult.getResult().getTunnelType();
}
} catch (InterruptedException | ExecutionException e) {
LOG.warn("Exception when getting tunnel interface Id for tunnel type", e);
}
return null;
}
Aggregations