From: Vijayalakshmi Chickkamenahalli Nagaraju Date: Wed, 25 Jan 2017 11:12:30 +0000 (+0530) Subject: Bug 7674 Update of DHCP flag support for subnet-update configuration X-Git-Tag: release/carbon~445 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=d604d353c3ad5b9ed2650173748f816a08338e21;p=netvirt.git Bug 7674 Update of DHCP flag support for subnet-update configuration Change-Id: Ibe318e207dfeb4ea95ac99df733fd31c0f8d1dd6 Signed-off-by: Vijayalakshmi Chickkamenahalli Nagaraju --- diff --git a/vpnservice/dhcpservice/dhcpservice-impl/src/main/java/org/opendaylight/netvirt/dhcpservice/DhcpSubnetListener.java b/vpnservice/dhcpservice/dhcpservice-impl/src/main/java/org/opendaylight/netvirt/dhcpservice/DhcpSubnetListener.java index e8b0b29c52..2d91c07725 100644 --- a/vpnservice/dhcpservice/dhcpservice-impl/src/main/java/org/opendaylight/netvirt/dhcpservice/DhcpSubnetListener.java +++ b/vpnservice/dhcpservice/dhcpservice-impl/src/main/java/org/opendaylight/netvirt/dhcpservice/DhcpSubnetListener.java @@ -18,6 +18,7 @@ import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; 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; @@ -108,11 +109,16 @@ public class DhcpSubnetListener extends AsyncClusteredDataTreeChangeListenerBase 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); @@ -124,12 +130,17 @@ public class DhcpSubnetListener extends AsyncClusteredDataTreeChangeListenerBase 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);