/** * Get the effective profile, which is the overlay profile with substituted configurations. */ public static Profile getEffectiveProfile(FabricService fabricService, Profile profile) { ProfileService profileService = fabricService.adapt(ProfileService.class); Profile overlayProfile = profileService.getOverlayProfile(profile); Map<String, Map<String, String>> configurations = overlayProfile.getConfigurations(); ProfileBuilder builder = ProfileBuilder.Factory.createFrom(overlayProfile); builder.setConfigurations(fabricService.substituteConfigurations(configurations)); return builder.getProfile(); }
@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()); }
@Override public Map<String, String> getProfileProperties(String versionId, String profileId, String pid) { Map<String, String> answer = null; Version version = profileService.getVersion(versionId); if (version != null) { Profile profile = version.getRequiredProfile(profileId); if (profile != null) { answer = profile.getConfiguration(pid); } } return answer; }
public static void copyProfile(FabricService fabricService, String versionId, String sourceId, String targetId, boolean force) { ProfileService profileService = fabricService.adapt(ProfileService.class); Profile sourceProfile = profileService.getRequiredProfile(versionId, sourceId); LOGGER.info("copyProfile: {} => {}", sourceProfile, targetId); // [TODO] delete/create profile must be done in an atomic operation maybeDeleteProfile(fabricService, versionId, targetId, force); ProfileBuilder builder = ProfileBuilder.Factory.createFrom(sourceProfile); profileService.createProfile(builder.identity(targetId).getProfile()); }
@Override public void setProfileFeatures(String versionId, String profileId, List<String> features) { Profile profile = profileService.getRequiredProfile(versionId, profileId); ProfileBuilder builder = ProfileBuilder.Factory.createFrom(profile); builder.setFeatures(features); profileService.updateProfile(builder.getProfile()); }
@Override public void setProfileFabs(String versionId, String profileId, List<String> fabs) { Profile profile = profileService.getRequiredProfile(versionId, profileId); ProfileBuilder builder = ProfileBuilder.Factory.createFrom(profile); builder.setFabs(fabs); profileService.updateProfile(builder.getProfile()); }
@Override public Version getVersion() { String versionId = dataStore.getContainerVersion(id); ProfileService profileService = fabricService.adapt(ProfileService.class); return versionId != null ? profileService.getVersion(versionId) : null; }
/** * Returns all the current alive and successful containers for the given profile which have completed provisioning */ public static List<Container> aliveAndSuccessfulContainersForProfile(String profile, FabricService fabricService) { Container[] allContainers = fabricService.getContainers(); return aliveAndSuccessfulContainersForProfile(profile, allContainers); }
/** * Returns all the current alive or pending profiles for the given profile */ public static List<Container> aliveOrPendingContainersForProfile(String profile, FabricService fabricService) { Container[] allContainers = fabricService.getContainers(); return aliveOrPendingContainersForProfile(profile, allContainers); }
/** * Returns true if the given container has the given profile */ public static boolean containerHasProfile(Container container, Profile profile) { return containerHasProfile(container, profile.getId()); }
void applyUpdatedCredentials(Container container) { if (user != null || password != null) { CreateContainerMetadata<?> metadata = container.getMetadata(); if (metadata != null) { metadata.updateCredentials(user, password); dataStore.setContainerMetadata(container.getMetadata()); } } }
/** * Returns the overlay configuration for the given list of profile ids and the configuration PID. * * This method will find the overlay profile for each profile id and combine all the configurations together. * * Usually we would use the Profile objects directly; but this API call is useful when creating new containers; letting us * figure out the effective overlay before a container exists. */ public static Map<String, String> getOverlayConfiguration(FabricService fabricService, Iterable<String> profileIds, String versionId, String pid) { String environment = fabricService.getEnvironment(); return getOverlayConfiguration(fabricService, profileIds, versionId, pid, environment); }
/** * Lazily creates the scaling requirements for the child container provider */ public ChildScalingRequirements childScaling() { if (childScalingRequirements == null) { childScalingRequirements = new ChildScalingRequirements(); } return getChildScalingRequirements(); }
/** * Returns the host configuration for the given host name; lazily creating a new one if one does not exist yet */ public DockerHostConfiguration host(String hostName) { DockerHostConfiguration answer = getHost(hostName); if (answer == null) { answer = new DockerHostConfiguration(hostName); addHost(answer); } return answer; }
/** * Returns the host configuration for the given host name; lazily creating a new one if one does not exist yet */ public SshHostConfiguration host(String hostName) { SshHostConfiguration answer = getHost(hostName); if (answer == null) { answer = new SshHostConfiguration(hostName); addHost(answer); } return answer; }
/** * Returns true if there are any requirements for the given profile ID and it has at least 1 minimum instances defined */ public boolean hasMinimumInstances(String profileId) { ProfileRequirements profileRequirement = findProfileRequirements(profileId); if (profileRequirement != null) { return profileRequirement.hasMinimumInstances(); } return false; }
/** * Lazily creates the scaling requirements for the docker container provider */ public DockerScalingRequirements dockerScaling() { if (dockerScalingRequirements == null) { dockerScalingRequirements = new DockerScalingRequirements(); } return getDockerScalingRequirements(); }
/** * Returns the value if present. * @return The value or Null. */ public T getIfPresent() { return currentRevision().getIfPresent(); }
/** * Lazily creates the scaling requirements for the OpenShift container provider */ public OpenShiftScalingRequirements openShiftScaling() { if (openShiftScalingRequirements == null) { openShiftScalingRequirements = new OpenShiftScalingRequirements(); } return getOpenShiftScalingRequirements(); }
/** * Get the effective profile, which is the overlay profile with substituted configurations. */ public static Profile getEffectiveProfile(FabricService fabricService, Profile profile) { ProfileService profileService = fabricService.adapt(ProfileService.class); Profile overlayProfile = profileService.getOverlayProfile(profile); Map<String, Map<String, String>> configurations = overlayProfile.getConfigurations(); ProfileBuilder builder = ProfileBuilder.Factory.createFrom(overlayProfile); builder.setConfigurations(fabricService.substituteConfigurations(configurations, overlayProfile.getId())); return builder.getProfile(); }