use of com.sequenceiq.cloudbreak.domain.Cluster in project cloudbreak by hortonworks.
the class StackToAutoscaleStackResponseJsonConverter method convert.
@Override
public AutoscaleStackResponse convert(Stack source) {
AutoscaleStackResponse result = new AutoscaleStackResponse();
result.setStackId(source.getId());
result.setName(source.getName());
result.setOwner(source.getOwner());
result.setAccount(source.getOwner());
result.setGatewayPort(source.getGatewayPort());
result.setCreated(source.getCreated());
result.setStatus(source.getStatus());
if (source.getCluster() != null) {
Cluster cluster = source.getCluster();
String gatewayIp = gatewayConfigService.getPrimaryGatewayIp(source);
result.setAmbariServerIp(gatewayIp);
result.setUserName(cluster.getUserName());
result.setPassword(cluster.getPassword());
result.setClusterStatus(cluster.getStatus());
}
return result;
}
use of com.sequenceiq.cloudbreak.domain.Cluster in project cloudbreak by hortonworks.
the class StackToStatusConverter method convert.
@Override
public Map<String, Object> convert(Stack source) {
Map<String, Object> stackStatus = new HashMap<>();
stackStatus.put("id", source.getId());
stackStatus.put("status", source.getStatus().name());
stackStatus.put("statusReason", source.getStatusReason());
Cluster cluster = source.getCluster();
if (cluster != null) {
stackStatus.put("clusterStatus", cluster.getStatus().name());
stackStatus.put("clusterStatusReason", cluster.getStatusReason());
}
return stackStatus;
}
use of com.sequenceiq.cloudbreak.domain.Cluster in project cloudbreak by hortonworks.
the class StackService method updateStatus.
@Transactional(TxType.NEVER)
public void updateStatus(Long stackId, StatusRequest status, boolean updateCluster) {
Stack stack = getByIdWithLists(stackId);
Cluster cluster = null;
if (stack.getCluster() != null) {
cluster = clusterRepository.findOneWithLists(stack.getCluster().getId());
}
switch(status) {
case SYNC:
sync(stack, false);
break;
case FULL_SYNC:
sync(stack, true);
break;
case REPAIR_FAILED_NODES:
repairFailedNodes(stack);
break;
case STOPPED:
stop(stack, cluster, updateCluster);
break;
case STARTED:
start(stack, cluster, updateCluster);
break;
default:
throw new BadRequestException("Cannot update the status of stack because status request not valid.");
}
}
use of com.sequenceiq.cloudbreak.domain.Cluster in project cloudbreak by hortonworks.
the class AmbariClusterSecurityService method changeOriginalAmbariCredentialsAndCreateCloudbreakUser.
@Override
public void changeOriginalAmbariCredentialsAndCreateCloudbreakUser(Stack stack) throws CloudbreakException {
Cluster cluster = stack.getCluster();
LOGGER.info("Changing ambari credentials for cluster: {}, ambari ip: {}", cluster.getName(), cluster.getAmbariIp());
AmbariClient client = clientFactory.getDefaultAmbariClient(stack);
String cloudbreakUserName = ambariSecurityConfigProvider.getAmbariUserName(cluster);
String cloudbreakPassword = ambariSecurityConfigProvider.getAmbariPassword(cluster);
ambariUserHandler.createAmbariUser(cloudbreakUserName, cloudbreakPassword, stack, client);
if (ADMIN.equals(cluster.getUserName())) {
if (!ADMIN.equals(cluster.getPassword())) {
changeAmbariPassword(ADMIN, ADMIN, cluster.getPassword(), stack, client);
}
} else {
client = ambariUserHandler.createAmbariUser(cluster.getUserName(), cluster.getPassword(), stack, client);
client.deleteUser(ADMIN);
}
}
use of com.sequenceiq.cloudbreak.domain.Cluster in project cloudbreak by hortonworks.
the class AmbariClusterSetupService method buildCluster.
@Override
public void buildCluster(Stack stack) {
Cluster cluster = stack.getCluster();
try {
clusterService.updateCreationDateOnCluster(cluster);
AmbariClient ambariClient = clientFactory.getAmbariClient(stack, stack.getCluster());
Set<HostGroup> hostGroups = hostGroupService.getByCluster(cluster.getId());
BlueprintPreparationObject blueprintPreparationObject = conversionService.convert(stack, BlueprintPreparationObject.class);
Map<String, List<Map<String, String>>> hostGroupMappings = hostGroupAssociationBuilder.buildHostGroupAssociations(hostGroups);
Set<HostMetadata> hostsInCluster = hostMetadataRepository.findHostsInCluster(cluster.getId());
recipeEngine.executePostAmbariStartRecipes(stack, hostGroups);
ambariRepositoryVersionService.setBaseRepoURL(stack.getName(), cluster.getId(), stack.getOrchestrator(), ambariClient);
String blueprintText = centralBlueprintUpdater.getBlueprintText(blueprintPreparationObject);
addBlueprint(stack.getId(), ambariClient, blueprintText, cluster.getTopologyValidation());
cluster.setExtendedBlueprintText(blueprintText);
clusterService.updateCluster(cluster);
PollingResult waitForHostsResult = ambariPollingServiceProvider.hostsPollingService(stack, ambariClient, hostsInCluster);
ambariClusterConnectorPollingResultChecker.checkPollingResult(waitForHostsResult, cloudbreakMessagesService.getMessage(AMBARI_CLUSTER_HOST_JOIN_FAILED.code()));
ambariClusterTemplateService.addClusterTemplate(cluster, hostGroupMappings, ambariClient);
Pair<PollingResult, Exception> pollingResult = ambariOperationService.waitForOperationsToStart(stack, ambariClient, singletonMap("INSTALL_START", 1), START_OPERATION_STATE);
String message = pollingResult.getRight() == null ? cloudbreakMessagesService.getMessage(AMBARI_CLUSTER_INSTALL_FAILED.code()) : pollingResult.getRight().getMessage();
ambariClusterConnectorPollingResultChecker.checkPollingResult(pollingResult.getLeft(), message);
Pair<PollingResult, Exception> pollingResultExceptionPair = ambariOperationService.waitForOperations(stack, ambariClient, new HashMap<String, Integer>() {
{
put("CLUSTER_INSTALL", 1);
}
}, INSTALL_AMBARI_PROGRESS_STATE);
ambariClusterConnectorPollingResultChecker.checkPollingResult(pollingResultExceptionPair.getLeft(), cloudbreakMessagesService.getMessage(AMBARI_CLUSTER_INSTALL_FAILED.code()));
recipeEngine.executePostInstall(stack);
ambariSmartSenseCapturer.capture(0, ambariClient);
cluster = ambariViewProvider.provideViewInformation(ambariClient, cluster);
ambariClusterCreationSuccessHandler.handleClusterCreationSuccess(stack, cluster);
} catch (CancellationException cancellationException) {
throw cancellationException;
} catch (HttpResponseException hre) {
throw new AmbariOperationFailedException("Ambari could not create the cluster: " + AmbariClientExceptionUtil.getErrorMessage(hre), hre);
} catch (Exception e) {
LOGGER.error("Error while building the Ambari cluster. Message {}, throwable: {}", e.getMessage(), e);
throw new AmbariOperationFailedException(e.getMessage(), e);
}
}
Aggregations