Reference Guide

Table Of Contents
At line 15 the reference to the Device Service (ds) is used to get a Device object for the Data Path
ID. The Device object contains information about the device including the Facets that can be used
with that device.
At line 17 the Device object (dev) is used to check if the device is online. If the device is offline,
then no validation and adjustment is performed.
At line 19 the Device object is used to get a DeviceInfo object (di). The DeviceInfo object is
needed to get Facets that can be used with the device.
At line 22 the DeviceInfo object is used to determine if a Facet called FlowModFacet is supported
for the device.
At line 24 the DeviceInfo object is used to get the Facet called FlowModFacet.
At line 27 the Facet is used. The Facet’s adjustFlowMod method is called to validate and adjust a
FlowMod.
Handler Facet Usage Example
The previous example demonstrated how to get and use a Facet. This example will demonstrate
how to get and use a Handler Facet. As discussed above, a Facet does not directly interact with a
device, whereas a Handler Facet does. One additional step is required to get a Handler Facet.
A Device Handler object is needed in order to get a Handler Facet.
/**
* Get the VLANs configured on the specified device.
*
* @param ds reference to the DeviceService
* @param dds reference to the DerviceDriverService
* @param dpid DataPathId for the device the vlan information to be read.
* @return set of vlans.
*/
private Set<VlanInfo> getVlans(DeviceService ds,DeviceDriverService dds,
DataPathId dpid) {
Set<VlanInfo> vlans = new HashSet<>(VlanInfo);
try {
// get the device object associated with the data path id (dpid)
Device dev = ds.getDevice(dpid);
DeviceInfo di = dev.info(); // get the DeviceInfo object
DeviceHandler dh = dds.create(di, getIp(di)); // create a Device
Handler
// check if the Handler Facet is available for the device
123