Search in sources :

Example 36 with FabricService

use of io.fabric8.api.FabricService in project fabric8 by jboss-fuse.

the class FabricManager method containers.

@Override
public List<Map<String, Object>> containers(List<String> fields, List<String> profileFields) {
    List<Map<String, Object>> answer = new ArrayList<Map<String, Object>>();
    for (Container c : fabricService.getContainers()) {
        Map<String, Object> map = BeanUtils.convertContainerToMap(fabricService, c, fields);
        List<Map<String, Object>> profiles = new ArrayList<Map<String, Object>>();
        for (Profile p : c.getProfiles()) {
            profiles.add(BeanUtils.convertProfileToMap(fabricService, p, profileFields));
        }
        map.put("profiles", profiles);
        answer.add(map);
    }
    return answer;
}
Also used : Container(io.fabric8.api.Container) 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)

Example 37 with FabricService

use of io.fabric8.api.FabricService 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 38 with FabricService

use of io.fabric8.api.FabricService 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 39 with FabricService

use of io.fabric8.api.FabricService in project fabric8 by jboss-fuse.

the class FabricManager method currentContainerConfigurationFiles.

/**
 * Returns a map of all the current configuration files in the profiles of
 * the current container with the file name as the key and the profile ID as
 * the value
 */
@Override
public Map<String, String> currentContainerConfigurationFiles() {
    String containerName = getCurrentContainerName();
    FabricServiceImpl service = fabricService;
    Container container = service.getContainer(containerName);
    if (container != null) {
        Profile[] profiles = container.getProfiles();
        return Profiles.getConfigurationFileNameMap(profiles);
    }
    return new HashMap<String, String>();
}
Also used : Container(io.fabric8.api.Container) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) FabricServiceImpl(io.fabric8.service.FabricServiceImpl) Profile(io.fabric8.api.Profile)

Example 40 with FabricService

use of io.fabric8.api.FabricService 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)

Aggregations

FabricService (io.fabric8.api.FabricService)80 Container (io.fabric8.api.Container)76 Test (org.junit.Test)52 Profile (io.fabric8.api.Profile)50 BundleContext (org.osgi.framework.BundleContext)29 Version (io.fabric8.api.Version)24 ArrayList (java.util.ArrayList)21 ProfileService (io.fabric8.api.ProfileService)19 HashMap (java.util.HashMap)16 CuratorFramework (org.apache.curator.framework.CuratorFramework)16 HashSet (java.util.HashSet)14 Map (java.util.Map)13 FabricException (io.fabric8.api.FabricException)12 IOException (java.io.IOException)12 ContainerProxy (io.fabric8.itests.paxexam.support.ContainerProxy)11 Ignore (org.junit.Ignore)10 File (java.io.File)9 LinkedList (java.util.LinkedList)9 Path (javax.ws.rs.Path)8 FabricRequirements (io.fabric8.api.FabricRequirements)7