use of io.fabric8.maven.core.config.Profile in project fabric8 by jboss-fuse.
the class MQCreateAction method doExecute.
@Override
protected Object doExecute() throws Exception {
MQBrokerConfigDTO dto = createDTO();
Profile profile = MQManager.createOrUpdateProfile(dto, fabricService, runtimeProperties);
if (profile == null) {
return null;
}
String profileId = profile.getId();
System.out.println("MQ profile " + profileId + " ready");
// assign profile to existing containers
if (assign != null) {
String[] assignContainers = assign.split(",");
MQManager.assignProfileToContainers(fabricService, profile, assignContainers);
}
// create containers
if (create != null) {
String[] createContainers = create.split(",");
List<CreateContainerBasicOptions.Builder> builderList = MQManager.createContainerBuilders(dto, fabricService, "child", profileId, dto.version(), createContainers);
for (CreateContainerBasicOptions.Builder builder : builderList) {
CreateContainerMetadata[] metadatas;
try {
if (builder instanceof CreateChildContainerOptions.Builder) {
CreateChildContainerOptions.Builder childBuilder = (CreateChildContainerOptions.Builder) builder;
builder = childBuilder.jmxUser(username).jmxPassword(password);
}
metadatas = fabricService.createContainers(builder.build());
// check if there was a FabricAuthenticationException as failure then we can try again
if (metadatas != null) {
for (CreateContainerMetadata meta : metadatas) {
if (meta.getFailure() != null && meta.getFailure() instanceof FabricAuthenticationException) {
throw (FabricAuthenticationException) meta.getFailure();
}
}
}
ShellUtils.storeFabricCredentials(session, username, password);
} catch (FabricAuthenticationException fae) {
// If authentication fails, prompts for credentials and try again.
if (builder instanceof CreateChildContainerOptions.Builder) {
CreateChildContainerOptions.Builder childBuilder = (CreateChildContainerOptions.Builder) builder;
promptForJmxCredentialsIfNeeded();
metadatas = fabricService.createContainers(childBuilder.jmxUser(username).jmxPassword(password).build());
ShellUtils.storeFabricCredentials(session, username, password);
}
}
}
}
return null;
}
use of io.fabric8.maven.core.config.Profile in project fabric8 by jboss-fuse.
the class ProfileChangeParentsAction method doExecute.
@Override
protected Object doExecute() throws Exception {
Version version = versionId != null ? profileService.getRequiredVersion(versionId) : fabricService.getRequiredDefaultVersion();
Profile profile = version.getRequiredProfile(profileId);
// we can only change parents to existing profiles
Profile[] parents = FabricCommand.getExistingProfiles(fabricService, version, parentIds);
ProfileBuilder builder = ProfileBuilder.Factory.createFrom(profile);
List<String> oldParents = builder.getParents();
for (Profile parent : parents) {
builder.addParent(parent.getId());
}
// remove old parent profiles
for (String oldParent : oldParents) {
if (!parentIds.contains(oldParent)) {
builder.removeParent(oldParent);
}
}
profileService.updateProfile(builder.getProfile());
return null;
}
use of io.fabric8.maven.core.config.Profile in project fabric8 by jboss-fuse.
the class ProfileEditAction method doExecute.
@Override
protected Object doExecute() throws Exception {
try {
FabricValidations.validateProfileName(profileName);
if (!(delete || remove)) {
FabricValidations.validatePidProperties(pidProperties);
}
} catch (IllegalArgumentException e) {
// we do not want exception in the server log, so print the error message to the console
System.out.println(e.getMessage());
return 1;
}
if (delete) {
set = false;
}
Version version = versionId != null ? profileService.getRequiredVersion(versionId) : fabricService.getRequiredDefaultVersion();
Profile profile = version.getProfile(profileName);
if (profile != null) {
editProfile(profile);
} else {
System.out.println("Profile " + profileName + " does not exists!");
return 1;
}
return null;
}
use of io.fabric8.maven.core.config.Profile in project fabric8 by jboss-fuse.
the class ProfileScaleAction method doExecute.
@Override
protected Object doExecute() throws Exception {
try {
FabricValidations.validateProfileName(name);
} catch (IllegalArgumentException e) {
// we do not want exception in the server log, so print the error message to the console
System.out.println(e.getMessage());
return 1;
}
fabricService.scaleProfile(name, count);
ProfileRequirements profileRequirements = fabricService.getRequirements().getOrCreateProfileRequirement(name);
Integer minimumInstances = profileRequirements.getMinimumInstances();
int size = Containers.containersForProfile(fabricService.getContainers(), name).size();
PrintStream output = System.out;
output.println("Profile " + name + " " + (minimumInstances != null ? "now requires " + minimumInstances + " container(s)" : "does not require any containers") + " currently has " + size + " container(s) running");
return null;
}
use of io.fabric8.maven.core.config.Profile in project fabric8 by jboss-fuse.
the class RequireProfileListAction method printRequirements.
@Override
protected void printRequirements(PrintStream out, FabricRequirements requirements) {
TablePrinter table = new TablePrinter();
table.columns("profile", "# minimum", "# maximum", "depends on");
List<ProfileRequirements> profileRequirements = requirements.getProfileRequirements();
for (ProfileRequirements profile : profileRequirements) {
table.row(profile.getProfile(), getStringOrBlank(profile.getMinimumInstances()), getStringOrBlank(profile.getMaximumInstances()), getStringOrBlank(profile.getDependentProfiles()));
}
table.print();
}
Aggregations