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
"Host Location Provider; default is false")
private boolean ipv6NeighborDiscovery = false;
@Property(name = "requestInterceptsEnabled", boolValue = true,
label = "Enable requesting packet intercepts")
private boolean requestInterceptsEnabled = true;
protected ExecutorService eventHandler;
/**
......@@ -133,12 +137,13 @@ public class HostLocationProvider extends AbstractProvider implements HostProvid
public void activate(ComponentContext context) {
cfgService.registerProperties(getClass());
appId = coreService.registerApplication("org.onosproject.provider.host");
eventHandler = newSingleThreadScheduledExecutor(groupedThreads("onos/host-loc-provider", "event-handler"));
eventHandler = newSingleThreadScheduledExecutor(
groupedThreads("onos/host-loc-provider", "event-handler"));
providerService = providerRegistry.register(this);
packetService.addProcessor(processor, PacketProcessor.advisor(1));
deviceService.addListener(deviceListener);
readComponentConfiguration(context);
requestIntercepts();
modified(context);
log.info("Started with Application ID {}", appId.id());
}
......@@ -160,7 +165,12 @@ public class HostLocationProvider extends AbstractProvider implements HostProvid
@Modified
public void modified(ComponentContext context) {
readComponentConfiguration(context);
requestIntercepts();
if (requestInterceptsEnabled) {
requestIntercepts();
} else {
withdrawIntercepts();
}
}
/**
......@@ -237,6 +247,16 @@ public class HostLocationProvider extends AbstractProvider implements HostProvid
log.info("Configured. Using IPv6 Neighbor Discovery is {}",
ipv6NeighborDiscovery ? "enabled" : "disabled");
}
flag = isPropertyEnabled(properties, "requestInterceptsEnabled");
if (flag == null) {
log.info("Request intercepts is not configured, " +
"using current value of {}", requestInterceptsEnabled);
} else {
requestInterceptsEnabled = flag;
log.info("Configured. Request intercepts is {}",
requestInterceptsEnabled ? "enabled" : "disabled");
}
}
/**
......