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);
}
}
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);
}
}
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());
}
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());
}
}
Aggregations