use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.dpid.l3vpn.lb.nexthops.DpnLbNexthops in project netvirt by opendaylight.
the class NexthopManager method removeOrUpdateDcGwLoadBalancingGroup.
/**
* This method is invoked when the tunnel state is removed from DS.
* If the there is just one DC-GW left in configuration then the LB groups can be deleted.
* Otherwise, the groups are just updated.
*/
public void removeOrUpdateDcGwLoadBalancingGroup(List<String> availableDcGws, BigInteger dpnId, String destinationIp) {
Preconditions.checkNotNull(availableDcGws, "There are no dc-gws present");
WriteTransaction configTx = dataBroker.newWriteOnlyTransaction();
WriteTransaction operationalTx = dataBroker.newWriteOnlyTransaction();
int noOfDcGws = availableDcGws.size();
// If availableDcGws does not contain the destination Ip it means this is a configuration delete.
if (!availableDcGws.contains(destinationIp)) {
availableDcGws.add(destinationIp);
Collections.sort(availableDcGws);
}
// TODO : Place the logic to construct all possible DC-GW combination here.
int bucketId = availableDcGws.indexOf(destinationIp);
Optional<DpnLbNexthops> dpnLbNextHops = fibUtil.getDpnLbNexthops(dpnId, destinationIp);
if (!dpnLbNextHops.isPresent()) {
return;
}
List<String> nextHopKeys = dpnLbNextHops.get().getNexthopKey();
nextHopKeys.forEach(nextHopKey -> {
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);
if (noOfDcGws > 1) {
mdsalApiManager.removeBucketToTx(dpnId, groupIdValue, bucketId, configTx);
} else {
Group group = MDSALUtil.buildGroup(groupIdValue, nextHopKey, GroupTypes.GroupSelect, MDSALUtil.buildBucketLists(Collections.emptyList()));
LOG.trace("Removed LB group {} on dpn {}", group, dpnId);
mdsalApiManager.removeGroupToTx(dpnId, group, configTx);
removeNextHopPointer(nextHopKey);
}
// When the DC-GW is removed from configuration.
if (noOfDcGws != availableDcGws.size()) {
FibUtil.removeOrUpdateNextHopInfo(dpnId, nextHopKey, groupId, nexthops, operationalTx);
}
});
FibUtil.removeDpnIdToNextHopInfo(destinationIp, dpnId, operationalTx);
configTx.submit();
operationalTx.submit();
return;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.dpid.l3vpn.lb.nexthops.DpnLbNexthops in project netvirt by opendaylight.
the class FibUtil method updateLbGroupInfo.
public static void updateLbGroupInfo(BigInteger dpnId, String destinationIp, String groupIdKey, String groupId, WriteTransaction tx) {
InstanceIdentifier<DpnLbNexthops> id = getDpnLbNexthopsIdentifier(dpnId, destinationIp);
DpnLbNexthops dpnToLbNextHop = buildDpnLbNextHops(dpnId, destinationIp, groupIdKey);
tx.merge(LogicalDatastoreType.OPERATIONAL, id, dpnToLbNextHop);
InstanceIdentifier<Nexthops> nextHopsId = getNextHopsIdentifier(groupIdKey);
Nexthops nextHopsToGroupId = buildNextHops(dpnId, groupIdKey, groupId);
tx.merge(LogicalDatastoreType.OPERATIONAL, nextHopsId, nextHopsToGroupId);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.dpid.l3vpn.lb.nexthops.DpnLbNexthops in project netvirt by opendaylight.
the class NexthopManager method updateDcGwLoadBalancingGroup.
/**
* This method is invoked when the tunnel status is updated.
* The bucket is directly removed/added based on the operational status of the tunnel.
*/
public void updateDcGwLoadBalancingGroup(List<String> availableDcGws, BigInteger dpnId, String destinationIp, boolean isTunnelUp) {
Preconditions.checkNotNull(availableDcGws, "There are no dc-gws present");
WriteTransaction configTx = dataBroker.newWriteOnlyTransaction();
// TODO : Place the logic to construct all possible DC-GW combination here.
int bucketId = availableDcGws.indexOf(destinationIp);
Optional<DpnLbNexthops> dpnLbNextHops = fibUtil.getDpnLbNexthops(dpnId, destinationIp);
if (!dpnLbNextHops.isPresent()) {
return;
}
List<String> nextHopKeys = dpnLbNextHops.get().getNexthopKey();
nextHopKeys.forEach(nextHopKey -> {
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);
if (isTunnelUp) {
Bucket bucket = buildBucketForDcGwLbGroup(destinationIp, dpnId, bucketId);
LOG.trace("Added bucket {} to group {} on dpn {}.", bucket, groupId, dpnId);
mdsalApiManager.addBucketToTx(dpnId, groupIdValue, bucket, configTx);
} else {
LOG.trace("Removed bucketId {} from group {} on dpn {}.", bucketId, groupId, dpnId);
mdsalApiManager.removeBucketToTx(dpnId, groupIdValue, bucketId, configTx);
}
});
configTx.submit();
return;
}
Aggregations