Search in sources :

Example 16 with Builder

use of io.fabric8.maven.docker.config.ImageConfiguration.Builder in project fabric8 by jboss-fuse.

the class ProfileServiceImpl method getOverlayProfile.

@Override
public Profile getOverlayProfile(Profile profile) {
    assertValid();
    Profile overlayProfile;
    synchronized (this) {
        if (profile.isOverlay()) {
            LOGGER.debug("getOverlayProfile, given profile is already an overlay: " + profile);
            overlayProfile = profile;
        } else {
            String profileId = profile.getId();
            String environment = runtimeProperties.get().getProperty(SystemProperties.FABRIC_ENVIRONMENT);
            if (environment == null) {
                // lets default to the environment from the current active
                // set of profiles (e.g. docker or openshift)
                environment = System.getProperty(SystemProperties.FABRIC_PROFILE_ENVIRONMENT);
            }
            Version version = getRequiredVersion(profile.getVersion());
            ProfileBuilder builder = ProfileBuilder.Factory.create(profile.getVersion(), profileId);
            builder.addOptions(new OverlayOptionsProvider(version, profile, environment));
            overlayProfile = builder.getProfile();
            // Log the overlay profile difference
            if (LOGGER.isDebugEnabled()) {
                OverlayAudit audit = getOverlayAudit();
                synchronized (audit) {
                    Profile lastOverlay = audit.overlayProfiles.get(profileId);
                    if (lastOverlay == null) {
                        LOGGER.debug("Overlay" + Profiles.getProfileInfo(overlayProfile));
                        audit.overlayProfiles.put(profileId, overlayProfile);
                    } else if (!lastOverlay.equals(overlayProfile)) {
                        LOGGER.debug("Overlay" + Profiles.getProfileDifference(lastOverlay, overlayProfile));
                        audit.overlayProfiles.put(profileId, overlayProfile);
                    }
                }
            }
        }
    }
    return overlayProfile;
}
Also used : Version(io.fabric8.api.Version) ProfileBuilder(io.fabric8.api.ProfileBuilder) Profile(io.fabric8.api.Profile)

Example 17 with Builder

use of io.fabric8.maven.docker.config.ImageConfiguration.Builder in project fabric8 by jboss-fuse.

the class SshAutoScalerTest method assertSshAutoScale.

public static HostProfileCounter assertSshAutoScale(FabricRequirements requirements, AutoScaleStatus status) {
    HostProfileCounter hostProfileCounter = new HostProfileCounter();
    String version = requirements.getVersion();
    if (Strings.isEmpty(version)) {
        version = "1.0";
    }
    List<ProfileRequirements> profileRequirements = requirements.getProfileRequirements();
    for (ProfileRequirements profileRequirement : profileRequirements) {
        Integer minimumInstances = profileRequirement.getMinimumInstances();
        if (minimumInstances != null) {
            for (int i = 0; i < minimumInstances; i++) {
                String profileId = profileRequirement.getProfile();
                AutoScaleRequest request = new AutoScaleRequest(null, version, profileId, 1, requirements, profileRequirement, status);
                CreateSshContainerOptions.Builder builder = chooseHostContainerOptions(request, hostProfileCounter);
                assertNotNull("Should have found a builder for " + profileId, builder);
                String host = builder.getHost();
                hostProfileCounter.incrementContainers(host);
                hostProfileCounter.incrementProfileCount(host, profileId);
            }
        }
    }
    Map<String, CountingMap> hostToProfileCounts = hostProfileCounter.getHostToProfileCounts();
    assertProfilesUseSeparateHost(requirements, hostToProfileCounts);
    assertMaximumContainerCountNotExceeded(requirements, hostToProfileCounts);
    return hostProfileCounter;
}
Also used : CountingMap(io.fabric8.utils.CountingMap) ProfileRequirements(io.fabric8.api.ProfileRequirements) AutoScaleRequest(io.fabric8.api.AutoScaleRequest) HostProfileCounter(io.fabric8.internal.autoscale.HostProfileCounter)

Example 18 with Builder

use of io.fabric8.maven.docker.config.ImageConfiguration.Builder in project fabric8 by jboss-fuse.

the class FabricManager method setProfileTags.

@Override
public void setProfileTags(String versionId, String profileId, List<String> tags) {
    Profile profile = profileService.getRequiredProfile(versionId, profileId);
    ProfileBuilder builder = ProfileBuilder.Factory.createFrom(profile);
    builder.setTags(tags);
    profileService.updateProfile(builder.getProfile());
}
Also used : ProfileBuilder(io.fabric8.api.ProfileBuilder) Profile(io.fabric8.api.Profile)

Example 19 with Builder

use of io.fabric8.maven.docker.config.ImageConfiguration.Builder in project fabric8 by jboss-fuse.

the class FabricManager method changeProfileParents.

@Override
public Map<String, Object> changeProfileParents(String versionId, String profileId, List<String> parents) {
    Profile profile = profileService.getRequiredProfile(versionId, profileId);
    ProfileBuilder builder = ProfileBuilder.Factory.createFrom(profile).setParents(parents);
    profile = profileService.updateProfile(builder.getProfile());
    return getProfile(versionId, profile.getId());
}
Also used : ProfileBuilder(io.fabric8.api.ProfileBuilder) Profile(io.fabric8.api.Profile)

Example 20 with Builder

use of io.fabric8.maven.docker.config.ImageConfiguration.Builder in project fabric8 by jboss-fuse.

the class FabricManager method createProfile.

@Override
// Creates a profile with empty content. Is this meaningful?
@Deprecated
public Map<String, Object> createProfile(String versionId, String profileId) {
    ProfileBuilder builder = ProfileBuilder.Factory.create(versionId, profileId);
    Profile profile = profileService.createProfile(builder.getProfile());
    return getProfile(versionId, profile.getId());
}
Also used : ProfileBuilder(io.fabric8.api.ProfileBuilder) Profile(io.fabric8.api.Profile)

Aggregations

Test (org.junit.Test)60 ProfileBuilder (io.fabric8.api.ProfileBuilder)34 Profile (io.fabric8.api.Profile)33 KubernetesListBuilder (io.fabric8.kubernetes.api.model.KubernetesListBuilder)27 FabricService (io.fabric8.api.FabricService)24 InputStream (java.io.InputStream)21 Deployment (org.jboss.arquillian.container.test.api.Deployment)21 OSGiManifestBuilder (org.jboss.osgi.metadata.OSGiManifestBuilder)21 Asset (org.jboss.shrinkwrap.api.asset.Asset)21 JavaArchive (org.jboss.shrinkwrap.api.spec.JavaArchive)21 ServiceTracker (org.osgi.util.tracker.ServiceTracker)20 HashMap (java.util.HashMap)19 Map (java.util.Map)19 Logger (org.slf4j.Logger)19 CommandSupport (io.fabric8.itests.support.CommandSupport)18 ConfigurationAdmin (org.osgi.service.cm.ConfigurationAdmin)17 ServiceLocator (io.fabric8.api.gravia.ServiceLocator)16 IOException (java.io.IOException)16 Action (org.apache.felix.gogo.commands.Action)16 AbstractCommand (org.apache.felix.gogo.commands.basic.AbstractCommand)16