use of org.onlab.util.ItemNotFoundException 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.onlab.util.ItemNotFoundException in project onos by opennetworkinglab.
the class OpenFlowGroupProvider method isGroupCapable.
/**
* Determine whether the given switch is group-capable.
*
* @param sw switch
* @return the boolean value of groupCapable property, or true if it is not configured.
*/
private boolean isGroupCapable(OpenFlowSwitch sw) {
Driver driver;
try {
driver = driverService.getDriver(DeviceId.deviceId(Dpid.uri(sw.getDpid())));
} catch (ItemNotFoundException e) {
driver = driverService.getDriver(sw.manufacturerDescription(), sw.hardwareDescription(), sw.softwareDescription());
}
if (driver == null) {
return true;
}
String isGroupCapable = driver.getProperty(GROUP_CAPABLE);
return isGroupCapable == null || Boolean.parseBoolean(isGroupCapable);
}
use of org.onlab.util.ItemNotFoundException in project onos by opennetworkinglab.
the class OpenFlowMeterProvider method isMeterCapable.
/**
* Determine whether the given switch is meter-capable.
*
* @param sw switch
* @return the boolean value of meterCapable property, or true if it is not configured.
*/
private boolean isMeterCapable(OpenFlowSwitch sw) {
Driver driver;
try {
driver = driverService.getDriver(DeviceId.deviceId(Dpid.uri(sw.getDpid())));
} catch (ItemNotFoundException e) {
driver = driverService.getDriver(sw.manufacturerDescription(), sw.hardwareDescription(), sw.softwareDescription());
}
String isMeterCapable = driver.getProperty(METER_CAPABLE);
return isMeterCapable == null || Boolean.parseBoolean(isMeterCapable);
}
use of org.onlab.util.ItemNotFoundException in project onos by opennetworkinglab.
the class ResourceDeviceListener method queryMplsLabels.
private Set<MplsLabel> queryMplsLabels(DeviceId device, PortNumber port) {
try {
DriverHandler handler = driverService.createHandler(device);
if (handler == null || !handler.hasBehaviour(MplsQuery.class)) {
return ImmutableSet.of();
}
MplsQuery query = handler.behaviour(MplsQuery.class);
if (query == null) {
return ImmutableSet.of();
}
return query.queryMplsLabels(port);
} catch (ItemNotFoundException e) {
return ImmutableSet.of();
}
}
use of org.onlab.util.ItemNotFoundException in project onos by opennetworkinglab.
the class ResourceDeviceListener method queryLambdas.
private Set<OchSignal> queryLambdas(DeviceId did, PortNumber port) {
try {
DriverHandler handler = driverService.createHandler(did);
if (handler == null || !handler.hasBehaviour(LambdaQuery.class)) {
return Collections.emptySet();
}
LambdaQuery query = handler.behaviour(LambdaQuery.class);
if (query != null) {
return query.queryLambdas(port).stream().flatMap(ResourceDeviceListener::toResourceGrid).collect(ImmutableSet.toImmutableSet());
} else {
return Collections.emptySet();
}
} catch (ItemNotFoundException e) {
return Collections.emptySet();
}
}
Aggregations