Jonathan Hart
Committed by Gerrit Code Review

Make error messages more accurate when OpenFlow provider can't find a driver for a device

Change-Id: If40f2446fab215950689b6846aadc8024e8eb8e1
...@@ -195,7 +195,6 @@ public class Controller { ...@@ -195,7 +195,6 @@ public class Controller {
195 } catch (Exception ex) { 195 } catch (Exception ex) {
196 log.error("SSL init failed: {}", ex.getMessage()); 196 log.error("SSL init failed: {}", ex.getMessage());
197 } 197 }
198 -
199 } 198 }
200 199
201 private void getTlsParameters() { 200 private void getTlsParameters() {
...@@ -227,7 +226,6 @@ public class Controller { ...@@ -227,7 +226,6 @@ public class Controller {
227 } 226 }
228 227
229 private void initSsl() throws Exception { 228 private void initSsl() throws Exception {
230 -
231 TrustManagerFactory tmFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); 229 TrustManagerFactory tmFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
232 KeyStore ts = KeyStore.getInstance("JKS"); 230 KeyStore ts = KeyStore.getInstance("JKS");
233 ts.load(new FileInputStream(tsLocation), tsPwd); 231 ts.load(new FileInputStream(tsLocation), tsPwd);
...@@ -240,8 +238,6 @@ public class Controller { ...@@ -240,8 +238,6 @@ public class Controller {
240 238
241 sslContext = SSLContext.getInstance("TLS"); 239 sslContext = SSLContext.getInstance("TLS");
242 sslContext.init(kmf.getKeyManagers(), tmFactory.getTrustManagers(), null); 240 sslContext.init(kmf.getKeyManagers(), tmFactory.getTrustManagers(), null);
243 -
244 -
245 } 241 }
246 242
247 // ************** 243 // **************
...@@ -286,22 +282,28 @@ public class Controller { ...@@ -286,22 +282,28 @@ public class Controller {
286 driver = driverService.getDriver(desc.getMfrDesc(), desc.getHwDesc(), desc.getSwDesc()); 282 driver = driverService.getDriver(desc.getMfrDesc(), desc.getHwDesc(), desc.getSwDesc());
287 } 283 }
288 284
289 - if (driver != null && driver.hasBehaviour(OpenFlowSwitchDriver.class)) { 285 + if (driver == null) {
290 - Dpid did = new Dpid(dpid); 286 + log.error("No OpenFlow driver for {} : {}", dpid, desc);
287 + return null;
288 + }
289 +
290 + log.info("Driver {} assigned to device {}", driver.name(), dpidObj);
291 +
292 + if (!driver.hasBehaviour(OpenFlowSwitchDriver.class)) {
293 + log.error("Driver {} does not support OpenFlowSwitchDriver behaviour", driver.name());
294 + return null;
295 + }
296 +
291 DefaultDriverHandler handler = 297 DefaultDriverHandler handler =
292 - new DefaultDriverHandler(new DefaultDriverData(driver, deviceId(uri(did)))); 298 + new DefaultDriverHandler(new DefaultDriverData(driver, deviceId(uri(dpidObj))));
293 OpenFlowSwitchDriver ofSwitchDriver = 299 OpenFlowSwitchDriver ofSwitchDriver =
294 driver.createBehaviour(handler, OpenFlowSwitchDriver.class); 300 driver.createBehaviour(handler, OpenFlowSwitchDriver.class);
295 - ofSwitchDriver.init(did, desc, ofv); 301 + ofSwitchDriver.init(dpidObj, desc, ofv);
296 ofSwitchDriver.setAgent(agent); 302 ofSwitchDriver.setAgent(agent);
297 ofSwitchDriver.setRoleHandler(new RoleManager(ofSwitchDriver)); 303 ofSwitchDriver.setRoleHandler(new RoleManager(ofSwitchDriver));
298 log.info("OpenFlow handshaker found for device {}: {}", dpid, ofSwitchDriver); 304 log.info("OpenFlow handshaker found for device {}: {}", dpid, ofSwitchDriver);
299 return ofSwitchDriver; 305 return ofSwitchDriver;
300 } 306 }
301 - log.error("No OpenFlow driver for {} : {}", dpid, desc);
302 - return null;
303 -
304 - }
305 307
306 public void start(OpenFlowAgent ag, DriverService driverService) { 308 public void start(OpenFlowAgent ag, DriverService driverService) {
307 log.info("Starting OpenFlow IO"); 309 log.info("Starting OpenFlow IO");
......