Bump odlparent->6.0.0,mdsal->5.0.3
[netvirt.git] / dhcpservice / impl / src / main / java / org / opendaylight / netvirt / dhcpservice / DhcpManager.java
index 687db4e75cfea72ac0d19b6f39fe8aca8d97eeda..54fd5ba4cbce0cd5efe143f5d763eed1cfe8b38d 100644 (file)
@@ -8,18 +8,20 @@
 package org.opendaylight.netvirt.dhcpservice;
 
 import com.google.common.base.Optional;
-import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.List;
-import javax.annotation.Nullable;
+import java.util.concurrent.ExecutionException;
 import javax.annotation.PostConstruct;
 import javax.annotation.PreDestroy;
 import javax.inject.Inject;
 import javax.inject.Named;
 import javax.inject.Singleton;
+import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 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;
@@ -47,6 +49,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.s
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.SubnetKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dhcpservice.config.rev150710.DhcpserviceConfig;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.Uint64;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -143,6 +146,7 @@ public class DhcpManager {
         this.dhcpOptLeaseTime = leaseTime;
     }
 
+    @Nullable
     public Subnet getNeutronSubnet(Port port) {
         if (port != null) {
             // DHCP Service is only interested in IPv4 IPs/Subnets
@@ -151,6 +155,7 @@ public class DhcpManager {
         return null;
     }
 
+    @Nullable
     public Subnet getNeutronSubnet(List<FixedIps> fixedIps) {
         for (FixedIps fixedIp: fixedIps) {
             if (fixedIp.getIpAddress().getIpv4Address() != null) {
@@ -160,6 +165,7 @@ public class DhcpManager {
         return null;
     }
 
+    @Nullable
     private Subnet getNeutronSubnet(Uuid subnetId) {
         Subnet subnet = null;
         InstanceIdentifier<Subnet> inst = InstanceIdentifier.create(Neutron.class).child(Subnets.class).child(Subnet
@@ -172,6 +178,7 @@ public class DhcpManager {
         return subnet;
     }
 
+    @Nullable
     public Port getNeutronPort(String name) {
         Port prt = null;
         InstanceIdentifier<Port> inst = InstanceIdentifier.create(Neutron.class).child(Ports.class).child(Port.class,
@@ -184,24 +191,26 @@ public class DhcpManager {
         return prt;
     }
 
-    public void installDhcpEntries(@Nullable BigInteger dpnId, @Nullable String vmMacAddress, WriteTransaction tx) {
+    public void installDhcpEntries(@Nullable Uint64 dpnId, @Nullable String vmMacAddress,
+            TypedReadWriteTransaction<Configuration> tx) throws ExecutionException, InterruptedException {
         DhcpServiceUtils.setupDhcpFlowEntry(dpnId, NwConstants.DHCP_TABLE, vmMacAddress, NwConstants.ADD_FLOW,
                 mdsalUtil, dhcpServiceCounters, tx);
     }
 
-    public void unInstallDhcpEntries(@Nullable BigInteger dpId, @Nullable String vmMacAddress, WriteTransaction tx) {
+    public void unInstallDhcpEntries(@Nullable Uint64 dpId, @Nullable String vmMacAddress,
+            TypedReadWriteTransaction<Configuration> tx) throws ExecutionException, InterruptedException {
         DhcpServiceUtils.setupDhcpFlowEntry(dpId, NwConstants.DHCP_TABLE, vmMacAddress, NwConstants.DEL_FLOW,
                 mdsalUtil, dhcpServiceCounters, tx);
     }
 
-    public void setupDefaultDhcpFlows(BigInteger dpId) {
-        setupTableMissForDhcpTable(dpId);
+    public void setupDefaultDhcpFlows(TypedWriteTransaction<Configuration> tx, Uint64 dpId) {
+        setupTableMissForDhcpTable(tx, dpId);
         if (config.isDhcpDynamicAllocationPoolEnabled()) {
-            setupDhcpAllocationPoolFlow(dpId);
+            setupDhcpAllocationPoolFlow(tx, dpId);
         }
     }
 
-    private void setupTableMissForDhcpTable(BigInteger dpId) {
+    private void setupTableMissForDhcpTable(TypedWriteTransaction<Configuration> tx, Uint64 dpId) {
         List<MatchInfo> matches = new ArrayList<>();
         List<InstructionInfo> instructions = new ArrayList<>();
         List<ActionInfo> actionsInfos = new ArrayList<>();
@@ -211,11 +220,11 @@ public class DhcpManager {
                 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, Uint64 dpId) {
         List<MatchInfo> matches = DhcpServiceUtils.getDhcpMatch();
         List<InstructionInfo> instructions = new ArrayList<>();
         List<ActionInfo> actionsInfos = new ArrayList<>();
@@ -226,10 +235,10 @@ public class DhcpManager {
                 "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, Uint64 dpId) {
         List<MatchInfo> matches = new ArrayList<>();
         List<InstructionInfo> instructions = new ArrayList<>();
         instructions.add(new InstructionGotoTable(NwConstants.EXTERNAL_TUNNEL_TABLE));
@@ -239,6 +248,6 @@ public class DhcpManager {
                 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);
     }
 }