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);
}
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;
}
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;
}
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());
}
}
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);
}
}
Aggregations