Search in sources :

Example 56 with Version

use of io.fabric8.kubernetes.model.annotation.Version in project fabric8 by jboss-fuse.

the class FabricManager method containersForVersion.

@Override
public List<Map<String, Object>> containersForVersion(String versionId, List<String> fields) {
    Version version = profileService.getVersion(versionId);
    List<Map<String, Object>> answer = new ArrayList<Map<String, Object>>();
    if (version != null) {
        for (Container c : fabricService.getContainers()) {
            if (c.getVersion().equals(version)) {
                answer.add(BeanUtils.convertContainerToMap(fabricService, c, fields));
            }
        }
    }
    return answer;
}
Also used : Container(io.fabric8.api.Container) GitVersion(io.fabric8.api.commands.GitVersion) Version(io.fabric8.api.Version) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) TreeMap(java.util.TreeMap)

Example 57 with Version

use of io.fabric8.kubernetes.model.annotation.Version in project fabric8 by jboss-fuse.

the class FabricManager method getConfigurationFileNames.

@Override
public List<String> getConfigurationFileNames(String versionId, String profileId) {
    Version version = profileService.getVersion(versionId);
    Profile profile = version.getProfile(profileId);
    if (profile != null) {
        ArrayList<String> fileNames = new ArrayList<>(profile.getConfigurationFileNames());
        return Collections.unmodifiableList(fileNames);
    } else {
        return Collections.emptyList();
    }
}
Also used : GitVersion(io.fabric8.api.commands.GitVersion) Version(io.fabric8.api.Version) ArrayList(java.util.ArrayList) Profile(io.fabric8.api.Profile)

Example 58 with Version

use of io.fabric8.kubernetes.model.annotation.Version in project fabric8 by jboss-fuse.

the class FabricManager method containersForProfile.

@Override
public List<Map<String, Object>> containersForProfile(String versionId, String profileId, List<String> fields, boolean checkParents) {
    Version version = profileService.getVersion(versionId);
    Profile profile = version != null ? version.getRequiredProfile(profileId) : null;
    Set<Map<String, Object>> answer = new LinkedHashSet<Map<String, Object>>();
    if (profile != null) {
        for (Container c : fabricService.getContainers()) {
            for (Profile p : c.getProfiles()) {
                if (p.equals(profile)) {
                    answer.add(BeanUtils.convertContainerToMap(fabricService, c, fields));
                } else if (checkParents) {
                    HashSet<Profile> profileIDs = new HashSet<>();
                    getAllParentProfiles(version, p, profileIDs);
                    for (Profile pprofile : profileIDs) {
                        if (pprofile.equals(profile)) {
                            answer.add(BeanUtils.convertContainerToMap(fabricService, c, fields));
                            break;
                        }
                    }
                }
            }
        }
    }
    return new ArrayList<>(answer);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Container(io.fabric8.api.Container) GitVersion(io.fabric8.api.commands.GitVersion) Version(io.fabric8.api.Version) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) TreeMap(java.util.TreeMap) Profile(io.fabric8.api.Profile) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 59 with Version

use of io.fabric8.kubernetes.model.annotation.Version in project fabric8 by jboss-fuse.

the class FabricManager method createVersion.

@Override
public Map<String, Object> createVersion() {
    Version latestVersion = getLatestVersion();
    VersionSequence sequence = new VersionSequence(latestVersion.getId());
    return createVersion(sequence.next().getName());
}
Also used : GitVersion(io.fabric8.api.commands.GitVersion) Version(io.fabric8.api.Version) VersionSequence(io.fabric8.api.VersionSequence)

Example 60 with Version

use of io.fabric8.kubernetes.model.annotation.Version in project fabric8 by jboss-fuse.

the class MQManager method loadBrokerStatus.

@Override
public List<MQBrokerStatusDTO> loadBrokerStatus(String versionId) throws Exception {
    FabricRequirements requirements = fabricService.getRequirements();
    List<MQBrokerStatusDTO> answer = new ArrayList<MQBrokerStatusDTO>();
    Version version = versionId == null ? fabricService.getDefaultVersion() : profileService.getVersion(versionId);
    Container[] containers = fabricService.getContainers();
    List<Profile> values = getActiveOrRequiredBrokerProfileMap(version, requirements);
    for (Profile profile : values) {
        List<MQBrokerConfigDTO> list = createConfigDTOs(mqService, profile);
        for (MQBrokerConfigDTO configDTO : list) {
            ProfileRequirements profileRequirements = requirements.findProfileRequirements(profile.getId());
            int count = 0;
            for (Container container : containers) {
                if (Containers.containerHasProfile(container, profile)) {
                    MQBrokerStatusDTO status = createStatusDTO(profile, configDTO, profileRequirements, container);
                    count++;
                    answer.add(status);
                }
            }
            // if there are no containers yet, lets create a record anyway
            if (count == 0) {
                MQBrokerStatusDTO status = createStatusDTO(profile, configDTO, profileRequirements, null);
                answer.add(status);
            }
        }
    }
    addMasterSlaveStatus(answer);
    return answer;
}
Also used : ProfileRequirements(io.fabric8.api.ProfileRequirements) ArrayList(java.util.ArrayList) Profile(io.fabric8.api.Profile) MQBrokerStatusDTO(io.fabric8.api.jmx.MQBrokerStatusDTO) MQBrokerConfigDTO(io.fabric8.api.jmx.MQBrokerConfigDTO) Container(io.fabric8.api.Container) Version(io.fabric8.api.Version) FabricRequirements(io.fabric8.api.FabricRequirements)

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)63 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