import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
+import org.opendaylight.genius.infra.Datastore;
import org.opendaylight.genius.infra.Datastore.Configuration;
import org.opendaylight.genius.infra.ManagedNewTransactionRunner;
import org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl;
String strVni = DhcpServiceUtils.getSegmentationId(nwUuid, broker);
BigInteger vni = strVni != null ? new BigInteger(strVni) : BigInteger.ZERO;
if (!vni.equals(BigInteger.ZERO)) {
- if (addFlow) {
- LOG.trace("Installing the SR-IOV DHCP Arp flow for DPN {} Port Ip {}, Lport {}.",
- dpnId, dhcpIpAddress, lportTag);
- installDhcpArpRequestFlows(dpnId, vni, dhcpIpAddress, lportTag,
- optElan.get().getElanTag());
- installDhcpArpResponderFlows(dpnId, tunnelInterfaceName, lportTag, elanInstanceName,
- dhcpIpAddress, dhcpMacAddress);
- } else {
- LOG.trace("Uninstalling the SR-IOV DHCP Arp flows for DPN {} Port Ip {}, Lport {}.",
- dpnId, dhcpIpAddress, lportTag);
- uninstallDhcpArpRequestFlows(dpnId, vni, dhcpIpAddress, lportTag);
- uninstallDhcpArpResponderFlows(dpnId, tunnelInterfaceName, lportTag, dhcpIpAddress);
- }
+ return Collections.singletonList(txRunner.callWithNewReadWriteTransactionAndSubmit(
+ Datastore.CONFIGURATION, tx -> {
+ if (addFlow) {
+ LOG.trace("Installing the SR-IOV DHCP Arp flow for DPN {} Port Ip {}, Lport {}.",
+ dpnId, dhcpIpAddress, lportTag);
+ installDhcpArpRequestFlows(tx, dpnId, vni, dhcpIpAddress, lportTag,
+ optElan.get().getElanTag());
+ installDhcpArpResponderFlows(dpnId, tunnelInterfaceName, lportTag, elanInstanceName,
+ dhcpIpAddress, dhcpMacAddress);
+ } else {
+ LOG.trace("Uninstalling the SR-IOV DHCP Arp flows for DPN {} Port Ip {}, Lport {}.",
+ dpnId, dhcpIpAddress, lportTag);
+ uninstallDhcpArpRequestFlows(tx, dpnId, vni, dhcpIpAddress, lportTag);
+ uninstallDhcpArpResponderFlows(dpnId, tunnelInterfaceName, lportTag, dhcpIpAddress);
+ }
+ }));
}
}
}
- return null;
+ return Collections.emptyList();
});
}
return optSubnetDhcp;
}
- private void installDhcpArpRequestFlows(BigInteger dpnId, BigInteger vni, String dhcpIpAddress,
- int lportTag, Long elanTag) {
+ private void installDhcpArpRequestFlows(TypedReadWriteTransaction<Configuration> tx, BigInteger dpnId,
+ BigInteger vni, String dhcpIpAddress, int lportTag, Long elanTag)
+ throws ExecutionException, InterruptedException {
DhcpServiceUtils.setupDhcpArpRequest(dpnId, NwConstants.EXTERNAL_TUNNEL_TABLE, vni, dhcpIpAddress,
- lportTag, elanTag, true, mdsalUtil);
+ lportTag, elanTag, true, mdsalUtil, tx);
}
private void installDhcpArpResponderFlows(BigInteger dpnId, String interfaceName, int lportTag,
elanService.removeArpResponderFlow(arpInput);
}
- private void uninstallDhcpArpRequestFlows(BigInteger dpnId, BigInteger vni, String dhcpIpAddress,
- int lportTag) {
+ private void uninstallDhcpArpRequestFlows(TypedReadWriteTransaction<Configuration> tx, BigInteger dpnId,
+ BigInteger vni, String dhcpIpAddress, int lportTag)
+ throws ExecutionException, InterruptedException {
DhcpServiceUtils.setupDhcpArpRequest(dpnId, NwConstants.EXTERNAL_TUNNEL_TABLE, vni, dhcpIpAddress,
- lportTag, null, false, mdsalUtil);
+ lportTag, null, false, mdsalUtil, tx);
}
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.genius.infra.Datastore.Configuration;
import org.opendaylight.genius.infra.TypedReadWriteTransaction;
+import org.opendaylight.genius.infra.TypedWriteTransaction;
import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
import org.opendaylight.genius.mdsalutil.ActionInfo;
import org.opendaylight.genius.mdsalutil.FlowEntity;
mdsalUtil, dhcpServiceCounters, tx);
}
- public void setupDefaultDhcpFlows(BigInteger dpId) {
- setupTableMissForDhcpTable(dpId);
+ public void setupDefaultDhcpFlows(TypedWriteTransaction<Configuration> tx, BigInteger dpId) {
+ setupTableMissForDhcpTable(tx, dpId);
if (config.isDhcpDynamicAllocationPoolEnabled()) {
- setupDhcpAllocationPoolFlow(dpId);
+ setupDhcpAllocationPoolFlow(tx, dpId);
}
}
- private void setupTableMissForDhcpTable(BigInteger dpId) {
+ private void setupTableMissForDhcpTable(TypedWriteTransaction<Configuration> tx, BigInteger dpId) {
List<MatchInfo> matches = new ArrayList<>();
List<InstructionInfo> instructions = new ArrayList<>();
List<ActionInfo> actionsInfos = new ArrayList<>();
0, "DHCP Table Miss Flow", 0, 0,
DhcpMConstants.COOKIE_DHCP_BASE, matches, instructions);
dhcpServiceCounters.installDhcpTableMissFlow();
- mdsalUtil.installFlow(flowEntity);
- setupTableMissForHandlingExternalTunnel(dpId);
+ mdsalUtil.addFlow(tx, flowEntity);
+ setupTableMissForHandlingExternalTunnel(tx, dpId);
}
- private void setupDhcpAllocationPoolFlow(BigInteger dpId) {
+ private void setupDhcpAllocationPoolFlow(TypedWriteTransaction<Configuration> tx, BigInteger dpId) {
List<MatchInfo> matches = DhcpServiceUtils.getDhcpMatch();
List<InstructionInfo> instructions = new ArrayList<>();
List<ActionInfo> actionsInfos = new ArrayList<>();
"Dhcp Allocation Pool Flow", 0, 0, DhcpMConstants.COOKIE_DHCP_BASE, matches, instructions);
LOG.trace("Installing DHCP Allocation Pool Flow DpId {}", dpId);
dhcpServiceCounters.installDhcpFlow();
- mdsalUtil.installFlow(flowEntity);
+ mdsalUtil.addFlow(tx, flowEntity);
}
- private void setupTableMissForHandlingExternalTunnel(BigInteger dpId) {
+ private void setupTableMissForHandlingExternalTunnel(TypedWriteTransaction<Configuration> tx, BigInteger dpId) {
List<MatchInfo> matches = new ArrayList<>();
List<InstructionInfo> instructions = new ArrayList<>();
instructions.add(new InstructionGotoTable(NwConstants.EXTERNAL_TUNNEL_TABLE));
0, "DHCP Table Miss Flow For External Tunnel", 0, 0,
DhcpMConstants.COOKIE_DHCP_BASE, matches, instructions);
dhcpServiceCounters.installDhcpTableMissFlowForExternalTable();
- mdsalUtil.installFlow(flowEntity);
+ mdsalUtil.addFlow(tx, flowEntity);
}
}
}
public static void setupDhcpArpRequest(BigInteger dpId, short tableId, BigInteger vni, String dhcpIpAddress,
- int lportTag, Long elanTag, boolean add, IMdsalApiManager mdsalUtil) {
+ int lportTag, Long elanTag, boolean add, IMdsalApiManager mdsalUtil,
+ TypedReadWriteTransaction<Configuration> tx)
+ throws ExecutionException, InterruptedException {
List<MatchInfo> matches = getDhcpArpMatch(vni, dhcpIpAddress);
if (add) {
Flow flow = MDSALUtil.buildFlowNew(tableId, getDhcpArpFlowRef(dpId, tableId, lportTag, dhcpIpAddress),
DhcpMConstants.DEFAULT_DHCP_ARP_FLOW_PRIORITY, "DHCPArp", 0, 0,
generateDhcpArpCookie(lportTag, dhcpIpAddress), matches, null);
LOG.trace("Removing DHCP ARP Flow DpId {}, DHCP Port IpAddress {}", dpId, dhcpIpAddress);
- mdsalUtil.removeFlow(dpId, flow);
+ mdsalUtil.removeFlow(tx, dpId, flow);
} else {
Flow flow = MDSALUtil.buildFlowNew(tableId, getDhcpArpFlowRef(dpId, tableId, lportTag, dhcpIpAddress),
DhcpMConstants.DEFAULT_DHCP_ARP_FLOW_PRIORITY, "DHCPArp", 0, 0,
generateDhcpArpCookie(lportTag, dhcpIpAddress), matches,
getDhcpArpInstructions(elanTag, lportTag));
LOG.trace("Adding DHCP ARP Flow DpId {}, DHCPPort IpAddress {}", dpId, dhcpIpAddress);
- mdsalUtil.installFlow(dpId, flow);
+ mdsalUtil.addFlow(tx, dpId, flow);
}
}
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase;
+import org.opendaylight.genius.infra.Datastore;
+import org.opendaylight.genius.infra.ManagedNewTransactionRunner;
+import org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl;
import org.opendaylight.genius.mdsalutil.MDSALUtil;
+import org.opendaylight.infrautils.utils.concurrent.ListenableFutures;
import org.opendaylight.netvirt.dhcpservice.api.DhcpMConstants;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
private final DataBroker broker;
private final DhcpManager dhcpManager;
private final DhcpExternalTunnelManager dhcpExternalTunnelManager;
+ private final ManagedNewTransactionRunner txRunner;
@Inject
public NodeListener(final DataBroker db, final DhcpManager dhcpMgr,
this.broker = db;
this.dhcpManager = dhcpMgr;
this.dhcpExternalTunnelManager = dhcpExternalTunnelManager;
+ this.txRunner = new ManagedNewTransactionRunnerImpl(db);
}
@Override
return;
}
BigInteger dpId = new BigInteger(node[1]);
- dhcpManager.setupDefaultDhcpFlows(dpId);
+ ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(Datastore.CONFIGURATION,
+ tx -> dhcpManager.setupDefaultDhcpFlows(tx, dpId)), LOG, "Error handling node addition for {}", add);
dhcpExternalTunnelManager.installDhcpDropActionOnDpn(dpId);
List<BigInteger> listOfDpns = DhcpServiceUtils.getListOfDpns(broker);
dhcpExternalTunnelManager.handleDesignatedDpnDown(DhcpMConstants.INVALID_DPID, listOfDpns);