use of com.sequenceiq.cloudbreak.orchestrator.host.GrainOperation in project cloudbreak by hortonworks.
the class SaltOrchestrator method runOrchestratorGrainRunner.
@Override
public void runOrchestratorGrainRunner(OrchestratorGrainRunnerParams grainRunnerParams) throws CloudbreakOrchestratorFailedException {
try (SaltConnector sc = saltService.createSaltConnector(grainRunnerParams.getPrimaryGatewayConfig())) {
Set<String> targetHostNames = grainRunnerParams.getTargetHostNames();
GrainOperation grainOperation = grainRunnerParams.getGrainOperation();
Set<Node> allNodes = grainRunnerParams.getAllNodes();
String key = grainRunnerParams.getKey();
String value = grainRunnerParams.getValue();
ModifyGrainBase runner;
switch(grainOperation) {
case ADD:
runner = new GrainAddRunner(targetHostNames, allNodes, key, value);
break;
case REMOVE:
runner = new GrainRemoveRunner(targetHostNames, allNodes, key, value);
break;
default:
throw new IllegalStateException("Unexpected value: " + grainOperation);
}
saltCommandRunner.runModifyGrainCommand(sc, runner, grainRunnerParams.getExitCriteriaModel(), exitCriteria);
} catch (Exception e) {
LOGGER.error("Exception during grain runner", e);
throw new CloudbreakOrchestratorFailedException(e.getMessage(), e);
}
}
Aggregations