[ONOS-5158] Allow to remove gateway nodes using network config file.
Change-Id: If59216bc7992517fa6f247e09cb0152c340ce6af
diff --git a/apps/openstacknode/src/main/java/org/onosproject/openstacknode/OpenstackNodeManager.java b/apps/openstacknode/src/main/java/org/onosproject/openstacknode/OpenstackNodeManager.java
index 5ef8045..1bf5858 100644
--- a/apps/openstacknode/src/main/java/org/onosproject/openstacknode/OpenstackNodeManager.java
+++ b/apps/openstacknode/src/main/java/org/onosproject/openstacknode/OpenstackNodeManager.java
@@ -74,6 +74,16 @@
import org.osgi.service.component.ComponentContext;
import org.slf4j.Logger;
+import java.util.Dictionary;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
+import java.util.concurrent.ExecutorService;
+import java.util.stream.Collectors;
+
import static com.google.common.base.Preconditions.checkArgument;
import static java.util.concurrent.Executors.newSingleThreadScheduledExecutor;
import static org.onlab.util.Tools.groupedThreads;
@@ -84,14 +94,6 @@
import static org.onosproject.openstacknode.OpenstackNodeEvent.NodeState.*;
import static org.slf4j.LoggerFactory.getLogger;
-import java.util.Dictionary;
-import java.util.List;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.Set;
-import java.util.concurrent.ExecutorService;
-import java.util.stream.Collectors;
-
/**
* Initializes devices in compute/gateway nodes according to there type.
*/
@@ -161,6 +163,7 @@
private final BridgeHandler bridgeHandler = new BridgeHandler();
private ConsistentMap<String, OpenstackNode> nodeStore;
+
private ApplicationId appId;
private NodeId localNodeId;
@@ -654,7 +657,13 @@
log.debug("No configuration found");
return;
}
- config.openstackNodes().forEach(this::addOrUpdateNode);
+
+ Map<String, OpenstackNode> prevNodeMap = new HashMap(nodeStore.asJavaMap());
+ config.openstackNodes().forEach(node -> {
+ prevNodeMap.remove(node.hostname());
+ addOrUpdateNode(node);
+ });
+ prevNodeMap.values().stream().forEach(this::deleteNode);
}
private class InternalConfigListener implements NetworkConfigListener {