Search in sources :

Example 1 with AmbariStackDetailsJson

use of com.sequenceiq.cloudbreak.api.model.AmbariStackDetailsJson in project cloudbreak by hortonworks.

the class ClusterCreationSetupService method determineHDPRepoConfig.

private ClusterComponent determineHDPRepoConfig(Blueprint blueprint, long stackId, Optional<Component> stackHdpRepoConfig, ClusterRequest request, Cluster cluster, IdentityUser user, Optional<Component> stackImageComponent) throws JsonProcessingException {
    Json stackRepoDetailsJson;
    if (!stackHdpRepoConfig.isPresent()) {
        AmbariStackDetailsJson ambariStackDetails = request.getAmbariStackDetails();
        if (ambariStackDetails != null) {
            setOsTypeFromImageIfMissing(cluster, stackImageComponent, ambariStackDetails);
            StackRepoDetails stackRepoDetails = conversionService.convert(ambariStackDetails, StackRepoDetails.class);
            stackRepoDetailsJson = new Json(stackRepoDetails);
        } else {
            StackRepoDetails stackRepoDetails = SerializationUtils.clone(defaultHDPInfo(blueprint, request, user).getRepo());
            Optional<String> vdfUrl = getVDFUrlByOsType(stackId, stackRepoDetails);
            vdfUrl.ifPresent(s -> stackRepoDetails.getStack().put(CUSTOM_VDF_REPO_KEY, s));
            stackRepoDetailsJson = new Json(stackRepoDetails);
        }
    } else {
        stackRepoDetailsJson = stackHdpRepoConfig.get().getAttributes();
    }
    return new ClusterComponent(ComponentType.HDP_REPO_DETAILS, stackRepoDetailsJson, cluster);
}
Also used : AmbariStackDetailsJson(com.sequenceiq.cloudbreak.api.model.AmbariStackDetailsJson) StackRepoDetails(com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails) ClusterComponent(com.sequenceiq.cloudbreak.domain.ClusterComponent) AmbariRepoDetailsJson(com.sequenceiq.cloudbreak.api.model.AmbariRepoDetailsJson) AmbariStackDetailsJson(com.sequenceiq.cloudbreak.api.model.AmbariStackDetailsJson) Json(com.sequenceiq.cloudbreak.domain.json.Json)

Example 2 with AmbariStackDetailsJson

use of com.sequenceiq.cloudbreak.api.model.AmbariStackDetailsJson 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 3 with AmbariStackDetailsJson

use of com.sequenceiq.cloudbreak.api.model.AmbariStackDetailsJson in project cloudbreak by hortonworks.

the class ClusterCommonService method recreateCluster.

private void recreateCluster(Long stackId, UpdateClusterJson updateJson) {
    IdentityUser user = authenticatedUserService.getCbUser();
    Set<HostGroup> hostGroups = new HashSet<>();
    for (HostGroupRequest json : updateJson.getHostgroups()) {
        HostGroup hostGroup = conversionService.convert(json, HostGroup.class);
        hostGroup = hostGroupDecorator.decorate(hostGroup, json, user, stackId, false, false);
        hostGroups.add(hostGroup);
    }
    AmbariStackDetailsJson stackDetails = updateJson.getAmbariStackDetails();
    StackRepoDetails stackRepoDetails = null;
    if (stackDetails != null) {
        stackRepoDetails = conversionService.convert(stackDetails, StackRepoDetails.class);
    }
    clusterService.recreate(stackId, updateJson.getBlueprintId(), hostGroups, updateJson.getValidateBlueprint(), stackRepoDetails, updateJson.getKerberosPassword(), updateJson.getKerberosPrincipal());
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) AmbariStackDetailsJson(com.sequenceiq.cloudbreak.api.model.AmbariStackDetailsJson) StackRepoDetails(com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails) HostGroupRequest(com.sequenceiq.cloudbreak.api.model.HostGroupRequest) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) HashSet(java.util.HashSet)

