Search in sources :

Example 6 with DefaultDriverData

use of org.onosproject.net.driver.DefaultDriverData in project onos by opennetworkinglab.

the class SelectGroupHandler method buildNiciraExtenstion.

/**
 * Builds Nicira extension for tagging remoteIp of vxlan.
 *
 * @param id device id of vxlan source device
 * @param hostIp remote ip of vxlan destination device
 * @return NiciraExtension Treatment
 */
private ExtensionTreatment buildNiciraExtenstion(DeviceId id, Ip4Address hostIp) {
    Driver driver = driverService.getDriver(id);
    DriverHandler driverHandler = new DefaultDriverHandler(new DefaultDriverData(driver, id));
    ExtensionTreatmentResolver resolver = driverHandler.behaviour(ExtensionTreatmentResolver.class);
    ExtensionTreatment extensionInstruction = resolver.getExtensionInstruction(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_TUNNEL_DST.type());
    try {
        extensionInstruction.setPropertyValue(TUNNEL_DESTINATION, hostIp);
    } catch (ExtensionPropertyException e) {
        log.error("Error setting Nicira extension setting {}", e);
    }
    return extensionInstruction;
}
Also used : DefaultDriverHandler(org.onosproject.net.driver.DefaultDriverHandler) DefaultDriverHandler(org.onosproject.net.driver.DefaultDriverHandler) DriverHandler(org.onosproject.net.driver.DriverHandler) Driver(org.onosproject.net.driver.Driver) ExtensionTreatmentResolver(org.onosproject.net.behaviour.ExtensionTreatmentResolver) ExtensionTreatment(org.onosproject.net.flow.instructions.ExtensionTreatment) ExtensionPropertyException(org.onosproject.net.flow.instructions.ExtensionPropertyException) DefaultDriverData(org.onosproject.net.driver.DefaultDriverData)

Example 7 with DefaultDriverData

use of org.onosproject.net.driver.DefaultDriverData 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 8 with DefaultDriverData

use of org.onosproject.net.driver.DefaultDriverData in project onos by opennetworkinglab.

the class FlowModBuilderVer13 method buildExtensionAction.

protected OFAction buildExtensionAction(ExtensionTreatment i) {
    if (!driverService.isPresent()) {
        log.error("No driver service present");
        return null;
    }
    Driver driver = driverService.get().getDriver(deviceId);
    if (driver.hasBehaviour(ExtensionTreatmentInterpreter.class)) {
        DefaultDriverHandler handler = new DefaultDriverHandler(new DefaultDriverData(driver, deviceId));
        ExtensionTreatmentInterpreter interpreter = handler.behaviour(ExtensionTreatmentInterpreter.class);
        return interpreter.mapInstruction(factory(), i);
    }
    return null;
}
Also used : DefaultDriverHandler(org.onosproject.net.driver.DefaultDriverHandler) Driver(org.onosproject.net.driver.Driver) ExtensionTreatmentInterpreter(org.onosproject.openflow.controller.ExtensionTreatmentInterpreter) DefaultDriverData(org.onosproject.net.driver.DefaultDriverData)

Example 9 with DefaultDriverData

use of org.onosproject.net.driver.DefaultDriverData in project onos by opennetworkinglab.

the class GroupBucketEntryBuilder method getDriver.

private DriverHandler getDriver(Dpid dpid) {
    DeviceId deviceId = DeviceId.deviceId(Dpid.uri(dpid));
    Driver driver = driverService.getDriver(deviceId);
    DriverHandler handler = new DefaultDriverHandler(new DefaultDriverData(driver, deviceId));
    return handler;
}
Also used : DeviceId(org.onosproject.net.DeviceId) DefaultDriverHandler(org.onosproject.net.driver.DefaultDriverHandler) DriverHandler(org.onosproject.net.driver.DriverHandler) DefaultDriverHandler(org.onosproject.net.driver.DefaultDriverHandler) Driver(org.onosproject.net.driver.Driver) DefaultDriverData(org.onosproject.net.driver.DefaultDriverData)

Example 10 with DefaultDriverData

use of org.onosproject.net.driver.DefaultDriverData in project onos by opennetworkinglab.

the class SnmpAlarmProvider method getAlarmTranslator.

private DeviceAlarmConfig getAlarmTranslator(SnmpDevice device) {
    Driver deviceDriver = driverService.getDriver(device.deviceId());
    if (deviceDriver != null && deviceDriver.hasBehaviour(DeviceAlarmConfig.class)) {
        DriverData driverData = new DefaultDriverData(deviceDriver, device.deviceId());
        DeviceAlarmConfig alarmTranslator = deviceDriver.createBehaviour(driverData, DeviceAlarmConfig.class);
        alarmTranslator.setHandler(new DefaultDriverHandler(driverData));
        return alarmTranslator;
    } else {
        log.warn("Device does not support alarm {}", device.deviceId());
    }
    return null;
}
Also used : DefaultDriverData(org.onosproject.net.driver.DefaultDriverData) DriverData(org.onosproject.net.driver.DriverData) DefaultDriverHandler(org.onosproject.net.driver.DefaultDriverHandler) Driver(org.onosproject.net.driver.Driver) DeviceAlarmConfig(org.onosproject.alarm.DeviceAlarmConfig) DefaultDriverData(org.onosproject.net.driver.DefaultDriverData)

Aggregations

DefaultDriverData (org.onosproject.net.driver.DefaultDriverData)22 DefaultDriverHandler (org.onosproject.net.driver.DefaultDriverHandler)18 Driver (org.onosproject.net.driver.Driver)14 DriverHandler (org.onosproject.net.driver.DriverHandler)8 DeviceId (org.onosproject.net.DeviceId)6 DriverData (org.onosproject.net.driver.DriverData)6 ItemNotFoundException (org.onlab.util.ItemNotFoundException)3 DefaultDriver (org.onosproject.net.driver.DefaultDriver)3 ArrayList (java.util.ArrayList)2 ExtensionTreatmentResolver (org.onosproject.net.behaviour.ExtensionTreatmentResolver)2 PipelineTraceable (org.onosproject.net.behaviour.PipelineTraceable)2 DeviceDescriptionDiscovery (org.onosproject.net.device.DeviceDescriptionDiscovery)2 DriverService (org.onosproject.net.driver.DriverService)2 Beta (com.google.common.annotations.Beta)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 EnumSet (java.util.EnumSet)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Optional (java.util.Optional)1