use of io.fabric8.kubernetes.model.annotation.Version in project fabric8 by jboss-fuse.
the class MQManager method createConfigDTOs.
public static List<MQBrokerConfigDTO> createConfigDTOs(MQService mqService, Profile profile) {
List<MQBrokerConfigDTO> answer = new ArrayList<MQBrokerConfigDTO>();
Map<String, Map<String, String>> configurations = profile.getConfigurations();
Set<Map.Entry<String, Map<String, String>>> entries = configurations.entrySet();
for (Map.Entry<String, Map<String, String>> entry : entries) {
String key = entry.getKey();
Map<String, String> configuration = entry.getValue();
if (isBrokerConfigPid(key)) {
String brokerName = getBrokerNameFromPID(key);
String profileId = profile.getId();
MQBrokerConfigDTO dto = new MQBrokerConfigDTO();
dto.setProfile(profileId);
dto.setBrokerName(brokerName);
String version = profile.getVersion();
dto.setVersion(version);
List<String> parentIds = profile.getParentIds();
if (parentIds.size() > 0) {
dto.setParentProfile(parentIds.get(0));
}
if (configuration != null) {
dto.setData(configuration.get(DATA));
dto.setConfigUrl(configuration.get(CONFIG_URL));
dto.setGroup(configuration.get(GROUP));
dto.setKind(BrokerKind.fromValue(configuration.get(KIND)));
dto.setMinimumInstances(Maps.integerValue(configuration, MINIMUM_INSTANCES));
dto.setNetworks(Maps.stringValues(configuration, NETWORKS));
dto.setNetworksUserName(configuration.get(NETWORK_USER_NAME));
dto.setNetworksPassword(configuration.get(NETWORK_PASSWORD));
dto.setReplicas(Maps.integerValue(configuration, REPLICAS));
for (Map.Entry<String, String> configurationEntry : configuration.entrySet()) {
if (configurationEntry.getKey().endsWith("-port")) {
dto.getPorts().put(configurationEntry.getKey().substring(0, configurationEntry.getKey().indexOf("-port")), configurationEntry.getValue());
}
}
}
answer.add(dto);
}
}
return answer;
}
use of io.fabric8.kubernetes.model.annotation.Version in project fabric8 by jboss-fuse.
the class MQManager method getActiveOrRequiredBrokerProfileMap.
private List<Profile> getActiveOrRequiredBrokerProfileMap(Version version, FabricRequirements requirements) {
IllegalArgumentAssertion.assertNotNull(fabricService, "fabricService");
List<Profile> answer = new ArrayList<Profile>();
if (version != null) {
ProfileService profileService = fabricService.adapt(ProfileService.class);
List<Profile> profiles = version.getProfiles();
for (Profile profile : profiles) {
String versionId = profile.getVersion();
String profileId = profile.getId();
if (!IGNORED_PROFILES.contains(profileId)) {
Profile overlay = profileService.getOverlayProfile(profile);
Map<String, Map<String, String>> configurations = overlay.getConfigurations();
Set<Map.Entry<String, Map<String, String>>> entries = configurations.entrySet();
for (Map.Entry<String, Map<String, String>> entry : entries) {
String key = entry.getKey();
if (isBrokerConfigPid(key)) {
answer.add(overlay);
}
}
}
}
}
return answer;
}
use of io.fabric8.kubernetes.model.annotation.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.kubernetes.model.annotation.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.kubernetes.model.annotation.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;
}
Aggregations