Do not override configured hosts
- When multiple host providers add the same host, the configured one will always win
- A provider can only remove a host provided by itself
Change-Id: I38d95cceed6f36c71b8417ce6812bbd5add10e57
diff --git a/core/net/src/main/java/org/onosproject/net/host/impl/HostManager.java b/core/net/src/main/java/org/onosproject/net/host/impl/HostManager.java
index 3f5d643..8a3cf7d 100644
--- a/core/net/src/main/java/org/onosproject/net/host/impl/HostManager.java
+++ b/core/net/src/main/java/org/onosproject/net/host/impl/HostManager.java
@@ -399,9 +399,6 @@
});
}
-
-
-
// returns a HostDescription made from the union of the BasicHostConfig
// annotations if it exists
private HostDescription validateHost(HostDescription hostDescription, HostId hostId) {
@@ -416,6 +413,12 @@
checkNotNull(hostId, HOST_ID_NULL);
checkValidity();
Host host = store.getHost(hostId);
+
+ // Disallow removing inexistent host or host provided by others
+ if (host == null || !host.providerId().equals(provider().id())) {
+ return;
+ }
+
if (monitorHosts) {
host.ipAddresses().forEach(ip -> {
monitor.stopMonitoring(ip);