Search in sources :

Example 66 with Version

use of io.fabric8.api.Version in project fabric8 by jboss-fuse.

the class ContainerImpl method setProfiles.

public void setProfiles(Profile[] profiles) {
    String versionId = dataStore.getContainerVersion(id);
    List<String> currentProfileIds = dataStore.getContainerProfiles(id);
    List<String> profileIds = new ArrayList<String>();
    if (profiles != null) {
        for (Profile profile : profiles) {
            IllegalArgumentAssertion.assertTrue(versionId.equals(profile.getVersion()), "Version mismatch setting profile " + profile + ", expected version " + versionId);
            IllegalArgumentAssertion.assertFalse(profile.isAbstract(), "The profile " + profile + " is abstract and can not be associated to containers");
            IllegalArgumentAssertion.assertFalse(profile.getId().matches(ENSEMBLE_PROFILE_PATTERN) && !currentProfileIds.contains(profile.getId()), "The profile " + profile + " is not assignable.");
            profileIds.add(profile.getId());
        }
    }
    if (profileIds.isEmpty()) {
        profileIds.add(ZkDefs.DEFAULT_PROFILE);
    }
    dataStore.setContainerProfiles(id, profileIds);
}
Also used : ArrayList(java.util.ArrayList) Profile(io.fabric8.api.Profile)

Example 67 with Version

use of io.fabric8.api.Version in project fabric8 by jboss-fuse.

the class ContainerImpl method getVersion.

@Override
public Version getVersion() {
    String versionId = dataStore.getContainerVersion(id);
    ProfileService profileService = fabricService.adapt(ProfileService.class);
    return versionId != null ? profileService.getVersion(versionId) : null;
}
Also used : ProfileService(io.fabric8.api.ProfileService)

Example 68 with Version

use of io.fabric8.api.Version in project fabric8 by jboss-fuse.

the class ContainerCreateCloud method doExecute.

@Override
protected Object doExecute() throws Exception {
    // validate input before creating containers
    preCreateContainer(name);
    FabricValidations.validateProfileNames(profiles);
    if (isEnsembleServer && newUserPassword == null) {
        newUserPassword = zookeeperPassword != null ? zookeeperPassword : fabricService.getZookeeperPassword();
    }
    CreateJCloudsContainerOptions.Builder builder = CreateJCloudsContainerOptions.builder().name(name).bindAddress(bindAddress).resolver(resolver).manualIp(manualIp).ensembleServer(isEnsembleServer).credential(credential).group(group).hardwareId(hardwareId).identity(identity).osFamily(osFamily).osVersion(osVersion).imageId(imageId).instanceType(instanceType).locationId(locationId).number(number).nodeOptions(CloudUtils.parseProviderOptions(options)).owner(owner).adminAccess(!disableAdminAccess).publicKeyFile(publicKeyFile).contextName(contextName).providerName(providerName).apiName(apiName).user(user).password(password).proxyUri(proxyUri != null ? proxyUri : fabricService.getMavenRepoURI()).zookeeperUrl(fabricService.getZookeeperUrl()).zookeeperPassword(isEnsembleServer && zookeeperPassword != null ? zookeeperPassword : fabricService.getZookeeperPassword()).jvmOpts(jvmOpts).environmentalVariable(environmentalVariables).version(version).withUser(newUser, newUserPassword, newUserRole).profiles(getProfileNames()).dataStoreProperties(getDataStoreProperties()).uploadDistribution(!distributionUploadDisable);
    if (path != null && !path.isEmpty()) {
        builder.path(path);
    }
    CreateContainerMetadata[] metadatas = fabricService.createContainers(builder.build(), new PrintStreamCreationStateListener(System.out));
    if (isEnsembleServer && metadatas != null && metadatas.length > 0 && metadatas[0].isSuccess()) {
        ShellUtils.storeZookeeperPassword(session, metadatas[0].getCreateOptions().getZookeeperPassword());
    }
    // display containers
    displayContainers(metadatas);
    return null;
}
Also used : PrintStreamCreationStateListener(io.fabric8.internal.PrintStreamCreationStateListener) CreateContainerMetadata(io.fabric8.api.CreateContainerMetadata) CreateJCloudsContainerOptions(io.fabric8.service.jclouds.CreateJCloudsContainerOptions)

Example 69 with Version

use of io.fabric8.api.Version in project fabric8 by jboss-fuse.

the class VersionListAction method printVersions.

protected void printVersions(Container[] containers, List<String> versions, String defaultVersionId, PrintStream out) {
    TablePrinter table = new TablePrinter();
    table.columns("version", "default", "# containers", "description");
    List<String> invalidVersion = new ArrayList<String>();
    // they are sorted in the correct order by default
    for (String versionId : versions) {
        if (versionId != null && !versionId.isEmpty() && ALLOWED_PROFILE_NAMES_PATTERN.matcher(versionId).matches()) {
            boolean isDefault = versionId.equals(defaultVersionId);
            Version version = profileService.getRequiredVersion(versionId);
            int active = countContainersByVersion(containers, version);
            String description = version.getAttributes().get(Version.DESCRIPTION);
            table.row(version.getId(), (isDefault ? "true" : ""), activeContainerCountText(active), description);
        } else {
            invalidVersion.add(versionId);
        }
    }
    table.print();
    if (!invalidVersion.isEmpty()) {
        System.out.println("The following profile versions have been skipped since their names are not correct: " + invalidVersion.toString());
    }
}
Also used : CommandUtils.countContainersByVersion(io.fabric8.commands.support.CommandUtils.countContainersByVersion) Version(io.fabric8.api.Version) TablePrinter(io.fabric8.utils.TablePrinter) ArrayList(java.util.ArrayList)

Example 70 with Version

use of io.fabric8.api.Version in project fabric8 by jboss-fuse.

the class DefaultVersionBuilder method validate.

@Override
protected void validate() {
    super.validate();
    IllegalStateAssertion.assertNotNull(versionId, "Version must have an identity");
    for (Profile profile : profiles.values()) {
        String prfversion = profile.getVersion();
        IllegalStateAssertion.assertEquals(versionId, prfversion, "Profile version not '" + versionId + "' for: " + profile);
    }
}
Also used : Profile(io.fabric8.api.Profile)

Aggregations

Version (io.fabric8.api.Version)74 Profile (io.fabric8.api.Profile)70 File (java.io.File)52 Test (org.junit.Test)46 IOException (java.io.IOException)41 ArrayList (java.util.ArrayList)36 Container (io.fabric8.api.Container)35 HashMap (java.util.HashMap)34 ProfileService (io.fabric8.api.ProfileService)27 Map (java.util.Map)25 Git (org.eclipse.jgit.api.Git)22 FabricService (io.fabric8.api.FabricService)21 Version (org.osgi.framework.Version)21 ProfileBuilder (io.fabric8.api.ProfileBuilder)18 GitVersion (io.fabric8.api.commands.GitVersion)18 PatchException (io.fabric8.patch.management.PatchException)15 HashSet (java.util.HashSet)15 TreeMap (java.util.TreeMap)14 LinkedList (java.util.LinkedList)13 GitPatchRepository (io.fabric8.patch.management.impl.GitPatchRepository)12