use of io.fabric8.api.FabricService in project fabric8 by jboss-fuse.
the class ContainerAddProfileAction method doExecute.
protected Object doExecute() throws Exception {
FabricValidations.validateContainerName(container);
FabricValidations.validateProfileNames(profiles);
Container cont = FabricCommand.getContainer(fabricService, container);
// we can add existing profiles
Profile[] profs = FabricCommand.getExistingProfiles(fabricService, cont.getVersion(), this.profiles);
cont.addProfiles(profs);
return null;
}
use of io.fabric8.api.FabricService in project fabric8 by jboss-fuse.
the class ContainerChangeProfileAction method doExecute.
protected Object doExecute() throws Exception {
FabricValidations.validateContainerName(container);
FabricValidations.validateProfileNames(profiles);
Container cont = FabricCommand.getContainer(fabricService, container);
// we can only change to existing profiles
Profile[] profs = FabricCommand.getExistingProfiles(fabricService, cont.getVersion(), profiles);
cont.setProfiles(profs);
return null;
}
use of io.fabric8.api.FabricService in project fabric8 by jboss-fuse.
the class WelcomeAction method doExecute.
@Override
protected Object doExecute() throws Exception {
String name = runtimeProperties.getRuntimeIdentity();
String appName = runtimeProperties.getProperty("karaf.app.name", "JBoss Fuse");
System.out.println("Welcome to " + appName);
System.out.println("");
// are we part of fabric?
if (fabricService != null) {
Container container = fabricService.getCurrentContainer();
if (container != null) {
boolean ensemble = container.isEnsembleServer();
if (ensemble) {
System.out.println("This container \u001B[1m" + container.getId() + "\u001B[0m is a Fabric ensemble server.");
} else {
System.out.println("This container \u001B[1m" + container.getId() + "\u001B[0m is joined to an existing Fabric.");
}
} else {
System.out.println("This container \u001B[1m" + name + "\u001B[0m is a standalone container.");
}
String url = fabricService.getWebConsoleUrl();
if (url != null) {
System.out.println("Web management console available at: \u001B[1m" + url + "\u001B[0m");
}
System.out.println("");
} else {
// no we are standalone
System.out.println("This container \u001B[1m" + name + "\u001B[0m is a standalone container.");
System.out.println("");
System.out.println("Create a new Fabric via '\u001B[1mfabric:create\u001B[0m'");
System.out.println("or join an existing Fabric via '\u001B[1mfabric:join [someUrls]\u001B[0m'");
System.out.println("");
}
return null;
}
use of io.fabric8.api.FabricService in project fabric8 by jboss-fuse.
the class AbstractChildContainerCreateAction method preCreateContainer.
/**
* Pre validates input before creating the container(s)
*
* @param name the name of the container to create
* @throws IllegalArgumentException is thrown if input is invalid
*/
protected void preCreateContainer(String name) throws IllegalArgumentException {
FabricValidations.validateContainerName(name);
if (clusterService.getEnsembleContainers().isEmpty()) {
return;
}
if (FabricCommand.doesContainerExist(fabricService, name)) {
throw new IllegalArgumentException("A container with name " + name + " already exists.");
}
// get the profiles for the given version
Version ver = version != null ? profileService.getRequiredVersion(version) : fabricService.getRequiredDefaultVersion();
List<Profile> profiles = ver.getProfiles();
// validate profiles exists before creating a new container
Set<String> names = getProfileNames();
for (String profile : names) {
Profile prof = getProfile(profiles, profile, ver);
if (prof == null) {
throw new IllegalArgumentException("Profile " + profile + " with version " + ver.getId() + " does not exist.");
}
if (prof.isAbstract()) {
throw new IllegalArgumentException("Profile " + profile + " with version " + ver.getId() + " is abstract and can not be associated to containers.");
}
}
if (fabricService.getZookeeperUrl() == null) {
throw new IllegalArgumentException("should start a zookeeper ensemble first.");
}
}
use of io.fabric8.api.FabricService in project fabric8 by jboss-fuse.
the class AbstractContainerCreateAction method preCreateContainer.
/**
* Pre validates input before creating the container(s)
*
* @param name the name of the container to create
* @throws IllegalArgumentException is thrown if input is invalid
*/
protected void preCreateContainer(String name) throws IllegalArgumentException {
FabricValidations.validateContainerName(name);
if (!isEnsembleServer) {
if (clusterService.getEnsembleContainers().isEmpty()) {
if (!isEnsembleServer) {
throw new IllegalStateException("The use of the --ensemble-server option is mandatory when creating an initial container");
}
return;
}
if (FabricCommand.doesContainerExist(fabricService, name)) {
throw new IllegalArgumentException("A container with name " + name + " already exists.");
}
// get the profiles for the given version
Version ver = version != null ? profileService.getRequiredVersion(version) : fabricService.getRequiredDefaultVersion();
List<Profile> profiles = ver.getProfiles();
// validate profiles exists before creating a new container
Set<String> names = getProfileNames();
for (String profile : names) {
Profile prof = getProfile(profiles, profile, ver);
if (prof == null) {
throw new IllegalArgumentException("Profile " + profile + " with version " + ver.getId() + " does not exist.");
}
if (prof.isAbstract()) {
throw new IllegalArgumentException("Profile " + profile + " with version " + ver.getId() + " is abstract and can not be associated to containers.");
}
}
}
if (!isEnsembleServer && fabricService.getZookeeperUrl() == null) {
throw new IllegalArgumentException("Either start a zookeeper ensemble or use --ensemble-server.");
}
}
Aggregations