Search in sources :

Example 11 with TablePrinter

use of io.fabric8.utils.TablePrinter in project fabric8 by jboss-fuse.

the class ContainerListAction method printContainers.

private void printContainers(Container[] containers, Version version, PrintStream out) {
    TablePrinter table = new TablePrinter();
    table.columns("id", "version", "type", "connected", "profiles", "provision status");
    for (Container container : containers) {
        if (CommandUtils.matchVersion(container, version)) {
            String indent = "";
            for (Container c = container; !c.isRoot(); c = c.getParent()) {
                indent += "  ";
            }
            // Mark local container with a star symbol
            String marker = "";
            if (container.getId().equals(fabricService.getCurrentContainer().getId())) {
                marker = "*";
            }
            List<String> assignedProfiles = dataStore.getContainerProfiles(container.getId());
            try {
                table.row(indent + container.getId() + marker, container.getVersion().getId(), container.getType(), aliveText(container), assignedProfiles.get(0), CommandUtils.status(container));
            } catch (RuntimeException e) {
                LOG.warn("Problem getting the overlay profile for container " + container.getId(), e);
            }
            // we want multiple profiles to be displayed on next lines
            for (int i = 1; i < assignedProfiles.size(); i++) {
                table.row("", "", "", "", assignedProfiles.get(i), "");
            }
        }
    }
    table.print();
}
Also used : Container(io.fabric8.api.Container) TablePrinter(io.fabric8.utils.TablePrinter)

Example 12 with TablePrinter

use of io.fabric8.utils.TablePrinter in project fabric8 by jboss-fuse.

the class ContainerResolverListAction method doExecute.

@Override
protected Object doExecute() throws Exception {
    if (containerIds == null || containerIds.isEmpty()) {
        containerIds = new ArrayList<String>();
        for (Container container : fabricService.getContainers()) {
            containerIds.add(container.getId());
        }
    }
    TablePrinter table = new TablePrinter();
    table.columns("id", "resolver", "local hostname", "local ip", "public hostname", "public ip", "manual ip");
    for (String containerId : containerIds) {
        Container container = fabricService.getContainer(containerId);
        String localHostName = container.getLocalHostname();
        String localIp = container.getLocalIp();
        String publicHostName = container.getPublicHostname();
        String publicIp = container.getPublicIp();
        String manualIp = container.getManualIp();
        localHostName = localHostName != null ? localHostName : "";
        localIp = localIp != null ? localIp : "";
        publicHostName = publicHostName != null ? publicHostName : "";
        publicIp = publicIp != null ? publicIp : "";
        manualIp = manualIp != null ? manualIp : "";
        String resolver = container.getResolver();
        table.row(containerId, resolver, localHostName, localIp, publicHostName, publicIp, manualIp);
    }
    table.print();
    return null;
}
Also used : Container(io.fabric8.api.Container) TablePrinter(io.fabric8.utils.TablePrinter)

Example 13 with TablePrinter

use of io.fabric8.utils.TablePrinter in project fabric8 by jboss-fuse.

the class FabricGitSummaryAction method printVersions.

private void printVersions(String title, List<GitVersion> versions) {
    System.out.println(title);
    TablePrinter table = new TablePrinter();
    table.columns("version", "SHA1", "timestamp", "message");
    for (GitVersion version : versions) {
        table.row(version.getVersion(), version.getSha1(), version.getTimestamp(), version.getMessage());
    }
    table.print();
}
Also used : GitVersion(io.fabric8.api.commands.GitVersion) TablePrinter(io.fabric8.utils.TablePrinter)

Example 14 with TablePrinter

use of io.fabric8.utils.TablePrinter in project fabric8 by jboss-fuse.

the class DomainListAction method doExecute.

@Override
protected Object doExecute() throws Exception {
    IOpenShiftConnection connection = getOrCreateConnection();
    TablePrinter printer = new TablePrinter();
    printer.column("id");
    for (IDomain domain : connection.getDomains()) {
        printer.row(domain.getId());
    }
    printer.print();
    return null;
}
Also used : IDomain(com.openshift.client.IDomain) IOpenShiftConnection(com.openshift.client.IOpenShiftConnection) TablePrinter(io.fabric8.utils.TablePrinter)

Aggregations

TablePrinter (io.fabric8.utils.TablePrinter)14 Container (io.fabric8.api.Container)3 IDomain (com.openshift.client.IDomain)2 IOpenShiftConnection (com.openshift.client.IOpenShiftConnection)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 JsonParseException (com.fasterxml.jackson.core.JsonParseException)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 IApplication (com.openshift.client.IApplication)1 ProfileVersionKey (io.fabric8.agent.commands.support.ProfileVersionKey)1 AutoScaleProfileStatus (io.fabric8.api.AutoScaleProfileStatus)1 Profile (io.fabric8.api.Profile)1 ProfileRequirements (io.fabric8.api.ProfileRequirements)1 Version (io.fabric8.api.Version)1 GitVersion (io.fabric8.api.commands.GitVersion)1 CommandUtils.countContainersByVersion (io.fabric8.commands.support.CommandUtils.countContainersByVersion)1 Parser (io.fabric8.maven.util.Parser)1 Archetype (io.fabric8.tooling.archetype.catalog.Archetype)1 HashMap (java.util.HashMap)1 List (java.util.List)1