use of org.opendaylight.controller.md.sal.common.api.data.ReadFailedException in project netvirt by opendaylight.
the class BgpConfigurationManager method getConfig.
public Bgp getConfig() {
AtomicInteger bgpDSretryCount = new AtomicInteger(DS_RETRY_COUNT);
while (0 != bgpDSretryCount.decrementAndGet()) {
try {
return SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.create(Bgp.class)).orNull();
} catch (ReadFailedException e) {
// Config DS may not be up, so sleep for 1 second and retry
LOG.debug("failed to get bgp config, may be DS is yet in consistent state(?)", e);
try {
Thread.sleep(WAIT_TIME_BETWEEN_EACH_TRY_MILLIS);
} catch (InterruptedException timerEx) {
LOG.debug("WAIT_TIME_BETWEEN_EACH_TRY_MILLIS, Timer got interrupted while waiting for" + "config DS availability", timerEx);
}
}
}
LOG.error("failed to get bgp config");
return null;
}
use of org.opendaylight.controller.md.sal.common.api.data.ReadFailedException in project netvirt by opendaylight.
the class FibDSWriter method removeOrUpdateFibEntryFromDS.
public synchronized void removeOrUpdateFibEntryFromDS(String rd, String prefix, String nextHop) {
if (rd == null || rd.isEmpty()) {
LOG.error("Prefix {} not associated with vpn", prefix);
return;
}
LOG.debug("Removing fib entry with destination prefix {} from vrf table for rd {} and nextHop {}", prefix, rd, nextHop);
try {
InstanceIdentifier<VrfEntry> vrfEntryId = InstanceIdentifier.builder(FibEntries.class).child(VrfTables.class, new VrfTablesKey(rd)).child(VrfEntry.class, new VrfEntryKey(prefix)).build();
Optional<VrfEntry> existingVrfEntry = singleTxDB.syncReadOptional(LogicalDatastoreType.CONFIGURATION, vrfEntryId);
List<RoutePaths> routePaths = existingVrfEntry.toJavaUtil().map(VrfEntry::getRoutePaths).orElse(Collections.emptyList());
if (routePaths.size() == 1) {
if (routePaths.get(0).getNexthopAddress().equals(nextHop)) {
bgpUtil.delete(vrfEntryId);
}
} else {
routePaths.stream().map(RoutePaths::getNexthopAddress).filter(nextHopAddress -> nextHopAddress.equals(nextHop)).findFirst().ifPresent(nh -> {
InstanceIdentifier<RoutePaths> routePathId = FibHelper.buildRoutePathId(rd, prefix, nextHop);
bgpUtil.delete(routePathId);
});
}
} catch (ReadFailedException e) {
LOG.error("Error while reading vrfEntry for rd {}, prefix {}", rd, prefix);
return;
}
}
use of org.opendaylight.controller.md.sal.common.api.data.ReadFailedException in project netvirt by opendaylight.
the class FibDSWriter method removeVrfSubFamilyFromDS.
public synchronized void removeVrfSubFamilyFromDS(String rd, AddressFamily addressFamily) {
if (rd == null) {
return;
}
LOG.debug("removeVrfSubFamilyFromDS : addressFamily {} from vrf rd {}", addressFamily, rd);
InstanceIdentifier<VrfTables> id = InstanceIdentifier.create(FibEntries.class).child(VrfTables.class, new VrfTablesKey(rd));
try {
VrfTables vrfTable = singleTxDB.syncRead(LogicalDatastoreType.CONFIGURATION, id);
if (vrfTable != null) {
List<VrfEntry> vrfEntries = vrfTable.getVrfEntry();
if (vrfEntries == null) {
LOG.error("removeVrfSubFamilyFromDS : VrfEntry not found for rd {}", rd);
return;
}
for (VrfEntry vrfEntry : vrfEntries) {
boolean found = false;
if (vrfEntry.getEncapType() != null) {
if (!vrfEntry.getEncapType().equals(EncapType.Mplsgre) && addressFamily == AddressFamily.L2VPN) {
found = true;
} else if (vrfEntry.getEncapType().equals(EncapType.Mplsgre)) {
if (addressFamily == AddressFamily.IPV4 && FibHelper.isIpv4Prefix(vrfEntry.getDestPrefix())) {
found = true;
} else if (addressFamily == AddressFamily.IPV6 && FibHelper.isIpv6Prefix(vrfEntry.getDestPrefix())) {
found = true;
}
}
}
if (found == false) {
continue;
}
bgpUtil.removeVrfEntry(rd, vrfEntry);
}
}
} catch (ReadFailedException rfe) {
LOG.error("removeVrfSubFamilyFromDS : Internal Error rd {}", rd, rfe);
}
return;
}
use of org.opendaylight.controller.md.sal.common.api.data.ReadFailedException in project netvirt by opendaylight.
the class DhcpPktHandler method handleDhcpAllocationPoolPacket.
private DhcpInfo handleDhcpAllocationPoolPacket(byte msgType, String interfaceName, String macAddress) {
try {
String networkId = dhcpAllocationPoolMgr.getNetworkByPort(interfaceName);
AllocationPool pool = networkId != null ? dhcpAllocationPoolMgr.getAllocationPoolByNetwork(networkId) : null;
if (networkId == null || pool == null) {
LOG.warn("No Dhcp Allocation Pool was found for interface: {}", interfaceName);
return null;
}
switch(msgType) {
case DHCPConstants.MSG_DISCOVER:
case DHCPConstants.MSG_REQUEST:
// FIXME: requested ip is currently ignored in moment of allocation
return getDhcpInfoFromAllocationPool(networkId, pool, macAddress);
case DHCPConstants.MSG_RELEASE:
dhcpAllocationPoolMgr.releaseIpAllocation(networkId, pool, macAddress);
break;
default:
break;
}
} catch (ReadFailedException e) {
LOG.error("Error reading from MD-SAL", e);
}
return null;
}
use of org.opendaylight.controller.md.sal.common.api.data.ReadFailedException in project netvirt by opendaylight.
the class DhcpExternalTunnelManager method createRemoteMcastMac.
public RemoteMcastMacs createRemoteMcastMac(Node dstDevice, String logicalSwitchName, IpAddress internalTunnelIp) {
Set<LocatorSet> locators = new HashSet<>();
TerminationPointKey terminationPointKey = HwvtepSouthboundUtils.getTerminationPointKey(internalTunnelIp.getIpv4Address().getValue());
HwvtepPhysicalLocatorRef phyLocRef = new HwvtepPhysicalLocatorRef(HwvtepSouthboundUtils.createInstanceIdentifier(dstDevice.getNodeId()).child(TerminationPoint.class, terminationPointKey));
locators.add(new LocatorSetBuilder().setLocatorRef(phyLocRef).build());
HwvtepLogicalSwitchRef lsRef = new HwvtepLogicalSwitchRef(HwvtepSouthboundUtils.createLogicalSwitchesInstanceIdentifier(dstDevice.getNodeId(), new HwvtepNodeName(logicalSwitchName)));
RemoteMcastMacs remoteMcastMacs = new RemoteMcastMacsBuilder().setMacEntryKey(new MacAddress(UNKNOWN_DMAC)).setLogicalSwitchRef(lsRef).build();
InstanceIdentifier<RemoteMcastMacs> iid = HwvtepSouthboundUtils.createRemoteMcastMacsInstanceIdentifier(dstDevice.getNodeId(), remoteMcastMacs.getKey());
ReadOnlyTransaction transaction = broker.newReadOnlyTransaction();
try {
// TODO do async mdsal read
remoteMcastMacs = transaction.read(LogicalDatastoreType.CONFIGURATION, iid).checkedGet().get();
locators.addAll(remoteMcastMacs.getLocatorSet());
return new RemoteMcastMacsBuilder(remoteMcastMacs).setLocatorSet(new ArrayList<>(locators)).build();
} catch (ReadFailedException e) {
LOG.error("Failed to read the macs {}", iid);
}
return null;
}
Aggregations