Correct parent class for portstats CLI

- Fixes issue, where --help looked as this command support -s,
  even if it actually didn't
- cosmetic fixes

Change-Id: I28df33be41b97e49ccc2c47b876076ac87c7742a
This commit is contained in:
Yuta HIGUCHI 2017-01-25 19:26:08 -08:00 committed by Jonathan Hart
parent 6c28aa4711
commit 1560384ea3

View File

@ -15,6 +15,7 @@
*/ */
package org.onosproject.cli.net; package org.onosproject.cli.net;
import static org.onosproject.cli.net.DevicesListCommand.getSortedDevices;
import static org.onosproject.net.DeviceId.deviceId; import static org.onosproject.net.DeviceId.deviceId;
import java.util.List; import java.util.List;
@ -24,6 +25,7 @@ import com.google.common.collect.Lists;
import org.apache.karaf.shell.commands.Argument; import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command; import org.apache.karaf.shell.commands.Command;
import org.apache.karaf.shell.commands.Option; import org.apache.karaf.shell.commands.Option;
import org.onosproject.cli.AbstractShellCommand;
import org.onosproject.net.Device; import org.onosproject.net.Device;
import org.onosproject.net.DeviceId; import org.onosproject.net.DeviceId;
import org.onosproject.net.device.DeviceService; import org.onosproject.net.device.DeviceService;
@ -34,18 +36,21 @@ import org.onosproject.net.device.PortStatistics;
*/ */
@Command(scope = "onos", name = "portstats", @Command(scope = "onos", name = "portstats",
description = "Lists statistics of all ports in the system") description = "Lists statistics of all ports in the system")
public class DevicePortStatsCommand extends DevicesListCommand { public class DevicePortStatsCommand extends AbstractShellCommand {
@Option(name = "-nz", aliases = "--nonzero", description = "Show only non-zero portstats", @Option(name = "-nz", aliases = "--nonzero", description = "Show only non-zero portstats",
required = false, multiValued = false) required = false, multiValued = false)
private boolean nonzero = false; private boolean nonzero = false;
@Option(name = "-d", aliases = "--delta", description = "Show Delta Port Statistics," @Option(name = "-d", aliases = "--delta",
description = "Show delta port statistics,"
+ "only for the last polling interval", + "only for the last polling interval",
required = false, multiValued = false) required = false, multiValued = false)
private boolean delta = false; private boolean delta = false;
@Option(name = "-t", aliases = "--table", description = "Show human readable table format for statistics", @Option(name = "-t", aliases = "--table",
description = "Show delta port statistics in table format "
+ "using human readable unit",
required = false, multiValued = false) required = false, multiValued = false)
private boolean table = false; private boolean table = false;
@ -111,6 +116,7 @@ public class DevicePortStatsCommand extends DevicesListCommand {
stat.bytesSent(), stat.packetsRxDropped(), stat.packetsTxDropped(), stat.durationSec()); stat.bytesSent(), stat.packetsRxDropped(), stat.packetsTxDropped(), stat.durationSec());
} }
} }
/** /**
* Prints Port delta statistics. * Prints Port delta statistics.
* *
@ -200,6 +206,7 @@ public class DevicePortStatsCommand extends DevicesListCommand {
Character pre = ("KMGTPE").charAt(exp - 1); Character pre = ("KMGTPE").charAt(exp - 1);
return String.format("%.2f%s", bytes / Math.pow(unit, exp), pre); return String.format("%.2f%s", bytes / Math.pow(unit, exp), pre);
} }
/** /**
* Converts bps to human readable format. * Converts bps to human readable format.
* *
@ -209,7 +216,7 @@ public class DevicePortStatsCommand extends DevicesListCommand {
public static String humanReadableBps(float bps) { public static String humanReadableBps(float bps) {
int unit = 1000; int unit = 1000;
if (bps < unit) { if (bps < unit) {
return String.format("%.0f ", (float) bps); return String.format("%.0f ", bps);
} }
int exp = (int) (Math.log(bps) / Math.log(unit)); int exp = (int) (Math.log(bps) / Math.log(unit));
Character pre = ("KMGTPE").charAt(exp - 1); Character pre = ("KMGTPE").charAt(exp - 1);