Example 4 with AmbariStackDetailsJson

use of com.sequenceiq.cloudbreak.api.model.AmbariStackDetailsJson in project cloudbreak by hortonworks.

the class StackRepoDetailsToStackRepoDetailsJsonConverter method convert.

@Override
public AmbariStackDetailsJson convert(StackRepoDetails source) {
    AmbariStackDetailsJson ambariStackDetailsJson = new AmbariStackDetailsJson();
    Map<String, String> stack = source.getStack();
    ambariStackDetailsJson.setStackRepoId(stack.get(StackRepoDetails.REPO_ID_TAG));
    ambariStackDetailsJson.setStack(stack.get(StackRepoDetails.REPO_ID_TAG));
    ambariStackDetailsJson.setRepositoryVersion(stack.get(StackRepoDetails.REPOSITORY_VERSION));
    ambariStackDetailsJson.setVersionDefinitionFileUrl(stack.get(StackRepoDetails.CUSTOM_VDF_REPO_KEY));
    ambariStackDetailsJson.setMpackUrl(stack.get(StackRepoDetails.MPACK_TAG));
    if (stack.containsKey(REDHAT_6)) {
        ambariStackDetailsJson.setOs(REDHAT_6);
        ambariStackDetailsJson.setStackBaseURL(stack.get(REDHAT_6));
    } else if (stack.containsKey(REDHAT_7)) {
        ambariStackDetailsJson.setOs(REDHAT_7);
        ambariStackDetailsJson.setStackBaseURL(stack.get(REDHAT_7));
    } else if (stack.containsKey(DEBIAN_9)) {
        ambariStackDetailsJson.setOs(DEBIAN_9);
        ambariStackDetailsJson.setStackBaseURL(stack.get(DEBIAN_9));
    } else if (stack.containsKey(UBUNTU_16)) {
        ambariStackDetailsJson.setOs(UBUNTU_16);
        ambariStackDetailsJson.setStackBaseURL(stack.get(UBUNTU_16));
    }
    Map<String, String> util = source.getUtil();
    ambariStackDetailsJson.setUtilsRepoId(util.get(StackRepoDetails.REPO_ID_TAG));
    if (util.containsKey(REDHAT_6)) {
        ambariStackDetailsJson.setUtilsBaseURL(util.get(REDHAT_6));
    } else if (util.containsKey(REDHAT_7)) {
        ambariStackDetailsJson.setUtilsBaseURL(util.get(REDHAT_7));
    } else if (util.containsKey(DEBIAN_9)) {
        ambariStackDetailsJson.setUtilsBaseURL(util.get(DEBIAN_9));
    } else if (util.containsKey(UBUNTU_16)) {
        ambariStackDetailsJson.setUtilsBaseURL(util.get(UBUNTU_16));
    }
    ambariStackDetailsJson.setEnableGplRepo(source.isEnableGplRepo());
    ambariStackDetailsJson.setVerify(source.isVerify());
    ambariStackDetailsJson.setVersion(source.getHdpVersion());
    return ambariStackDetailsJson;
}
Also used : AmbariStackDetailsJson(com.sequenceiq.cloudbreak.api.model.AmbariStackDetailsJson)

Aggregations

AmbariStackDetailsJson (com.sequenceiq.cloudbreak.api.model.AmbariStackDetailsJson)4 StackRepoDetails (com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails)3 AmbariRepoDetailsJson (com.sequenceiq.cloudbreak.api.model.AmbariRepoDetailsJson)1 HostGroupRequest (com.sequenceiq.cloudbreak.api.model.HostGroupRequest)1 IdentityUser (com.sequenceiq.cloudbreak.common.model.user.IdentityUser)1 ClusterComponent (com.sequenceiq.cloudbreak.domain.ClusterComponent)1 HostGroup (com.sequenceiq.cloudbreak.domain.HostGroup)1 Json (com.sequenceiq.cloudbreak.domain.json.Json)1 HashSet (java.util.HashSet)1 Test (org.junit.Test)1