Search in sources :

Example 1 with HostList

use of com.sequenceiq.cloudbreak.orchestrator.salt.client.target.HostList in project cloudbreak by hortonworks.

the class SaltOrchestrator method applyDiagnosticsState.

@Override
public void applyDiagnosticsState(List<GatewayConfig> gatewayConfigs, String state, Map<String, Object> properties, ExitCriteriaModel exitCriteriaModel) throws CloudbreakOrchestratorFailedException {
    GatewayConfig primaryGateway = saltService.getPrimaryGatewayConfig(gatewayConfigs);
    Target<String> gatewayHost = new HostList(Set.of(primaryGateway.getHostname()));
    try (SaltConnector sc = saltService.createSaltConnector(primaryGateway)) {
        Map<String, Object> inlinePillars = Collections.singletonMap("filecollector", properties);
        SaltStates.applyState(sc, state, gatewayHost, inlinePillars);
    } catch (Exception e) {
        LOGGER.info("Error occurred during the salt bootstrap", e);
        throw new CloudbreakOrchestratorFailedException(e.getMessage(), e);
    }
}
Also used : CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) HostList(com.sequenceiq.cloudbreak.orchestrator.salt.client.target.HostList) SaltConnector(com.sequenceiq.cloudbreak.orchestrator.salt.client.SaltConnector) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) CloudbreakOrchestratorTimeoutException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorTimeoutException) CloudbreakOrchestratorException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException) CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)

Example 2 with HostList

use of com.sequenceiq.cloudbreak.orchestrator.salt.client.target.HostList in project cloudbreak by hortonworks.

the class SaltOrchestrator method getFreeDiskSpaceByNodes.

@Override
public Map<String, String> getFreeDiskSpaceByNodes(Set<Node> nodes, List<GatewayConfig> gatewayConfigs) {
    Map<String, String> freeDiskSpaceByNode;
    try {
        GatewayConfig primaryGateway = saltService.getPrimaryGatewayConfig(gatewayConfigs);
        SaltConnector sc = saltService.createSaltConnector(primaryGateway);
        Target<String> allHosts = new HostList(nodes.stream().map(Node::getHostname).collect(Collectors.toSet()));
        freeDiskSpaceByNode = SaltStates.runCommandOnHosts(retry, sc, allHosts, "df -k / | tail -1 | awk '{print $4}'");
    } catch (Exception e) {
        String errorMessage = String.format("Failed to get free disk space on hosts. Reason: %s", e.getMessage());
        LOGGER.warn(errorMessage, e);
        throw new CloudbreakServiceException(errorMessage, e);
    }
    return freeDiskSpaceByNode;
}
Also used : CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) JsonNode(com.fasterxml.jackson.databind.JsonNode) Node(com.sequenceiq.cloudbreak.common.orchestration.Node) HostList(com.sequenceiq.cloudbreak.orchestrator.salt.client.target.HostList) SaltConnector(com.sequenceiq.cloudbreak.orchestrator.salt.client.SaltConnector) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) CloudbreakOrchestratorTimeoutException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorTimeoutException) CloudbreakOrchestratorException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException) CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)

Example 3 with HostList

use of com.sequenceiq.cloudbreak.orchestrator.salt.client.target.HostList in project cloudbreak by hortonworks.

the class SaltTelemetryOrchestrator method updatePartialSaltDefinition.

@Override
public void updatePartialSaltDefinition(byte[] partialSaltState, List<String> components, List<GatewayConfig> gatewayConfigs, ExitCriteriaModel exitModel) throws CloudbreakOrchestratorFailedException {
    LOGGER.debug("Start partial salt update for components: {}.", components);
    GatewayConfig primaryGateway = saltService.getPrimaryGatewayConfig(gatewayConfigs);
    Set<String> gatewayTargets = getGatewayPrivateIps(gatewayConfigs);
    Set<String> gatewayHostnames = getGatewayHostnames(gatewayConfigs);
    Target<String> targets = new HostList(gatewayHostnames);
    try (SaltConnector sc = saltService.createSaltConnector(primaryGateway)) {
        uploadScripts(sc, gatewayTargets, exitModel, LOCAL_SALT_RESOURCES_LOCATION, SALT_STATE_UPDATER_SCRIPT);
        String stateZip = "partial_salt_states.zip";
        uploadFileToTargetsWithContentAndPermission(sc, gatewayTargets, exitModel, partialSaltState, REMOTE_TMP_FOLDER, stateZip, READ_WRITE_PERMISSION);
        updateSaltStateComponentDefinition(sc, targets, stateZip, Joiner.on(',').join(components));
        LOGGER.debug("Partial salt update has been successfully finished with components {}", components);
    }
}
Also used : HostList(com.sequenceiq.cloudbreak.orchestrator.salt.client.target.HostList) SaltConnector(com.sequenceiq.cloudbreak.orchestrator.salt.client.SaltConnector) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)

