use of com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig in project cloudbreak by hortonworks.
the class ClusterHostServiceRunner method createGrainProperties.
private Map<String, Map<String, String>> createGrainProperties(Iterable<GatewayConfig> gatewayConfigs) {
Map<String, Map<String, String>> grainProperties = new HashMap<>();
for (GatewayConfig gatewayConfig : gatewayConfigs) {
Map<String, String> hostGrain = new HashMap<>();
hostGrain.put("gateway-address", gatewayConfig.getPublicAddress());
grainProperties.put(gatewayConfig.getPrivateAddress(), hostGrain);
}
return grainProperties;
}
use of com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig in project cloudbreak by hortonworks.
the class ClusterHostServiceRunner method changePrimaryGateway.
public String changePrimaryGateway(Stack stack) throws CloudbreakException {
GatewayConfig formerPrimaryGatewayConfig = gatewayConfigService.getPrimaryGatewayConfig(stack);
List<GatewayConfig> gatewayConfigs = gatewayConfigService.getAllGatewayConfigs(stack);
Optional<GatewayConfig> newPrimaryCandidate = gatewayConfigs.stream().filter(gc -> !gc.isPrimary()).findFirst();
if (newPrimaryCandidate.isPresent()) {
GatewayConfig newPrimary = newPrimaryCandidate.get();
Set<Node> allNodes = collectNodes(stack);
try {
hostOrchestratorResolver.get(stack.getOrchestrator().getType()).changePrimaryGateway(formerPrimaryGatewayConfig, newPrimary, gatewayConfigs, allNodes, clusterDeletionBasedModel(stack.getId(), stack.getCluster().getId()));
return newPrimary.getHostname();
} catch (CloudbreakOrchestratorException ex) {
throw new CloudbreakException(ex);
}
} else {
throw new CloudbreakException("Primary gateway change is not possible because there is no available node for the action");
}
}
use of com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig in project cloudbreak by hortonworks.
the class ClusterHostServiceRunner method runAmbariServices.
@Transactional
public void runAmbariServices(Stack stack, Cluster cluster) throws CloudbreakException {
try {
Set<Node> nodes = collectNodes(stack);
HostOrchestrator hostOrchestrator = hostOrchestratorResolver.get(stack.getOrchestrator().getType());
GatewayConfig primaryGatewayConfig = gatewayConfigService.getPrimaryGatewayConfig(stack);
List<GatewayConfig> gatewayConfigs = gatewayConfigService.getAllGatewayConfigs(stack);
SaltConfig saltConfig = createSaltConfig(stack, cluster, primaryGatewayConfig, gatewayConfigs);
hostOrchestrator.runService(gatewayConfigs, nodes, saltConfig, clusterDeletionBasedModel(stack.getId(), cluster.getId()));
} catch (CloudbreakOrchestratorCancelledException e) {
throw new CancellationException(e.getMessage());
} catch (CloudbreakOrchestratorException | IOException e) {
throw new CloudbreakException(e);
}
}
use of com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig in project cloudbreak by hortonworks.
the class SaltOrchestrator method bootstrapNewNodes.
@Override
public void bootstrapNewNodes(List<GatewayConfig> allGatewayConfigs, Set<Node> targets, Set<Node> allNodes, byte[] stateConfigZip, ExitCriteriaModel exitModel) throws CloudbreakOrchestratorException {
GatewayConfig primaryGateway = getPrimaryGatewayConfig(allGatewayConfigs);
Set<String> gatewayTargets = allGatewayConfigs.stream().filter(gc -> targets.stream().anyMatch(n -> gc.getPrivateAddress().equals(n.getPrivateIp()))).map(GatewayConfig::getPrivateAddress).collect(Collectors.toSet());
try (SaltConnector sc = new SaltConnector(primaryGateway, restDebug)) {
if (!gatewayTargets.isEmpty()) {
uploadSaltConfig(sc, gatewayTargets, stateConfigZip, exitModel);
}
uploadSignKey(sc, primaryGateway, gatewayTargets, targets.stream().map(Node::getPrivateIp).collect(Collectors.toSet()), exitModel);
// if there is a new salt master then re-bootstrap all nodes
Set<Node> nodes = gatewayTargets.isEmpty() ? targets : allNodes;
OrchestratorBootstrap saltBootstrap = new SaltBootstrap(sc, allGatewayConfigs, nodes);
Callable<Boolean> saltBootstrapRunner = runner(saltBootstrap, exitCriteria, exitModel);
Future<Boolean> saltBootstrapRunnerFuture = parallelOrchestratorComponentRunner.submit(saltBootstrapRunner);
saltBootstrapRunnerFuture.get();
} catch (Exception e) {
LOGGER.error("Error occurred during salt upscale", e);
throw new CloudbreakOrchestratorFailedException(e);
}
}
use of com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig in project cloudbreak by hortonworks.
the class SaltOrchestrator method tearDown.
@Override
public void tearDown(List<GatewayConfig> allGatewayConfigs, Map<String, String> privateIPsByFQDN) throws CloudbreakOrchestratorException {
GatewayConfig primaryGateway = getPrimaryGatewayConfig(allGatewayConfigs);
try (SaltConnector saltConnector = new SaltConnector(primaryGateway, restDebug)) {
SaltStates.stopMinions(saltConnector, privateIPsByFQDN);
} catch (Exception e) {
LOGGER.error("Error occurred during salt minion tear down", e);
throw new CloudbreakOrchestratorFailedException(e);
}
List<GatewayConfig> liveGateways = allGatewayConfigs.stream().filter(gw -> !privateIPsByFQDN.values().contains(gw.getPrivateAddress())).collect(Collectors.toList());
for (GatewayConfig gatewayConfig : liveGateways) {
try (SaltConnector sc = new SaltConnector(gatewayConfig, restDebug)) {
sc.wheel("key.delete", privateIPsByFQDN.keySet(), Object.class);
} catch (Exception e) {
LOGGER.error("Error occurred during salt minion tear down", e);
throw new CloudbreakOrchestratorFailedException(e);
}
}
}
Aggregations