Search in sources :

Example 11 with ExtensionPropertyException

use of org.onosproject.net.flow.instructions.ExtensionPropertyException in project onos by opennetworkinglab.

the class RulePopulatorUtil method buildLoadExtension.

/**
 * Returns the nicira load extension treatment.
 *
 * @param device        device instance
 * @param field         field code
 * @param value         value to load
 * @return load extension treatment
 */
public static ExtensionTreatment buildLoadExtension(Device device, long field, long value) {
    if (!checkTreatmentResolver(device)) {
        return null;
    }
    ExtensionTreatmentResolver resolver = device.as(ExtensionTreatmentResolver.class);
    ExtensionTreatment treatment = resolver.getExtensionInstruction(NICIRA_LOAD.type());
    int ofsNbits = OFF_SET_BIT << 6 | (REMAINDER_BIT - 1);
    try {
        treatment.setPropertyValue(OFF_SET_N_BITS, ofsNbits);
        treatment.setPropertyValue(DESTINATION, field);
        treatment.setPropertyValue(VALUE, value);
        return treatment;
    } catch (ExtensionPropertyException e) {
        log.error("Failed to set nicira load extension treatment for {}", device.id());
        return null;
    }
}
Also used : ExtensionTreatmentResolver(org.onosproject.net.behaviour.ExtensionTreatmentResolver) ExtensionTreatment(org.onosproject.net.flow.instructions.ExtensionTreatment) ExtensionPropertyException(org.onosproject.net.flow.instructions.ExtensionPropertyException)

Example 12 with ExtensionPropertyException

use of org.onosproject.net.flow.instructions.ExtensionPropertyException in project onos by opennetworkinglab.

the class OpenstackVtapManager method buildResubmitExtension.

private ExtensionTreatment buildResubmitExtension(DeviceId deviceId, int tableId) {
    Device device = deviceService.getDevice(deviceId);
    if (device == null || !device.is(ExtensionTreatmentResolver.class)) {
        log.warn("Nicira extension treatment is not supported");
        return null;
    }
    ExtensionTreatmentResolver resolver = device.as(ExtensionTreatmentResolver.class);
    ExtensionTreatment treatment = resolver.getExtensionInstruction(NICIRA_RESUBMIT_TABLE.type());
    try {
        treatment.setPropertyValue(TABLE_EXTENSION, ((short) tableId));
        return treatment;
    } catch (ExtensionPropertyException e) {
        log.error("Failed to set nicira resubmit extension treatment for {}", deviceId);
        return null;
    }
}
Also used : Device(org.onosproject.net.Device) ExtensionTreatmentResolver(org.onosproject.net.behaviour.ExtensionTreatmentResolver) ExtensionTreatment(org.onosproject.net.flow.instructions.ExtensionTreatment) ExtensionPropertyException(org.onosproject.net.flow.instructions.ExtensionPropertyException)

Example 13 with ExtensionPropertyException

use of org.onosproject.net.flow.instructions.ExtensionPropertyException in project onos by opennetworkinglab.

the class RulePopulatorUtil method buildResubmitExtension.

/**
 * Returns the nicira resubmit extension treatment with given table ID.
 *
 * @param device        device instance
 * @param tableId       table identifier
 * @return resubmit extension treatment
 */
public static ExtensionTreatment buildResubmitExtension(Device device, int tableId) {
    if (!checkTreatmentResolver(device)) {
        return null;
    }
    ExtensionTreatmentResolver resolver = device.as(ExtensionTreatmentResolver.class);
    ExtensionTreatment treatment = resolver.getExtensionInstruction(NICIRA_RESUBMIT_TABLE.type());
    try {
        treatment.setPropertyValue(TABLE_EXTENSION, ((short) tableId));
        return treatment;
    } catch (ExtensionPropertyException e) {
        log.error("Failed to set nicira resubmit extension treatment for {}", device.id());
        return null;
    }
}
Also used : ExtensionTreatmentResolver(org.onosproject.net.behaviour.ExtensionTreatmentResolver) ExtensionTreatment(org.onosproject.net.flow.instructions.ExtensionTreatment) ExtensionPropertyException(org.onosproject.net.flow.instructions.ExtensionPropertyException)

Aggregations

ExtensionPropertyException (org.onosproject.net.flow.instructions.ExtensionPropertyException)13 ExtensionTreatmentResolver (org.onosproject.net.behaviour.ExtensionTreatmentResolver)11 ExtensionTreatment (org.onosproject.net.flow.instructions.ExtensionTreatment)11 Device (org.onosproject.net.Device)6 Field (java.lang.reflect.Field)2 DefaultDriverData (org.onosproject.net.driver.DefaultDriverData)1 DefaultDriverHandler (org.onosproject.net.driver.DefaultDriverHandler)1 Driver (org.onosproject.net.driver.Driver)1 DriverHandler (org.onosproject.net.driver.DriverHandler)1