use of org.opendaylight.controller.md.sal.common.api.data.ReadFailedException in project bgpcep by opendaylight.
the class NodeChangedListener method updateTransaction.
private void updateTransaction(final ReadWriteTransaction trans, final Set<InstanceIdentifier<ReportedLsp>> lsps, final Map<InstanceIdentifier<?>, ? extends DataObject> old, final Map<InstanceIdentifier<?>, DataObject> updated, final Map<InstanceIdentifier<?>, DataObject> created) {
for (final InstanceIdentifier<ReportedLsp> i : lsps) {
final ReportedLsp oldValue = (ReportedLsp) old.get(i);
ReportedLsp newValue = (ReportedLsp) updated.get(i);
if (newValue == null) {
newValue = (ReportedLsp) created.get(i);
}
LOG.debug("Updating lsp {} value {} -> {}", i, oldValue, newValue);
if (oldValue != null) {
try {
remove(trans, i, oldValue);
} catch (final ReadFailedException e) {
LOG.warn("Failed to remove LSP {}", i, e);
}
}
if (newValue != null) {
try {
create(trans, i, newValue);
} catch (final ReadFailedException e) {
LOG.warn("Failed to add LSP {}", i, e);
}
}
}
}
use of org.opendaylight.controller.md.sal.common.api.data.ReadFailedException in project netvirt by opendaylight.
the class ElanL2GatewayMulticastUtils method getRemoteBCGroupBucketsOfElanExternalTeps.
public List<Bucket> getRemoteBCGroupBucketsOfElanExternalTeps(ElanInstance elanInfo, BigInteger dpnId, int bucketId) {
ElanInstance operElanInstance = null;
try {
operElanInstance = new SingleTransactionDataBroker(broker).syncReadOptional(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.builder(ElanInstances.class).child(ElanInstance.class, elanInfo.getKey()).build()).orNull();
} catch (ReadFailedException e) {
LOG.error("Failed to read elan instance operational path {}", elanInfo, e);
return emptyList();
}
if (operElanInstance == null) {
return emptyList();
}
List<ExternalTeps> teps = operElanInstance.getExternalTeps();
if (teps == null || teps.isEmpty()) {
return emptyList();
}
List<Bucket> listBucketInfo = new ArrayList<>();
for (ExternalTeps tep : teps) {
String externalTep = tep.getNodeid() != null ? tep.getNodeid() : tep.getTepIp().toString();
String interfaceName = elanItmUtils.getExternalTunnelInterfaceName(String.valueOf(dpnId), externalTep);
if (interfaceName == null) {
LOG.error("Could not get interface name to ext tunnel {} {}", dpnId, tep.getTepIp());
continue;
}
List<Action> listActionInfo = elanItmUtils.buildTunnelItmEgressActions(interfaceName, elanUtils.getVxlanSegmentationId(elanInfo));
listBucketInfo.add(MDSALUtil.buildBucket(listActionInfo, MDSALUtil.GROUP_WEIGHT, bucketId, MDSALUtil.WATCH_PORT, MDSALUtil.WATCH_GROUP));
bucketId++;
}
return listBucketInfo;
}
use of org.opendaylight.controller.md.sal.common.api.data.ReadFailedException in project netvirt by opendaylight.
the class TransportZoneNotificationUtil method updateTransportZone.
@SuppressWarnings("checkstyle:IllegalCatch")
private void updateTransportZone(String zoneName, BigInteger dpnId, @Nullable String localIp, @Nonnull ReadWriteTransaction tx) throws ReadFailedException {
InstanceIdentifier<TransportZone> inst = InstanceIdentifier.create(TransportZones.class).child(TransportZone.class, new TransportZoneKey(zoneName));
// FIXME: Read this through a cache
TransportZone zone = tx.read(LogicalDatastoreType.CONFIGURATION, inst).checkedGet().orNull();
if (zone == null) {
zone = createZone(ALL_SUBNETS, zoneName);
}
try {
if (addVtep(zone, ALL_SUBNETS, dpnId, localIp)) {
updateTransportZone(zone, dpnId, tx);
}
} catch (Exception e) {
LOG.error("Failed to add tunnels for dpn {} in zone {}", dpnId, zoneName, e);
}
}
use of org.opendaylight.controller.md.sal.common.api.data.ReadFailedException in project netvirt by opendaylight.
the class TransportZoneNotificationUtil method deleteTransportZone.
@SuppressWarnings("checkstyle:IllegalCatch")
private void deleteTransportZone(String zoneName, BigInteger dpnId, @Nonnull ReadWriteTransaction tx) throws ReadFailedException {
InstanceIdentifier<TransportZone> inst = InstanceIdentifier.create(TransportZones.class).child(TransportZone.class, new TransportZoneKey(zoneName));
// FIXME: Read this through a cache
TransportZone zone = tx.read(LogicalDatastoreType.CONFIGURATION, inst).checkedGet().orNull();
if (zone != null) {
try {
deleteTransportZone(zone, dpnId, tx);
} catch (Exception e) {
LOG.error("Failed to remove tunnels for dpn {} in zone {}", dpnId, zoneName, e);
}
}
}
use of org.opendaylight.controller.md.sal.common.api.data.ReadFailedException in project netvirt by opendaylight.
the class HwvtepPhysicalSwitchListener method added.
@Override
protected void added(InstanceIdentifier<PhysicalSwitchAugmentation> identifier, final PhysicalSwitchAugmentation phySwitchAdded) {
String globalNodeId = getManagedByNodeId(identifier);
final InstanceIdentifier<Node> globalNodeIid = getManagedByNodeIid(identifier);
NodeId nodeId = getNodeId(identifier);
if (TUNNEL_IP_NOT_AVAILABLE.test(phySwitchAdded)) {
LOG.error("Could not find the /tunnel ips for node {}", nodeId.getValue());
return;
}
final String psName = getPsName(identifier);
LOG.trace("Received physical switch {} added event received for node {}", psName, nodeId.getValue());
haOpClusteredListener.runAfterNodeIsConnected(globalNodeIid, (node) -> {
LOG.trace("Running job for node {} ", globalNodeIid);
if (!node.isPresent()) {
LOG.error("Global node is absent {}", globalNodeId);
return;
}
HAOpClusteredListener.addToCacheIfHAChildNode(globalNodeIid, node.get());
if (hwvtepHACache.isHAEnabledDevice(globalNodeIid)) {
LOG.trace("Ha enabled device {}", globalNodeIid);
return;
}
LOG.trace("Updating cache for node {}", globalNodeIid);
L2GatewayDevice l2GwDevice = l2GatewayCache.get(psName);
if (childConnectedAfterParent.test(l2GwDevice, globalNodeIid)) {
LOG.trace("Device {} {} is already Connected by {}", psName, globalNodeId, l2GwDevice.getHwvtepNodeId());
return;
}
InstanceIdentifier<Node> existingIid = globalNodeIid;
if (l2GwDevice != null && l2GwDevice.getHwvtepNodeId() != null) {
existingIid = HwvtepHAUtil.convertToInstanceIdentifier(l2GwDevice.getHwvtepNodeId());
}
if (parentConnectedAfterChild.test(l2GwDevice, globalNodeIid) && alreadyHasL2Gwids.test(l2GwDevice)) {
LOG.error("Child node {} having l2gw configured became ha node " + " removing the l2device {} from all elan cache and provision parent node {}", existingIid, psName, globalNodeIid);
ElanL2GwCacheUtils.removeL2GatewayDeviceFromAllElanCache(l2GwDevice.getHwvtepNodeId());
}
l2GwDevice = l2GatewayCache.addOrGet(psName);
l2GwDevice.setConnected(true);
l2GwDevice.setHwvtepNodeId(globalNodeId);
List<TunnelIps> tunnelIps = phySwitchAdded.getTunnelIps();
if (tunnelIps != null) {
for (TunnelIps tunnelIp : tunnelIps) {
IpAddress tunnelIpAddr = tunnelIp.getTunnelIpsKey();
l2GwDevice.addTunnelIp(tunnelIpAddr);
}
}
handleAdd(l2GwDevice);
elanClusterUtils.runOnlyInOwnerNode("Update config tunnels IP ", () -> {
try {
updateConfigTunnelIp(identifier, phySwitchAdded);
} catch (ReadFailedException e) {
LOG.error("Failed to update tunnel ips {}", identifier);
}
});
return;
});
}
Aggregations