Add configuration setting to allow one switch to use the Corsa driver.
Change-Id: I6b17098e6d7c31a2d19ccbb0b5a56bd3b5b1e33a
diff --git a/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/OpenFlowControllerImpl.java b/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/OpenFlowControllerImpl.java
index a98f000..762a8f5 100644
--- a/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/OpenFlowControllerImpl.java
+++ b/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/OpenFlowControllerImpl.java
@@ -22,6 +22,7 @@
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.Service;
import org.onosproject.openflow.controller.DefaultOpenFlowPacketContext;
import org.onosproject.openflow.controller.Dpid;
@@ -33,6 +34,7 @@
import org.onosproject.openflow.controller.PacketListener;
import org.onosproject.openflow.controller.RoleState;
import org.onosproject.openflow.controller.driver.OpenFlowAgent;
+import org.osgi.service.component.ComponentContext;
import org.projectfloodlight.openflow.protocol.OFCircuitPortStatus;
import org.projectfloodlight.openflow.protocol.OFExperimenter;
import org.projectfloodlight.openflow.protocol.OFFactories;
@@ -52,7 +54,10 @@
import org.slf4j.LoggerFactory;
import java.util.Collection;
+import java.util.Dictionary;
+import java.util.HashMap;
import java.util.HashSet;
+import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
@@ -102,7 +107,9 @@
private final Controller ctrl = new Controller();
@Activate
- public void activate() {
+ public void activate(ComponentContext context) {
+ Map<String, String> properties = readComponentConfiguration(context);
+ ctrl.setConfigParams(properties);
ctrl.start(agent);
}
@@ -111,6 +118,32 @@
ctrl.stop();
}
+ /**
+ * Extracts properties from the component configuration context.
+ *
+ * @param context the component context
+ */
+ private Map<String, String> readComponentConfiguration(ComponentContext context) {
+ Dictionary<?, ?> properties = context.getProperties();
+ Map<String, String> outProperties = new HashMap<>();
+ try {
+ String strDpid = (String) properties.get("corsaDpid");
+ if (strDpid != null) {
+ outProperties.put("corsaDpid", strDpid);
+ }
+ } catch (ClassCastException e) {
+ return outProperties;
+ }
+ return outProperties;
+ }
+
+ @Modified
+ public void modified(ComponentContext context) {
+ // Blank @Modified method to catch modifications to the context.
+ // If no @Modified method exists, @Activate is called again
+ // when the context is modified.
+ }
+
@Override
public Iterable<OpenFlowSwitch> getSwitches() {
return connectedSwitches.values();