Search in sources :

Example 1 with TablePrinter

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();
}
Also used : Pattern(java.util.regex.Pattern) OccurenceCounterEntry(org.opendaylight.infrautils.counters.impl.service.OccurenceCounterEntry) Matcher(java.util.regex.Matcher) TablePrinter(org.opendaylight.infrautils.utils.TablePrinter)

Example 2 with TablePrinter

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;
}
Also used : IVirtualRouter(org.opendaylight.netvirt.ipv6service.api.IVirtualRouter) IVirtualSubnet(org.opendaylight.netvirt.ipv6service.api.IVirtualSubnet) TablePrinter(org.opendaylight.infrautils.utils.TablePrinter) IVirtualPort(org.opendaylight.netvirt.ipv6service.api.IVirtualPort) IVirtualNetwork(org.opendaylight.netvirt.ipv6service.api.IVirtualNetwork) List(java.util.List)

Aggregations

TablePrinter (org.opendaylight.infrautils.utils.TablePrinter)2 List (java.util.List)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 OccurenceCounterEntry (org.opendaylight.infrautils.counters.impl.service.OccurenceCounterEntry)1 IVirtualNetwork (org.opendaylight.netvirt.ipv6service.api.IVirtualNetwork)1 IVirtualPort (org.opendaylight.netvirt.ipv6service.api.IVirtualPort)1 IVirtualRouter (org.opendaylight.netvirt.ipv6service.api.IVirtualRouter)1 IVirtualSubnet (org.opendaylight.netvirt.ipv6service.api.IVirtualSubnet)1