use of org.onosproject.net.behaviour.VlanQuery in project onos by opennetworkinglab.
the class PortQueryVlansCommand method printVlans.
private void printVlans(Port port) {
DeviceService deviceService = get(DeviceService.class);
DriverService driverService = get(DriverService.class);
DeviceId deviceId = (DeviceId) port.element().id();
Device device = deviceService.getDevice(deviceId);
if (!device.is(VlanQuery.class)) {
// The relevant behavior is not supported by the device.
print(NO_SUPPORT);
return;
}
DriverHandler h = driverService.createHandler(deviceId);
VlanQuery vlanQuery = h.behaviour(VlanQuery.class);
try {
Set<VlanId> vlanIds = vlanQuery.queryVlanIds(port.number());
if (vlanIds.isEmpty()) {
print(VLAN_NOT_AVAILABLE);
} else {
print(AVAIL_VLANS, getRanges(vlanIds).toString());
}
} catch (Exception e) {
print(FAILURE + e.getMessage());
}
}
use of org.onosproject.net.behaviour.VlanQuery in project onos by opennetworkinglab.
the class ResourceDeviceListener method queryVlanIds.
private Set<VlanId> queryVlanIds(DeviceId device, PortNumber port) {
try {
DriverHandler handler = driverService.createHandler(device);
if (handler == null || !handler.hasBehaviour(VlanQuery.class)) {
return ImmutableSet.of();
}
VlanQuery query = handler.behaviour(VlanQuery.class);
if (query == null) {
return ImmutableSet.of();
}
return query.queryVlanIds(port);
} catch (ItemNotFoundException e) {
return ImmutableSet.of();
}
}
Aggregations