Search in sources :

Example 61 with Version

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;
}
Also used : MQBrokerConfigDTO(io.fabric8.api.jmx.MQBrokerConfigDTO) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap)

Example 62 with Version

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;
}
Also used : ProfileService(io.fabric8.api.ProfileService) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap) Profile(io.fabric8.api.Profile)

Example 63 with Version

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);
}
Also used : ArrayList(java.util.ArrayList) Profile(io.fabric8.api.Profile)

Example 64 with Version

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;
}
Also used : ProfileService(io.fabric8.api.ProfileService)

Example 65 with Version

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;
}
Also used : PrintStreamCreationStateListener(io.fabric8.internal.PrintStreamCreationStateListener) CreateContainerMetadata(io.fabric8.api.CreateContainerMetadata) CreateJCloudsContainerOptions(io.fabric8.service.jclouds.CreateJCloudsContainerOptions)

Aggregations

Test (org.junit.jupiter.api.Test)143 Map (java.util.Map)106 IOException (java.io.IOException)78 Version (io.fabric8.api.Version)74 ArrayList (java.util.ArrayList)73 File (java.io.File)71 HashMap (java.util.HashMap)71 Profile (io.fabric8.api.Profile)70 Test (org.junit.Test)65 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)62 Vertx (io.vertx.core.Vertx)58 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)57 Pod (io.fabric8.kubernetes.api.model.Pod)56 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)56 List (java.util.List)55 Checkpoint (io.vertx.junit5.Checkpoint)54 VertxExtension (io.vertx.junit5.VertxExtension)54 VertxTestContext (io.vertx.junit5.VertxTestContext)54 Collections (java.util.Collections)54 BeforeAll (org.junit.jupiter.api.BeforeAll)53