Search in sources :

Example 11 with CloudVmMetaDataStatus

use of com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus in project cloudbreak by hortonworks.

the class StackCreationMock method addSPIEndpoints.

public void addSPIEndpoints() {
    Map<String, CloudVmMetaDataStatus> instanceMap = getInstanceMap();
    getSparkService().post(MOCK_ROOT + "/cloud_metadata_statuses", new CloudMetaDataStatuses(instanceMap), gson()::toJson);
}
Also used : CloudVmMetaDataStatus(com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus) CloudMetaDataStatuses(com.sequenceiq.it.spark.spi.CloudMetaDataStatuses)

Example 12 with CloudVmMetaDataStatus

use of com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus in project cloudbreak by hortonworks.

the class StackCreationMock method verifyCalls.

public void verifyCalls(String clusterName) {
    verify(SALT_BOOT_ROOT + "/health", "GET").exactTimes(1).verify();
    Verification distributeVerification = verify(SALT_BOOT_ROOT + "/salt/action/distribute", "POST").exactTimes(1);
    for (CloudVmMetaDataStatus status : getInstanceMap().values()) {
        distributeVerification.bodyContains("address\":\"" + status.getMetaData().getPrivateIp());
    }
    distributeVerification.verify();
    verify(AMBARI_API_ROOT + "/services/AMBARI/components/AMBARI_SERVER", "GET").exactTimes(1).verify();
    verify(AMBARI_API_ROOT + "/clusters", "GET").exactTimes(2).verify();
    verify(AMBARI_API_ROOT + "/check", "GET").atLeast(1).verify();
    verify(AMBARI_API_ROOT + "/users/admin", "PUT").exactTimes(1).bodyContains("Users/password").bodyContains("Users/old_password").verify();
    verify(AMBARI_API_ROOT + "/blueprints/bp", "POST").exactTimes(1).bodyContains("blueprint_name").bodyContains("stack_name").bodyContains("stack_version").bodyContains("host_groups").exactTimes(1).verify();
    verify(AMBARI_API_ROOT + "/clusters/" + clusterName, "POST").exactTimes(1).bodyContains("blueprint").bodyContains("default_password").bodyContains("host_groups").verify();
    verify(AMBARI_API_ROOT + "/clusters/" + clusterName + "/requests/1", "GET").atLeast(1).verify();
    verify(SALT_API_ROOT + "/run", "POST").bodyContains("fun=saltutil.sync_grains").atLeast(1).verify();
    verify(SALT_API_ROOT + "/run", "POST").bodyContains("fun=mine.update").atLeast(1).verify();
    verify(SALT_API_ROOT + "/run", "POST").bodyContains("fun=state.highstate").atLeast(2).verify();
    verify(SALT_API_ROOT + "/run", "POST").bodyContains("fun=jobs.lookup_jid").bodyContains("jid=1").atLeast(2).verify();
    verify(SALT_API_ROOT + "/run", "POST").bodyContains("fun=grains.append").bodyContains("ambari_agent_install").exactTimes(1).verify();
    verify(SALT_API_ROOT + "/run", "POST").bodyContains("fun=grains.append").bodyContains("ambari_agent").exactTimes(2).verify();
    verify(SALT_API_ROOT + "/run", "POST").bodyContains("fun=grains.append").bodyContains("ambari_server_install").exactTimes(1).verify();
    verify(SALT_API_ROOT + "/run", "POST").bodyContains("fun=grains.append").bodyContains("ambari_server").exactTimes(2).verify();
    verify(SALT_API_ROOT + "/run", "POST").bodyContains("fun=grains.append").bodyContains("recipes").exactTimes(2).verify();
    verify(SALT_API_ROOT + "/run", "POST").bodyContains("fun=grains.remove").bodyContains("recipes").exactTimes(2).verify();
    verify(SALT_API_ROOT + "/run", "POST").bodyContains("fun=jobs.active").atLeast(2).verify();
    verify(SALT_BOOT_ROOT + "/file", "POST").exactTimes(0).verify();
    verify(SALT_BOOT_ROOT + "/file/distribute", "POST").exactTimes(4).verify();
}
Also used : CloudVmMetaDataStatus(com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus) Verification(com.sequenceiq.it.verification.Verification)

Example 13 with CloudVmMetaDataStatus

