Jonathan Hart
Committed by Charles Chan

Add property to toggle whether HostLocationProvider requests packet intercepts.

The default intercept flows that are pushed are too naiive for some
use cases, but those use cases may still want host location tracking to work.

Change-Id: Ic4ae3916a1dcee8e753362c3ce5bdfe10756100e
...@@ -120,6 +120,10 @@ public class HostLocationProvider extends AbstractProvider implements HostProvid ...@@ -120,6 +120,10 @@ public class HostLocationProvider extends AbstractProvider implements HostProvid
120 "Host Location Provider; default is false") 120 "Host Location Provider; default is false")
121 private boolean ipv6NeighborDiscovery = false; 121 private boolean ipv6NeighborDiscovery = false;
122 122
123 + @Property(name = "requestInterceptsEnabled", boolValue = true,
124 + label = "Enable requesting packet intercepts")
125 + private boolean requestInterceptsEnabled = true;
126 +
123 protected ExecutorService eventHandler; 127 protected ExecutorService eventHandler;
124 128
125 /** 129 /**
...@@ -133,12 +137,13 @@ public class HostLocationProvider extends AbstractProvider implements HostProvid ...@@ -133,12 +137,13 @@ public class HostLocationProvider extends AbstractProvider implements HostProvid
133 public void activate(ComponentContext context) { 137 public void activate(ComponentContext context) {
134 cfgService.registerProperties(getClass()); 138 cfgService.registerProperties(getClass());
135 appId = coreService.registerApplication("org.onosproject.provider.host"); 139 appId = coreService.registerApplication("org.onosproject.provider.host");
136 - eventHandler = newSingleThreadScheduledExecutor(groupedThreads("onos/host-loc-provider", "event-handler")); 140 + eventHandler = newSingleThreadScheduledExecutor(
141 + groupedThreads("onos/host-loc-provider", "event-handler"));
137 providerService = providerRegistry.register(this); 142 providerService = providerRegistry.register(this);
138 packetService.addProcessor(processor, PacketProcessor.advisor(1)); 143 packetService.addProcessor(processor, PacketProcessor.advisor(1));
139 deviceService.addListener(deviceListener); 144 deviceService.addListener(deviceListener);
140 - readComponentConfiguration(context); 145 +
141 - requestIntercepts(); 146 + modified(context);
142 147
143 log.info("Started with Application ID {}", appId.id()); 148 log.info("Started with Application ID {}", appId.id());
144 } 149 }
...@@ -160,7 +165,12 @@ public class HostLocationProvider extends AbstractProvider implements HostProvid ...@@ -160,7 +165,12 @@ public class HostLocationProvider extends AbstractProvider implements HostProvid
160 @Modified 165 @Modified
161 public void modified(ComponentContext context) { 166 public void modified(ComponentContext context) {
162 readComponentConfiguration(context); 167 readComponentConfiguration(context);
163 - requestIntercepts(); 168 +
169 + if (requestInterceptsEnabled) {
170 + requestIntercepts();
171 + } else {
172 + withdrawIntercepts();
173 + }
164 } 174 }
165 175
166 /** 176 /**
...@@ -237,6 +247,16 @@ public class HostLocationProvider extends AbstractProvider implements HostProvid ...@@ -237,6 +247,16 @@ public class HostLocationProvider extends AbstractProvider implements HostProvid
237 log.info("Configured. Using IPv6 Neighbor Discovery is {}", 247 log.info("Configured. Using IPv6 Neighbor Discovery is {}",
238 ipv6NeighborDiscovery ? "enabled" : "disabled"); 248 ipv6NeighborDiscovery ? "enabled" : "disabled");
239 } 249 }
250 +
251 + flag = isPropertyEnabled(properties, "requestInterceptsEnabled");
252 + if (flag == null) {
253 + log.info("Request intercepts is not configured, " +
254 + "using current value of {}", requestInterceptsEnabled);
255 + } else {
256 + requestInterceptsEnabled = flag;
257 + log.info("Configured. Request intercepts is {}",
258 + requestInterceptsEnabled ? "enabled" : "disabled");
259 + }
240 } 260 }
241 261
242 /** 262 /**
......