Committed by
Gerrit Code Review
[ONOS-5158] Allow to remove gateway nodes using network config file.
Change-Id: If59216bc7992517fa6f247e09cb0152c340ce6af
Showing
1 changed file
with
18 additions
and
9 deletions
| ... | @@ -74,6 +74,16 @@ import org.onosproject.store.service.Versioned; | ... | @@ -74,6 +74,16 @@ import org.onosproject.store.service.Versioned; |
| 74 | import org.osgi.service.component.ComponentContext; | 74 | import org.osgi.service.component.ComponentContext; |
| 75 | import org.slf4j.Logger; | 75 | import org.slf4j.Logger; |
| 76 | 76 | ||
| 77 | +import java.util.Dictionary; | ||
| 78 | +import java.util.HashMap; | ||
| 79 | +import java.util.List; | ||
| 80 | +import java.util.Map; | ||
| 81 | +import java.util.Objects; | ||
| 82 | +import java.util.Optional; | ||
| 83 | +import java.util.Set; | ||
| 84 | +import java.util.concurrent.ExecutorService; | ||
| 85 | +import java.util.stream.Collectors; | ||
| 86 | + | ||
| 77 | import static com.google.common.base.Preconditions.checkArgument; | 87 | import static com.google.common.base.Preconditions.checkArgument; |
| 78 | import static java.util.concurrent.Executors.newSingleThreadScheduledExecutor; | 88 | import static java.util.concurrent.Executors.newSingleThreadScheduledExecutor; |
| 79 | import static org.onlab.util.Tools.groupedThreads; | 89 | import static org.onlab.util.Tools.groupedThreads; |
| ... | @@ -84,14 +94,6 @@ import static org.onosproject.openstacknode.Constants.*; | ... | @@ -84,14 +94,6 @@ import static org.onosproject.openstacknode.Constants.*; |
| 84 | import static org.onosproject.openstacknode.OpenstackNodeEvent.NodeState.*; | 94 | import static org.onosproject.openstacknode.OpenstackNodeEvent.NodeState.*; |
| 85 | import static org.slf4j.LoggerFactory.getLogger; | 95 | import static org.slf4j.LoggerFactory.getLogger; |
| 86 | 96 | ||
| 87 | -import java.util.Dictionary; | ||
| 88 | -import java.util.List; | ||
| 89 | -import java.util.Objects; | ||
| 90 | -import java.util.Optional; | ||
| 91 | -import java.util.Set; | ||
| 92 | -import java.util.concurrent.ExecutorService; | ||
| 93 | -import java.util.stream.Collectors; | ||
| 94 | - | ||
| 95 | /** | 97 | /** |
| 96 | * Initializes devices in compute/gateway nodes according to there type. | 98 | * Initializes devices in compute/gateway nodes according to there type. |
| 97 | */ | 99 | */ |
| ... | @@ -161,6 +163,7 @@ public final class OpenstackNodeManager extends ListenerRegistry<OpenstackNodeEv | ... | @@ -161,6 +163,7 @@ public final class OpenstackNodeManager extends ListenerRegistry<OpenstackNodeEv |
| 161 | private final BridgeHandler bridgeHandler = new BridgeHandler(); | 163 | private final BridgeHandler bridgeHandler = new BridgeHandler(); |
| 162 | 164 | ||
| 163 | private ConsistentMap<String, OpenstackNode> nodeStore; | 165 | private ConsistentMap<String, OpenstackNode> nodeStore; |
| 166 | + | ||
| 164 | private ApplicationId appId; | 167 | private ApplicationId appId; |
| 165 | private NodeId localNodeId; | 168 | private NodeId localNodeId; |
| 166 | 169 | ||
| ... | @@ -654,7 +657,13 @@ public final class OpenstackNodeManager extends ListenerRegistry<OpenstackNodeEv | ... | @@ -654,7 +657,13 @@ public final class OpenstackNodeManager extends ListenerRegistry<OpenstackNodeEv |
| 654 | log.debug("No configuration found"); | 657 | log.debug("No configuration found"); |
| 655 | return; | 658 | return; |
| 656 | } | 659 | } |
| 657 | - config.openstackNodes().forEach(this::addOrUpdateNode); | 660 | + |
| 661 | + Map<String, OpenstackNode> prevNodeMap = new HashMap(nodeStore.asJavaMap()); | ||
| 662 | + config.openstackNodes().forEach(node -> { | ||
| 663 | + prevNodeMap.remove(node.hostname()); | ||
| 664 | + addOrUpdateNode(node); | ||
| 665 | + }); | ||
| 666 | + prevNodeMap.values().stream().forEach(this::deleteNode); | ||
| 658 | } | 667 | } |
| 659 | 668 | ||
| 660 | private class InternalConfigListener implements NetworkConfigListener { | 669 | private class InternalConfigListener implements NetworkConfigListener { | ... | ... |
-
Please register or login to post a comment