Bug 7674 Update of DHCP flag support for subnet-update configuration 00/51000/3
authorVijayalakshmi Chickkamenahalli Nagaraju <vijayalakshmi.c@altencalsoftlabs.com>
Wed, 25 Jan 2017 11:12:30 +0000 (16:42 +0530)
committerSam Hague <shague@redhat.com>
Wed, 1 Feb 2017 16:22:15 +0000 (16:22 +0000)
Change-Id: Ibe318e207dfeb4ea95ac99df733fd31c0f8d1dd6
Signed-off-by: Vijayalakshmi Chickkamenahalli Nagaraju <vijayalakshmi.c@altencalsoftlabs.com>
vpnservice/dhcpservice/dhcpservice-impl/src/main/java/org/opendaylight/netvirt/dhcpservice/DhcpSubnetListener.java

index e8b0b29c52ff343a35fa8fa76bdee81ef366a983..2d91c077255c4e2e0bfd26b8362bdc205c92d95e 100644 (file)
@@ -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);