Example 4 with HostList

use of com.sequenceiq.cloudbreak.orchestrator.salt.client.target.HostList in project cloudbreak by hortonworks.

the class ConcurrentParameterizedStateRunner method submit.

@Override
public String submit(SaltConnector saltConnector) throws SaltJobFailedException {
    HostList targets = new HostList(getTargetHostnames());
    try {
        ApplyResponse applyResponse = SaltStates.applyConcurrentState(saltConnector, state, targets, parameters);
        LOGGER.debug("Executing salt state: '{}'. Parameters: '{}'. Targets: '{}'. applyResponse: '{}'", state, parameters, targets, applyResponse.getResult());
        return applyResponse.getJid();
    } catch (JsonProcessingException e) {
        throw new SaltJobFailedException("ConcurrentParameterizedStateRunner job failed.", e);
    }
}
Also used : HostList(com.sequenceiq.cloudbreak.orchestrator.salt.client.target.HostList) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) ApplyResponse(com.sequenceiq.cloudbreak.orchestrator.salt.domain.ApplyResponse)

Example 5 with HostList

use of com.sequenceiq.cloudbreak.orchestrator.salt.client.target.HostList in project cloudbreak by hortonworks.

the class ModifyGrainBase method submit.

@Override
public String submit(SaltConnector saltConnector) throws SaltJobFailedException {
    Target<String> target = new HostList(getTargetHostnames());
    LOGGER.info("Starting salt modify grain process. {}", this);
    ApplyResponse response = modifyGrain(saltConnector, target);
    Map<String, JsonNode> grains = SaltStates.getGrains(saltConnector, target, key);
    if (isModificationFailed(grains)) {
        LOGGER.info("Modify grain process failed. Starting to retry. {}", this);
        response = retryModification(saltConnector, target, response);
    }
    Set<String> missingHostnames = collectMissingHostnames(collectSucceededNodes(response));
    setTargetHostnames(missingHostnames);
    return missingHostnames.toString();
}
Also used : HostList(com.sequenceiq.cloudbreak.orchestrator.salt.client.target.HostList) JsonNode(com.fasterxml.jackson.databind.JsonNode) ApplyResponse(com.sequenceiq.cloudbreak.orchestrator.salt.domain.ApplyResponse)

Aggregations

HostList (com.sequenceiq.cloudbreak.orchestrator.salt.client.target.HostList)10 SaltConnector (com.sequenceiq.cloudbreak.orchestrator.salt.client.SaltConnector)8 GatewayConfig (com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)6 JsonNode (com.fasterxml.jackson.databind.JsonNode)5 CloudbreakOrchestratorException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException)5 CloudbreakOrchestratorFailedException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException)5 IOException (java.io.IOException)5 ExecutionException (java.util.concurrent.ExecutionException)5 CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)4 NotFoundException (com.sequenceiq.cloudbreak.common.exception.NotFoundException)4 Node (com.sequenceiq.cloudbreak.common.orchestration.Node)4 CloudbreakOrchestratorTimeoutException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorTimeoutException)4 ApplyResponse (com.sequenceiq.cloudbreak.orchestrator.salt.domain.ApplyResponse)3 Joiner (com.google.common.base.Joiner)2 Sets (com.google.common.collect.Sets)2 PackageInfo (com.sequenceiq.cloudbreak.common.model.PackageInfo)2 NodeVolumes (com.sequenceiq.cloudbreak.common.orchestration.NodeVolumes)2 OrchestratorAware (com.sequenceiq.cloudbreak.common.orchestration.OrchestratorAware)2 SALT (com.sequenceiq.cloudbreak.common.type.OrchestratorConstants.SALT)2 RecipeExecutionPhase (com.sequenceiq.cloudbreak.common.type.RecipeExecutionPhase)2