Search in sources :

Example 16 with CloudVmMetaDataStatus

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");
    });
}
Also used : AmbariHostResponse(com.sequenceiq.it.spark.ambari.v2.AmbariHostResponse) AmbariComponentStatusOnHostResponse(com.sequenceiq.it.spark.ambari.AmbariComponentStatusOnHostResponse) EmptyAmbariClusterResponse(com.sequenceiq.it.spark.ambari.EmptyAmbariClusterResponse) Service(spark.Service) AmbariRequestStatusResponse(com.sequenceiq.it.spark.ambari.v2.AmbariRequestStatusResponse) AmbariStrRequestIdRespone(com.sequenceiq.it.spark.ambari.v2.AmbariStrRequestIdRespone) AmbariRequestIdRespone(com.sequenceiq.it.spark.ambari.v2.AmbariRequestIdRespone) EmptyAmbariResponse(com.sequenceiq.it.spark.ambari.EmptyAmbariResponse) EmptyAmbariClusterResponse(com.sequenceiq.it.spark.ambari.EmptyAmbariClusterResponse) AmbariClusterResponse(com.sequenceiq.it.spark.ambari.AmbariClusterResponse) CloudVmMetaDataStatus(com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus) AmbariClustersHostsResponse(com.sequenceiq.it.spark.ambari.v2.AmbariClustersHostsResponse) AmbariServiceConfigResponse(com.sequenceiq.it.spark.ambari.AmbariServiceConfigResponse) AmbariHostComponentStateResponse(com.sequenceiq.it.spark.ambari.v2.AmbariHostComponentStateResponse)

Example 17 with CloudVmMetaDataStatus

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");
    });
}
Also used : AmbariHostResponse(com.sequenceiq.it.spark.ambari.v2.AmbariHostResponse) AmbariComponentStatusOnHostResponse(com.sequenceiq.it.spark.ambari.AmbariComponentStatusOnHostResponse) EmptyAmbariClusterResponse(com.sequenceiq.it.spark.ambari.EmptyAmbariClusterResponse) Service(spark.Service) AmbariRequestStatusResponse(com.sequenceiq.it.spark.ambari.v2.AmbariRequestStatusResponse) AmbariStrRequestIdRespone(com.sequenceiq.it.spark.ambari.v2.AmbariStrRequestIdRespone) AmbariRequestIdRespone(com.sequenceiq.it.spark.ambari.v2.AmbariRequestIdRespone) EmptyAmbariResponse(com.sequenceiq.it.spark.ambari.EmptyAmbariResponse) EmptyAmbariClusterResponse(com.sequenceiq.it.spark.ambari.EmptyAmbariClusterResponse) AmbariClusterResponse(com.sequenceiq.it.spark.ambari.AmbariClusterResponse) CloudVmMetaDataStatus(com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus) AmbariClustersHostsResponse(com.sequenceiq.it.spark.ambari.v2.AmbariClustersHostsResponse) AmbariServiceConfigResponse(com.sequenceiq.it.spark.ambari.AmbariServiceConfigResponse) AmbariHostComponentStateResponse(com.sequenceiq.it.spark.ambari.v2.AmbariHostComponentStateResponse)

Example 18 with CloudVmMetaDataStatus

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;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) CloudVmMetaDataStatus(com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) Map(java.util.Map)

Example 19 with CloudVmMetaDataStatus

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);
}
Also used : NetworkInterfaceResponse(com.sequenceiq.cloudbreak.orchestrator.salt.domain.NetworkInterfaceResponse) CloudVmMetaDataStatus(com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) Map(java.util.Map)

Example 20 with CloudVmMetaDataStatus

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);
}
Also used : HashMap(java.util.HashMap) CloudVmMetaDataStatus(com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus) ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) Map(java.util.Map) ApplyResponse(com.sequenceiq.cloudbreak.orchestrator.salt.domain.ApplyResponse)

Aggregations

CloudVmMetaDataStatus (com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus)43 CloudInstance (com.sequenceiq.cloudbreak.cloud.model.CloudInstance)20 ArrayList (java.util.ArrayList)18 InstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate)13 CloudVmInstanceStatus (com.sequenceiq.cloudbreak.cloud.model.CloudVmInstanceStatus)12 CloudInstanceMetaData (com.sequenceiq.cloudbreak.cloud.model.CloudInstanceMetaData)10 InstanceAuthentication (com.sequenceiq.cloudbreak.cloud.model.InstanceAuthentication)9 Service (spark.Service)8 AuthenticatedContext (com.sequenceiq.cloudbreak.cloud.context.AuthenticatedContext)7 Map (java.util.Map)7 AmazonAutoScalingClient (com.amazonaws.services.autoscaling.AmazonAutoScalingClient)6 AmazonCloudFormationClient (com.amazonaws.services.cloudformation.AmazonCloudFormationClient)6 Instance (com.amazonaws.services.ec2.model.Instance)6 Reservation (com.amazonaws.services.ec2.model.Reservation)6 AwsCredentialView (com.sequenceiq.cloudbreak.cloud.aws.view.AwsCredentialView)6 CloudResource (com.sequenceiq.cloudbreak.cloud.model.CloudResource)6 AmbariClusterResponse (com.sequenceiq.it.spark.ambari.AmbariClusterResponse)6 EmptyAmbariResponse (com.sequenceiq.it.spark.ambari.EmptyAmbariResponse)6 CreateTagsRequest (com.amazonaws.services.ec2.model.CreateTagsRequest)5 Volume (com.sequenceiq.cloudbreak.cloud.model.Volume)5