use of com.sequenceiq.cloudbreak.orchestrator.model.GenericResponse in project cloudbreak by hortonworks.
the class SaltOrchestratorTest method isBootstrapApiAvailableFailTest.
@Test
public void isBootstrapApiAvailableFailTest() {
SaltOrchestrator saltOrchestrator = new SaltOrchestrator();
saltOrchestrator.init(parallelOrchestratorComponentRunner, exitCriteria);
GenericResponse response = new GenericResponse();
response.setStatusCode(404);
when(saltConnector.health()).thenReturn(response);
boolean bootstrapApiAvailable = saltOrchestrator.isBootstrapApiAvailable(gatewayConfig);
assertFalse(bootstrapApiAvailable);
}
use of com.sequenceiq.cloudbreak.orchestrator.model.GenericResponse in project cloudbreak by hortonworks.
the class SaltOrchestratorTest method isBootstrapApiAvailableTest.
@Test
public void isBootstrapApiAvailableTest() {
SaltOrchestrator saltOrchestrator = new SaltOrchestrator();
saltOrchestrator.init(parallelOrchestratorComponentRunner, exitCriteria);
GenericResponse response = new GenericResponse();
response.setStatusCode(200);
when(saltConnector.health()).thenReturn(response);
boolean bootstrapApiAvailable = saltOrchestrator.isBootstrapApiAvailable(gatewayConfig);
assertTrue(bootstrapApiAvailable);
}
use of com.sequenceiq.cloudbreak.orchestrator.model.GenericResponse in project cloudbreak by hortonworks.
the class SaltBootstrap method call.
@Override
public Boolean call() throws Exception {
LOGGER.info("Bootstrapping of nodes [{}/{}]", originalTargets.size() - targets.size(), originalTargets.size());
if (!targets.isEmpty()) {
LOGGER.info("Missing targets for SaltBootstrap: {}", targets);
SaltAction saltAction = createBootstrap();
GenericResponses responses = sc.action(saltAction);
Set<Node> failedTargets = new HashSet<>();
LOGGER.info("SaltBootstrap responses: {}", responses);
for (GenericResponse genericResponse : responses.getResponses()) {
if (genericResponse.getStatusCode() != HttpStatus.OK.value()) {
LOGGER.info("Failed to distributed salt run to: " + genericResponse.getAddress());
String address = genericResponse.getAddress().split(":")[0];
failedTargets.addAll(originalTargets.stream().filter(a -> a.getPrivateIp().equals(address)).collect(Collectors.toList()));
}
}
targets = failedTargets;
if (!targets.isEmpty()) {
LOGGER.info("Missing nodes to run saltbootstrap: {}", targets);
throw new CloudbreakOrchestratorFailedException("There are missing nodes from saltbootstrap: " + targets);
}
}
String iFace = SaltStates.defaultRoute(sc, Glob.ALL).getGatewayInterfaceName();
Map<String, String> networkResult = SaltStates.networkInterfaceIP(sc, Glob.ALL, iFace).getResultGroupByIP();
originalTargets.forEach(node -> {
if (!networkResult.containsKey(node.getPrivateIp())) {
LOGGER.info("Salt-minion is not responding on host: {}, yet", node);
targets.add(node);
}
});
if (!targets.isEmpty()) {
throw new CloudbreakOrchestratorFailedException("There are missing nodes from salt network response: " + targets);
}
LOGGER.info("Bootstrapping of nodes completed: {}", originalTargets.size());
return true;
}
use of com.sequenceiq.cloudbreak.orchestrator.model.GenericResponse in project cloudbreak by hortonworks.
the class SaltUpload method call.
@Override
public Boolean call() throws Exception {
LOGGER.info("Uploading files to: {}", targets);
if (!targets.isEmpty()) {
LOGGER.info("Current targets for upload: {}", targets);
GenericResponses responses = sc.upload(targets, path, fileName, content);
Set<String> failedTargets = new HashSet<>();
LOGGER.info("Salt file upload responses: {}", responses);
for (GenericResponse genericResponse : responses.getResponses()) {
if (genericResponse.getStatusCode() != HttpStatus.CREATED.value()) {
LOGGER.info("Failed upload attempt to: " + genericResponse.getAddress());
String address = genericResponse.getAddress().split(":")[0];
failedTargets.addAll(originalTargets.stream().filter(a -> a.equals(address)).collect(Collectors.toList()));
}
}
targets = failedTargets;
if (!targets.isEmpty()) {
LOGGER.info("Missing nodes for file upload: {}", targets);
throw new CloudbreakOrchestratorFailedException("There are missing nodes for file upload: " + targets);
}
}
LOGGER.info("File upload has been completed on nodes: {}", originalTargets);
return true;
}
use of com.sequenceiq.cloudbreak.orchestrator.model.GenericResponse in project cloudbreak by hortonworks.
the class MockClusterCreationWithSaltFailTest method addSaltMappings.
private void addSaltMappings(Map<String, CloudVmMetaDataStatus> instanceMap) {
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.setVisibility(objectMapper.getVisibilityChecker().withGetterVisibility(Visibility.NONE));
post(SALT_API_ROOT + "/run", new SaltApiRunPostResponse(instanceMap) {
@Override
protected Object jobsLookupJid() {
return responseFromJsonFile("saltapi/lookup_jid_fail_response.json");
}
});
post(SALT_BOOT_ROOT + "/salt/server/pillar", (request, response) -> {
GenericResponse genericResponse = new GenericResponse();
genericResponse.setStatusCode(HttpStatus.OK.value());
return genericResponse;
}, gson()::toJson);
}
Aggregations