Search in sources :

Example 6 with Versioned

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);
}
Also used : Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) ImageCatalogMetaData(com.sequenceiq.cloudbreak.service.image.catalog.model.ImageCatalogMetaData) Versioned(com.sequenceiq.cloudbreak.common.type.Versioned) CloudbreakImageCatalogException(com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException) ImageFilterResult(com.sequenceiq.cloudbreak.service.upgrade.image.ImageFilterResult) CloudbreakImageCatalogV3(com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3) VersionComparator(com.sequenceiq.cloudbreak.util.VersionComparator) StatedImages(com.sequenceiq.cloudbreak.service.image.StatedImages) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image) ImageFilter(com.sequenceiq.cloudbreak.service.image.ImageFilter) Versioned(com.sequenceiq.cloudbreak.common.type.Versioned) ImageCatalogMetaData(com.sequenceiq.cloudbreak.service.image.catalog.model.ImageCatalogMetaData) ImageFilterResult(com.sequenceiq.cloudbreak.service.upgrade.image.ImageFilterResult)

Example 7 with Versioned

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;
}
Also used : Versioned(com.sequenceiq.cloudbreak.common.type.Versioned) VersionComparator(com.sequenceiq.cloudbreak.util.VersionComparator) CloudStorageSupportedV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.CloudStorageSupportedV4Response) HashSet(java.util.HashSet)

Example 8 with Versioned

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)));
}
Also used : Versioned(com.sequenceiq.cloudbreak.common.type.Versioned) HashMap(java.util.HashMap) Node(com.sequenceiq.cloudbreak.common.orchestration.Node) SaltPillarProperties(com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties) BlueprintTextProcessor(com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor) HashMap(java.util.HashMap) Map(java.util.Map) Collections.singletonMap(java.util.Collections.singletonMap)

Example 9 with Versioned

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;
        }
    }
}
Also used : Versioned(com.sequenceiq.cloudbreak.common.type.Versioned) VersionComparator(com.sequenceiq.cloudbreak.util.VersionComparator) IOException(java.io.IOException) Image(com.sequenceiq.cloudbreak.cloud.model.Image)

Example 10 with Versioned

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);
}
Also used : Versioned(com.sequenceiq.cloudbreak.common.type.Versioned) CmTemplateProcessor(com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor)

Aggregations

Versioned (com.sequenceiq.cloudbreak.common.type.Versioned)15 Test (org.junit.jupiter.api.Test)4 VersionComparator (com.sequenceiq.cloudbreak.util.VersionComparator)3 AutoscaleRecommendation (com.sequenceiq.cloudbreak.cloud.model.AutoscaleRecommendation)2 ResizeRecommendation (com.sequenceiq.cloudbreak.cloud.model.ResizeRecommendation)2 CmTemplateProcessor (com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ClustersResourceApi (com.cloudera.api.swagger.ClustersResourceApi)1 ApiClient (com.cloudera.api.swagger.client.ApiClient)1 CloudStorageSupportedV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.CloudStorageSupportedV4Response)1 ClouderaManagerRepo (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)1 Image (com.sequenceiq.cloudbreak.cloud.model.Image)1 CloudbreakImageCatalogV3 (com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3)1 Image (com.sequenceiq.cloudbreak.cloud.model.catalog.Image)1 ClouderaManagerClientInitException (com.sequenceiq.cloudbreak.cm.client.ClouderaManagerClientInitException)1 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)1 Node (com.sequenceiq.cloudbreak.common.orchestration.Node)1 CloudbreakImageCatalogException (com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException)1 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)1