diff --git a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/cli/OpenstackNodeInitCommand.java b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/cli/OpenstackNodeInitCommand.java
index 226560d..f9a51b0 100644
--- a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/cli/OpenstackNodeInitCommand.java
+++ b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/cli/OpenstackNodeInitCommand.java
@@ -54,10 +54,7 @@
         OpenstackNodeService osNodeService = get(OpenstackNodeService.class);
         OpenstackNodeAdminService osNodeAdminService = get(OpenstackNodeAdminService.class);
 
-        if ((!isAll && !isIncomplete && hostnames == null) ||
-                (isAll && isIncomplete) ||
-                (isIncomplete && hostnames != null) ||
-                (hostnames != null && isAll)) {
+        if (isAll && isIncomplete) {
             print("Please specify one of hostname, --all, and --incomplete options.");
             return;
         }
@@ -71,6 +68,11 @@
                     .map(OpenstackNode::hostname).toArray(String[]::new);
         }
 
+        if (hostnames == null) {
+            print("Please specify one of hostname, --all, and --incomplete options.");
+            return;
+        }
+
         for (String hostname : hostnames) {
             OpenstackNode osNode = osNodeService.node(hostname);
             if (osNode == null) {
diff --git a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/codec/DpdkConfigCodec.java b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/codec/DpdkConfigCodec.java
index dcaed0f..13c8662 100644
--- a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/codec/DpdkConfigCodec.java
+++ b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/codec/DpdkConfigCodec.java
@@ -20,12 +20,13 @@
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import org.onosproject.codec.CodecContext;
 import org.onosproject.codec.JsonCodec;
+import org.onosproject.openstacknode.api.DefaultDpdkConfig;
 import org.onosproject.openstacknode.api.DpdkConfig;
 import org.onosproject.openstacknode.api.DpdkInterface;
-import org.onosproject.openstacknode.api.DefaultDpdkConfig;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Locale;
 import java.util.stream.IntStream;
 
 import static org.onlab.util.Tools.nullIsIllegal;
@@ -70,7 +71,7 @@
                 DATA_PATH_TYPE + MISSING_MESSAGE);
 
         DefaultDpdkConfig.Builder builder = DefaultDpdkConfig.builder()
-                .datapathType(DpdkConfig.DatapathType.valueOf(datapathType.toUpperCase()));
+                .datapathType(DpdkConfig.DatapathType.valueOf(datapathType.toUpperCase(Locale.ENGLISH)));
 
         if (json.get(SOCKET_DIR) != null) {
             builder.socketDir(json.get(SOCKET_DIR).asText());
diff --git a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/codec/DpdkInterfaceCodec.java b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/codec/DpdkInterfaceCodec.java
index 2d38221..deb9eb5 100644
--- a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/codec/DpdkInterfaceCodec.java
+++ b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/codec/DpdkInterfaceCodec.java
@@ -19,17 +19,23 @@
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import org.onosproject.codec.CodecContext;
 import org.onosproject.codec.JsonCodec;
+import org.onosproject.openstacknode.api.DefaultDpdkInterface;
 import org.onosproject.openstacknode.api.DpdkInterface;
 import org.onosproject.openstacknode.api.DpdkInterface.Type;
-import org.onosproject.openstacknode.api.DefaultDpdkInterface;
+import org.slf4j.Logger;
+
+import java.util.Locale;
 
 import static com.google.common.base.Preconditions.checkNotNull;
 import static org.onlab.util.Tools.nullIsIllegal;
+import static org.slf4j.LoggerFactory.getLogger;
 
 /**
  * DPDK interface codec used for serializing and de-serializing JSON string.
  */
 public class DpdkInterfaceCodec extends JsonCodec<DpdkInterface> {
+    protected final Logger log = getLogger(getClass());
+
     private static final String DEVICE_NAME = "deviceName";
     private static final String INTF = "intf";
     private static final String PCI_ADDRESS = "pciAddress";
@@ -68,9 +74,10 @@
 
         Type type;
         try {
-            type = Type.valueOf(typeString.toUpperCase());
+            type = Type.valueOf(typeString.toUpperCase(Locale.ENGLISH));
         } catch (IllegalArgumentException e) {
-            throw new IllegalArgumentException(TYPE + MISSING_MESSAGE);
+            log.error(TYPE + MISSING_MESSAGE);
+            throw new IllegalArgumentException(e);
         }
 
         DpdkInterface.Builder builder = DefaultDpdkInterface.builder()
diff --git a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/codec/OpenstackAuthCodec.java b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/codec/OpenstackAuthCodec.java
index d3ddabb..2964980 100644
--- a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/codec/OpenstackAuthCodec.java
+++ b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/codec/OpenstackAuthCodec.java
@@ -18,13 +18,11 @@
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import org.onosproject.codec.CodecContext;
 import org.onosproject.codec.JsonCodec;
-import org.onosproject.openstacknode.api.OpenstackAuth;
 import org.onosproject.openstacknode.api.DefaultOpenstackAuth;
-import org.slf4j.Logger;
+import org.onosproject.openstacknode.api.OpenstackAuth;
 
 import static com.google.common.base.Preconditions.checkNotNull;
 import static org.onlab.util.Tools.nullIsIllegal;
-import static org.slf4j.LoggerFactory.getLogger;
 
 /**
  * Openstack keystone authentication codec used for serializing and
@@ -32,8 +30,6 @@
  */
 public class OpenstackAuthCodec extends JsonCodec<OpenstackAuth> {
 
-    private final Logger log = getLogger(getClass());
-
     private static final String VERSION = "version";
     private static final String PROTOCOL = "protocol";
     private static final String USERNAME = "username";
diff --git a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/codec/OpenstackControllerCodec.java b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/codec/OpenstackControllerCodec.java
index 1921d43..7ac0659 100644
--- a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/codec/OpenstackControllerCodec.java
+++ b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/codec/OpenstackControllerCodec.java
@@ -20,19 +20,15 @@
 import org.onosproject.codec.CodecContext;
 import org.onosproject.codec.JsonCodec;
 import org.onosproject.net.behaviour.ControllerInfo;
-import org.slf4j.Logger;
 
 import static com.google.common.base.Preconditions.checkNotNull;
 import static org.onlab.util.Tools.nullIsIllegal;
-import static org.slf4j.LoggerFactory.getLogger;
 
 /**
  * Openstack controller codec used for serializing and de-serializing JSON string.
  */
 public class OpenstackControllerCodec extends JsonCodec<ControllerInfo> {
 
-    private final Logger log = getLogger(getClass());
-
     private static final String IP = "ip";
     private static final String PORT = "port";
     private static final String TCP = "tcp";  // controller connection should always be TCP
diff --git a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/codec/OpenstackPhyInterfaceCodec.java b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/codec/OpenstackPhyInterfaceCodec.java
index d84abf8..551606e 100644
--- a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/codec/OpenstackPhyInterfaceCodec.java
+++ b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/codec/OpenstackPhyInterfaceCodec.java
@@ -18,21 +18,17 @@
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import org.onosproject.codec.CodecContext;
 import org.onosproject.codec.JsonCodec;
-import org.onosproject.openstacknode.api.OpenstackPhyInterface;
 import org.onosproject.openstacknode.api.DefaultOpenstackPhyInterface;
-import org.slf4j.Logger;
+import org.onosproject.openstacknode.api.OpenstackPhyInterface;
 
 import static com.google.common.base.Preconditions.checkNotNull;
 import static org.onlab.util.Tools.nullIsIllegal;
-import static org.slf4j.LoggerFactory.getLogger;
 
 /**
  * Openstack physical interface codec used for serializing and de-serializing JSON string.
  */
 public final class OpenstackPhyInterfaceCodec extends JsonCodec<OpenstackPhyInterface> {
 
-    private final Logger log = getLogger(getClass());
-
     private static final String NETWORK = "network";
     private static final String INTERFACE = "intf";
 
diff --git a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/codec/OpenstackSshAuthCodec.java b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/codec/OpenstackSshAuthCodec.java
index 56b860a..c7b4b49 100644
--- a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/codec/OpenstackSshAuthCodec.java
+++ b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/codec/OpenstackSshAuthCodec.java
@@ -19,13 +19,11 @@
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import org.onosproject.codec.CodecContext;
 import org.onosproject.codec.JsonCodec;
-import org.onosproject.openstacknode.api.OpenstackSshAuth;
 import org.onosproject.openstacknode.api.DefaultOpenstackSshAuth;
-import org.slf4j.Logger;
+import org.onosproject.openstacknode.api.OpenstackSshAuth;
 
 import static com.google.common.base.Preconditions.checkNotNull;
 import static org.onlab.util.Tools.nullIsIllegal;
-import static org.slf4j.LoggerFactory.getLogger;
 
 /**
  * Node ssh authentication info codec used for serializing and
@@ -33,8 +31,6 @@
  */
 public class OpenstackSshAuthCodec extends JsonCodec<OpenstackSshAuth> {
 
-    private final Logger log = getLogger(getClass());
-
     private static final String ID = "id";
     private static final String PASSWORD = "password";
 
diff --git a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/DefaultOpenstackNodeHandler.java b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/DefaultOpenstackNodeHandler.java
index c2c3d57..01f8e4f 100644
--- a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/DefaultOpenstackNodeHandler.java
+++ b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/DefaultOpenstackNodeHandler.java
@@ -121,6 +121,7 @@
     private final Logger log = getLogger(getClass());
 
     private static final String DEFAULT_OF_PROTO = "tcp";
+    private static final String NO_OVSDB_CLIENT_MSG = "Failed to get ovsdb client";
     private static final int DEFAULT_OFPORT = 6653;
     private static final int DPID_BEGIN = 3;
 
@@ -278,7 +279,7 @@
 
     @Override
     public void processIncompleteState(OpenstackNode osNode) {
-        //TODO
+        //Do nothing for now
     }
 
     private boolean hasDpdkTunnelBridge(OpenstackNode osNode) {
@@ -293,7 +294,7 @@
 
         OvsdbClientService client = getOvsdbClient(osNode, ovsdbPortNum, ovsdbController);
         if (client == null) {
-            log.info("Failed to get ovsdb client");
+            log.info(NO_OVSDB_CLIENT_MSG);
             return false;
         }
 
@@ -453,6 +454,57 @@
                                 port.isEnabled());
     }
 
+
+    private boolean initStateDone(OpenstackNode osNode) {
+        if (!isOvsdbConnected(osNode, ovsdbPortNum, ovsdbController, deviceService)) {
+            return false;
+        }
+
+        boolean initStateDone = deviceService.isAvailable(osNode.intgBridge());
+        if (hasDpdkTunnelBridge(osNode)) {
+            initStateDone = initStateDone && dpdkTunnelBridgeCreated(osNode);
+        }
+
+        return initStateDone;
+    }
+
+    private boolean deviceCreatedStateDone(OpenstackNode osNode) {
+        if (osNode.dataIp() != null &&
+                !isIntfEnabled(osNode, VXLAN_TUNNEL)) {
+            return false;
+        }
+        if (osNode.dataIp() != null &&
+                !isIntfEnabled(osNode, GRE_TUNNEL)) {
+            return false;
+        }
+        if (osNode.dataIp() != null &&
+                !isIntfEnabled(osNode, GENEVE_TUNNEL)) {
+            return false;
+        }
+        if (osNode.vlanIntf() != null &&
+                !isIntfEnabled(osNode, osNode.vlanIntf())) {
+            return false;
+        }
+        if (osNode.type() == GATEWAY &&
+                !isIntfEnabled(osNode, osNode.uplinkPort())) {
+            return false;
+        }
+        if (osNode.dpdkConfig() != null &&
+                osNode.dpdkConfig().dpdkIntfs() != null &&
+                !isDpdkIntfsCreated(osNode, osNode.dpdkConfig().dpdkIntfs())) {
+            return false;
+        }
+
+        for (OpenstackPhyInterface intf : osNode.phyIntfs()) {
+            if (intf != null && !isIntfEnabled(osNode, intf.intf())) {
+                return false;
+            }
+        }
+
+        return true;
+    }
+
+
     /**
      * Checks whether all requirements for this state are fulfilled or not.
      *
@@ -462,50 +514,9 @@
     private boolean isCurrentStateDone(OpenstackNode osNode) {
         switch (osNode.state()) {
             case INIT:
-                if (!isOvsdbConnected(osNode, ovsdbPortNum,
-                                                ovsdbController, deviceService)) {
-                    return false;
-                }
-
-                boolean initStateDone = deviceService.isAvailable(osNode.intgBridge());
-                if (hasDpdkTunnelBridge(osNode)) {
-                    initStateDone = initStateDone && dpdkTunnelBridgeCreated(osNode);
-                }
-                return initStateDone;
+                return initStateDone(osNode);
             case DEVICE_CREATED:
-                if (osNode.dataIp() != null &&
-                        !isIntfEnabled(osNode, VXLAN_TUNNEL)) {
-                    return false;
-                }
-                if (osNode.dataIp() != null &&
-                        !isIntfEnabled(osNode, GRE_TUNNEL)) {
-                    return false;
-                }
-                if (osNode.dataIp() != null &&
-                        !isIntfEnabled(osNode, GENEVE_TUNNEL)) {
-                    return false;
-                }
-                if (osNode.vlanIntf() != null &&
-                        !isIntfEnabled(osNode, osNode.vlanIntf())) {
-                    return false;
-                }
-                if (osNode.type() == GATEWAY &&
-                        !isIntfEnabled(osNode, osNode.uplinkPort())) {
-                    return false;
-                }
-                if (osNode.dpdkConfig() != null &&
-                        osNode.dpdkConfig().dpdkIntfs() != null &&
-                        !isDpdkIntfsCreated(osNode, osNode.dpdkConfig().dpdkIntfs())) {
-                    return false;
-                }
-
-                for (OpenstackPhyInterface intf : osNode.phyIntfs()) {
-                    if (intf != null && !isIntfEnabled(osNode, intf.intf())) {
-                        return false;
-                    }
-                }
-
-                return true;
+                return deviceCreatedStateDone(osNode);
             case COMPLETE:
             case INCOMPLETE:
                 // always return false
@@ -632,41 +643,6 @@
         }
     }
 
-    private void processOpenstackNodeRemoved(OpenstackNode osNode) {
-        OvsdbClientService client = getOvsdbClient(osNode, ovsdbPortNum, ovsdbController);
-        if (client == null) {
-            log.info("Failed to get ovsdb client");
-            return;
-        }
-
-        //delete physical interfaces from the node
-        removePhysicalInterface(osNode);
-
-        //delete vlan interface from the node
-        removeVlanInterface(osNode);
-
-        //delete dpdk interfaces from the node
-        if (osNode.dpdkConfig() != null) {
-            osNode.dpdkConfig().dpdkIntfs().forEach(dpdkInterface -> {
-                if (isDpdkIntfsCreated(osNode, Lists.newArrayList(dpdkInterface))) {
-                    addOrRemoveDpdkInterface(osNode, dpdkInterface, ovsdbPortNum,
-                                                ovsdbController, false);
-                }
-            });
-        }
-
-        //delete tunnel bridge from the node
-        if (hasDpdkTunnelBridge(osNode)) {
-            client.dropBridge(TUNNEL_BRIDGE);
-        }
-
-        //delete integration bridge from the node
-        client.dropBridge(INTEGRATION_BRIDGE);
-
-        //disconnect ovsdb
-        client.disconnect();
-    }
-
     /**
      * Checks the validity of the given endpoint.
      *
@@ -742,21 +718,10 @@
                 case DEVICE_AVAILABILITY_CHANGED:
                 case DEVICE_ADDED:
                     eventExecutor.execute(() -> {
-
                         if (!isRelevantHelper()) {
                             return;
                         }
-
-                        OpenstackNode osNode = osNodeService.node(device.id());
-
-                        if (osNode == null || osNode.type() == CONTROLLER) {
-                            return;
-                        }
-
-                        if (deviceService.isAvailable(device.id())) {
-                            log.debug("OVSDB {} detected", device.id());
-                            bootstrapNode(osNode);
-                        }
+                        processDeviceAddedOfOvsdbDevice(osNodeService.node(device.id()), device);
                     });
                     break;
                 case PORT_ADDED:
@@ -767,6 +732,17 @@
                     break;
             }
         }
+
+        private void processDeviceAddedOfOvsdbDevice(OpenstackNode osNode, Device device) {
+            if (osNode == null || osNode.type() == CONTROLLER) {
+                return;
+            }
+
+            if (deviceService.isAvailable(device.id())) {
+                log.debug("OVSDB {} detected", device.id());
+                bootstrapNode(osNode);
+            }
+        }
     }
 
     /**
@@ -794,92 +770,27 @@
                 case DEVICE_AVAILABILITY_CHANGED:
                 case DEVICE_ADDED:
                     eventExecutor.execute(() -> {
-
                         if (!isRelevantHelper()) {
                             return;
                         }
-
-                        OpenstackNode osNode = osNodeService.node(device.id());
-
-                        if (osNode == null || osNode.type() == CONTROLLER) {
-                            return;
-                        }
-
-                        if (deviceService.isAvailable(device.id())) {
-                            log.debug("Integration bridge created on {}", osNode.hostname());
-                            bootstrapNode(osNode);
-                        } else if (osNode.state() == COMPLETE) {
-                            log.info("Device {} disconnected", device.id());
-                            setState(osNode, INCOMPLETE);
-                        }
-
-                        if (autoRecovery) {
-                            if (osNode.state() == INCOMPLETE ||
-                                    osNode.state() == DEVICE_CREATED) {
-                                log.info("Device {} is reconnected", device.id());
-                                osNodeAdminService.updateNode(
-                                        osNode.updateState(NodeState.INIT));
-                            }
-                        }
+                        processDeviceAddedOfBridge(osNodeService.node(device.id()), device);
                     });
                     break;
                 case PORT_UPDATED:
                 case PORT_ADDED:
                     eventExecutor.execute(() -> {
-
                         if (!isRelevantHelper()) {
                             return;
                         }
-
-                        OpenstackNode osNode = osNodeService.node(device.id());
-
-                        if (osNode == null || osNode.type() == CONTROLLER) {
-                            return;
-                        }
-
-                        Port port = event.port();
-                        String portName = port.annotations().value(PORT_NAME);
-                        if (osNode.state() == DEVICE_CREATED && (
-                                Objects.equals(portName, VXLAN_TUNNEL) ||
-                                Objects.equals(portName, GRE_TUNNEL) ||
-                                Objects.equals(portName, GENEVE_TUNNEL) ||
-                                Objects.equals(portName, osNode.vlanIntf()) ||
-                                Objects.equals(portName, osNode.uplinkPort()) ||
-                                        containsPhyIntf(osNode, portName)) ||
-                                containsDpdkIntfs(osNode, portName)) {
-                            log.info("Interface {} added or updated to {}",
-                                                portName, device.id());
-                            bootstrapNode(osNode);
-                        }
+                        processPortAddedOfBridge(osNodeService.node(device.id()), event.port());
                     });
                     break;
                 case PORT_REMOVED:
                     eventExecutor.execute(() -> {
-
                         if (!isRelevantHelper()) {
                             return;
                         }
-
-                        OpenstackNode osNode = osNodeService.node(device.id());
-
-                        if (osNode == null || osNode.type() == CONTROLLER) {
-                            return;
-                        }
-
-                        Port port = event.port();
-                        String portName = port.annotations().value(PORT_NAME);
-                        if (osNode.state() == COMPLETE && (
-                                Objects.equals(portName, VXLAN_TUNNEL) ||
-                                Objects.equals(portName, GRE_TUNNEL) ||
-                                Objects.equals(portName, GENEVE_TUNNEL) ||
-                                Objects.equals(portName, osNode.vlanIntf()) ||
-                                Objects.equals(portName, osNode.uplinkPort()) ||
-                                        containsPhyIntf(osNode, portName)) ||
-                                containsDpdkIntfs(osNode, portName)) {
-                            log.warn("Interface {} removed from {}",
-                                                portName, event.subject().id());
-                            setState(osNode, INCOMPLETE);
-                        }
+                        processPortRemovedOfBridge(osNodeService.node(device.id()), event.port());
                     });
                     break;
                 case DEVICE_REMOVED:
@@ -888,37 +799,103 @@
                     break;
             }
         }
-    }
 
-    /**
-     * Checks whether the openstack node contains the given physical interface.
-     *
-     * @param osNode openstack node
-     * @param portName physical interface
-     * @return true if openstack node contains the given physical interface,
-     *          false otherwise
-     */
-    private boolean containsPhyIntf(OpenstackNode osNode, String portName) {
-        return osNode.phyIntfs().stream()
-                .anyMatch(phyInterface -> phyInterface.intf().equals(portName));
-    }
+        private void processDeviceAddedOfBridge(OpenstackNode osNode, Device device) {
 
-    /**
-     * Checks whether the openstack node contains the given dpdk interface.
-     *
-     * @param osNode openstack node
-     * @param portName dpdk interface
-     * @return true if openstack node contains the given dpdk interface,
-     *          false otherwise
-     */
-    private boolean containsDpdkIntfs(OpenstackNode osNode, String portName) {
-        if (osNode.dpdkConfig() == null) {
-            return false;
+            if (osNode == null || osNode.type() == CONTROLLER) {
+                return;
+            }
+
+            if (deviceService.isAvailable(device.id())) {
+                log.debug("Integration bridge created on {}", osNode.hostname());
+                bootstrapNode(osNode);
+            } else if (osNode.state() == COMPLETE) {
+                log.info("Device {} disconnected", device.id());
+                setState(osNode, INCOMPLETE);
+            }
+
+            if (autoRecovery) {
+                if (osNode.state() == INCOMPLETE ||
+                        osNode.state() == DEVICE_CREATED) {
+                    log.info("Device {} is reconnected", device.id());
+                    osNodeAdminService.updateNode(
+                            osNode.updateState(NodeState.INIT));
+                }
+            }
         }
-        return osNode.dpdkConfig().dpdkIntfs().stream()
-                .anyMatch(dpdkInterface -> dpdkInterface.intf().equals(portName));
+
+        private void processPortAddedOfBridge(OpenstackNode osNode, Port port) {
+            if (osNode == null || osNode.type() == CONTROLLER) {
+                return;
+            }
+
+            String portName = port.annotations().value(PORT_NAME);
+            if (osNode.state() == DEVICE_CREATED && (
+                    Objects.equals(portName, VXLAN_TUNNEL) ||
+                            Objects.equals(portName, GRE_TUNNEL) ||
+                            Objects.equals(portName, GENEVE_TUNNEL) ||
+                            Objects.equals(portName, osNode.vlanIntf()) ||
+                            Objects.equals(portName, osNode.uplinkPort()) ||
+                            containsPhyIntf(osNode, portName)) ||
+                    containsDpdkIntfs(osNode, portName)) {
+                log.info("Interface {} added or updated to {}",
+                        portName, osNode.intgBridge());
+                bootstrapNode(osNode);
+            }
+        }
+
+        private void processPortRemovedOfBridge(OpenstackNode osNode, Port port) {
+            if (osNode == null || osNode.type() == CONTROLLER) {
+                return;
+            }
+
+            String portName = port.annotations().value(PORT_NAME);
+            if (osNode.state() == COMPLETE && (
+                    Objects.equals(portName, VXLAN_TUNNEL) ||
+                            Objects.equals(portName, GRE_TUNNEL) ||
+                            Objects.equals(portName, GENEVE_TUNNEL) ||
+                            Objects.equals(portName, osNode.vlanIntf()) ||
+                            Objects.equals(portName, osNode.uplinkPort()) ||
+                            containsPhyIntf(osNode, portName)) ||
+                    containsDpdkIntfs(osNode, portName)) {
+                log.warn("Interface {} removed from {}",
+                        portName, osNode.intgBridge());
+                setState(osNode, INCOMPLETE);
+            }
+        }
+
+
+        /**
+         * Checks whether the openstack node contains the given physical interface.
+         *
+         * @param osNode openstack node
+         * @param portName physical interface
+         * @return true if openstack node contains the given physical interface,
+         *          false otherwise
+         */
+        private boolean containsPhyIntf(OpenstackNode osNode, String portName) {
+            return osNode.phyIntfs().stream()
+                    .anyMatch(phyInterface -> phyInterface.intf().equals(portName));
+        }
+
+        /**
+         * Checks whether the openstack node contains the given dpdk interface.
+         *
+         * @param osNode openstack node
+         * @param portName dpdk interface
+         * @return true if openstack node contains the given dpdk interface,
+         *          false otherwise
+         */
+        private boolean containsDpdkIntfs(OpenstackNode osNode, String portName) {
+            if (osNode.dpdkConfig() == null) {
+                return false;
+            }
+            return osNode.dpdkConfig().dpdkIntfs().stream()
+                    .anyMatch(dpdkInterface -> dpdkInterface.intf().equals(portName));
+        }
     }
 
+
     /**
      * An internal openstack node listener.
      * The notification is triggered by OpenstackNodeStore.
@@ -949,7 +926,6 @@
                         if (!isRelevantHelper()) {
                             return;
                         }
-
                         processOpenstackNodeRemoved(event.subject());
                     });
                     break;
@@ -958,5 +934,40 @@
                     break;
             }
         }
+
+        private void processOpenstackNodeRemoved(OpenstackNode osNode) {
+            OvsdbClientService client = getOvsdbClient(osNode, ovsdbPortNum, ovsdbController);
+            if (client == null) {
+                log.info("Failed to get ovsdb client");
+                return;
+            }
+
+            //delete physical interfaces from the node
+            removePhysicalInterface(osNode);
+
+            //delete vlan interface from the node
+            removeVlanInterface(osNode);
+
+            //delete dpdk interfaces from the node
+            if (osNode.dpdkConfig() != null) {
+                osNode.dpdkConfig().dpdkIntfs().forEach(dpdkInterface -> {
+                    if (isDpdkIntfsCreated(osNode, Lists.newArrayList(dpdkInterface))) {
+                        addOrRemoveDpdkInterface(osNode, dpdkInterface, ovsdbPortNum,
+                                ovsdbController, false);
+                    }
+                });
+            }
+
+            //delete tunnel bridge from the node
+            if (hasDpdkTunnelBridge(osNode)) {
+                client.dropBridge(TUNNEL_BRIDGE);
+            }
+
+            //delete integration bridge from the node
+            client.dropBridge(INTEGRATION_BRIDGE);
+
+            //disconnect ovsdb
+            client.disconnect();
+        }
     }
 }
diff --git a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/DistributedOpenstackNodeStore.java b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/DistributedOpenstackNodeStore.java
index 9014076..c6f5dac 100644
--- a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/DistributedOpenstackNodeStore.java
+++ b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/DistributedOpenstackNodeStore.java
@@ -184,51 +184,20 @@
      */
     private class OpenstackNodeMapListener
                             implements MapEventListener<String, OpenstackNode> {
-
         @Override
         public void event(MapEvent<String, OpenstackNode> event) {
-
             switch (event.type()) {
                 case INSERT:
                     log.debug("OpenStack node created {}", event.newValue());
-                    eventExecutor.execute(() ->
-                            notifyDelegate(new OpenstackNodeEvent(
-                                OPENSTACK_NODE_CREATED, event.newValue().value()
-                    )));
+                    eventExecutor.execute(() -> processNodeCreation(event));
                     break;
                 case UPDATE:
                     log.debug("OpenStack node updated {}", event.newValue());
-                    eventExecutor.execute(() -> {
-                        notifyDelegate(new OpenstackNodeEvent(
-                                OPENSTACK_NODE_UPDATED,
-                                event.newValue().value()
-                        ));
-
-                        // if the event is about controller node, we will not
-                        // process COMPLETE and INCOMPLETE state
-                        if (isControllerNode(event)) {
-                            return;
-                        }
-
-                        if (event.newValue().value().state() == COMPLETE) {
-                            notifyDelegate(new OpenstackNodeEvent(
-                                    OPENSTACK_NODE_COMPLETE,
-                                    event.newValue().value()
-                            ));
-                        } else if (event.newValue().value().state() == INCOMPLETE) {
-                            notifyDelegate(new OpenstackNodeEvent(
-                                    OPENSTACK_NODE_INCOMPLETE,
-                                    event.newValue().value()
-                            ));
-                        }
-                    });
+                    eventExecutor.execute(() -> processNodeUpdate(event));
                     break;
                 case REMOVE:
                     log.debug("OpenStack node removed {}", event.oldValue());
-                    eventExecutor.execute(() ->
-                            notifyDelegate(new OpenstackNodeEvent(
-                                OPENSTACK_NODE_REMOVED, event.oldValue().value()
-                    )));
+                    eventExecutor.execute(() -> processNodeRemoval(event));
                     break;
                 default:
                     // do nothing
@@ -236,6 +205,41 @@
             }
         }
 
+        private void processNodeCreation(MapEvent<String, OpenstackNode> event) {
+            notifyDelegate(new OpenstackNodeEvent(
+                    OPENSTACK_NODE_CREATED, event.newValue().value()));
+        }
+
+        private void processNodeUpdate(MapEvent<String, OpenstackNode> event) {
+            notifyDelegate(new OpenstackNodeEvent(
+                    OPENSTACK_NODE_UPDATED,
+                    event.newValue().value()
+            ));
+
+            // if the event is about controller node, we will not
+            // process COMPLETE and INCOMPLETE state
+            if (isControllerNode(event)) {
+                return;
+            }
+
+            if (event.newValue().value().state() == COMPLETE) {
+                notifyDelegate(new OpenstackNodeEvent(
+                        OPENSTACK_NODE_COMPLETE,
+                        event.newValue().value()
+                ));
+            } else if (event.newValue().value().state() == INCOMPLETE) {
+                notifyDelegate(new OpenstackNodeEvent(
+                        OPENSTACK_NODE_INCOMPLETE,
+                        event.newValue().value()
+                ));
+            }
+        }
+
+        private void processNodeRemoval(MapEvent<String, OpenstackNode> event) {
+            notifyDelegate(new OpenstackNodeEvent(
+                    OPENSTACK_NODE_REMOVED, event.oldValue().value()));
+        }
+
         /**
          * Checks the openstack node whether a controller node or not with
          * the given MapEvent.
diff --git a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/util/OpenstackNodeUtil.java b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/util/OpenstackNodeUtil.java
index 277e58e..d478bcc 100644
--- a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/util/OpenstackNodeUtil.java
+++ b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/util/OpenstackNodeUtil.java
@@ -163,7 +163,7 @@
                 return null;
             }
         } catch (AuthenticationException e) {
-            log.error("Authentication failed due to {}", e.toString());
+            log.error("Authentication failed due to {}", e);
             return null;
         }
     }
@@ -183,6 +183,7 @@
             String s = get(properties, propertyName);
             value = Strings.isNullOrEmpty(s) ? null : Boolean.valueOf(s);
         } catch (ClassCastException e) {
+            log.error("Exception occurred because of {}. set valud to null..", e);
             value = null;
         }
         return value;
@@ -375,16 +376,21 @@
 
         TrustManager[] trustAllCerts = new TrustManager[]{
                 new X509TrustManager() {
+                    @Override
                     public X509Certificate[] getAcceptedIssuers() {
                         return null;
                     }
 
+                    @Override
                     public void checkClientTrusted(X509Certificate[] certs,
                                                    String authType) {
+                        return;
                     }
 
+                    @Override
                     public void checkServerTrusted(X509Certificate[] certs,
                                                    String authType) {
+                        return;
                     }
                 }
         };
@@ -400,7 +406,7 @@
 
             config.withSSLContext(sc);
         } catch (Exception e) {
-            log.error("Failed to access OpenStack service due to {}", e.toString());
+            log.error("Failed to access OpenStack service due to {}", e);
             return null;
         }
 
diff --git a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/web/OpenstackNodeWebResource.java b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/web/OpenstackNodeWebResource.java
index 0acdb88..ae85af0 100644
--- a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/web/OpenstackNodeWebResource.java
+++ b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/web/OpenstackNodeWebResource.java
@@ -162,16 +162,11 @@
              JsonNode jsonTree = readTreeFromStream(mapper().enable(INDENT_OUTPUT), input);
              ArrayNode nodes = (ArrayNode) jsonTree.path(NODES);
              nodes.forEach(node -> {
-                 try {
                      ObjectNode objectNode = node.deepCopy();
                      OpenstackNode openstackNode =
                              codec(OpenstackNode.class).decode(objectNode, this);
 
                      nodeSet.add(openstackNode);
-                 } catch (Exception e) {
-                     log.error("Exception occurred due to {}", e);
-                     throw new IllegalArgumentException();
-                 }
              });
         } catch (Exception e) {
             throw new IllegalArgumentException(e);
