Search in sources :

Example 6 with StackRepoDetails

use of com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails in project cloudbreak by hortonworks.

the class AmbariRepositoryVersionService method setBaseRepoURL.

public void setBaseRepoURL(String stackName, long clusterId, Orchestrator orchestrator, StackService ambariClient) throws CloudbreakException {
    StackRepoDetails stackRepoDetails = getStackRepoDetails(clusterId, orchestrator);
    if (stackRepoDetails != null) {
        try {
            LOGGER.info("Use specific Ambari repository: {}", stackRepoDetails);
            AmbariRepo ambariRepoDetails = clusterComponentConfigProvider.getAmbariRepo(clusterId);
            if (isVersionNewerOrEqualThanLimited(ambariRepoDetails::getVersion, AMBARI_VERSION_2_6_0_0)) {
                addVersionDefinitionFileToAmbari(stackName, ambariClient, stackRepoDetails);
            } else {
                setRepositoryVersionOnApi(ambariClient, stackRepoDetails);
            }
        } catch (HttpResponseException e) {
            String exceptionErrorMsg = AmbariClientExceptionUtil.getErrorMessage(e);
            String msg = String.format("Cannot use the specified Ambari stack: %s. Error: %s", stackRepoDetails.toString(), exceptionErrorMsg);
            throw new AmbariServiceException(msg, e);
        }
    } else {
        LOGGER.info("Using latest HDP repository");
    }
}
Also used : StackRepoDetails(com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails) HttpResponseException(groovyx.net.http.HttpResponseException) AmbariRepo(com.sequenceiq.cloudbreak.cloud.model.AmbariRepo)

Example 7 with StackRepoDetails

use of com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails in project cloudbreak by hortonworks.

the class AmbariStackDetailsJsonToStackRepoDetailsConverter method convert.

@Override
public StackRepoDetails convert(AmbariStackDetailsJson source) {
    StackRepoDetails repo = new StackRepoDetails();
    Map<String, String> stack = new HashMap<>();
    Map<String, String> util = new HashMap<>();
    boolean baseRepoRequiredFieldsExists = Stream.of(source.getStackRepoId(), source.getStackBaseURL(), source.getUtilsRepoId(), source.getUtilsBaseURL()).noneMatch(StringUtils::isEmpty);
    if (!isVdfRequiredFieldsExists(source) && !baseRepoRequiredFieldsExists) {
        String msg = "The 'repositoryVersion', 'versionDefinitionFileUrl' or " + "'stackBaseURL', 'stackRepoId', 'utilsBaseUrl', 'utilsRepoId' fields must be specified!";
        throw new BadRequestException(msg);
    }
    stack.put("repoid", source.getStackRepoId());
    util.put("repoid", source.getUtilsRepoId());
    if (baseRepoRequiredFieldsExists) {
        String stackBaseURL = source.getStackBaseURL();
        String utilsBaseURL = source.getUtilsBaseURL();
        if (source.getOs() == null) {
            stack.put(REDHAT_6, stackBaseURL);
            stack.put(REDHAT_7, stackBaseURL);
            stack.put(DEBIAN_9, stackBaseURL);
            stack.put(UBUNTU_16, stackBaseURL);
            util.put(REDHAT_6, utilsBaseURL);
            util.put(REDHAT_7, utilsBaseURL);
            util.put(DEBIAN_9, utilsBaseURL);
            util.put(UBUNTU_16, utilsBaseURL);
        } else {
            stack.put(source.getOs(), stackBaseURL);
            util.put(source.getOs(), utilsBaseURL);
        }
    }
    if (!StringUtils.isEmpty(source.getRepositoryVersion())) {
        stack.put(StackRepoDetails.REPOSITORY_VERSION, source.getRepositoryVersion());
        stack.put("repoid", source.getStack());
    }
    if (!StringUtils.isEmpty(source.getVersionDefinitionFileUrl())) {
        stack.put(StackRepoDetails.CUSTOM_VDF_REPO_KEY, source.getVersionDefinitionFileUrl());
    }
    if (!StringUtils.isEmpty(source.getMpackUrl())) {
        stack.put(StackRepoDetails.MPACK_TAG, source.getMpackUrl());
    }
    repo.setStack(stack);
    repo.setUtil(util);
    repo.setEnableGplRepo(source.isEnableGplRepo());
    repo.setVerify(source.getVerify());
    repo.setHdpVersion(source.getVersion());
    return repo;
}
Also used : StackRepoDetails(com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails) HashMap(java.util.HashMap) StringUtils(org.apache.commons.lang3.StringUtils) BadRequestException(com.sequenceiq.cloudbreak.controller.BadRequestException)

