*/
package org.opendaylight.netvirt.vpnmanager.intervpnlink;
+import static org.opendaylight.controller.md.sal.binding.api.WriteTransaction.CREATE_MISSING_PARENTS;
+import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
+
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
-import java.math.BigInteger;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.ExecutionException;
import javax.inject.Singleton;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase;
import org.opendaylight.genius.infra.ManagedNewTransactionRunner;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.inter.vpn.links.InterVpnLinkKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.Uint32;
+import org.opendaylight.yangtools.yang.common.Uint64;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
interVpnLinkCache.addInterVpnLinkToCaches(add);
// Wait for VPN Operational data ready
- long vpn1Id = vpnUtil.getVpnId(vpn1Name);
- if (vpn1Id == VpnConstants.INVALID_ID) {
+ Uint32 vpn1Id = vpnUtil.getVpnId(vpn1Name);
+ if (VpnConstants.INVALID_ID.equals(vpn1Id)) {
boolean vpn1Ready =
vpnOpDataSyncer.waitForVpnDataReady(VpnOpDataSyncer.VpnOpDataType.vpnInstanceToId, vpn1Name,
VpnConstants.PER_VPN_INSTANCE_MAX_WAIT_TIME_IN_MILLISECONDS);
return;
}
}
- long vpn2Id = vpnUtil.getVpnId(vpn2Name);
- if (vpn2Id == VpnConstants.INVALID_ID) {
+ Uint32 vpn2Id = vpnUtil.getVpnId(vpn2Name);
+ if (VpnConstants.INVALID_ID.equals(vpn2Id)) {
boolean vpn1Ready =
vpnOpDataSyncer.waitForVpnDataReady(VpnOpDataSyncer.VpnOpDataType.vpnInstanceToId,vpn2Name,
VpnConstants.PER_VPN_INSTANCE_MAX_WAIT_TIME_IN_MILLISECONDS);
}
}
- List<BigInteger> firstDpnList = ivpnLinkLocator.selectSuitableDpns(add);
+ List<Uint64> firstDpnList = ivpnLinkLocator.selectSuitableDpns(add);
if (firstDpnList != null && !firstDpnList.isEmpty()) {
- List<BigInteger> secondDpnList = firstDpnList;
+ List<Uint64> secondDpnList = firstDpnList;
Long firstVpnLportTag = allocateVpnLinkLportTag(key.getName() + vpn1Name);
Long secondVpnLportTag = allocateVpnLinkLportTag(key.getName() + vpn2Name);
InterVpnLinkState interVpnLinkState = optIVpnLinkState.get();
boolean isVpnFirstEndPoint = true;
if (interVpnLinkState.getFirstEndpointState() != null) {
- Long firstEndpointLportTag = interVpnLinkState.getFirstEndpointState().getLportTag();
+ Long firstEndpointLportTag = interVpnLinkState.getFirstEndpointState().getLportTag().toJava();
removeVpnLinkEndpointFlows(del, vpn2Uuid, rd1,
interVpnLinkState.getSecondEndpointState().getDpId(),
firstEndpointLportTag.intValue(),
}
isVpnFirstEndPoint = false;
if (interVpnLinkState.getSecondEndpointState() != null) {
- Long secondEndpointLportTag = interVpnLinkState.getSecondEndpointState().getLportTag();
+ Long secondEndpointLportTag = interVpnLinkState.getSecondEndpointState().getLportTag().toJava();
removeVpnLinkEndpointFlows(del, vpn1Uuid, rd2,
interVpnLinkState.getFirstEndpointState().getDpId(),
secondEndpointLportTag.intValue(),
// Removing the InterVpnLinkState
InstanceIdentifier<InterVpnLinkState> interVpnLinkStateIid =
InterVpnLinkUtil.getInterVpnLinkStateIid(del.getName());
- ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx ->
- tx.delete(LogicalDatastoreType.CONFIGURATION, interVpnLinkStateIid)), LOG,
- "Error deleting inter-VPN link state {}", interVpnLinkStateIid);
+ ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx ->
+ tx.delete(interVpnLinkStateIid)), LOG, "Error deleting inter-VPN link state {}", interVpnLinkStateIid);
}
// We're catching Exception here to continue deleting as much as possible
// TODO Rework this so it's done in one transaction
@SuppressWarnings("checkstyle:IllegalCatch")
- private void removeVpnLinkEndpointFlows(InterVpnLink del, String vpnUuid, String rd, List<BigInteger> dpns,
+ private void removeVpnLinkEndpointFlows(InterVpnLink del, String vpnUuid, String rd, List<Uint64> dpns,
int otherEndpointLportTag, String otherEndpointIpAddr,
List<VrfEntry> vrfEntries, final boolean isVpnFirstEndPoint) {
return;
}
- for (BigInteger dpnId : dpns) {
+ for (Uint64 dpnId : dpns) {
try {
// Removing flow from LportDispatcher table
String flowRef = InterVpnLinkUtil.getLportDispatcherFlowRef(interVpnLinkName, otherEndpointLportTag);
Future<RpcResult<AllocateIdOutput>> result = idManager.allocateId(getIdInput);
RpcResult<AllocateIdOutput> rpcResult = result.get();
if (rpcResult.isSuccessful()) {
- return rpcResult.getResult().getIdValue();
+ return rpcResult.getResult().getIdValue().toJava();
} else {
LOG.warn("RPC Call to Get Unique Id returned with Errors {}", rpcResult.getErrors());
}
new InterVpnLinkStateBuilder(vpnLinkState).setState(InterVpnLinkState.State.Error)
.setErrorDescription(errorMsg)
.build();
- ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx ->
- tx.put(LogicalDatastoreType.CONFIGURATION, vpnLinkStateIid, vpnLinkErrorState,
- WriteTransaction.CREATE_MISSING_PARENTS)),
+ ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx ->
+ tx.put(vpnLinkStateIid, vpnLinkErrorState, CREATE_MISSING_PARENTS)),
LOG, "Error storing the VPN link error state for {}, {}", vpnLinkStateIid, vpnLinkErrorState);
// Sending out an error Notification