use of com.sequenceiq.it.spark.salt.SaltApiRunPostResponse in project cloudbreak by hortonworks.
the class StackCreationMock method addSaltMappings.
public void addSaltMappings() {
Map<String, CloudVmMetaDataStatus> instanceMap = getInstanceMap();
ObjectMapper objectMapper = new ObjectMapper();
Service sparkService = getSparkService();
sparkService.get(SALT_BOOT_ROOT + "/health", (request, response) -> {
GenericResponse genericResponse = new GenericResponse();
genericResponse.setStatusCode(HttpStatus.OK.value());
return genericResponse;
}, gson()::toJson);
objectMapper.setVisibility(objectMapper.getVisibilityChecker().withGetterVisibility(Visibility.NONE));
sparkService.post(SALT_API_ROOT + "/run", new SaltApiRunPostResponse(instanceMap));
sparkService.post(SALT_BOOT_ROOT + "/file", (request, response) -> {
response.status(HttpStatus.CREATED.value());
return response;
});
sparkService.post(SALT_BOOT_ROOT + "/salt/server/pillar", (request, response) -> {
GenericResponse genericResponse = new GenericResponse();
genericResponse.setStatusCode(HttpStatus.OK.value());
return genericResponse;
}, gson()::toJson);
sparkService.post(SALT_BOOT_ROOT + "/salt/action/distribute", (request, response) -> {
GenericResponses genericResponses = new GenericResponses();
genericResponses.setResponses(new ArrayList<>());
return genericResponses;
}, gson()::toJson);
sparkService.post(SALT_BOOT_ROOT + "/hostname/distribute", (request, response) -> {
GenericResponses genericResponses = new GenericResponses();
List<GenericResponse> responses = new ArrayList<>();
for (CloudVmMetaDataStatus status : instanceMap.values()) {
GenericResponse genericResponse = new GenericResponse();
genericResponse.setAddress(status.getMetaData().getPrivateIp());
genericResponse.setStatus(HostNameUtil.generateHostNameByIp(status.getMetaData().getPrivateIp()));
genericResponse.setStatusCode(HttpStatus.OK.value());
responses.add(genericResponse);
}
genericResponses.setResponses(responses);
return genericResponses;
}, gson()::toJson);
sparkService.post(SALT_BOOT_ROOT + "/file/distribute", (request, response) -> {
GenericResponses genericResponses = new GenericResponses();
GenericResponse genericResponse = new GenericResponse();
genericResponse.setStatusCode(HttpStatus.CREATED.value());
genericResponses.setResponses(Collections.singletonList(genericResponse));
return genericResponses;
}, gson()::toJson);
sparkService.post(SALT_BOOT_ROOT + "/salt/server/pillar/distribute", (request, response) -> {
GenericResponses genericResponses = new GenericResponses();
GenericResponse genericResponse = new GenericResponse();
genericResponse.setStatusCode(HttpStatus.OK.value());
genericResponses.setResponses(Collections.singletonList(genericResponse));
return genericResponses;
}, gson()::toJson);
}
use of com.sequenceiq.it.spark.salt.SaltApiRunPostResponse 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);
}
use of com.sequenceiq.it.spark.salt.SaltApiRunPostResponse in project cloudbreak by hortonworks.
the class InstanceTerminationMock method addMockEndpoints.
public void addMockEndpoints() {
Service sparkService = getSparkService();
sparkService.get(SALT_BOOT_ROOT + "/health", (request, response) -> {
GenericResponse genericResponse = new GenericResponse();
genericResponse.setStatusCode(HttpStatus.OK.value());
return genericResponse;
}, gson()::toJson);
sparkService.post(SALT_BOOT_ROOT + "/salt/server/pillar", (request, response) -> {
GenericResponse genericResponse = new GenericResponse();
genericResponse.setStatusCode(HttpStatus.OK.value());
return genericResponse;
}, gson()::toJson);
sparkService.post(SALT_BOOT_ROOT + "/salt/action/distribute", (request, response) -> {
GenericResponses genericResponses = new GenericResponses();
genericResponses.setResponses(new ArrayList<>());
return genericResponses;
}, gson()::toJson);
sparkService.post(SALT_BOOT_ROOT + "/hostname/distribute", (request, response) -> {
GenericResponses genericResponses = new GenericResponses();
List<GenericResponse> responses = new ArrayList<>();
JsonObject parsedRequest = new JsonParser().parse(request.body()).getAsJsonObject();
JsonArray nodeArray = parsedRequest.getAsJsonArray("clients");
for (int i = 0; i < nodeArray.size(); i++) {
String address = nodeArray.get(i).getAsString();
GenericResponse genericResponse = new GenericResponse();
genericResponse.setAddress(address);
genericResponse.setStatus(HostNameUtil.generateHostNameByIp(address));
genericResponse.setStatusCode(200);
responses.add(genericResponse);
}
genericResponses.setResponses(responses);
return genericResponses;
}, gson()::toJson);
sparkService.post(SALT_API_ROOT + "/run", new SaltApiRunPostResponse(getInstanceMap()));
sparkService.post(SALT_BOOT_ROOT + "/file/distribute", (request, response) -> {
GenericResponses genericResponses = new GenericResponses();
GenericResponse genericResponse = new GenericResponse();
genericResponse.setStatusCode(HttpStatus.CREATED.value());
genericResponses.setResponses(Collections.singletonList(genericResponse));
return genericResponses;
}, gson()::toJson);
sparkService.post(SALT_BOOT_ROOT + "/salt/server/pillar/distribute", (request, response) -> {
GenericResponses genericResponses = new GenericResponses();
GenericResponse genericResponse = new GenericResponse();
genericResponse.setStatusCode(HttpStatus.OK.value());
genericResponses.setResponses(Collections.singletonList(genericResponse));
return genericResponses;
}, gson()::toJson);
sparkService.get("/ws/v1/cluster/apps", (request, response) -> {
ObjectNode rootNode = JsonNodeFactory.instance.objectNode();
ArrayNode appNode = rootNode.putObject("apps").putArray("app");
appNode.addObject().put("amHostHttpAddress", "192.168.1.1");
return rootNode;
});
}
use of com.sequenceiq.it.spark.salt.SaltApiRunPostResponse in project cloudbreak by hortonworks.
the class InstanceTerminationReplicationErrorMock method addMockEndpoints.
public void addMockEndpoints() {
Service sparkService = getSparkService();
sparkService.get(SALT_BOOT_ROOT + "/health", (request, response) -> {
GenericResponse genericResponse = new GenericResponse();
genericResponse.setStatusCode(HttpStatus.OK.value());
return genericResponse;
}, gson()::toJson);
sparkService.post(SALT_BOOT_ROOT + "/salt/server/pillar", (request, response) -> {
GenericResponse genericResponse = new GenericResponse();
genericResponse.setStatusCode(HttpStatus.OK.value());
return genericResponse;
}, gson()::toJson);
sparkService.post(SALT_BOOT_ROOT + "/salt/action/distribute", (request, response) -> {
GenericResponses genericResponses = new GenericResponses();
genericResponses.setResponses(new ArrayList<>());
return genericResponses;
}, gson()::toJson);
sparkService.post(SALT_BOOT_ROOT + "/hostname/distribute", (request, response) -> {
GenericResponses genericResponses = new GenericResponses();
List<GenericResponse> responses = new ArrayList<>();
JsonObject parsedRequest = new JsonParser().parse(request.body()).getAsJsonObject();
JsonArray nodeArray = parsedRequest.getAsJsonArray("clients");
for (int i = 0; i < nodeArray.size(); i++) {
String address = nodeArray.get(i).getAsString();
GenericResponse genericResponse = new GenericResponse();
genericResponse.setAddress(address);
genericResponse.setStatus(HostNameUtil.generateHostNameByIp(address));
genericResponse.setStatusCode(200);
responses.add(genericResponse);
}
genericResponses.setResponses(responses);
return genericResponses;
}, gson()::toJson);
sparkService.post(SALT_API_ROOT + "/run", new SaltApiRunPostResponse(getInstanceMap()));
sparkService.post(SALT_BOOT_ROOT + "/file/distribute", (request, response) -> {
GenericResponses genericResponses = new GenericResponses();
GenericResponse genericResponse = new GenericResponse();
genericResponse.setStatusCode(HttpStatus.CREATED.value());
genericResponses.setResponses(Collections.singletonList(genericResponse));
return genericResponses;
}, gson()::toJson);
sparkService.post(SALT_BOOT_ROOT + "/salt/server/pillar/distribute", (request, response) -> {
GenericResponses genericResponses = new GenericResponses();
GenericResponse genericResponse = new GenericResponse();
genericResponse.setStatusCode(HttpStatus.OK.value());
genericResponses.setResponses(Collections.singletonList(genericResponse));
return genericResponses;
}, gson()::toJson);
sparkService.get("/ws/v1/cluster/apps", (request, response) -> {
ObjectNode rootNode = JsonNodeFactory.instance.objectNode();
ArrayNode appNode = rootNode.putObject("apps").putArray("app");
appNode.addObject().put("amHostHttpAddress", "192.168.1.1");
return rootNode;
});
}
use of com.sequenceiq.it.spark.salt.SaltApiRunPostResponse in project cloudbreak by hortonworks.
the class InstanceTerminationReplicationMock method addMockEndpoints.
public void addMockEndpoints() {
Service sparkService = getSparkService();
sparkService.get(SALT_BOOT_ROOT + "/health", (request, response) -> {
GenericResponse genericResponse = new GenericResponse();
genericResponse.setStatusCode(HttpStatus.OK.value());
return genericResponse;
}, gson()::toJson);
sparkService.post(SALT_BOOT_ROOT + "/salt/server/pillar", (request, response) -> {
GenericResponse genericResponse = new GenericResponse();
genericResponse.setStatusCode(HttpStatus.OK.value());
return genericResponse;
}, gson()::toJson);
sparkService.post(SALT_BOOT_ROOT + "/salt/action/distribute", (request, response) -> {
GenericResponses genericResponses = new GenericResponses();
genericResponses.setResponses(new ArrayList<>());
return genericResponses;
}, gson()::toJson);
sparkService.post(SALT_BOOT_ROOT + "/hostname/distribute", (request, response) -> {
GenericResponses genericResponses = new GenericResponses();
List<GenericResponse> responses = new ArrayList<>();
JsonObject parsedRequest = new JsonParser().parse(request.body()).getAsJsonObject();
JsonArray nodeArray = parsedRequest.getAsJsonArray("clients");
for (int i = 0; i < nodeArray.size(); i++) {
String address = nodeArray.get(i).getAsString();
GenericResponse genericResponse = new GenericResponse();
genericResponse.setAddress(address);
genericResponse.setStatus(HostNameUtil.generateHostNameByIp(address));
genericResponse.setStatusCode(200);
responses.add(genericResponse);
}
genericResponses.setResponses(responses);
return genericResponses;
}, gson()::toJson);
sparkService.post(SALT_API_ROOT + "/run", new SaltApiRunPostResponse(getInstanceMap()));
sparkService.post(SALT_BOOT_ROOT + "/file/distribute", (request, response) -> {
GenericResponses genericResponses = new GenericResponses();
GenericResponse genericResponse = new GenericResponse();
genericResponse.setStatusCode(HttpStatus.CREATED.value());
genericResponses.setResponses(Collections.singletonList(genericResponse));
return genericResponses;
}, gson()::toJson);
sparkService.post(SALT_BOOT_ROOT + "/salt/server/pillar/distribute", (request, response) -> {
GenericResponses genericResponses = new GenericResponses();
GenericResponse genericResponse = new GenericResponse();
genericResponse.setStatusCode(HttpStatus.OK.value());
genericResponses.setResponses(Collections.singletonList(genericResponse));
return genericResponses;
}, gson()::toJson);
sparkService.get("/ws/v1/cluster/apps", (request, response) -> {
ObjectNode rootNode = JsonNodeFactory.instance.objectNode();
ArrayNode appNode = rootNode.putObject("apps").putArray("app");
appNode.addObject().put("amHostHttpAddress", "192.168.1.1");
return rootNode;
});
}
Aggregations