Search in sources :

Example 1 with DriverHandler

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

the class RulePopulatorUtil method buildCtExtensionSelector.

/**
 * Builds OVS ConnTrack matches.
 *
 * @param driverService driver service
 * @param deviceId device ID
 * @param ctState connection tracking sate masking value
 * @param ctSateMask connection tracking sate masking value
 * @return OVS ConnTrack extension match
 */
public static ExtensionSelector buildCtExtensionSelector(DriverService driverService, DeviceId deviceId, long ctState, long ctSateMask) {
    DriverHandler handler = driverService.createHandler(deviceId);
    ExtensionSelectorResolver esr = handler.behaviour(ExtensionSelectorResolver.class);
    ExtensionSelector extensionSelector = esr.getExtensionSelector(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_CONNTRACK_STATE.type());
    try {
        extensionSelector.setPropertyValue(CT_STATE, ctState);
        extensionSelector.setPropertyValue(CT_STATE_MASK, ctSateMask);
    } catch (Exception e) {
        log.error("Failed to set nicira match CT state because of {}", e);
        return null;
    }
    return extensionSelector;
}
Also used : ExtensionSelector(org.onosproject.net.flow.criteria.ExtensionSelector) DriverHandler(org.onosproject.net.driver.DriverHandler) ExtensionSelectorResolver(org.onosproject.net.behaviour.ExtensionSelectorResolver) ExtensionPropertyException(org.onosproject.net.flow.instructions.ExtensionPropertyException)

Example 2 with DriverHandler

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

the class OFAgentVirtualGroupBucketEntryBuilder method buildTreatment.

private TrafficTreatment buildTreatment(List<OFAction> actions) {
    DriverHandler driverHandler = getDriver(dpid);
    TrafficTreatment.Builder builder = DefaultTrafficTreatment.builder();
    // If this is a drop rule
    if (actions.isEmpty()) {
        builder.drop();
        return builder.build();
    }
    return FlowEntryBuilder.configureTreatmentBuilder(actions, builder, driverHandler, DeviceId.deviceId(Dpid.uri(dpid))).build();
}
Also used : DriverHandler(org.onosproject.net.driver.DriverHandler) DefaultDriverHandler(org.onosproject.net.driver.DefaultDriverHandler) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment)

Example 3 with DriverHandler

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

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

the class DeviceInterfaceRemoveCommand method doExecute.

@Override
protected void doExecute() {
    DriverService service = get(DriverService.class);
    DeviceId deviceId = DeviceId.deviceId(uri);
    DriverHandler h = service.createHandler(deviceId);
    InterfaceConfig interfaceConfig = h.behaviour(InterfaceConfig.class);
    if (trunkMode && !accessMode && !rateLimit) {
        // Trunk mode for VLAN to be removed.
        removeTrunkModeFromIntf(interfaceConfig);
    } else if (accessMode && !trunkMode && !rateLimit) {
        // Access mode for VLAN to be removed.
        removeAccessModeFromIntf(interfaceConfig);
    } else if (rateLimit && !trunkMode && !accessMode) {
        // Rate limit to be removed.
        removeRateLimitFromIntf(interfaceConfig);
    } else {
        // Option has not been correctly set.
        print(ONE_ACTION_ALLOWED);
    }
}
Also used : InterfaceConfig(org.onosproject.net.behaviour.InterfaceConfig) DeviceId(org.onosproject.net.DeviceId) DriverHandler(org.onosproject.net.driver.DriverHandler) DriverService(org.onosproject.net.driver.DriverService)

Example 5 with DriverHandler

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

the class DeviceInterfaceAddCommand method doExecute.

@Override
protected void doExecute() {
    DriverService service = get(DriverService.class);
    DeviceId deviceId = DeviceId.deviceId(uri);
    DriverHandler h = service.createHandler(deviceId);
    InterfaceConfig interfaceConfig = h.behaviour(InterfaceConfig.class);
    if (accessVlanString != null && trunkVlanStrings == null && limitString == null) {
        // Access mode to be enabled for VLAN.
        addAccessModeToIntf(interfaceConfig);
    } else if (trunkVlanStrings != null && accessVlanString == null && limitString == null) {
        // Trunk mode to be enabled for VLANs.
        addTrunkModeToIntf(interfaceConfig);
    } else if (limitString != null && accessVlanString == null && trunkVlanStrings == null) {
        // Rate limit to be set on interface.
        addRateLimitToIntf(interfaceConfig);
    } else {
        // Option has not been correctly set.
        print(ONE_ACTION_ALLOWED);
    }
}
Also used : InterfaceConfig(org.onosproject.net.behaviour.InterfaceConfig) DeviceId(org.onosproject.net.DeviceId) DriverHandler(org.onosproject.net.driver.DriverHandler) DriverService(org.onosproject.net.driver.DriverService)

Aggregations

DriverHandler (org.onosproject.net.driver.DriverHandler)101 DeviceId (org.onosproject.net.DeviceId)45 DriverService (org.onosproject.net.driver.DriverService)22 NetconfController (org.onosproject.netconf.NetconfController)22 NetconfException (org.onosproject.netconf.NetconfException)22 MastershipService (org.onosproject.mastership.MastershipService)20 ArrayList (java.util.ArrayList)12 DefaultDriverHandler (org.onosproject.net.driver.DefaultDriverHandler)12 ItemNotFoundException (org.onlab.util.ItemNotFoundException)9 OvsdbClientService (org.onosproject.ovsdb.controller.OvsdbClientService)9 DefaultDriverData (org.onosproject.net.driver.DefaultDriverData)8 Driver (org.onosproject.net.driver.Driver)8 Test (org.junit.Test)7 DeviceService (org.onosproject.net.device.DeviceService)7 ControllerInfo (org.onosproject.net.behaviour.ControllerInfo)6 RestSBController (org.onosproject.protocol.rest.RestSBController)6 JsonNode (com.fasterxml.jackson.databind.JsonNode)5 ByteArrayInputStream (java.io.ByteArrayInputStream)5 PolicerConfigurable (org.onosproject.net.behaviour.trafficcontrol.PolicerConfigurable)5 PolicerId (org.onosproject.net.behaviour.trafficcontrol.PolicerId)5