Reference Guide

Table Of Contents
* @param ofm the FlowMod to be validated and adjusted if needed.
* @return set of FlowMods.
*/
private Set<OfmFlowMod> adjustFlowMod(DeviceService ds,
DataPathId dpid, OfmFlowMod ofm) {
Set<OfmFlowMod> adjustedFlows = new HashSet<>(OfmFlowMod);
try {
// get the device object associted with the data path id (dpid)
Device dev = ds.getDevice(dpid);
if (!dev.isOnline()) {
// get the DeviceInfo object which is needed to get a Facet
DeviceInfo di = dev.info();
// check if the FlowMod Facet is supported for this device
if (di.isSupported(FlowModFacet.class)) {
// get the FlowMod Facet
FlowModFacet facet = di.getFacet(FlowModFacet.class);
// call the FlowMod Facet to validate and adjust theFlowMod
adjustedFlows = facet.adjustFlowMod(ofm);
}
}
} catch (Exception e) {
e.printStackTrace();
}
return adjustedFlows;
}
This method demonstrated how to get a Facet and use the Facet. This method is used to validate
and adjust, if necessary, FlowMods for a specific device. This method is passed 3 parameters.
- ds: A reference to the Device Service. The Device Service is used to get the Device object
that contains information about the device.
- dpid: This parameter contains the OpenFlow Data Path ID for the device that a FlowMod
is to bet sent to.
- Ofm: This parameter is the FlowMod that is to be validated and adjusted if necessary.
NOTE: Applications should not set the table id of the OfmFlowMod. Instead, the
FlowModFacet will choose the best table based on the capabilities of the device to which
the OfmFlowMod is intended. If the FlowModFacet receives an OfmFlowMod that
already has a table id set, it will not adjust the table id for the intended device.
This method will get the FlowMod Facet and use it to validated the FlowMod, and possibly adjust
the FlowMod. This method returns a Set of FlowMods. A Set is necessary because it is possible
that the device cannot support all the features specified in the original FlowMod in a single table,
and several FlowMods are required to achieve the desired behavior.
122