use of com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus 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);
}
Also used : SaltApiRunPostResponse(com.sequenceiq.it.spark.salt.SaltApiRunPostResponse) CloudVmMetaDataStatus(com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus) GenericResponse(com.sequenceiq.cloudbreak.orchestrator.model.GenericResponse) ArrayList(java.util.ArrayList) Service(spark.Service) GenericResponses(com.sequenceiq.cloudbreak.orchestrator.model.GenericResponses) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 14 with CloudVmMetaDataStatus

use of com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus in project cloudbreak by hortonworks.

the class StackCreationMock method addAmbariMappings.

public void addAmbariMappings(String clusterName) {
    Map<String, CloudVmMetaDataStatus> instanceMap = getInstanceMap();
    Service sparkService = getSparkService();
    sparkService.get(AMBARI_API_ROOT + "/clusters/:cluster/requests/:request", new AmbariStatusResponse());
    sparkService.post(AMBARI_API_ROOT + "/views/:view/versions/1.0.0/instances/*", new EmptyAmbariResponse());
    sparkService.get(AMBARI_API_ROOT + "/clusters", (req, resp) -> {
        ITResponse itResp = clusterCreated ? new AmbariClusterResponse(instanceMap, clusterName) : new EmptyAmbariClusterResponse();
        return itResp.handle(req, resp);
    });
    sparkService.post(AMBARI_API_ROOT + "/clusters/:cluster/requests", new AmbariClusterRequestsResponse());
    sparkService.post(AMBARI_API_ROOT + "/clusters/:cluster", (req, resp) -> {
        clusterCreated = true;
        return new EmptyAmbariResponse().handle(req, resp);
    }, gson()::toJson);
    sparkService.get(AMBARI_API_ROOT + "/clusters", new AmbariClusterResponse(instanceMap, clusterName));
    sparkService.post(AMBARI_API_ROOT + "/clusters/:cluster/requests", new AmbariClusterRequestsResponse());
    sparkService.post(AMBARI_API_ROOT + "/clusters/:cluster", new EmptyAmbariResponse());
    sparkService.get(AMBARI_API_ROOT + "/services/AMBARI/components/AMBARI_SERVER", new AmbariServicesComponentsResponse(), gson()::toJson);
    sparkService.get(AMBARI_API_ROOT + "/hosts", new AmbariHostsResponse(instanceMap), gson()::toJson);
    sparkService.get(AMBARI_API_ROOT + "/blueprints/:blueprintname", (request, response) -> {
        response.type("text/plain");
        return responseFromJsonFile("blueprint/" + request.params("blueprintname") + ".bp");
    });
    sparkService.post(AMBARI_API_ROOT + "/blueprints/*", new EmptyAmbariResponse());
    sparkService.put(AMBARI_API_ROOT + "/users/admin", new EmptyAmbariResponse());
    sparkService.get(AMBARI_API_ROOT + "/check", new AmbariCheckResponse());
    sparkService.post(AMBARI_API_ROOT + "/users", new EmptyAmbariResponse());
    sparkService.get(AMBARI_API_ROOT + "/clusters/:cluster/hosts", new AmbariClustersHostsResponse(instanceMap, "SUCCESSFUL"));
    sparkService.put(AMBARI_API_ROOT + "/stacks/HDP/versions/:version/operating_systems/:os/repositories/:hdpversion", new AmbariVersionDefinitionResponse());
    sparkService.get(AMBARI_API_ROOT + "/version_definitions", new AmbariVersionDefinitionResponse());
    sparkService.post(AMBARI_API_ROOT + "/version_definitions", new EmptyAmbariResponse());
}
Also used : AmbariVersionDefinitionResponse(com.sequenceiq.it.spark.ambari.AmbariVersionDefinitionResponse) AmbariHostsResponse(com.sequenceiq.it.spark.ambari.AmbariHostsResponse) EmptyAmbariClusterResponse(com.sequenceiq.it.spark.ambari.EmptyAmbariClusterResponse) Service(spark.Service) AmbariClusterRequestsResponse(com.sequenceiq.it.spark.ambari.AmbariClusterRequestsResponse) AmbariStatusResponse(com.sequenceiq.it.spark.ambari.AmbariStatusResponse) 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.AmbariClustersHostsResponse) AmbariServicesComponentsResponse(com.sequenceiq.it.spark.ambari.AmbariServicesComponentsResponse) ITResponse(com.sequenceiq.it.spark.ITResponse) AmbariCheckResponse(com.sequenceiq.it.spark.ambari.AmbariCheckResponse)

Example 15 with CloudVmMetaDataStatus

use of com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus in project cloudbreak by hortonworks.

the class InstanceTerminationReplicationErrorMock 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)

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