import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.genius.datastoreutils.AsyncClusteredDataTreeChangeListenerBase;
import org.opendaylight.genius.mdsalutil.MDSALUtil;
+import org.opendaylight.genius.mdsalutil.NwConstants;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfacesState;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface;
for (Uuid portIntf : portList) {
NodeConnectorId nodeConnectorId = getNodeConnectorIdForPortIntf(portIntf);
BigInteger dpId = BigInteger.valueOf(MDSALUtil.getDpnIdFromPortName(nodeConnectorId));
- Port port = dhcpManager.getNeutronPort(portIntf.getValue());
+ String interfaceName = portIntf.getValue();
+ Port port = dhcpManager.getNeutronPort(interfaceName);
String vmMacAddress = port.getMacAddress().getValue();
//check whether any changes have happened
LOG.trace("DhcpSubnetListener installNeutronPortEntries dpId: {} vmMacAddress : {}", dpId, vmMacAddress);
- //install the entriesd
+ //Bind the dhcp service when enabled
+ WriteTransaction bindTx = dataBroker.newWriteOnlyTransaction();
+ DhcpServiceUtils.bindDhcpService(interfaceName, NwConstants.DHCP_TABLE, bindTx);
+ DhcpServiceUtils.submitTransaction(bindTx);
+ //install the entries
WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
dhcpManager.installDhcpEntries(dpId, vmMacAddress, tx);
DhcpServiceUtils.submitTransaction(tx);
for (Uuid portIntf : portList) {
NodeConnectorId nodeConnectorId = getNodeConnectorIdForPortIntf(portIntf);
BigInteger dpId = BigInteger.valueOf(MDSALUtil.getDpnIdFromPortName(nodeConnectorId));
- Port port = dhcpManager.getNeutronPort(portIntf.getValue());
+ String interfaceName = portIntf.getValue();
+ Port port = dhcpManager.getNeutronPort(interfaceName);
String vmMacAddress = port.getMacAddress().getValue();
//check whether any changes have happened
LOG.trace("DhcpSubnetListener uninstallNeutronPortEntries dpId: {} vmMacAddress : {}",
dpId, vmMacAddress);
- //install the entries
+ //Unbind the dhcp service when disabled
+ WriteTransaction unbindTx = dataBroker.newWriteOnlyTransaction();
+ DhcpServiceUtils.unbindDhcpService(interfaceName, unbindTx);
+ DhcpServiceUtils.submitTransaction(unbindTx);
+ //uninstall the entries
WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
dhcpManager.unInstallDhcpEntries(dpId, vmMacAddress, tx);
DhcpServiceUtils.submitTransaction(tx);