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);
}
}
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;
}
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);
}
}
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);
}
}
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();
}
Aggregations