use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.Identifier in project netvirt by opendaylight.
the class SubnetRouteInterfaceStateChangeListener method remove.
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
@Override
public void remove(InstanceIdentifier<Interface> identifier, Interface intrf) {
if (L2vlan.class.equals(intrf.getType())) {
LOG.trace("SubnetRouteInterfaceListener remove: Received interface {} down event", intrf);
List<Uuid> subnetIdList = getSubnetId(intrf);
if (subnetIdList.isEmpty()) {
LOG.trace("SubnetRouteInterfaceListener remove: Port {} doesn't exist in configDS", intrf.getName());
return;
}
LOG.trace("{} remove: Processing interface {} down event in ", LOGGING_PREFIX, intrf.getName());
for (Uuid subnetId : subnetIdList) {
jobCoordinator.enqueueJob("SUBNETROUTE-" + subnetId, () -> {
List<ListenableFuture<Void>> futures = new ArrayList<>();
try {
String interfaceName = intrf.getName();
Uint64 dpnId = Uint64.ZERO;
LOG.info("{} remove: Received port DOWN event for interface {} in subnet {} ", LOGGING_PREFIX, interfaceName, subnetId);
try {
dpnId = InterfaceUtils.getDpIdFromInterface(intrf);
} catch (Exception e) {
LOG.error("{} remove: Unable to retrieve dpnId for interface {} in subnet {}. " + "Fetching from vpn interface itself", LOGGING_PREFIX, intrf.getName(), subnetId, e);
}
InstanceIdentifier<VpnInterface> id = VpnUtil.getVpnInterfaceIdentifier(interfaceName);
Optional<VpnInterface> cfgVpnInterface = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, id);
if (!cfgVpnInterface.isPresent()) {
return futures;
}
boolean interfaceDownEligible = false;
for (VpnInstanceNames vpnInterfaceVpnInstance : cfgVpnInterface.get().nonnullVpnInstanceNames().values()) {
String vpnName = vpnInterfaceVpnInstance.getVpnName();
InstanceIdentifier<VpnInterfaceOpDataEntry> idOper = VpnUtil.getVpnInterfaceOpDataEntryIdentifier(interfaceName, vpnName);
Optional<VpnInterfaceOpDataEntry> optVpnInterface = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.OPERATIONAL, idOper);
if (optVpnInterface.isPresent()) {
Uint64 dpnIdLocal = dpnId;
if (Uint64.ZERO.equals(dpnIdLocal)) {
dpnIdLocal = optVpnInterface.get().getDpnId();
}
if (!Uint64.ZERO.equals(dpnIdLocal)) {
interfaceDownEligible = true;
break;
}
}
}
if (interfaceDownEligible) {
vpnSubnetRouteHandler.onInterfaceDown(dpnId, intrf.getName(), subnetId);
}
LOG.info("{} remove: Processed interface {} down event in ", LOGGING_PREFIX, intrf.getName());
} catch (InterruptedException | ExecutionException e) {
LOG.error("{} remove: Failed to read data store for {}", LOGGING_PREFIX, intrf.getName());
}
return futures;
});
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.Identifier in project netvirt by opendaylight.
the class SubnetmapChangeListener method add.
@Override
public void add(InstanceIdentifier<Subnetmap> identifier, Subnetmap subnetmap) {
LOG.debug("add: subnetmap method - key: {}, value: {}", identifier, subnetmap);
Uuid subnetId = subnetmap.getId();
Network network = vpnUtil.getNeutronNetwork(subnetmap.getNetworkId());
if (network == null) {
LOG.error("add: network was not found for subnetId {}", subnetId.getValue());
return;
}
if (subnetmap.getVpnId() != null) {
if (NetworkType.VLAN.equals(subnetmap.getNetworkType())) {
vpnUtil.addRouterPortToElanDpnListForVlaninAllDpn(subnetmap.getVpnId().getValue());
}
}
if (VpnUtil.getIsExternal(network)) {
LOG.debug("SubnetmapListener:add: provider subnetwork {} is handling in " + "ExternalSubnetVpnInstanceListener", subnetId.getValue());
return;
}
jobCoordinator.enqueueJob("SUBNETROUTE-" + subnetId, () -> {
String elanInstanceName = subnetmap.getNetworkId().getValue();
long elanTag = getElanTag(elanInstanceName);
if (elanTag == 0L) {
LOG.error("add: unable to fetch elantag from ElanInstance {} for subnet {}", elanInstanceName, subnetId.getValue());
return Collections.emptyList();
}
Uuid vpnId = subnetmap.getVpnId();
if (vpnId != null) {
boolean isBgpVpn = !vpnId.equals(subnetmap.getRouterId());
LOG.info("add: subnetmap {} with elanTag {} to VPN {}", subnetmap, elanTag, vpnId);
vpnSubnetRouteHandler.onSubnetAddedToVpn(subnetmap, isBgpVpn, elanTag);
if (isBgpVpn && subnetmap.getRouterId() == null) {
Set<VpnTarget> routeTargets = vpnManager.getRtListForVpn(vpnId.getValue());
if (!routeTargets.isEmpty()) {
// FIXME: separate this out somehow?
final ReentrantLock lock = JvmGlobalLocks.getLockForString(subnetmap.getSubnetIp());
lock.lock();
try {
vpnManager.updateRouteTargetsToSubnetAssociation(routeTargets, subnetmap.getSubnetIp(), vpnId.getValue());
} finally {
lock.unlock();
}
}
}
}
return Collections.emptyList();
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.Identifier in project netvirt by opendaylight.
the class TunnelInterfaceStateListener method add.
@Override
public 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());
}
boolean isTunnelUp = TunnelOperStatus.Up == add.getOperState();
if (isGreTunnel(add)) {
programDcGwLoadBalancingGroup(add, NwConstants.ADD_FLOW, isTunnelUp);
}
LOG.info("add: ITM Tunnel ,type {} ,added between src: {} and dest: {}", fibManager.getTransportTypeStr(add.getTransportType() != null ? add.getTransportType().toString() : "Invalid"), add.getSrcInfo() != null ? add.getSrcInfo().getTepDeviceId() : "0", add.getDstInfo() != null ? add.getDstInfo().getTepDeviceId() : "0");
handleTunnelEventForDPN(add, TunnelAction.TUNNEL_EP_ADD);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.Identifier in project netvirt by opendaylight.
the class TunnelInterfaceStateListener method update.
@Override
public 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;
}
boolean isTunnelUp = TunnelOperStatus.Up == update.getOperState();
if (isGreTunnel(update)) {
programDcGwLoadBalancingGroup(update, NwConstants.MOD_FLOW, isTunnelUp);
}
// Remove the corresponding nexthop from the routepath under extraroute in fibentries.
Uint64 srcDpnId = Uint64.valueOf(update.getSrcInfo().getTepDeviceId()).intern();
String srcTepIp = update.getSrcInfo().getTepIp().stringValue();
List<VpnInstanceOpDataEntry> vpnInstanceOpData = vpnUtil.getAllVpnInstanceOpData();
if (vpnInstanceOpData == null) {
LOG.trace("update: No vpnInstanceOpdata present");
return;
}
vpnInstanceOpData.stream().filter(opData -> opData.getVpnToDpnList() != null && opData.getVpnToDpnList().values().stream().anyMatch(vpnToDpn -> Objects.equals(vpnToDpn.getDpnId(), srcDpnId))).forEach(opData -> {
List<DestPrefixes> prefixes = VpnExtraRouteHelper.getExtraRouteDestPrefixes(dataBroker, opData.getVpnId());
prefixes.forEach(destPrefix -> {
VrfEntry vrfEntry = vpnUtil.getVrfEntry(opData.getVrfId(), destPrefix.getDestPrefix());
if (vrfEntry == null || vrfEntry.getRoutePaths() == null) {
return;
}
List<RoutePaths> routePaths = new ArrayList<RoutePaths>(vrfEntry.getRoutePaths().values());
routePaths.forEach(routePath -> {
if (Objects.equals(routePath.getNexthopAddress(), srcTepIp)) {
String prefix = destPrefix.getDestPrefix();
String vpnPrefixKey = VpnUtil.getVpnNamePrefixKey(opData.getVpnInstanceName(), prefix);
// FIXME: separate out to somehow?
final ReentrantLock lock = JvmGlobalLocks.getLockForString(vpnPrefixKey);
lock.lock();
try {
fibManager.refreshVrfEntry(opData.getVrfId(), prefix);
} finally {
lock.unlock();
}
}
});
});
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.Identifier in project netvirt by opendaylight.
the class VpnInterfaceManager method remove.
@Override
public void remove(InstanceIdentifier<VpnInterface> identifier, VpnInterface vpnInterface) {
LOG.trace("Received VpnInterface remove event: vpnInterface={}", vpnInterface);
final VpnInterfaceKey key = identifier.firstKeyOf(VpnInterface.class);
final String interfaceName = key.getName();
for (VpnInstanceNames vpnInterfaceVpnInstance : vpnInterface.nonnullVpnInstanceNames().values()) {
String vpnName = vpnInterfaceVpnInstance.getVpnName();
removeVpnInterfaceCall(identifier, vpnInterface, vpnName, interfaceName);
}
}
Aggregations