use of org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver in project onos by opennetworkinglab.
the class Controller method getOFSwitchInstance.
/**
* Forward to the driver-manager to get an IOFSwitch instance.
*
* @param dpid data path id
* @param desc switch description
* @param ofv OpenFlow version
* @return switch instance
*/
protected OpenFlowSwitchDriver getOFSwitchInstance(long dpid, OFDescStatsReply desc, OFVersion ofv) {
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) {
log.error("No OpenFlow driver for {} : {}", dpidObj, 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));
return ofSwitchDriver;
}
use of org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver in project onos by opennetworkinglab.
the class ControllerTest method switchItemNotFoundTest.
/**
* Tests fetching a driver that throws an ItemNotFoundException.
*/
@Test
public void switchItemNotFoundTest() {
controller.start(null, new MockDriverService(), null);
OFDescStatsReply stats = new OFDescStatsReplyAdapter();
OpenFlowSwitchDriver driver = controller.getOFSwitchInstance(MockDriverService.ITEM_NOT_FOUND_DRIVER_ID, stats, null);
assertThat(driver, nullValue());
controller.stop();
}
use of org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver in project onos by opennetworkinglab.
the class ControllerTest method driverExistsTest.
/**
* Tests fetching a driver that throws an ItemNotFoundException.
*/
@Test
public void driverExistsTest() {
controller.start(null, new MockDriverService(), null);
OFDescStatsReply stats = new OFDescStatsReplyAdapter();
OpenFlowSwitchDriver driver = controller.getOFSwitchInstance(MockDriverService.DRIVER_EXISTS_ID, stats, null);
assertThat(driver, notNullValue());
controller.stop();
}
use of org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver in project onos by opennetworkinglab.
the class ControllerTest method switchInstanceNotFoundTest.
/**
* Tests fetching a driver that does not exist.
*/
@Test
public void switchInstanceNotFoundTest() {
controller.start(null, new MockDriverService(), null);
OpenFlowSwitchDriver driver = controller.getOFSwitchInstance(MockDriverService.NO_SUCH_DRIVER_ID, null, null);
assertThat(driver, nullValue());
controller.stop();
}
Aggregations