Make error messages more accurate when OpenFlow provider can't find a driver for a device
Change-Id: If40f2446fab215950689b6846aadc8024e8eb8e1
diff --git a/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/Controller.java b/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/Controller.java
index 93301a4..deb95f3 100644
--- a/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/Controller.java
+++ b/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/Controller.java
@@ -195,7 +195,6 @@
} catch (Exception ex) {
log.error("SSL init failed: {}", ex.getMessage());
}
-
}
private void getTlsParameters() {
@@ -227,7 +226,6 @@
}
private void initSsl() throws Exception {
-
TrustManagerFactory tmFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
KeyStore ts = KeyStore.getInstance("JKS");
ts.load(new FileInputStream(tsLocation), tsPwd);
@@ -240,8 +238,6 @@
sslContext = SSLContext.getInstance("TLS");
sslContext.init(kmf.getKeyManagers(), tmFactory.getTrustManagers(), null);
-
-
}
// **************
@@ -286,21 +282,27 @@
driver = driverService.getDriver(desc.getMfrDesc(), desc.getHwDesc(), desc.getSwDesc());
}
- if (driver != null && driver.hasBehaviour(OpenFlowSwitchDriver.class)) {
- Dpid did = new Dpid(dpid);
- DefaultDriverHandler handler =
- new DefaultDriverHandler(new DefaultDriverData(driver, deviceId(uri(did))));
- OpenFlowSwitchDriver ofSwitchDriver =
- driver.createBehaviour(handler, OpenFlowSwitchDriver.class);
- ofSwitchDriver.init(did, desc, ofv);
- ofSwitchDriver.setAgent(agent);
- ofSwitchDriver.setRoleHandler(new RoleManager(ofSwitchDriver));
- log.info("OpenFlow handshaker found for device {}: {}", dpid, ofSwitchDriver);
- return ofSwitchDriver;
+ if (driver == null) {
+ log.error("No OpenFlow driver for {} : {}", dpid, desc);
+ return null;
}
- log.error("No OpenFlow driver for {} : {}", dpid, desc);
- return null;
+ log.info("Driver {} assigned to device {}", driver.name(), dpidObj);
+
+ if (!driver.hasBehaviour(OpenFlowSwitchDriver.class)) {
+ log.error("Driver {} does not support OpenFlowSwitchDriver behaviour", driver.name());
+ return null;
+ }
+
+ DefaultDriverHandler handler =
+ new DefaultDriverHandler(new DefaultDriverData(driver, deviceId(uri(dpidObj))));
+ OpenFlowSwitchDriver ofSwitchDriver =
+ driver.createBehaviour(handler, OpenFlowSwitchDriver.class);
+ ofSwitchDriver.init(dpidObj, desc, ofv);
+ ofSwitchDriver.setAgent(agent);
+ ofSwitchDriver.setRoleHandler(new RoleManager(ofSwitchDriver));
+ log.info("OpenFlow handshaker found for device {}: {}", dpid, ofSwitchDriver);
+ return ofSwitchDriver;
}
public void start(OpenFlowAgent ag, DriverService driverService) {