use of org.onosproject.net.flow.instructions.ExtensionPropertyException in project onos by opennetworkinglab.
the class RulePopulatorUtil method buildExtension.
/**
* Returns tunnel destination extension treatment object.
*
* @param deviceService driver service
* @param deviceId device id to apply this treatment
* @param remoteIp tunnel destination ip address
* @return extension treatment
*/
public static ExtensionTreatment buildExtension(DeviceService deviceService, DeviceId deviceId, Ip4Address remoteIp) {
Device device = deviceService.getDevice(deviceId);
if (!checkTreatmentResolver(device)) {
return null;
}
if (device == null) {
return null;
}
ExtensionTreatmentResolver resolver = device.as(ExtensionTreatmentResolver.class);
ExtensionTreatment treatment = resolver.getExtensionInstruction(NICIRA_SET_TUNNEL_DST.type());
try {
treatment.setPropertyValue(TUNNEL_DST, remoteIp);
return treatment;
} catch (ExtensionPropertyException e) {
log.warn("Failed to get tunnelDst extension treatment for {} " + "because of {}", deviceId, e);
return null;
}
}
use of org.onosproject.net.flow.instructions.ExtensionPropertyException in project onos by opennetworkinglab.
the class AbstractExtension method setPropertyValue.
@Override
public <T> void setPropertyValue(String key, T value) throws ExtensionPropertyException {
Class<?> clazz = this.getClass();
try {
Field field = clazz.getDeclaredField(key);
field.setAccessible(true);
field.set(this, value);
} catch (NoSuchFieldException | IllegalAccessException e) {
throw new ExtensionPropertyException(INVALID_KEY + key);
}
}
use of org.onosproject.net.flow.instructions.ExtensionPropertyException in project onos by opennetworkinglab.
the class AbstractExtension method getPropertyValue.
@Override
public <T> T getPropertyValue(String key) throws ExtensionPropertyException {
Class<?> clazz = this.getClass();
try {
Field field = clazz.getDeclaredField(key);
field.setAccessible(true);
@SuppressWarnings("unchecked") T result = (T) field.get(this);
return result;
} catch (NoSuchFieldException | IllegalAccessException e) {
throw new ExtensionPropertyException(INVALID_KEY + key);
} catch (ClassCastException e) {
throw new ExtensionPropertyException(INVALID_TYPE + key);
}
}
use of org.onosproject.net.flow.instructions.ExtensionPropertyException in project onos by opennetworkinglab.
the class RulePopulatorUtil method buildExtension.
/**
* Returns tunnel destination extension treatment object.
*
* @param deviceService driver service
* @param deviceId device id to apply this treatment
* @param remoteIp tunnel destination ip address
* @return extension treatment
*/
public static ExtensionTreatment buildExtension(DeviceService deviceService, DeviceId deviceId, Ip4Address remoteIp) {
Device device = deviceService.getDevice(deviceId);
if (!checkTreatmentResolver(device)) {
return null;
}
if (device == null) {
return null;
}
ExtensionTreatmentResolver resolver = device.as(ExtensionTreatmentResolver.class);
ExtensionTreatment treatment = resolver.getExtensionInstruction(NICIRA_SET_TUNNEL_DST.type());
try {
treatment.setPropertyValue(TUNNEL_DST, remoteIp);
return treatment;
} catch (ExtensionPropertyException e) {
log.warn("Failed to get tunnelDst extension treatment for {} " + "because of {}", deviceId, e);
return null;
}
}
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;
}
}
Aggregations