import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.genius.arputil.api.ArpConstants;
import org.opendaylight.genius.datastoreutils.AsyncClusteredDataTreeChangeListenerBase;
+import org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker;
import org.opendaylight.genius.infra.ManagedNewTransactionRunner;
import org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl;
import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
LOG.trace("Adding {} adjacency to VPN Interface {} ", srcPrefix, vpnInterface);
InstanceIdentifier<VpnInterface> vpnIfId = VpnUtil.getVpnInterfaceIdentifier(vpnInterface);
InstanceIdentifier<Adjacencies> path = vpnIfId.augmentation(Adjacencies.class);
- synchronized (vpnInterface.intern()) {
- Optional<Adjacencies> adjacencies = VpnUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, path);
- String nextHopIpAddr = null;
- String nextHopMacAddress = null;
- String ip = srcPrefix;
- if (interfaceManager.isExternalInterface(vpnInterface)) {
- String subnetId = getSubnetId(vpnInstName, dstPrefix);
- if (subnetId == null) {
- LOG.trace("Can't find corresponding subnet for src IP {}, src MAC {}, dst IP {}, in VPN {}",
- srcPrefix, mipMacAddress, dstPrefix, vpnInstName);
- return;
- }
- ip = VpnUtil.getIpPrefix(ip);
- AdjacencyBuilder newAdjBuilder = new AdjacencyBuilder().setIpAddress(ip)
- .withKey(new AdjacencyKey(ip)).setAdjacencyType(AdjacencyType.PrimaryAdjacency)
- .setMacAddress(mipMacAddress).setSubnetId(new Uuid(subnetId)).setPhysNetworkFunc(true);
-
- List<Adjacency> adjacencyList = adjacencies.isPresent()
- ? adjacencies.get().getAdjacency() : new ArrayList<>();
-
- adjacencyList.add(newAdjBuilder.build());
-
- Adjacencies aug = VpnUtil.getVpnInterfaceAugmentation(adjacencyList);
- Optional<VpnInterface> optionalVpnInterface =
- VpnUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, vpnIfId);
- VpnInterface newVpnIntf;
- if (optionalVpnInterface.isPresent()) {
- newVpnIntf =
- new VpnInterfaceBuilder(optionalVpnInterface.get())
- .addAugmentation(Adjacencies.class, aug)
- .build();
- VpnUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, vpnIfId, newVpnIntf);
- }
- LOG.debug(" Successfully stored subnetroute Adjacency into VpnInterface {}", vpnInterface);
- return;
- }
-
- if (adjacencies.isPresent()) {
- List<Adjacency> adjacencyList = adjacencies.get().getAdjacency();
- ip = VpnUtil.getIpPrefix(ip);
- for (Adjacency adjacs : adjacencyList) {
- if (adjacs.getAdjacencyType() == AdjacencyType.PrimaryAdjacency) {
- if (adjacs.getIpAddress().equals(ip)) {
- LOG.error("The MIP {} is already present as a primary adjacency for interface {}"
- + "vpn {} Skipping adjacency addition.", ip, vpnInterface, vpnInstName);
- return;
- }
- nextHopIpAddr = adjacs.getIpAddress();
- nextHopMacAddress = adjacs.getMacAddress();
- break;
- }
- }
- if (nextHopIpAddr != null) {
- String rd = VpnUtil.getVpnRd(dataBroker, vpnInstName);
- long label =
- VpnUtil.getUniqueId(idManager, VpnConstants.VPN_IDPOOL_NAME,
- VpnUtil.getNextHopLabelKey(rd != null ? rd : vpnInstName, ip));
- if (label == 0) {
- LOG.error("Unable to fetch label from Id Manager. Bailing out of adding MIP adjacency {} "
- + "to vpn interface {} for vpn {}", ip, vpnInterface, vpnInstName);
+ try {
+ synchronized (vpnInterface.intern()) {
+ Optional<Adjacencies> adjacencies = SingleTransactionDataBroker.syncReadOptional(dataBroker,
+ LogicalDatastoreType.CONFIGURATION, path);
+ String nextHopIpAddr = null;
+ String nextHopMacAddress = null;
+ String ip = srcPrefix;
+ if (interfaceManager.isExternalInterface(vpnInterface)) {
+ String subnetId = getSubnetId(vpnInstName, dstPrefix);
+ if (subnetId == null) {
+ LOG.trace("Can't find corresponding subnet for src IP {}, src MAC {}, dst IP {},"
+ + " in VPN {}", srcPrefix, mipMacAddress, dstPrefix, vpnInstName);
return;
}
- String nextHopIp = nextHopIpAddr.split("/")[0];
- AdjacencyBuilder newAdjBuilder =
- new AdjacencyBuilder().setIpAddress(ip).withKey(new AdjacencyKey(ip)).setNextHopIpList(
- Collections.singletonList(nextHopIp)).setAdjacencyType(AdjacencyType.LearntIp);
- if (mipMacAddress != null && !mipMacAddress.equalsIgnoreCase(nextHopMacAddress)) {
- newAdjBuilder.setMacAddress(mipMacAddress);
- }
+ ip = VpnUtil.getIpPrefix(ip);
+ AdjacencyBuilder newAdjBuilder = new AdjacencyBuilder().setIpAddress(ip)
+ .withKey(new AdjacencyKey(ip)).setAdjacencyType(AdjacencyType.PrimaryAdjacency)
+ .setMacAddress(mipMacAddress).setSubnetId(new Uuid(subnetId)).setPhysNetworkFunc(true);
+
+ List<Adjacency> adjacencyList = adjacencies.isPresent()
+ ? adjacencies.get().getAdjacency() : new ArrayList<>();
+
adjacencyList.add(newAdjBuilder.build());
+
Adjacencies aug = VpnUtil.getVpnInterfaceAugmentation(adjacencyList);
- Optional<VpnInterface> optionalVpnInterface =
- VpnUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, vpnIfId);
+ Optional<VpnInterface> optionalVpnInterface = SingleTransactionDataBroker.syncReadOptional(
+ dataBroker, LogicalDatastoreType.CONFIGURATION, vpnIfId);
VpnInterface newVpnIntf;
if (optionalVpnInterface.isPresent()) {
newVpnIntf =
new VpnInterfaceBuilder(optionalVpnInterface.get())
- .addAugmentation(Adjacencies.class, aug).build();
- VpnUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION,
- vpnIfId, newVpnIntf);
+ .addAugmentation(Adjacencies.class, aug)
+ .build();
+ SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION,
+ vpnIfId, newVpnIntf, VpnUtil.SINGLE_TRANSACTION_BROKER_NO_RETRY);
}
LOG.debug(" Successfully stored subnetroute Adjacency into VpnInterface {}", vpnInterface);
+ return;
+ }
+
+ if (adjacencies.isPresent()) {
+ List<Adjacency> adjacencyList = adjacencies.get().getAdjacency();
+ ip = VpnUtil.getIpPrefix(ip);
+ for (Adjacency adjacs : adjacencyList) {
+ if (adjacs.getAdjacencyType() == AdjacencyType.PrimaryAdjacency) {
+ if (adjacs.getIpAddress().equals(ip)) {
+ LOG.error("The MIP {} is already present as a primary adjacency for interface {}"
+ + "vpn {} Skipping adjacency addition.", ip, vpnInterface, vpnInstName);
+ return;
+ }
+ nextHopIpAddr = adjacs.getIpAddress();
+ nextHopMacAddress = adjacs.getMacAddress();
+ break;
+ }
+ }
+ if (nextHopIpAddr != null) {
+ String rd = VpnUtil.getVpnRd(dataBroker, vpnInstName);
+ long label =
+ VpnUtil.getUniqueId(idManager, VpnConstants.VPN_IDPOOL_NAME,
+ VpnUtil.getNextHopLabelKey(rd != null ? rd : vpnInstName, ip));
+ if (label == 0) {
+ LOG.error("Unable to fetch label from Id Manager. Bailing out of adding MIP"
+ + " adjacency {} to vpn interface {} for vpn {}", ip, vpnInterface,
+ vpnInstName);
+ return;
+ }
+ String nextHopIp = nextHopIpAddr.split("/")[0];
+ AdjacencyBuilder newAdjBuilder =
+ new AdjacencyBuilder().setIpAddress(ip).withKey(new AdjacencyKey(ip))
+ .setNextHopIpList(Collections.singletonList(nextHopIp))
+ .setAdjacencyType(AdjacencyType.LearntIp);
+ if (mipMacAddress != null && !mipMacAddress.equalsIgnoreCase(nextHopMacAddress)) {
+ newAdjBuilder.setMacAddress(mipMacAddress);
+ }
+ adjacencyList.add(newAdjBuilder.build());
+ Adjacencies aug = VpnUtil.getVpnInterfaceAugmentation(adjacencyList);
+ Optional<VpnInterface> optionalVpnInterface =
+ SingleTransactionDataBroker.syncReadOptional(dataBroker,
+ LogicalDatastoreType.CONFIGURATION, vpnIfId);
+ VpnInterface newVpnIntf;
+ if (optionalVpnInterface.isPresent()) {
+ newVpnIntf =
+ new VpnInterfaceBuilder(optionalVpnInterface.get())
+ .addAugmentation(Adjacencies.class, aug).build();
+ SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION,
+ vpnIfId, newVpnIntf, VpnUtil.SINGLE_TRANSACTION_BROKER_NO_RETRY);
+ }
+ LOG.debug(" Successfully stored subnetroute Adjacency into VpnInterface {}", vpnInterface);
+ }
}
}
+ } catch (ReadFailedException e) {
+ LOG.error("addMipAdjacency: Failed to read data store for interface {} vpn {} ip {} mac {}",
+ vpnInterface, vpnInstName, srcPrefix, mipMacAddress);
+ } catch (TransactionCommitFailedException e) {
+ LOG.error("addMipAdjacency: Failed to commit to data store for interface {} vpn {} ip {} mac {}",
+ vpnInterface, vpnInstName, srcPrefix, mipMacAddress);
}
}
import javax.inject.Singleton;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker;
-import org.opendaylight.genius.mdsalutil.MDSALUtil;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.PortOpData;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.SubnetOpData;
new SubnetOpDataEntryKey(subnetId)).build();
InstanceIdentifier<SubnetToDpn> dpnOpId =
subOpIdentifier.child(SubnetToDpn.class, new SubnetToDpnKey(dpnId));
- Optional<SubnetToDpn> optionalSubDpn = VpnUtil.read(broker, LogicalDatastoreType.OPERATIONAL, dpnOpId);
+ Optional<SubnetToDpn> optionalSubDpn = SingleTransactionDataBroker.syncReadOptional(broker,
+ LogicalDatastoreType.OPERATIONAL, dpnOpId);
if (optionalSubDpn.isPresent()) {
LOG.error("addDpnToSubnet: Cannot create, SubnetToDpn for subnet {} as DPN {}"
+ " already seen in datastore", subnetId.getValue(), dpnId);
List<VpnInterfaces> vpnIntfList = new ArrayList<>();
subDpnBuilder.setVpnInterfaces(vpnIntfList);
SubnetToDpn subDpn = subDpnBuilder.build();
- SingleTransactionDataBroker.syncWrite(broker, LogicalDatastoreType.OPERATIONAL, dpnOpId, subDpn);
+ SingleTransactionDataBroker.syncWrite(broker, LogicalDatastoreType.OPERATIONAL, dpnOpId, subDpn,
+ VpnUtil.SINGLE_TRANSACTION_BROKER_NO_RETRY);
LOG.info("addDpnToSubnet: Created SubnetToDpn entry for subnet {} with DPNId {} ", subnetId.getValue(),
dpnId);
return subDpn;
} catch (TransactionCommitFailedException ex) {
LOG.error("addDpnToSubnet: Creation of SubnetToDpn for subnet {} with DpnId {} failed",
subnetId.getValue(), dpnId, ex);
- return null;
+ } catch (ReadFailedException e) {
+ LOG.error("addDpnToSubnet: Failed to read data store for subnet {} dpn {}", subnetId.getValue(),
+ dpnId);
}
+ return null;
}
private void removeDpnFromSubnet(Uuid subnetId, BigInteger dpnId) {
new SubnetOpDataEntryKey(subnetId)).build();
InstanceIdentifier<SubnetToDpn> dpnOpId =
subOpIdentifier.child(SubnetToDpn.class, new SubnetToDpnKey(dpnId));
- Optional<SubnetToDpn> optionalSubDpn = VpnUtil.read(broker, LogicalDatastoreType.OPERATIONAL, dpnOpId);
+ Optional<SubnetToDpn> optionalSubDpn = SingleTransactionDataBroker.syncReadOptional(broker,
+ LogicalDatastoreType.OPERATIONAL, dpnOpId);
if (!optionalSubDpn.isPresent()) {
LOG.warn("removeDpnFromSubnet: Cannot delete, SubnetToDpn for subnet {} DPN {} not available"
+ " in datastore", subnetId.getValue(), dpnId);
}
LOG.trace("removeDpnFromSubnet: Deleting SubnetToDpn entry for subnet {} with DPNId {}",
subnetId.getValue(), dpnId);
- SingleTransactionDataBroker.syncDelete(broker, LogicalDatastoreType.OPERATIONAL, dpnOpId);
+ SingleTransactionDataBroker.syncDelete(broker, LogicalDatastoreType.OPERATIONAL, dpnOpId,
+ VpnUtil.SINGLE_TRANSACTION_BROKER_NO_RETRY);
} catch (TransactionCommitFailedException ex) {
LOG.error("removeDpnFromSubnet: Deletion of SubnetToDpn for subnet {} with DPN {} failed",
subnetId.getValue(), dpnId, ex);
+ } catch (ReadFailedException e) {
+ LOG.error("removeDpnFromSubnet: Failed to read data store for subnet {} dpn {}", subnetId, dpnId);
}
}
//Please use a synchronize block here as we donot need a cluster-wide lock
InstanceIdentifier<SubnetToDpn> dpnOpId =
subOpIdentifier.child(SubnetToDpn.class, new SubnetToDpnKey(dpnId));
- Optional<SubnetToDpn> optionalSubDpn = VpnUtil.read(broker, LogicalDatastoreType.OPERATIONAL, dpnOpId);
+ Optional<SubnetToDpn> optionalSubDpn = SingleTransactionDataBroker.syncReadOptional(broker,
+ LogicalDatastoreType.OPERATIONAL, dpnOpId);
if (!optionalSubDpn.isPresent()) {
// Create a new DPN Entry
subDpn = addDpnToSubnet(subnetId, dpnId);
vpnIntfList.add(vpnIntfs);
subDpnBuilder.setVpnInterfaces(vpnIntfList);
subDpn = subDpnBuilder.build();
-
- SingleTransactionDataBroker.syncWrite(broker, LogicalDatastoreType.OPERATIONAL, dpnOpId, subDpn);
+ SingleTransactionDataBroker.syncWrite(broker, LogicalDatastoreType.OPERATIONAL, dpnOpId, subDpn,
+ VpnUtil.SINGLE_TRANSACTION_BROKER_NO_RETRY);
LOG.info("addInterfaceToDpn: Created SubnetToDpn entry for subnet {} with DPNId {} intfName {}",
subnetId.getValue(), dpnId, intfName);
} catch (TransactionCommitFailedException ex) {
LOG.error("addInterfaceToDpn: Addition of Interface {} for SubnetToDpn on subnet {} with DPN {} failed",
intfName, subnetId.getValue(), dpnId, ex);
- return null;
+ } catch (ReadFailedException e) {
+ LOG.error("addInterfaceToDpn: Failed to read data store for interface {} subnet {} dpn {}", intfName,
+ subnetId, dpnId);
}
return subDpn;
}
// Add to PortOpData as well.
PortOpDataEntryBuilder portOpBuilder = null;
PortOpDataEntry portOpEntry = null;
-
InstanceIdentifier<PortOpDataEntry> portOpIdentifier =
InstanceIdentifier.builder(PortOpData.class).child(PortOpDataEntry.class,
new PortOpDataEntryKey(intfName)).build();
- Optional<PortOpDataEntry> optionalPortOp =
- VpnUtil.read(broker, LogicalDatastoreType.OPERATIONAL, portOpIdentifier);
+ Optional<PortOpDataEntry> optionalPortOp = SingleTransactionDataBroker.syncReadOptional(broker,
+ LogicalDatastoreType.OPERATIONAL, portOpIdentifier);
if (!optionalPortOp.isPresent()) {
// Create PortOpDataEntry only if not present
portOpBuilder =
}
portOpEntry = portOpBuilder.build();
SingleTransactionDataBroker.syncWrite(broker, LogicalDatastoreType.OPERATIONAL, portOpIdentifier,
- portOpEntry);
+ portOpEntry, VpnUtil.SINGLE_TRANSACTION_BROKER_NO_RETRY);
LOG.info("addPortOpDataEntry: Created PortOpData entry for port {} with DPNId {} subnetId {}",
intfName, dpnId, subnetId.getValue());
} catch (TransactionCommitFailedException ex) {
LOG.error("addPortOpDataEntry: Addition of Interface {} for SubnetToDpn on subnet {} with DPN {} failed",
intfName, subnetId.getValue(), dpnId, ex);
+ } catch (ReadFailedException e) {
+ LOG.error("addPortOpDataEntry: Failed to read from data store for interface {} subnet {} dpn {}",
+ intfName, subnetId, dpnId);
}
}
new SubnetOpDataEntryKey(subnetId)).build();
InstanceIdentifier<SubnetToDpn> dpnOpId =
subOpIdentifier.child(SubnetToDpn.class, new SubnetToDpnKey(dpnId));
- Optional<SubnetToDpn> optionalSubDpn = VpnUtil.read(broker, LogicalDatastoreType.OPERATIONAL, dpnOpId);
+ Optional<SubnetToDpn> optionalSubDpn = SingleTransactionDataBroker.syncReadOptional(broker,
+ LogicalDatastoreType.OPERATIONAL, dpnOpId);
if (!optionalSubDpn.isPresent()) {
LOG.debug("removeInterfaceFromDpn: Cannot delete, SubnetToDpn for intf {} subnet {} DPN {}"
+ " not available in datastore", intfName, subnetId.getValue(), dpnId);
} else {
subDpnBuilder.setVpnInterfaces(vpnIntfList);
SingleTransactionDataBroker.syncWrite(broker, LogicalDatastoreType.OPERATIONAL, dpnOpId,
- subDpnBuilder.build());
+ subDpnBuilder.build(), VpnUtil.SINGLE_TRANSACTION_BROKER_NO_RETRY);
}
LOG.info("removeInterfaceFromDpn: Removed interface {} from sunbet {} dpn {}",
intfName, subnetId.getValue(), dpnId);
} catch (TransactionCommitFailedException ex) {
LOG.error("removeInterfaceFromDpn: Deletion of Interface {} for SubnetToDpn on subnet {}"
+ " with DPN {} failed", intfName, subnetId.getValue(), dpnId, ex);
- return false;
+ } catch (ReadFailedException e) {
+ LOG.error("removeInterfaceFromDpn: Failed to read data store for interface {} subnet {} dpn {}",
+ intfName, subnetId, dpnId);
}
return dpnRemoved;
}
public PortOpDataEntry removePortOpDataEntry(String intfName, Uuid subnetId) {
// Remove PortOpData and return out
InstanceIdentifier<PortOpDataEntry> portOpIdentifier =
- InstanceIdentifier.builder(PortOpData.class).child(PortOpDataEntry.class,
- new PortOpDataEntryKey(intfName)).build();
+ InstanceIdentifier.builder(PortOpData.class).child(PortOpDataEntry.class,
+ new PortOpDataEntryKey(intfName)).build();
PortOpDataEntry portOpEntry = null;
- Optional<PortOpDataEntry> optionalPortOp =
- VpnUtil.read(broker, LogicalDatastoreType.OPERATIONAL, portOpIdentifier);
- if (!optionalPortOp.isPresent()) {
- LOG.info("removePortOpDataEntry: Cannot delete, portOp for port {} is not available in datastore",
- intfName);
- return null;
- } else {
- portOpEntry = optionalPortOp.get();
- List<Uuid> listSubnet = portOpEntry.getSubnetIds();
- if (listSubnet == null) {
- listSubnet = new ArrayList<>();
- }
- if (subnetId != null && listSubnet.contains(subnetId)) {
- listSubnet.remove(subnetId);
- }
- if (listSubnet.isEmpty() || subnetId == null) {
- MDSALUtil.syncDelete(broker, LogicalDatastoreType.OPERATIONAL, portOpIdentifier);
- LOG.info("removePortOpDataEntry: Deleted portOpData entry for port {}", intfName);
+ try {
+ Optional<PortOpDataEntry> optionalPortOp = SingleTransactionDataBroker.syncReadOptional(broker,
+ LogicalDatastoreType.OPERATIONAL, portOpIdentifier);
+ if (!optionalPortOp.isPresent()) {
+ LOG.info("removePortOpDataEntry: Cannot delete, portOp for port {} is not available in datastore",
+ intfName);
} else {
- try {
+ portOpEntry = optionalPortOp.get();
+ List<Uuid> listSubnet = portOpEntry.getSubnetIds();
+ if (listSubnet == null) {
+ listSubnet = new ArrayList<>();
+ }
+ if (subnetId != null && listSubnet.contains(subnetId)) {
+ listSubnet.remove(subnetId);
+ }
+ if (listSubnet.isEmpty() || subnetId == null) {
+ SingleTransactionDataBroker.syncDelete(broker, LogicalDatastoreType.OPERATIONAL, portOpIdentifier,
+ VpnUtil.SINGLE_TRANSACTION_BROKER_NO_RETRY);
+ LOG.info("removePortOpDataEntry: Deleted portOpData entry for port {}", intfName);
+ } else {
PortOpDataEntryBuilder portOpBuilder = null;
portOpBuilder = new PortOpDataEntryBuilder(portOpEntry);
portOpBuilder.setSubnetIds(listSubnet);
- SingleTransactionDataBroker.syncWrite(broker, LogicalDatastoreType.OPERATIONAL, portOpIdentifier,
- portOpEntry);
- LOG.info("removePortOpDataEntry: Updated PortOpData entry for port {} with removing subnetId {}",
- intfName, subnetId.getValue());
- } catch (TransactionCommitFailedException ex) {
- LOG.error("removePortOpDataEntry failed: Updated PortOpData entry for port {}"
- + " with removing subnetId {}", intfName, subnetId.getValue());
+ SingleTransactionDataBroker.syncWrite(broker, LogicalDatastoreType.OPERATIONAL,
+ portOpIdentifier, portOpEntry, VpnUtil.SINGLE_TRANSACTION_BROKER_NO_RETRY);
+ LOG.info("removePortOpDataEntry: Updated PortOpData entry for port {} with removing"
+ + " subnetId {}", intfName, subnetId.getValue());
+ portOpEntry = null;
}
- return null;
}
+ } catch (ReadFailedException e) {
+ LOG.error("removePortOpDataEntry: Failed to read data store for interface {} subnet {}", intfName,
+ subnetId);
+ } catch (TransactionCommitFailedException e) {
+ LOG.error("removePortOpDataEntry: Failed to commit to data store for interface {} subnet {}", intfName,
+ subnetId);
}
return portOpEntry;
}
public PortOpDataEntry getPortOpDataEntry(String intfName) {
- // Remove PortOpData and return out
- InstanceIdentifier<PortOpDataEntry> portOpIdentifier =
- InstanceIdentifier.builder(PortOpData.class).child(PortOpDataEntry.class,
- new PortOpDataEntryKey(intfName)).build();
- Optional<PortOpDataEntry> optionalPortOp =
- VpnUtil.read(broker, LogicalDatastoreType.OPERATIONAL, portOpIdentifier);
- if (!optionalPortOp.isPresent()) {
- return null;
+ PortOpDataEntry portOpDataEntry = null;
+ try {
+ // Remove PortOpData and return out
+ InstanceIdentifier<PortOpDataEntry> portOpIdentifier =
+ InstanceIdentifier.builder(PortOpData.class).child(PortOpDataEntry.class,
+ new PortOpDataEntryKey(intfName)).build();
+ Optional<PortOpDataEntry> optionalPortOp = SingleTransactionDataBroker.syncReadOptional(broker,
+ LogicalDatastoreType.OPERATIONAL, portOpIdentifier);
+ if (optionalPortOp.isPresent()) {
+ portOpDataEntry = optionalPortOp.get();
+ }
+ } catch (ReadFailedException e) {
+ LOG.error("getPortOpDataEntry: Failed to read data store for interface {}", intfName);
}
- return optionalPortOp.get();
+ return portOpDataEntry;
}
-
}