Search in sources :

Example 6 with Profile

use of io.fabric8.maven.core.config.Profile 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.");
    }
}
Also used : Version(io.fabric8.api.Version) Profile(io.fabric8.api.Profile)

Example 7 with Profile

use of io.fabric8.maven.core.config.Profile in project fabric8 by jboss-fuse.

the class AutoScaleStatusListAction method printStatus.

protected void printStatus(PrintStream out, AutoScaleStatus status) {
    TablePrinter table = new TablePrinter();
    table.columns("auto scale profile", "status", "message");
    List<AutoScaleProfileStatus> profileStatuses = status.getProfileStatuses();
    for (AutoScaleProfileStatus profile : profileStatuses) {
        table.row(getStringOrBlank(profile.getProfile()), getStringOrBlank(profile.getStatus()), getStringOrBlank(profile.getMessage()));
    }
    table.print();
}
Also used : TablePrinter(io.fabric8.utils.TablePrinter) AutoScaleProfileStatus(io.fabric8.api.AutoScaleProfileStatus)

Example 8 with Profile

use of io.fabric8.maven.core.config.Profile in project fabric8 by jboss-fuse.

the class ProfileFacade method setParents.

public Profile setParents(Profile[] profiles) {
    List<String> parentIds = new ArrayList<String>();
    for (Profile profile : profiles) {
        parentIds.add(profile.getId());
    }
    Helpers.exec(j4p, "changeProfileParents(java.lang.String, java.lang.String, java.util.List)", versionId, id, parentIds);
    return null;
}
Also used : ArrayList(java.util.ArrayList) Profile(io.fabric8.api.Profile)

Example 9 with Profile

use of io.fabric8.maven.core.config.Profile in project fabric8 by jboss-fuse.

the class VersionFacade method getProfiles.

@Override
public List<Profile> getProfiles() {
    List<Profile> rc = new ArrayList<Profile>();
    JSONArray array = getFieldValue("profiles");
    if (array == null || array.size() == 0) {
        return Collections.emptyList();
    }
    for (Object profile : array) {
        rc.add(new ProfileFacade(j4p, id, (String) profile));
    }
    return rc;
}
Also used : ArrayList(java.util.ArrayList) JSONArray(org.json.simple.JSONArray) Profile(io.fabric8.api.Profile)

Example 10 with Profile

use of io.fabric8.maven.core.config.Profile 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.");
    }
}
Also used : Version(io.fabric8.api.Version) Profile(io.fabric8.api.Profile)

Aggregations

Profile (io.fabric8.api.Profile)125 Version (io.fabric8.api.Version)50 Container (io.fabric8.api.Container)49 ArrayList (java.util.ArrayList)37 ProfileBuilder (io.fabric8.api.ProfileBuilder)34 Test (org.junit.Test)32 FabricService (io.fabric8.api.FabricService)28 HashMap (java.util.HashMap)25 File (java.io.File)24 ProfileService (io.fabric8.api.ProfileService)23 Map (java.util.Map)22 IOException (java.io.IOException)19 ProfileRequirements (io.fabric8.api.ProfileRequirements)13 HashSet (java.util.HashSet)12 GitVersion (io.fabric8.api.commands.GitVersion)11 FabricRequirements (io.fabric8.api.FabricRequirements)10 LinkedList (java.util.LinkedList)9 TreeMap (java.util.TreeMap)9 LockHandle (io.fabric8.api.LockHandle)8 Parser (io.fabric8.maven.util.Parser)8