use of com.sequenceiq.cloudbreak.common.type.OrchestratorConstants.SALT 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.common.type.OrchestratorConstants.SALT 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