Search in sources :

Example 1 with CloudbreakDetails

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

the class StackToStackResponseConverter method convertComponentConfig.

private void convertComponentConfig(StackResponse stackJson, Stack source) {
    try {
        if (source.getCluster() != null) {
            StackRepoDetails stackRepoDetails = clusterComponentConfigProvider.getHDPRepo(source.getCluster().getId());
            if (stackRepoDetails != null && stackRepoDetails.getStack() != null) {
                String repositoryVersion = stackRepoDetails.getStack().get(StackRepoDetails.REPOSITORY_VERSION);
                if (!StringUtils.isEmpty(repositoryVersion)) {
                    stackJson.setHdpVersion(repositoryVersion);
                } else {
                    stackJson.setHdpVersion(stackRepoDetails.getHdpVersion());
                }
            }
            AmbariRepo ambariRepo = clusterComponentConfigProvider.getAmbariRepo(source.getCluster().getId());
            if (ambariRepo != null) {
                stackJson.setAmbariVersion(ambariRepo.getVersion());
            }
        }
        CloudbreakDetails cloudbreakDetails = componentConfigProvider.getCloudbreakDetails(source.getId());
        if (cloudbreakDetails != null) {
            stackJson.setCloudbreakDetails(getConversionService().convert(cloudbreakDetails, CloudbreakDetailsJson.class));
        }
    } catch (RuntimeException e) {
        LOGGER.error("Failed to convert dynamic component.", e);
    }
}
Also used : StackRepoDetails(com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails) CloudbreakDetails(com.sequenceiq.cloudbreak.cloud.model.CloudbreakDetails) CloudbreakDetailsJson(com.sequenceiq.cloudbreak.api.model.CloudbreakDetailsJson) AmbariRepo(com.sequenceiq.cloudbreak.cloud.model.AmbariRepo)

Example 2 with CloudbreakDetails

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

the class StackService method addCloudbreakDetailsForStack.

private void addCloudbreakDetailsForStack(Stack stack) {
    CloudbreakDetails cbDetails = new CloudbreakDetails(cbVersion);
    try {
        Component cbDetailsComponent = new Component(ComponentType.CLOUDBREAK_DETAILS, ComponentType.CLOUDBREAK_DETAILS.name(), new Json(cbDetails), stack);
        componentConfigProvider.store(cbDetailsComponent);
    } catch (JsonProcessingException e) {
        LOGGER.error("Could not create Cloudbreak details component.", e);
    }
}
Also used : CloudbreakDetails(com.sequenceiq.cloudbreak.cloud.model.CloudbreakDetails) InstanceGroupAdjustmentJson(com.sequenceiq.cloudbreak.api.model.InstanceGroupAdjustmentJson) Json(com.sequenceiq.cloudbreak.domain.json.Json) Component(com.sequenceiq.cloudbreak.domain.Component) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException)

Example 3 with CloudbreakDetails

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

the class StackToStackResponseConverterTest method setUp.

@Before
public void setUp() throws CloudbreakImageNotFoundException {
    underTest = new StackToStackResponseConverter();
    MockitoAnnotations.initMocks(this);
    when(imageService.getImage(anyLong())).thenReturn(new Image("cb-centos66-amb200-2015-05-25", new HashMap<>(), "redhat6", "", "default", "default-id"));
    when(componentConfigProvider.getCloudbreakDetails(anyLong())).thenReturn(new CloudbreakDetails("version"));
    when(componentConfigProvider.getStackTemplate(anyLong())).thenReturn(new StackTemplate("{}", "version"));
    when(clusterComponentConfigProvider.getHDPRepo(anyLong())).thenReturn(new StackRepoDetails());
    when(clusterComponentConfigProvider.getAmbariDatabase(anyLong())).thenReturn(new AmbariDatabase());
    when(clusterComponentConfigProvider.getAmbariRepo(anyLong())).thenReturn(new AmbariRepo());
}
Also used : AmbariDatabase(com.sequenceiq.cloudbreak.cloud.model.AmbariDatabase) StackRepoDetails(com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails) HashMap(java.util.HashMap) CloudbreakDetails(com.sequenceiq.cloudbreak.cloud.model.CloudbreakDetails) StackTemplate(com.sequenceiq.cloudbreak.cloud.model.StackTemplate) AmbariRepo(com.sequenceiq.cloudbreak.cloud.model.AmbariRepo) Image(com.sequenceiq.cloudbreak.cloud.model.Image) Before(org.junit.Before)

Example 4 with CloudbreakDetails

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

the class StackToStackDetailsConverter method convertComponents.

private void convertComponents(StackDetails stackDetails, Stack stack) {
    Long stackId = stack.getId();
    CloudbreakDetails cloudbreakDetails = componentConfigProvider.getCloudbreakDetails(stackId);
    if (cloudbreakDetails != null) {
        stackDetails.setCloudbreakVersion(cloudbreakDetails.getVersion());
    }
    try {
        Image image = componentConfigProvider.getImage(stackId);
        stackDetails.setImageIdentifier(image.getImageName());
    } catch (CloudbreakImageNotFoundException e) {
        LOGGER.warn("Image not found! {}", e.getMessage());
    }
    AmbariRepo ambariRepo = componentConfigProvider.getAmbariRepo(stackId);
    if (ambariRepo != null) {
        stackDetails.setPrewarmedImage(ambariRepo.getPredefined());
        stackDetails.setAmbariVersion(ambariRepo.getVersion());
    } else {
        stackDetails.setPrewarmedImage(Boolean.FALSE);
    }
    StackRepoDetails stackRepoDetails = componentConfigProvider.getHDPRepo(stackId);
    if (stackRepoDetails != null) {
        stackDetails.setClusterType(stackRepoDetails.getStack().get(StackRepoDetails.REPO_ID_TAG));
        stackDetails.setClusterVersion(stackRepoDetails.getHdpVersion());
    }
}
Also used : StackRepoDetails(com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails) CloudbreakDetails(com.sequenceiq.cloudbreak.cloud.model.CloudbreakDetails) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) AmbariRepo(com.sequenceiq.cloudbreak.cloud.model.AmbariRepo) Image(com.sequenceiq.cloudbreak.cloud.model.Image)

Aggregations

CloudbreakDetails (com.sequenceiq.cloudbreak.cloud.model.CloudbreakDetails)4 AmbariRepo (com.sequenceiq.cloudbreak.cloud.model.AmbariRepo)3 StackRepoDetails (com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails)3 Image (com.sequenceiq.cloudbreak.cloud.model.Image)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 CloudbreakDetailsJson (com.sequenceiq.cloudbreak.api.model.CloudbreakDetailsJson)1 InstanceGroupAdjustmentJson (com.sequenceiq.cloudbreak.api.model.InstanceGroupAdjustmentJson)1 AmbariDatabase (com.sequenceiq.cloudbreak.cloud.model.AmbariDatabase)1 StackTemplate (com.sequenceiq.cloudbreak.cloud.model.StackTemplate)1 CloudbreakImageNotFoundException (com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException)1 Component (com.sequenceiq.cloudbreak.domain.Component)1 Json (com.sequenceiq.cloudbreak.domain.json.Json)1 HashMap (java.util.HashMap)1 Before (org.junit.Before)1