use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.TunnelOperStatus 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.genius.itm.op.rev160406.TunnelOperStatus 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.genius.itm.op.rev160406.TunnelOperStatus 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.genius.itm.op.rev160406.TunnelOperStatus in project genius by opendaylight.
the class ItmTunnelEventListener method update.
@Override
public void update(@Nonnull InstanceIdentifier<StateTunnelList> instanceIdentifier, @Nonnull StateTunnelList originalTunnelList, @Nonnull StateTunnelList updatedTunnelList) {
LOG.trace("Tunnel Interface updated. Old: {} New: {}", originalTunnelList, updatedTunnelList);
TunnelOperStatus operStatus = updatedTunnelList.getOperState();
if (!Objects.equals(originalTunnelList.getOperState(), updatedTunnelList.getOperState())) {
LOG.debug("Tunnel Interface {} changed state to {}", originalTunnelList.getTunnelInterfaceName(), operStatus);
ItmTunnelUpdateAlarmWorker itmTunnelUpdateAlarmWorker = new ItmTunnelUpdateAlarmWorker(originalTunnelList, updatedTunnelList);
jobCoordinator.enqueueJob(ITMConstants.ITM_ALARM, itmTunnelUpdateAlarmWorker);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.TunnelOperStatus in project genius by opendaylight.
the class ItmUtils method buildStateTunnelList.
public static StateTunnelList buildStateTunnelList(StateTunnelListKey tlKey, String name, boolean state, TunnelOperStatus tunOpStatus, IInterfaceManager ifaceManager, DataBroker broker) {
StateTunnelListBuilder stlBuilder = new StateTunnelListBuilder();
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface iface = ItmUtils.getInterface(name, ifaceManager);
IfTunnel ifTunnel = iface.getAugmentation(IfTunnel.class);
ParentRefs parentRefs = iface.getAugmentation(ParentRefs.class);
if (ifTunnel == null || parentRefs == null) {
return null;
}
DstInfoBuilder dstInfoBuilder = new DstInfoBuilder();
SrcInfoBuilder srcInfoBuilder = new SrcInfoBuilder();
dstInfoBuilder.setTepIp(ifTunnel.getTunnelDestination());
srcInfoBuilder.setTepIp(ifTunnel.getTunnelSource());
// TODO: Add/Improve logic for device type
InternalTunnel internalTunnel = ItmUtils.ITM_CACHE.getInternalTunnel(name);
ExternalTunnel externalTunnel = ItmUtils.ITM_CACHE.getExternalTunnel(name);
if (internalTunnel == null && externalTunnel == null) {
// both not present in cache. let us update and try again.
ItmUtils.updateTunnelsCache(broker);
internalTunnel = ItmUtils.ITM_CACHE.getInternalTunnel(name);
externalTunnel = ItmUtils.ITM_CACHE.getExternalTunnel(name);
}
if (internalTunnel != null) {
srcInfoBuilder.setTepDeviceId(internalTunnel.getSourceDPN().toString()).setTepDeviceType(TepTypeInternal.class);
dstInfoBuilder.setTepDeviceId(internalTunnel.getDestinationDPN().toString()).setTepDeviceType(TepTypeInternal.class);
stlBuilder.setTransportType(internalTunnel.getTransportType());
} else if (externalTunnel != null) {
ExternalTunnel tunnel = ItmUtils.ITM_CACHE.getExternalTunnel(name);
srcInfoBuilder.setTepDeviceId(tunnel.getSourceDevice()).setTepDeviceType(getDeviceType(tunnel.getSourceDevice()));
dstInfoBuilder.setTepDeviceId(tunnel.getDestinationDevice()).setTepDeviceType(getDeviceType(tunnel.getDestinationDevice())).setTepIp(ifTunnel.getTunnelDestination());
stlBuilder.setTransportType(tunnel.getTransportType());
}
stlBuilder.setKey(tlKey).setTunnelInterfaceName(name).setOperState(tunOpStatus).setTunnelState(state).setDstInfo(dstInfoBuilder.build()).setSrcInfo(srcInfoBuilder.build());
return stlBuilder.build();
}
Aggregations