use of org.opendaylight.infrautils.utils.TablePrinter in project infrautils by opendaylight.
the class CountersMain method dumpCounters.
public String dumpCounters(String regex) {
if (regex == null) {
regex = "";
}
Pattern pattern = Pattern.compile(regex);
int sortByColumn = 0;
TablePrinter printer = new TablePrinter(sortByColumn);
printer.setColumnNames("Counter name", "Value");
for (OccurenceCounterEntry entry : countersRunnable.getCounters()) {
String counterName = getCounterFullName(entry.counter.group, entry.counter.name);
Matcher matcher = pattern.matcher(counterName);
if (matcher.find()) {
printer.addRow(counterName, Long.toString(entry.counter.get()));
}
}
return printer.toString();
}
use of org.opendaylight.infrautils.utils.TablePrinter in project netvirt by opendaylight.
the class ShowIpv6Command method doExecute.
@Override
protected Object doExecute() {
TablePrinter tp = new TablePrinter();
if (listResource != null) {
if (listResource.equalsIgnoreCase("networks") || listResource.equalsIgnoreCase("net")) {
tp.setTitle("Network Cache List");
tp.setColumnNames("Sno", "NetworkId", "dpnId");
int count = 1;
List<IVirtualNetwork> vnetworks = elementCache.getNetworkCache();
for (IVirtualNetwork vnet : vnetworks) {
tp.addRow(count++, String.valueOf(vnet.getNetworkUuid().getValue()), vnet.getDpnsHostingNetwork());
}
session.getConsole().print(tp.toString());
} else if (listResource.equalsIgnoreCase("subnets") || listResource.equalsIgnoreCase("subnet")) {
tp.setTitle("Subnet Cache List");
tp.setColumnNames("Sno", "SubnetId", "SubnetCIDR", "ipVersion");
int count = 1;
List<IVirtualSubnet> vsubnets = elementCache.getSubnetCache();
for (IVirtualSubnet vsubnet : vsubnets) {
tp.addRow(count++, String.valueOf(vsubnet.getSubnetUUID().getValue()), String.valueOf(vsubnet.getSubnetCidr().getValue()), vsubnet.getIpVersion());
}
session.getConsole().print(tp.toString());
} else if (listResource.equalsIgnoreCase("routers") || listResource.equalsIgnoreCase("router")) {
tp.setTitle("Router Cache List");
tp.setColumnNames("Sno", "RouterId");
List<IVirtualRouter> vrouters = elementCache.getRouterCache();
int count = 1;
for (IVirtualRouter vrouter : vrouters) {
tp.addRow(count++, String.valueOf(vrouter.getRouterUUID().getValue()));
}
session.getConsole().print(tp.toString());
}
} else {
tp.setTitle("Interface Cache List");
tp.setColumnNames("Sno", "PortId", "Mac Address", "Owner", "dpnId", "FixedIPs");
List<IVirtualPort> vports = elementCache.getInterfaceCache();
int count = 1;
for (IVirtualPort vport : vports) {
String str = vport.getDeviceOwner();
tp.addRow(count++, String.valueOf(vport.getIntfUUID().getValue()), vport.getMacAddress(), str.startsWith("network:") ? str.substring(str.lastIndexOf(':') + 1) : "compute", vport.getDpId(), getPortIpv6Addresses(vport));
}
session.getConsole().print(tp.toString());
}
return null;
}
Aggregations