use of io.fabric8.maven.docker.model.Container in project fabric8 by jboss-fuse.
the class ContainerStartAction method doExecute.
protected Object doExecute() throws Exception {
Collection<String> expandedNames = super.expandGlobNames(containers);
for (String containerName : expandedNames) {
validateContainerName(containerName);
Container found = FabricCommand.getContainer(fabricService, containerName);
applyUpdatedCredentials(found);
if (force || !found.isAlive()) {
found.start(force);
} else {
System.err.println("Container " + containerName + " is already started");
}
}
return null;
}
use of io.fabric8.maven.docker.model.Container in project fabric8 by jboss-fuse.
the class ContainerStopAction method doExecute.
protected Object doExecute() throws Exception {
Collection<String> expandedNames = super.expandGlobNames(containers);
for (String containerName : expandedNames) {
validateContainerName(containerName);
if (!force && FabricCommand.isPartOfEnsemble(fabricService, containerName)) {
System.out.println("Container is part of the ensemble. If you still want to stop it, please use --force option.");
return null;
}
Container found = FabricCommand.getContainer(fabricService, containerName);
applyUpdatedCredentials(found);
if (found.isAlive()) {
found.stop(force);
found = FabricCommand.getContainer(fabricService, containerName);
if (!found.isAlive()) {
System.out.println("Container '" + found.getId() + "' stopped successfully.");
} else {
// In case of SSH container we can have timing issue with this command
// so we will poll the status of container for a fixed number of times
// if it's not stopped then we will output the message, otherwise we will continue normally
int count = 0;
boolean alive = true;
for (count = 0; count < attemptNumber; count++) {
found = FabricCommand.getContainer(fabricService, containerName);
if (!found.isAlive()) {
alive = false;
} else {
Thread.sleep(pollingInterval);
}
}
if (alive) {
System.out.println("Container '" + found.getId() + "' was not stopped successfully, something went wrong. Check Logs.");
}
}
} else {
System.err.println("Container '" + found.getId() + "' already stopped.");
}
}
return null;
}
use of io.fabric8.maven.docker.model.Container in project fabric8 by jboss-fuse.
the class ProfileScaleAction method doExecute.
@Override
protected Object doExecute() throws Exception {
try {
FabricValidations.validateProfileName(name);
} catch (IllegalArgumentException e) {
// we do not want exception in the server log, so print the error message to the console
System.out.println(e.getMessage());
return 1;
}
fabricService.scaleProfile(name, count);
ProfileRequirements profileRequirements = fabricService.getRequirements().getOrCreateProfileRequirement(name);
Integer minimumInstances = profileRequirements.getMinimumInstances();
int size = Containers.containersForProfile(fabricService.getContainers(), name).size();
PrintStream output = System.out;
output.println("Profile " + name + " " + (minimumInstances != null ? "now requires " + minimumInstances + " container(s)" : "does not require any containers") + " currently has " + size + " container(s) running");
return null;
}
use of io.fabric8.maven.docker.model.Container in project fabric8 by jboss-fuse.
the class EnsembleListAction method doExecute.
@Override
protected Object doExecute() throws Exception {
TablePrinter printer = new TablePrinter();
printer.column("id");
List<String> containers = clusterService.getEnsembleContainers();
if (containers != null) {
for (String container : containers) {
printer.row(container);
}
}
printer.print();
return null;
}
use of io.fabric8.maven.docker.model.Container in project fabric8 by jboss-fuse.
the class ContainerListAction method doExecute.
@Override
protected Object doExecute() throws Exception {
Container[] containers = fabricService.getContainers();
// filter unwanted containers, and split list into parent/child,
// so we can sort the list as we want it
containers = CommandUtils.filterContainers(containers, filter);
// we want the list to be sorted
containers = CommandUtils.sortContainers(containers);
Version ver = null;
if (version != null) {
// limit containers to only with same version
ver = profileService.getRequiredVersion(version);
}
if (verbose) {
printContainersVerbose(containers, ver, System.out);
} else {
printContainers(containers, ver, System.out);
}
return null;
}
Aggregations