use of org.opendaylight.mdsal.binding.util.Datastore.Operational in project netvirt by opendaylight.
the class ElanInstanceManager method update.
@Override
public void update(InstanceIdentifier<ElanInstance> identifier, ElanInstance original, ElanInstance update) {
EVENT_LOGGER.debug("ELAN-Instance, UPDATE {}", original.getElanInstanceName());
Uint32 existingElanTag = original.getElanTag();
String elanName = update.getElanInstanceName();
if (existingElanTag == null || !existingElanTag.equals(update.getElanTag())) {
if (update.getElanTag() == null || update.getElanTag().longValue() == 0L) {
// update the elan-Instance with new properties
LoggingFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(OPERATIONAL, operTx -> LoggingFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, confTx -> ElanUtils.updateOperationalDataStore(idManager, update, new ArrayList<>(), confTx, operTx)), LOG, "Error updating ELAN tag in ELAN instance for config " + "transaction")), LOG, "Error updating ELAN tag in ELAN instance for operational transaction");
} else {
jobCoordinator.enqueueJob(elanName, () -> elanInterfaceManager.handleunprocessedElanInterfaces(update), ElanConstants.JOB_MAX_RETRIES);
}
}
}
use of org.opendaylight.mdsal.binding.util.Datastore.Operational in project netvirt by opendaylight.
the class AclServiceUtils method deleteAclPortsLookup.
public void deleteAclPortsLookup(AclInterface port, List<Uuid> aclList, List<AllowedAddressPairs> allowedAddresses) {
String portId = port.getInterfaceId();
LOG.trace("Deleting AclPortsLookup for port={}, acls={}, AAPs={}", portId, aclList, allowedAddresses);
if (aclList == null || allowedAddresses == null || allowedAddresses.isEmpty()) {
LOG.warn("aclList or allowedAddresses is null. port={}, acls={}, AAPs={}", portId, aclList, allowedAddresses);
return;
}
for (Uuid aclId : aclList) {
String aclName = aclId.getValue();
jobCoordinator.enqueueJob(aclName, () -> {
List<ListenableFuture<?>> futures = new ArrayList<>();
futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(OPERATIONAL, tx -> {
for (AllowedAddressPairs aap : allowedAddresses) {
InstanceIdentifier<PortIds> path = AclServiceUtils.getPortIdsPathInAclPortsLookup(aclName, aap.getIpAddress(), portId);
tx.delete(path);
}
cleanUpStaleEntriesInAclPortsLookup(aclName, tx);
}));
return futures;
});
}
}
use of org.opendaylight.mdsal.binding.util.Datastore.Operational in project netvirt by opendaylight.
the class NexthopManager method removeDcGwLoadBalancingGroup.
/**
* This method is invoked when the neighbor is removed from DS.
* All the LB groups which point to the given destination will be deleted.
*/
public void removeDcGwLoadBalancingGroup(Uint64 dpnId, String destinationIp) {
jobCoordinator.enqueueJob(FibHelper.getJobKeyForDcGwLoadBalancingGroup(dpnId), () -> {
List<String> availableDcGws = fibUtil.getL3VpnDcGateWays();
if (availableDcGws.contains(destinationIp)) {
availableDcGws.remove(destinationIp);
}
List<ListenableFuture<?>> futures = new ArrayList<>();
futures.add(txRunner.callWithNewReadWriteTransactionAndSubmit(OPERATIONAL, operationalTx -> {
futures.add(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, configTx -> {
availableDcGws.forEach(dcGwIp -> {
List<String> dcGws = Arrays.asList(dcGwIp, destinationIp);
Collections.sort(dcGws);
String nextHopKey = FibUtil.getGreLbGroupKey(dcGws);
Optional<Nexthops> optionalNextHops = fibUtil.getNexthops(nextHopKey);
if (!optionalNextHops.isPresent()) {
return;
}
Nexthops nexthops = optionalNextHops.get();
final String groupId = nexthops.getGroupId();
final long groupIdValue = Long.parseLong(groupId);
Group group = MDSALUtil.buildGroup(groupIdValue, nextHopKey, GroupTypes.GroupSelect, MDSALUtil.buildBucketLists(Collections.emptyList()));
LOG.trace("Removed LB group {} on dpn {}", group, dpnId);
try {
mdsalApiManager.removeGroup(configTx, dpnId, group);
} catch (ExecutionException | InterruptedException e) {
LOG.error("Group removal failed for group {} with exception", groupId, e);
}
removeNextHopPointer(nextHopKey);
FibUtil.removeOrUpdateNextHopInfo(dpnId, nextHopKey, groupId, nexthops, operationalTx);
});
synchronized (getDcGateWaySyncKey(destinationIp)) {
FibUtil.removeL3vpnDcGateWay(destinationIp, operationalTx);
}
}));
}));
return futures;
}, RETRY_COUNT);
}
use of org.opendaylight.mdsal.binding.util.Datastore.Operational in project netvirt by opendaylight.
the class NexthopManager method createDcGwLoadBalancingGroup.
public void createDcGwLoadBalancingGroup(Uint64 dpnId, String destinationIp, Class<? extends TunnelTypeBase> tunnelType) {
jobCoordinator.enqueueJob(FibHelper.getJobKeyForDcGwLoadBalancingGroup(dpnId), () -> {
List<ListenableFuture<?>> futures = new ArrayList<>();
futures.add(txRunner.callWithNewReadWriteTransactionAndSubmit(OPERATIONAL, operationalTx -> {
synchronized (getDcGateWaySyncKey(destinationIp)) {
FibUtil.addL3vpnDcGateWay(destinationIp, operationalTx);
}
futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, configTx -> {
List<String> availableDcGws = getDcGwIps();
requireNonNull(availableDcGws, "There are no dc-gws present");
int noOfDcGws = availableDcGws.size();
if (noOfDcGws == 1) {
LOG.trace("There are no enough DC GateWays {} present to program LB group", availableDcGws);
return;
}
if (availableDcGws.contains(destinationIp)) {
availableDcGws.remove(destinationIp);
}
availableDcGws.forEach(dcGwIp -> {
List<String> dcGws = Arrays.asList(dcGwIp, destinationIp);
Collections.sort(dcGws);
String groupIdKey = FibUtil.getGreLbGroupKey(dcGws);
Long groupId = createNextHopPointer(groupIdKey);
List<Bucket> listBucket = new ArrayList<>();
for (int index = 0; index < dcGws.size(); index++) {
if (isTunnelUp(dcGws.get(index), dpnId, tunnelType)) {
listBucket.add(buildBucketForDcGwLbGroup(dcGws.get(index), dpnId, index, tunnelType, true));
}
}
Group group = MDSALUtil.buildGroup(groupId, groupIdKey, GroupTypes.GroupSelect, MDSALUtil.buildBucketLists(listBucket));
mdsalApiManager.addGroup(configTx, dpnId, group);
FibUtil.updateLbGroupInfo(dpnId, groupIdKey, groupId.toString(), operationalTx);
LOG.trace("LB group {} towards DC-GW installed on dpn {}. Group - {}", groupIdKey, dpnId, group);
});
}));
}));
return futures;
}, RETRY_COUNT);
}
use of org.opendaylight.mdsal.binding.util.Datastore.Operational in project netvirt by opendaylight.
the class VrfEntryListener method handleAdjacencyAndVpnOpInterfaceDeletion.
/**
* Check all the adjacency in VpnInterfaceOpData and decide whether to delete the entire interface or only adj.
* Remove Adjacency from VPNInterfaceOpData.
* if Adjacency != primary.
* if Adjacency == primary , then mark it for deletion.
* Remove entire VPNinterfaceOpData Entry.
* if sie of Adjacency <= 2 and all are marked for deletion , delete the entire VPNinterface Op entry.
* @param vrfEntry - VrfEntry removed
* @param ifName - Interface name from VRFentry
* @param vpnName - VPN name of corresponding VRF
* @param tx - ReadWrite Tx
*/
@SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "https://github.com/spotbugs/spotbugs/issues/811")
private void handleAdjacencyAndVpnOpInterfaceDeletion(VrfEntry vrfEntry, String ifName, String vpnName, TypedReadWriteTransaction<Operational> tx) throws ExecutionException, InterruptedException {
InstanceIdentifier<Adjacency> adjacencyIid = FibUtil.getAdjacencyIdentifierOp(ifName, vpnName, vrfEntry.getDestPrefix());
Optional<Adjacency> adjacencyOptional = tx.read(adjacencyIid).get();
if (adjacencyOptional.isPresent()) {
if (adjacencyOptional.get().getAdjacencyType() != Adjacency.AdjacencyType.PrimaryAdjacency) {
tx.delete(FibUtil.getAdjacencyIdentifierOp(ifName, vpnName, vrfEntry.getDestPrefix()));
} else {
tx.merge(adjacencyIid, new AdjacencyBuilder(adjacencyOptional.get()).setMarkedForDeletion(true).build());
}
}
Optional<AdjacenciesOp> optAdjacencies = tx.read(FibUtil.getAdjListPathOp(ifName, vpnName)).get();
if (!optAdjacencies.isPresent() || optAdjacencies.get().getAdjacency() == null) {
return;
}
@NonNull List<Adjacency> adjacencies = new ArrayList<Adjacency>(optAdjacencies.get().nonnullAdjacency().values());
if (adjacencies.size() <= 2 && adjacencies.stream().allMatch(adjacency -> adjacency.getAdjacencyType() == Adjacency.AdjacencyType.PrimaryAdjacency && adjacency.isMarkedForDeletion() != null && adjacency.isMarkedForDeletion())) {
LOG.info("Clean up vpn interface {} to vpn {} list.", ifName, vpnName);
tx.delete(FibUtil.getVpnInterfaceOpDataEntryIdentifier(ifName, vpnName));
}
}
Aggregations