use of com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus in project cloudbreak by hortonworks.
the class InstanceTerminationReplicationMock method addAmbariMappings.
public void addAmbariMappings(String clusterName) {
Map<String, CloudVmMetaDataStatus> instanceMap = getInstanceMap();
Service sparkService = getSparkService();
int requestId = 100;
sparkService.delete(AMBARI_API_ROOT + "/clusters/:cluster/hosts/:hostname", new EmptyAmbariResponse());
sparkService.delete(AMBARI_API_ROOT + "/clusters/:cluster/hosts/:hostname/host_components/*", new EmptyAmbariResponse());
sparkService.get(AMBARI_API_ROOT + "/clusters/:cluster/hosts/:hostname/host_components/*", new AmbariComponentStatusOnHostResponse());
sparkService.post(AMBARI_API_ROOT + "/clusters/" + clusterName + "/requests", new AmbariRequestIdRespone(requestId));
sparkService.get(AMBARI_API_ROOT + "/clusters/" + clusterName + "/requests/100", new AmbariRequestStatusResponse(requestId, 100));
sparkService.put(AMBARI_API_ROOT + "/clusters/" + clusterName + "/requests/" + requestId, new EmptyAmbariClusterResponse());
sparkService.put(AMBARI_API_ROOT + "/clusters/" + clusterName + "/host_components", new AmbariStrRequestIdRespone(requestId));
sparkService.get(AMBARI_API_ROOT + "/clusters/:cluster/hosts", new AmbariHostComponentStateResponse(instanceMap));
sparkService.get(AMBARI_API_ROOT + "/clusters/:cluster/hosts/:hostname", new AmbariHostResponse());
sparkService.get(AMBARI_API_ROOT + "/clusters", new AmbariClusterResponse(instanceMap, clusterName));
sparkService.get(AMBARI_API_ROOT + "/clusters/" + clusterName, new AmbariClustersHostsResponse(instanceMap, "SUCCESSFUL"));
sparkService.post(AMBARI_API_ROOT + "/clusters/" + clusterName, new EmptyAmbariClusterResponse());
sparkService.get(AMBARI_API_ROOT + "/clusters/:cluster/hosts/:hostname/host_components", new AmbariComponentStatusOnHostResponse());
sparkService.get(AMBARI_API_ROOT + "/clusters/" + clusterName + "/configurations/service_config_versions", new AmbariServiceConfigResponse(getMockServerAddress(), getMockPort()), gson()::toJson);
sparkService.get(AMBARI_API_ROOT + "/blueprints/:blueprintname", (request, response) -> {
response.type("text/plain");
return responseFromJsonFile("blueprint/" + request.params("blueprintname") + ".bp");
});
}
use of com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus in project cloudbreak by hortonworks.
the class InstanceTerminationUnknownMock method addAmbariMappings.
public void addAmbariMappings(String clusterName) {
Map<String, CloudVmMetaDataStatus> instanceMap = getInstanceMap();
Service sparkService = getSparkService();
int requestId = 100;
sparkService.delete(AMBARI_API_ROOT + "/clusters/:cluster/hosts/:hostname", new EmptyAmbariResponse());
sparkService.delete(AMBARI_API_ROOT + "/clusters/:cluster/hosts/:hostname/host_components/*", new EmptyAmbariResponse());
sparkService.get(AMBARI_API_ROOT + "/clusters/:cluster/hosts/:hostname/host_components/*", new AmbariComponentStatusOnHostResponse());
sparkService.post(AMBARI_API_ROOT + "/clusters/" + clusterName + "/requests", new AmbariRequestIdRespone(requestId));
sparkService.get(AMBARI_API_ROOT + "/clusters/" + clusterName + "/requests/100", new AmbariRequestStatusResponse(requestId, 100));
sparkService.put(AMBARI_API_ROOT + "/clusters/" + clusterName + "/requests/" + requestId, new EmptyAmbariClusterResponse());
sparkService.put(AMBARI_API_ROOT + "/clusters/" + clusterName + "/host_components", new AmbariStrRequestIdRespone(requestId));
sparkService.get(AMBARI_API_ROOT + "/clusters/:cluster/hosts", new AmbariHostComponentStateResponse(instanceMap));
sparkService.get(AMBARI_API_ROOT + "/clusters/:cluster/hosts/:hostname", new AmbariHostResponse(AmbariHostResponse.UNKNOWN));
sparkService.get(AMBARI_API_ROOT + "/clusters", new AmbariClusterResponse(instanceMap, clusterName));
sparkService.get(AMBARI_API_ROOT + "/clusters/" + clusterName, new AmbariClustersHostsResponse(instanceMap, "SUCCESSFUL"));
sparkService.post(AMBARI_API_ROOT + "/clusters/" + clusterName, new EmptyAmbariClusterResponse());
sparkService.get(AMBARI_API_ROOT + "/clusters/:cluster/hosts/:hostname/host_components", new AmbariComponentStatusOnHostResponse());
sparkService.get(AMBARI_API_ROOT + "/clusters/" + clusterName + "/configurations/service_config_versions", new AmbariServiceConfigResponse(getMockServerAddress(), getMockPort()), gson()::toJson);
sparkService.get(AMBARI_API_ROOT + "/blueprints/:blueprintname", (request, response) -> {
response.type("text/plain");
return responseFromJsonFile("blueprint/" + request.params("blueprintname") + ".bp");
});
}
use of com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus in project cloudbreak by hortonworks.
the class AmbariClustersHostsResponse method handle.
@Override
public Object handle(Request request, Response response) throws Exception {
response.type("text/plain");
ObjectNode rootNode = JsonNodeFactory.instance.objectNode();
ArrayNode items = rootNode.putArray("hosts");
for (Map.Entry<String, CloudVmMetaDataStatus> stringCloudVmMetaDataStatusEntry : instanceMap.entrySet()) {
CloudVmMetaDataStatus status = stringCloudVmMetaDataStatusEntry.getValue();
if (InstanceStatus.STARTED == status.getCloudVmInstanceStatus().getStatus()) {
ObjectNode item = items.addObject();
item.putObject("Hosts").put("host_name", HostNameUtil.generateHostNameByIp(status.getMetaData().getPrivateIp()));
ArrayNode components = item.putArray("host_components");
components.addObject().putObject("HostRoles").put("component_name", "DATANODE").put("state", state);
components.addObject().putObject("HostRoles").put("component_name", "NODEMANAGER").put("state", state);
}
}
return rootNode;
}
use of com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus in project cloudbreak by hortonworks.
the class SaltApiRunPostResponse method networkInterfaceIp.
protected Object networkInterfaceIp() throws JsonProcessingException {
NetworkInterfaceResponse networkInterfaceResponse = new NetworkInterfaceResponse();
List<Map<String, String>> result = new ArrayList<>();
for (Entry<String, CloudVmMetaDataStatus> stringCloudVmMetaDataStatusEntry : instanceMap.entrySet()) {
CloudVmMetaDataStatus cloudVmMetaDataStatus = stringCloudVmMetaDataStatusEntry.getValue();
if (InstanceStatus.STARTED == cloudVmMetaDataStatus.getCloudVmInstanceStatus().getStatus()) {
String privateIp = cloudVmMetaDataStatus.getMetaData().getPrivateIp();
Map<String, String> networkHashMap = new HashMap<>();
networkHashMap.put("host-" + privateIp.replace(".", "-"), privateIp);
result.add(networkHashMap);
}
}
networkInterfaceResponse.setResult(result);
return objectMapper.writeValueAsString(networkInterfaceResponse);
}
use of com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus in project cloudbreak by hortonworks.
the class SaltApiRunPostResponse method grainsResponse.
protected Object grainsResponse() throws JsonProcessingException {
ApplyResponse applyResponse = new ApplyResponse();
List<Map<String, Object>> responseList = new ArrayList<>();
Map<String, Object> hostMap = new HashMap<>();
for (Entry<String, CloudVmMetaDataStatus> stringCloudVmMetaDataStatusEntry : instanceMap.entrySet()) {
CloudVmMetaDataStatus cloudVmMetaDataStatus = stringCloudVmMetaDataStatusEntry.getValue();
if (InstanceStatus.STARTED == cloudVmMetaDataStatus.getCloudVmInstanceStatus().getStatus()) {
String privateIp = cloudVmMetaDataStatus.getMetaData().getPrivateIp();
hostMap.put("host-" + privateIp.replace(".", "-"), privateIp);
}
}
responseList.add(hostMap);
applyResponse.setResult(responseList);
return objectMapper.writeValueAsString(applyResponse);
}
Aggregations