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;
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;
this.dhcpOptLeaseTime = leaseTime;
}
+ @Nullable
public Subnet getNeutronSubnet(Port port) {
if (port != null) {
// DHCP Service is only interested in IPv4 IPs/Subnets
return null;
}
+ @Nullable
public Subnet getNeutronSubnet(List<FixedIps> fixedIps) {
for (FixedIps fixedIp: fixedIps) {
if (fixedIp.getIpAddress().getIpv4Address() != null) {
return null;
}
+ @Nullable
private Subnet getNeutronSubnet(Uuid subnetId) {
Subnet subnet = null;
InstanceIdentifier<Subnet> inst = InstanceIdentifier.create(Neutron.class).child(Subnets.class).child(Subnet
return subnet;
}
+ @Nullable
public Port getNeutronPort(String name) {
Port prt = null;
InstanceIdentifier<Port> inst = InstanceIdentifier.create(Neutron.class).child(Ports.class).child(Port.class,
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<>();
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<>();
"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));
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);
}
}