Example 8 with StackRepoDetails

use of com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails in project cloudbreak by hortonworks.

the class AmbariStackDetailsJsonToStackRepoDetailsConverterTest method testConvertWhenBaseImage.

@Test
public void testConvertWhenBaseImage() {
    StackRepoDetails result = underTest.convert(getRequest("stack/ambari-stack-details-base-image.json"));
    assertAllFieldsNotNull(result, Collections.singletonList("knox"));
    Assert.assertFalse(result.getStack().containsKey(StackRepoDetails.CUSTOM_VDF_REPO_KEY));
}
Also used : StackRepoDetails(com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails) Test(org.junit.Test)

Example 9 with StackRepoDetails

use of com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails in project cloudbreak by hortonworks.

the class AmbariStackDetailsJsonToStackRepoDetailsConverterTest method testConvertWhenVDFProvided.

@Test
public void testConvertWhenVDFProvided() {
    AmbariStackDetailsJson request = getRequest("stack/ambari-stack-details-vdf.json");
    StackRepoDetails result = underTest.convert(request);
    Assert.assertFalse(result.getStack().containsKey(request.getOs()));
}
Also used : AmbariStackDetailsJson(com.sequenceiq.cloudbreak.api.model.AmbariStackDetailsJson) StackRepoDetails(com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails) Test(org.junit.Test)

Example 10 with StackRepoDetails

use of com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails in project cloudbreak by hortonworks.

the class ClusterToClusterDetailsConverter method convertComponents.

private void convertComponents(ClusterDetails clusterDetails, Cluster cluster) {
    AmbariRepo ambariRepo = clusterComponentConfigProvider.getAmbariRepo(cluster.getId());
    if (ambariRepo != null) {
        clusterDetails.setAmbariVersion(ambariRepo.getVersion());
    }
    StackRepoDetails stackRepoDetails = clusterComponentConfigProvider.getHDPRepo(cluster.getId());
    if (stackRepoDetails != null) {
        clusterDetails.setClusterType(stackRepoDetails.getStack().get(StackRepoDetails.REPO_ID_TAG));
        clusterDetails.setClusterVersion(stackRepoDetails.getHdpVersion());
    }
}
Also used : StackRepoDetails(com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails) AmbariRepo(com.sequenceiq.cloudbreak.cloud.model.AmbariRepo)

Aggregations

StackRepoDetails (com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails)21 AmbariRepo (com.sequenceiq.cloudbreak.cloud.model.AmbariRepo)7 Test (org.junit.Test)4 AmbariStackDetailsJson (com.sequenceiq.cloudbreak.api.model.AmbariStackDetailsJson)3 CloudbreakDetails (com.sequenceiq.cloudbreak.cloud.model.CloudbreakDetails)3 Image (com.sequenceiq.cloudbreak.cloud.model.Image)3 ClusterComponent (com.sequenceiq.cloudbreak.domain.ClusterComponent)3 Json (com.sequenceiq.cloudbreak.domain.json.Json)3 AmbariRepoDetailsJson (com.sequenceiq.cloudbreak.api.model.AmbariRepoDetailsJson)2 IdentityUser (com.sequenceiq.cloudbreak.common.model.user.IdentityUser)2 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)2 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)2 RDSConfig (com.sequenceiq.cloudbreak.domain.RDSConfig)2 HashMap (java.util.HashMap)2 Before (org.junit.Before)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 AmbariStackDetailsResponse (com.sequenceiq.cloudbreak.api.model.AmbariStackDetailsResponse)1 BlueprintInputJson (com.sequenceiq.cloudbreak.api.model.BlueprintInputJson)1 BlueprintParameterJson (com.sequenceiq.cloudbreak.api.model.BlueprintParameterJson)1 CloudbreakDetailsJson (com.sequenceiq.cloudbreak.api.model.CloudbreakDetailsJson)1