use of com.sequenceiq.cloudbreak.common.type.Versioned in project cloudbreak by hortonworks.
the class ImageCatalogService method getImageCatalogMetaData.
default ImageCatalogMetaData getImageCatalogMetaData(CloudbreakImageCatalogV3 imageCatalogV3) {
ImageFilterResult imageFilterResult = getImageFilterResult(imageCatalogV3);
List<String> runtimes = imageFilterResult.getImages().stream().map(Image::getVersion).distinct().map(version -> (Versioned) () -> version).sorted(VERSION_COMPARATOR.reversed()).map(Versioned::getVersion).collect(toList());
return new ImageCatalogMetaData(runtimes);
}
use of com.sequenceiq.cloudbreak.common.type.Versioned in project cloudbreak by hortonworks.
the class FileSystemSupportMatrixService method getCloudStorageMatrix.
public Set<CloudStorageSupportedV4Response> getCloudStorageMatrix(String stackVersion) {
VersionComparator versionComparator = new VersionComparator();
Set<CloudStorageSupportedV4Response> response = new HashSet<>();
cloudFileSystemSupportMatrix.getProviders().forEach(supportConfigEntries -> {
Set<String> supportedFileSystems = supportConfigEntries.getConfigEntries().stream().filter(supportConfigEntry -> {
Versioned minVersion = supportConfigEntry::getMinVersion;
Versioned currentVersion = () -> stackVersion.length() > supportConfigEntry.getMinVersion().length() ? stackVersion.substring(0, supportConfigEntry.getMinVersion().length()) : stackVersion;
int compared = versionComparator.compare(minVersion, currentVersion);
return compared <= 0;
}).map(CloudFileSystemSupportConfigEntry::getSupportedFileSytem).collect(Collectors.toSet());
if (!supportedFileSystems.isEmpty()) {
CloudStorageSupportedV4Response cloudStorageSupportedV4Response = new CloudStorageSupportedV4Response();
cloudStorageSupportedV4Response.setProvider(supportConfigEntries.getProvider());
cloudStorageSupportedV4Response.setFileSystemType(supportedFileSystems);
response.add(cloudStorageSupportedV4Response);
}
});
return response;
}
use of com.sequenceiq.cloudbreak.common.type.Versioned in project cloudbreak by hortonworks.
the class HostAttributeDecorator method createHostAttributePillars.
public Map<String, SaltPillarProperties> createHostAttributePillars(Stack stack) {
Set<Node> allNodes = stackUtil.collectNodes(stack);
stack.getCluster().getBlueprint().getBlueprintText();
BlueprintTextProcessor blueprintTextProcessor = cmTemplateProcessorFactory.get(stack.getCluster().getBlueprint().getBlueprintText());
Versioned blueprintVersion = () -> blueprintTextProcessor.getVersion().get();
Map<String, Map<String, ServiceAttributes>> serviceAttributes = blueprintTextProcessor.getHostGroupBasedServiceAttributes(blueprintVersion);
Map<String, Map<String, Object>> attributes = new HashMap<>();
for (Node node : allNodes) {
Map<String, Map<String, String>> hgAttributes = getAttributesForHostGroup(node.getHostGroup(), serviceAttributes);
Map<String, Object> hostAttributes = new HashMap<>();
hostAttributes.put("attributes", hgAttributes);
if (node.getHostGroup() != null) {
hostAttributes.put("hostGroup", node.getHostGroup());
}
attributes.put(node.getHostname(), hostAttributes);
}
return Map.of("hostattrs", new SaltPillarProperties("/nodes/hostattrs.sls", singletonMap("hostattrs", attributes)));
}
use of com.sequenceiq.cloudbreak.common.type.Versioned in project cloudbreak by hortonworks.
the class SaltBootstrapVersionChecker method isSupported.
private boolean isSupported(Versioned version, Json image) {
if (image == null) {
LOGGER.info("Image is null, couldn't verify salt-bootstrap version");
return false;
} else {
try {
Image instanceImage = image.get(Image.class);
Map<String, String> packageVersions = instanceImage.getPackageVersions();
if (packageVersions != null) {
String saltBootstrapVersion = packageVersions.getOrDefault(PackageVersionChecker.SALT_BOOTSTRAP, "0.0.0");
Versioned currentVersion = () -> StringUtils.substringBefore(saltBootstrapVersion, "-");
LOGGER.debug("Saltboot version in image: {}", currentVersion.getVersion());
return -1 < new VersionComparator().compare(currentVersion, version);
} else {
LOGGER.info("PackageVersions is null in image {} {}", instanceImage.getImageId(), instanceImage.getImageName());
return false;
}
} catch (IOException e) {
LOGGER.warn("Couldn't parse image", e);
return false;
}
}
}
use of com.sequenceiq.cloudbreak.common.type.Versioned in project cloudbreak by hortonworks.
the class StackStatusCheckerJob method getComputeHostGroups.
private Set<String> getComputeHostGroups(Cluster cluster) {
String blueprintText = cluster.getBlueprint().getBlueprintText();
CmTemplateProcessor blueprintProcessor = cmTemplateProcessorFactory.get(blueprintText);
Versioned blueprintVersion = () -> blueprintProcessor.getVersion().get();
return blueprintProcessor.getComputeHostGroups(blueprintVersion);
}
Aggregations