Jonathan Hart

Retrieving handshaker drivers should respect driver annotation.

ONOS-2404.

Change-Id: Ib0cd76790612216030a9dd50ed434253d8202868
......@@ -21,6 +21,8 @@ import org.jboss.netty.channel.ChannelPipelineFactory;
import org.jboss.netty.channel.group.ChannelGroup;
import org.jboss.netty.channel.group.DefaultChannelGroup;
import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
import org.onlab.util.ItemNotFoundException;
import org.onosproject.net.DeviceId;
import org.onosproject.net.driver.DefaultDriverData;
import org.onosproject.net.driver.DefaultDriverHandler;
import org.onosproject.net.driver.Driver;
......@@ -204,13 +206,19 @@ public class Controller {
protected OpenFlowSwitchDriver getOFSwitchInstance(long dpid,
OFDescStatsReply desc,
OFVersion ofv) {
Driver driver = driverService
.getDriver(desc.getMfrDesc(), desc.getHwDesc(), desc.getSwDesc());
Dpid dpidObj = new Dpid(dpid);
Driver driver;
try {
driver = driverService.getDriver(DeviceId.deviceId(Dpid.uri(dpidObj)));
} catch (ItemNotFoundException e) {
driver = driverService.getDriver(desc.getMfrDesc(), desc.getHwDesc(), desc.getSwDesc());
}
if (driver != null && driver.hasBehaviour(OpenFlowSwitchDriver.class)) {
OpenFlowSwitchDriver ofSwitchDriver = driver.createBehaviour(new DefaultDriverHandler(
new DefaultDriverData(driver)), OpenFlowSwitchDriver.class);
ofSwitchDriver.init(new Dpid(dpid), desc, ofv);
ofSwitchDriver.init(dpidObj, desc, ofv);
ofSwitchDriver.setAgent(agent);
ofSwitchDriver.setRoleHandler(new RoleManager(ofSwitchDriver));
log.info("OpenFlow handshaker found for device {}: {}", dpid, ofSwitchDriver);
......