use of com.sequenceiq.cloudbreak.service.CloudbreakException in project cloudbreak by hortonworks.
the class OrchestratorRecipeExecutor method postAmbariStartRecipes.
public void postAmbariStartRecipes(Stack stack) throws CloudbreakException {
HostOrchestrator hostOrchestrator = hostOrchestratorResolver.get(stack.getOrchestrator().getType());
GatewayConfig gatewayConfig = gatewayConfigService.getPrimaryGatewayConfig(stack);
try {
hostOrchestrator.postAmbariStartRecipes(gatewayConfig, collectNodes(stack), clusterDeletionBasedModel(stack.getId(), stack.getCluster().getId()));
} catch (CloudbreakOrchestratorFailedException e) {
throw new CloudbreakException(e);
}
}
use of com.sequenceiq.cloudbreak.service.CloudbreakException in project cloudbreak by hortonworks.
the class OrchestratorRecipeExecutor method uploadRecipes.
public void uploadRecipes(Stack stack, Collection<HostGroup> hostGroups) throws CloudbreakException {
HostOrchestrator hostOrchestrator = hostOrchestratorResolver.get(stack.getOrchestrator().getType());
Map<String, List<RecipeModel>> recipeMap = hostGroups.stream().filter(hg -> !hg.getRecipes().isEmpty()).collect(Collectors.toMap(HostGroup::getName, h -> convert(h.getRecipes())));
List<GatewayConfig> allGatewayConfigs = gatewayConfigService.getAllGatewayConfigs(stack);
recipesEvent(stack.getId(), stack.getStatus(), recipeMap);
try {
hostOrchestrator.uploadRecipes(allGatewayConfigs, recipeMap, clusterDeletionBasedModel(stack.getId(), stack.getCluster().getId()));
} catch (CloudbreakOrchestratorFailedException e) {
throw new CloudbreakException(e);
}
}
use of com.sequenceiq.cloudbreak.service.CloudbreakException in project cloudbreak by hortonworks.
the class TlsSetupService method setupTls.
public void setupTls(Stack stack, InstanceMetaData gwInstance) throws CloudbreakException {
try {
SavingX509TrustManager x509TrustManager = new SavingX509TrustManager();
TrustManager[] trustManagers = { x509TrustManager };
SSLContext sslContext = SslConfigurator.newInstance().createSSLContext();
sslContext.init(null, trustManagers, new SecureRandom());
Client client = RestClientUtil.createClient(sslContext, false, null);
Integer gatewayPort = stack.getGatewayPort();
String ip = gatewayConfigService.getGatewayIp(stack, gwInstance);
LOGGER.info("Trying to fetch the server's certificate: {}:{}", ip, gatewayPort);
nginxPollerService.pollWithTimeoutSingleFailure(nginxCertListenerTask, new NginxPollerObject(stack, client, ip, gatewayPort, x509TrustManager), POLLING_INTERVAL, MAX_ATTEMPTS_FOR_HOSTS);
WebTarget nginxTarget = client.target(String.format("https://%s:%d", ip, gatewayPort));
nginxTarget.path("/").request().get();
X509Certificate[] chain = x509TrustManager.getChain();
String serverCert = PkiUtil.convert(chain[0]);
InstanceMetaData metaData = instanceMetaDataRepository.findOne(gwInstance.getId());
metaData.setServerCert(BaseEncoding.base64().encode(serverCert.getBytes()));
instanceMetaDataRepository.save(metaData);
} catch (Exception e) {
throw new CloudbreakException("Failed to retrieve the server's certificate", e);
}
}
use of com.sequenceiq.cloudbreak.service.CloudbreakException in project cloudbreak by hortonworks.
the class HostMetadataSetup method setupNewHostMetadata.
public void setupNewHostMetadata(Long stackId, Collection<String> newAddresses) throws CloudbreakException {
LOGGER.info("Extending host metadata.");
Stack stack = stackService.getByIdWithLists(stackId);
if (!orchestratorTypeResolver.resolveType(stack.getOrchestrator()).containerOrchestrator()) {
Set<InstanceMetaData> newInstanceMetadata = stack.getRunningInstanceMetaData().stream().filter(instanceMetaData -> newAddresses.contains(instanceMetaData.getPrivateIp())).collect(Collectors.toSet());
updateWithHostData(stack, newInstanceMetadata);
instanceMetaDataRepository.save(newInstanceMetadata);
}
}
use of com.sequenceiq.cloudbreak.service.CloudbreakException in project cloudbreak by hortonworks.
the class ContainerConfigService method get.
public ContainerConfig get(Stack stack, DockerContainer dc) {
try {
Component component = componentConfigProvider.getComponent(stack.getId(), ComponentType.CONTAINER, dc.name());
if (component == null) {
component = create(stack, dc);
LOGGER.info("Container component definition created: {}", component);
} else {
LOGGER.info("Container component definition found in database: {}", component);
}
return component.getAttributes().get(ContainerConfig.class);
} catch (CloudbreakException | IOException ignored) {
throw new CloudbreakServiceException(String.format("Failed to parse component ContainerConfig for stack: %d, container: %s", stack.getId(), dc.getName()));
}
}
Aggregations