use of io.fabric8.maven.docker.model.Container 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;
}
use of io.fabric8.maven.docker.model.Container in project fabric8 by jboss-fuse.
the class FabricManager method addProfilesToContainer.
@Override
public void addProfilesToContainer(String container, List<String> profiles) {
Container cont = fabricService.getContainer(container);
cont.addProfiles(stringsToProfiles(cont.getVersion(), profiles));
}
use of io.fabric8.maven.docker.model.Container in project fabric8 by jboss-fuse.
the class FabricManager method createContainers.
@Override
public Map<String, String> createContainers(Map<String, Object> options) {
if (LOG.isDebugEnabled()) {
LOG.debug("Creating containers from JSON data: " + options);
}
String providerType = (String) options.get("providerType");
if (providerType == null) {
throw new RuntimeException("No providerType provided");
}
CreateContainerBasicOptions.Builder builder = null;
ContainerProvider provider = fabricService.getValidProviders().get(providerType);
if (provider == null) {
throw new RuntimeException("Can't find valid provider of type: " + providerType);
}
Class<?> clazz = provider.getOptionsType();
try {
builder = (CreateContainerBasicOptions.Builder) clazz.getMethod("builder").invoke(null);
} catch (Exception e) {
LOG.warn("Failed to find builder type", e);
}
if (builder == null) {
throw new RuntimeException("Unknown provider type : " + providerType);
}
ObjectMapper mapper = getObjectMapper();
builder = mapper.convertValue(options, builder.getClass());
builder.zookeeperPassword(fabricService.getZookeeperPassword());
builder.zookeeperUrl(fabricService.getZookeeperUrl());
Object profileObject = options.get("profiles");
if (profileObject != null) {
List profiles = mapper.convertValue(profileObject, List.class);
builder.profiles(profiles);
}
if (builder.getProxyUri() == null) {
builder.proxyUri(fabricService.getMavenRepoURI());
}
CreateContainerOptions build = builder.build();
if (LOG.isDebugEnabled()) {
LOG.debug("Created container options: " + build + " with profiles " + build.getProfiles());
}
CreateContainerMetadata<?>[] metadatas = fabricService.createContainers(build);
Map<String, String> rc = new LinkedHashMap<String, String>();
for (CreateContainerMetadata<?> metadata : metadatas) {
if (!metadata.isSuccess()) {
LOG.error("Failed to create container {}: ", metadata.getContainerName(), metadata.getFailure());
rc.put(metadata.getContainerName(), metadata.getFailure().getMessage());
}
}
return rc;
}
use of io.fabric8.maven.docker.model.Container 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);
}
use of io.fabric8.maven.docker.model.Container 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>();
}
Aggregations