use of com.sequenceiq.cloudbreak.cloud.model.AmbariRepo 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.AmbariRepo in project cloudbreak by hortonworks.
the class AmbariClusterUpgradeService method upgradeCluster.
public void upgradeCluster(Long stackId) throws CloudbreakOrchestratorException {
Stack stack = stackRepository.findOneWithLists(stackId);
Cluster cluster = stack.getCluster();
try {
OrchestratorType orchestratorType = orchestratorTypeResolver.resolveType(stack.getOrchestrator().getType());
if (orchestratorType.hostOrchestrator()) {
HostOrchestrator hostOrchestrator = hostOrchestratorResolver.get(stack.getOrchestrator().getType());
InstanceMetaData gatewayInstance = stack.getPrimaryGatewayInstance();
GatewayConfig gatewayConfig = gatewayConfigService.getGatewayConfig(stack, gatewayInstance, cluster.getGateway().getEnableGateway());
Set<String> gatewayFQDN = Collections.singleton(gatewayInstance.getDiscoveryFQDN());
ExitCriteriaModel exitCriteriaModel = clusterDeletionBasedModel(stack.getId(), cluster.getId());
AmbariRepo ambariRepo = componentConfigProvider.getAmbariRepo(cluster.getId());
Map<String, SaltPillarProperties> servicePillar = new HashMap<>();
Map<String, Object> credentials = new HashMap<>();
credentials.put("username", ambariSecurityConfigProvider.getAmbariUserName(cluster));
credentials.put("password", ambariSecurityConfigProvider.getAmbariPassword(cluster));
servicePillar.put("ambari-credentials", new SaltPillarProperties("/ambari/credentials.sls", singletonMap("ambari", credentials)));
if (ambariRepo != null) {
servicePillar.put("ambari-repo", new SaltPillarProperties("/ambari/repo.sls", singletonMap("ambari", singletonMap("repo", ambariRepo))));
}
SaltConfig pillar = new SaltConfig(servicePillar);
hostOrchestrator.upgradeAmbari(gatewayConfig, gatewayFQDN, stackUtil.collectNodes(stack), pillar, exitCriteriaModel);
} else {
throw new UnsupportedOperationException("Ambari upgrade works only with host orchestrator");
}
} catch (CloudbreakException e) {
throw new CloudbreakOrchestratorFailedException(e);
}
}
use of com.sequenceiq.cloudbreak.cloud.model.AmbariRepo 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.AmbariRepo in project cloudbreak by hortonworks.
the class ClusterCreationSetupService method determineAmbariRepoConfig.
private ClusterComponent determineAmbariRepoConfig(Optional<Component> stackAmbariRepoConfig, AmbariRepoDetailsJson ambariRepoDetailsJson, Optional<Component> stackImageComponent, Cluster cluster) throws IOException {
Json json;
if (!stackAmbariRepoConfig.isPresent()) {
AmbariRepo ambariRepo = ambariRepoDetailsJson != null ? conversionService.convert(ambariRepoDetailsJson, AmbariRepo.class) : defaultAmbariRepoService.getDefault(getOsType(stackImageComponent));
if (ambariRepo == null) {
throw new BadRequestException(String.format("Couldn't determine Ambari repo for the stack: %s", cluster.getStack().getName()));
}
json = new Json(ambariRepo);
} else {
json = stackAmbariRepoConfig.get().getAttributes();
}
return new ClusterComponent(ComponentType.AMBARI_REPO_DETAILS, json, cluster);
}
use of com.sequenceiq.cloudbreak.cloud.model.AmbariRepo in project cloudbreak by hortonworks.
the class AmbariRepoDetailsJsonToAmbariRepoConverter method convert.
@Override
public AmbariRepo convert(AmbariRepoDetailsJson source) {
AmbariRepo ambariRepo = new AmbariRepo();
ambariRepo.setPredefined(Boolean.FALSE);
ambariRepo.setVersion(source.getVersion());
ambariRepo.setBaseUrl(source.getBaseUrl());
ambariRepo.setGpgKeyUrl(source.getGpgKeyUrl());
return ambariRepo;
}
Aggregations