Make vRouter components into separate apps.
This allows us to leverage the ONOS app subsystem for selecting which
components to load.
CORD-710
Change-Id: Ibd7c4c1afd2caa137b44c085e7b6b5b4a1082521
diff --git a/apps/vrouter/BUCK b/apps/vrouter/BUCK
index e2322e3..267460a 100644
--- a/apps/vrouter/BUCK
+++ b/apps/vrouter/BUCK
@@ -5,7 +5,7 @@
BUNDLES = [
'//apps/routing-api:onos-apps-routing-api',
- '//apps/routing:onos-apps-routing',
+ '//apps/routing/common:onos-apps-routing-common',
'//apps/vrouter:onos-apps-vrouter',
]
@@ -19,4 +19,5 @@
url = 'http://onosproject.org',
included_bundles = BUNDLES,
description = 'Virtual router (vRouter) application.',
+ required_apps = [ 'org.onosproject.fibinstaller', 'org.onosproject.cpr', 'org.onosproject.fpm' ],
)
diff --git a/apps/vrouter/src/main/java/org/onosproject/vrouter/Vrouter.java b/apps/vrouter/src/main/java/org/onosproject/vrouter/Vrouter.java
index 331d04a..d694996 100644
--- a/apps/vrouter/src/main/java/org/onosproject/vrouter/Vrouter.java
+++ b/apps/vrouter/src/main/java/org/onosproject/vrouter/Vrouter.java
@@ -19,20 +19,15 @@
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
-import org.apache.felix.scr.annotations.Modified;
-import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
-import org.onlab.util.Tools;
import org.onosproject.cfg.ComponentConfigService;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
import org.onosproject.incubator.component.ComponentService;
-import org.osgi.service.component.ComponentContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.Dictionary;
import java.util.List;
/**
@@ -44,9 +39,6 @@
private final Logger log = LoggerFactory.getLogger(getClass());
private static final String APP_NAME = "org.onosproject.vrouter";
- private static final String FPM_MANAGER = "org.onosproject.routing.fpm.FpmManager";
- private static final String FIB_INSTALLER = "org.onosproject.routing.impl.SingleSwitchFibInstaller";
- private static final String CP_REDIRECT = "org.onosproject.routing.impl.ControlPlaneRedirectManager";
private static final String DIRECT_HOST_MGR = "org.onosproject.routing.impl.DirectHostManager";
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
@@ -58,32 +50,19 @@
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
private ComponentConfigService componentConfigService;
- /**
- * vRouter will push flows to the switches when receiving routes by enabling
- * FIB installer.
- * <p>
- * It should be turned off when vRouter is deployed in a scenario where
- * other components that pushes the routes.
- */
- @Property(name = "fibInstallerEnabled", boolValue = true,
- label = "Enable single switch fib installer; default is true")
- private boolean fibInstallerEnabled = true;
-
private ApplicationId appId;
- private List<String> baseComponents = Lists.newArrayList(FPM_MANAGER, CP_REDIRECT, DIRECT_HOST_MGR);
+ private List<String> baseComponents = Lists.newArrayList(DIRECT_HOST_MGR);
@Activate
- protected void activate(ComponentContext context) {
+ protected void activate() {
appId = coreService.registerApplication(APP_NAME);
- componentConfigService.registerProperties(getClass());
componentConfigService.preSetProperty(
"org.onosproject.incubator.store.routing.impl.RouteStoreImpl",
"distributed", "true");
baseComponents.forEach(name -> componentService.activate(appId, name));
- modified(context);
log.info("Started");
}
@@ -96,28 +75,4 @@
log.info("Stopped");
}
-
- @Modified
- private void modified(ComponentContext context) {
- Dictionary<?, ?> properties = context.getProperties();
- if (properties == null) {
- return;
- }
-
- Boolean newFibInstallerEnabled = Tools.isPropertyEnabled(properties, "fibInstallerEnabled");
- if (newFibInstallerEnabled == null) {
- log.info("fibInstallerEnabled is not configured, " +
- "using current value of {}", fibInstallerEnabled);
- } else {
- fibInstallerEnabled = newFibInstallerEnabled;
- log.info("Configured. fibInstallerEnabled set to {}, ",
- fibInstallerEnabled ? "enabled" : "disabled");
- }
-
- if (fibInstallerEnabled) {
- componentService.activate(appId, FIB_INSTALLER);
- } else {
- componentService.deactivate(appId, FIB_INSTALLER);
- }
- }
}