本文整理匯總了Java中org.onosproject.net.behaviour.VlanQuery類的典型用法代碼示例。如果您正苦於以下問題:Java VlanQuery類的具體用法?Java VlanQuery怎麽用?Java VlanQuery使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
VlanQuery類屬於org.onosproject.net.behaviour包,在下文中一共展示了VlanQuery類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: queryVlanIds
import org.onosproject.net.behaviour.VlanQuery; //導入依賴的package包/類
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();
}
}
示例2: printVlans
import org.onosproject.net.behaviour.VlanQuery; //導入依賴的package包/類
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());
}
}