Search in sources :

Example 11 with ItemNotFoundException

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;
}
Also used : OpenFlowSwitchDriver(org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver) DefaultDriverHandler(org.onosproject.net.driver.DefaultDriverHandler) Dpid(org.onosproject.openflow.controller.Dpid) Driver(org.onosproject.net.driver.Driver) OpenFlowSwitchDriver(org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver) ItemNotFoundException(org.onlab.util.ItemNotFoundException) DefaultDriverData(org.onosproject.net.driver.DefaultDriverData)

Example 12 with ItemNotFoundException

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);
}
Also used : Driver(org.onosproject.net.driver.Driver) ItemNotFoundException(org.onlab.util.ItemNotFoundException)

Example 13 with ItemNotFoundException

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);
}
Also used : Driver(org.onosproject.net.driver.Driver) ItemNotFoundException(org.onlab.util.ItemNotFoundException)

Example 14 with ItemNotFoundException

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();
    }
}
Also used : DriverHandler(org.onosproject.net.driver.DriverHandler) MplsQuery(org.onosproject.net.behaviour.MplsQuery) ItemNotFoundException(org.onlab.util.ItemNotFoundException)

Example 15 with ItemNotFoundException

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();
    }
}
Also used : LambdaQuery(org.onosproject.net.behaviour.LambdaQuery) DriverHandler(org.onosproject.net.driver.DriverHandler) ItemNotFoundException(org.onlab.util.ItemNotFoundException)

Aggregations

ItemNotFoundException (org.onlab.util.ItemNotFoundException)25 DriverHandler (org.onosproject.net.driver.DriverHandler)9 Path (javax.ws.rs.Path)8 GET (javax.ws.rs.GET)7 Produces (javax.ws.rs.Produces)7 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)6 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)5 FlowRuleService (org.onosproject.net.flow.FlowRuleService)5 ApplicationId (org.onosproject.core.ApplicationId)4 Driver (org.onosproject.net.driver.Driver)4 List (java.util.List)3 Consumes (javax.ws.rs.Consumes)3 DeviceId (org.onosproject.net.DeviceId)3 FlowEntry (org.onosproject.net.flow.FlowEntry)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ArrayList (java.util.ArrayList)2 POST (javax.ws.rs.POST)2 PathParam (javax.ws.rs.PathParam)2 MediaType (javax.ws.rs.core.MediaType)2 Response (javax.ws.rs.core.Response)2