use of org.onosproject.net.device.DeviceService in project onos by opennetworkinglab.
the class TableStatisticsCommand method doExecute.
@Override
protected void doExecute() {
FlowRuleService flowService = get(FlowRuleService.class);
DeviceService deviceService = get(DeviceService.class);
SortedMap<Device, List<TableStatisticsEntry>> deviceTableStats = getSortedTableStats(deviceService, flowService);
if (outputJson()) {
print("%s", json(deviceTableStats.keySet(), deviceTableStats));
} else {
deviceTableStats.forEach((device, tableStats) -> printTableStats(device, tableStats));
}
}
use of org.onosproject.net.device.DeviceService in project onos by opennetworkinglab.
the class PathListCommand method doExecute.
@Override
protected void doExecute() {
init();
DeviceService deviceService = get(DeviceService.class);
DeviceId srcDid = deviceId(src);
if (deviceService.getDevice(srcDid) == null) {
print("Unknown device %s", src);
return;
}
DeviceId dstDid = deviceId(dst);
if (deviceService.getDevice(dstDid) == null) {
print("Unknown device %s", dst);
return;
}
Set<? extends Path> paths;
if (disjoint) {
paths = service.getDisjointPaths(topology, srcDid, dstDid);
} else {
paths = service.getPaths(topology, srcDid, dstDid);
}
if (outputJson()) {
print("%s", json(this, paths));
} else {
for (Path path : paths) {
print(pathString(path));
if (path instanceof DisjointPath) {
// print backup right after primary
print(pathString(((DisjointPath) path).backup()));
}
}
}
}
use of org.onosproject.net.device.DeviceService in project onos by opennetworkinglab.
the class PortNumberCompleter method choices.
@Override
protected List<String> choices() {
DeviceId deviceId = lookForDeviceId();
if (deviceId == null) {
return Collections.emptyList();
}
DeviceService deviceService = getService(DeviceService.class);
return StreamSupport.stream(deviceService.getPorts(deviceId).spliterator(), false).map(port -> port.number().toString()).collect(Collectors.toList());
}
use of org.onosproject.net.device.DeviceService 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.device.DeviceService in project onos by opennetworkinglab.
the class NumericPortNumberCompleter method choices.
@Override
protected List<String> choices() {
DeviceId deviceId = lookForDeviceId();
if (deviceId == null) {
return Collections.emptyList();
}
DeviceService deviceService = getService(DeviceService.class);
return StreamSupport.stream(deviceService.getPorts(deviceId).spliterator(), false).map(port -> Long.toString(port.number().toLong())).collect(Collectors.toList());
}
Aggregations