Search in sources :

Example 1 with DistroXV1Request

use of com.sequenceiq.distrox.api.v1.distrox.model.DistroXV1Request in project cloudbreak by hortonworks.

the class DistroXV1RequestTest method getAllRecipesIfRecipeNamesAreNullTest.

@Test
public void getAllRecipesIfRecipeNamesAreNullTest() {
    DistroXV1Request distroXV1Request = new DistroXV1Request();
    InstanceGroupV1Request instanceGroupV1Request = new InstanceGroupV1Request();
    instanceGroupV1Request.setRecipeNames(null);
    distroXV1Request.setInstanceGroups(Collections.singleton(instanceGroupV1Request));
    Set<String> allRecipes = distroXV1Request.getAllRecipes();
    assertEquals(0, allRecipes.size());
}
Also used : InstanceGroupV1Request(com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.InstanceGroupV1Request) Test(org.junit.jupiter.api.Test)

Example 2 with DistroXV1Request

use of com.sequenceiq.distrox.api.v1.distrox.model.DistroXV1Request in project cloudbreak by hortonworks.

the class DistroXService method validate.

private void validate(DistroXV1Request request) {
    DetailedEnvironmentResponse environment = Optional.ofNullable(environmentClientService.getByName(request.getEnvironmentName())).orElseThrow(() -> new BadRequestException("No environment name provided hence unable to obtain some important data"));
    if (environment == null) {
        throw new BadRequestException(format("'%s' Environment does not exist.", request.getEnvironmentName()));
    }
    DescribeFreeIpaResponse freeipa = freeipaClientService.getByEnvironmentCrn(environment.getCrn());
    if (freeipa == null || freeipa.getAvailabilityStatus() == null || !freeipa.getAvailabilityStatus().isAvailable()) {
        throw new BadRequestException(format("If you want to provision a Data Hub then the FreeIPA instance must be running in the '%s' Environment.", environment.getName()));
    }
    Set<String> sdxCrns = platformAwareSdxConnector.listSdxCrns(environment.getName(), environment.getCrn());
    if (sdxCrns.isEmpty()) {
        throw new BadRequestException(format("Data Lake stack cannot be found for environment CRN: %s (%s)", environment.getName(), environment.getCrn()));
    }
    Set<Pair<String, StatusCheckResult>> sdxCrnsWithAvailability = platformAwareSdxConnector.listSdxCrnsWithAvailability(environment.getName(), environment.getCrn(), sdxCrns);
    if (!sdxCrnsWithAvailability.stream().map(Pair::getValue).allMatch(statusCheckResult -> StatusCheckResult.AVAILABLE.equals(statusCheckResult))) {
        throw new BadRequestException("Data Lake stacks of environment should be available.");
    }
}
Also used : StackOperations(com.sequenceiq.distrox.v1.distrox.StackOperations) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) StatusCheckResult(com.sequenceiq.cloudbreak.saas.sdx.status.StatusCheckResult) Set(java.util.Set) WorkspaceService(com.sequenceiq.cloudbreak.service.workspace.WorkspaceService) EnvironmentClientService(com.sequenceiq.cloudbreak.service.environment.EnvironmentClientService) DistroXV1RequestToStackV4RequestConverter(com.sequenceiq.distrox.v1.distrox.converter.DistroXV1RequestToStackV4RequestConverter) String.format(java.lang.String.format) Inject(javax.inject.Inject) CloudbreakRestRequestThreadLocalService(com.sequenceiq.cloudbreak.structuredevent.CloudbreakRestRequestThreadLocalService) FreeipaClientService(com.sequenceiq.cloudbreak.service.freeipa.FreeipaClientService) DescribeFreeIpaResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse) Pair(org.apache.commons.lang3.tuple.Pair) Service(org.springframework.stereotype.Service) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) Optional(java.util.Optional) PlatformAwareSdxConnector(com.sequenceiq.cloudbreak.saas.sdx.PlatformAwareSdxConnector) StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) DistroXV1Request(com.sequenceiq.distrox.api.v1.distrox.model.DistroXV1Request) DescribeFreeIpaResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) Pair(org.apache.commons.lang3.tuple.Pair)

Example 3 with DistroXV1Request

use of com.sequenceiq.distrox.api.v1.distrox.model.DistroXV1Request in project cloudbreak by hortonworks.

the class DistroXV1RequestToStackV4RequestConverter method convert.

public DistroXV1Request convert(StackV4Request source) {
    DistroXV1Request request = new DistroXV1Request();
    request.setName(source.getName());
    DetailedEnvironmentResponse env = null;
    if (source.getEnvironmentCrn() != null) {
        env = environmentClientService.getByCrn(source.getEnvironmentCrn());
        request.setEnvironmentName(env != null ? env.getName() : null);
    }
    request.setImage(getIfNotNull(source.getImage(), imageConverter::convert));
    request.setCluster(getIfNotNull(source.getCluster(), clusterConverter::convert));
    request.setNetwork(getIfNotNull(source.getNetwork(), networkConverter::convertToNetworkV1Request));
    setInstanceGroups(source, request, env);
    request.setAws(getIfNotNull(source.getAws(), stackParameterConverter::convert));
    request.setAzure(getIfNotNull(source.getAzure(), stackParameterConverter::convert));
    request.setGcp(getIfNotNull(source.getGcp(), stackParameterConverter::convert));
    request.setYarn(getIfNotNull(source.getYarn(), stackParameterConverter::convert));
    request.setInputs(source.getInputs());
    request.setTags(getIfNotNull(source.getTags(), this::getTags));
    request.setSdx(getIfNotNull(source.getSharedService(), sdxConverter::getSdx));
    request.setGatewayPort(source.getGatewayPort());
    request.setExternalDatabase(getIfNotNull(source.getExternalDatabase(), databaseRequestConverter::convert));
    request.setEnableLoadBalancer(source.isEnableLoadBalancer());
    return request;
}
Also used : DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) DistroXV1Request(com.sequenceiq.distrox.api.v1.distrox.model.DistroXV1Request)

Example 4 with DistroXV1Request

use of com.sequenceiq.distrox.api.v1.distrox.model.DistroXV1Request in project cloudbreak by hortonworks.

the class DistroXV1RequestToStackV4RequestConverter method convert.

public StackV4Request convert(DistroXV1Request source) {
    DetailedEnvironmentResponse environment = Optional.ofNullable(environmentClientService.getByName(source.getEnvironmentName())).orElseThrow(() -> new BadRequestException("No environment name provided hence unable to obtain some important data"));
    StackV4Request request = new StackV4Request();
    SdxClusterResponse sdxClusterResponse = getSdxClusterResponse(environment);
    request.setName(source.getName());
    request.setType(StackType.WORKLOAD);
    request.setCloudPlatform(getCloudPlatform(environment));
    request.setEnvironmentCrn(environment.getCrn());
    request.setAuthentication(getIfNotNull(environment.getAuthentication(), authenticationConverter::convert));
    request.setImage(getIfNotNull(source.getImage(), imageConverter::convert));
    request.setCluster(getIfNotNull(source, environment, clusterConverter::convert));
    NetworkV4Request network = getNetwork(source.getNetwork(), environment, source.getInstanceGroups());
    request.setNetwork(network);
    request.setInstanceGroups(getIfNotNull(source.getInstanceGroups(), igs -> instanceGroupConverter.convertTo(network, igs, environment)));
    request.setAws(getIfNotNull(source.getAws(), stackParameterConverter::convert));
    request.setAzure(getIfNotNull(source.getAzure(), stackParameterConverter::convert));
    request.setGcp(getIfNotNull(source.getGcp(), stackParameterConverter::convert));
    request.setYarn(getYarnProperties(source, environment));
    request.setInputs(source.getInputs());
    request.setTags(getIfNotNull(source.getTags(), this::getTags));
    request.setPlacement(preparePlacement(environment));
    request.setSharedService(sdxConverter.getSharedService(sdxClusterResponse));
    request.setCustomDomain(null);
    request.setTimeToLive(source.getTimeToLive());
    request.setTelemetry(getTelemetryRequest(environment, sdxClusterResponse));
    request.setGatewayPort(source.getGatewayPort());
    request.setExternalDatabase(getIfNotNull(source.getExternalDatabase(), databaseRequestConverter::convert));
    request.setEnableLoadBalancer(source.isEnableLoadBalancer());
    request.setVariant(source.getVariant());
    checkMultipleGatewayNodes(source);
    return request;
}
Also used : PlacementSettingsV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.environment.placement.PlacementSettingsV4Request) InstanceGroupNetworkV1Base(com.sequenceiq.distrox.api.v1.distrox.model.network.InstanceGroupNetworkV1Base) InstanceGroupAwsNetworkV1Parameters(com.sequenceiq.distrox.api.v1.distrox.model.network.aws.InstanceGroupAwsNetworkV1Parameters) NullUtil.getIfNotNull(com.sequenceiq.cloudbreak.util.NullUtil.getIfNotNull) EnvironmentNetworkResponse(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse) TelemetryConverter(com.sequenceiq.cloudbreak.converter.v4.stacks.TelemetryConverter) LoggerFactory(org.slf4j.LoggerFactory) CloudPlatform(com.sequenceiq.cloudbreak.common.mappable.CloudPlatform) TagsV1Request(com.sequenceiq.distrox.api.v1.distrox.model.tags.TagsV1Request) ArrayList(java.util.ArrayList) TelemetryRequest(com.sequenceiq.common.api.telemetry.request.TelemetryRequest) HashSet(java.util.HashSet) Inject(javax.inject.Inject) SdxClusterResponse(com.sequenceiq.sdx.api.model.SdxClusterResponse) AwsNetworkV1Parameters(com.sequenceiq.distrox.api.v1.distrox.model.network.aws.AwsNetworkV1Parameters) Map(java.util.Map) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) TelemetryResponse(com.sequenceiq.common.api.telemetry.response.TelemetryResponse) NetworkV1Request(com.sequenceiq.distrox.api.v1.distrox.model.network.NetworkV1Request) DistroXV1Request(com.sequenceiq.distrox.api.v1.distrox.model.DistroXV1Request) InstanceGroupV1Request(com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.InstanceGroupV1Request) TagsV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.TagsV4Request) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) CloudSubnet(com.sequenceiq.cloudbreak.cloud.model.CloudSubnet) Logger(org.slf4j.Logger) Collection(java.util.Collection) Set(java.util.Set) NetworkV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.network.NetworkV4Request) EnvironmentClientService(com.sequenceiq.cloudbreak.service.environment.EnvironmentClientService) Collectors(java.util.stream.Collectors) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) YarnStackV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.stack.YarnStackV4Parameters) Component(org.springframework.stereotype.Component) StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request) SdxClientService(com.sequenceiq.cloudbreak.service.datalake.SdxClientService) Optional(java.util.Optional) StackType(com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType) StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) SdxClusterResponse(com.sequenceiq.sdx.api.model.SdxClusterResponse) NetworkV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.network.NetworkV4Request)

Example 5 with DistroXV1Request

use of com.sequenceiq.distrox.api.v1.distrox.model.DistroXV1Request in project cloudbreak by hortonworks.

the class DistroXClusterToClusterConverterTest method createDistroXV1Request.

private DistroXV1Request createDistroXV1Request() {
    DistroXV1Request r = new DistroXV1Request();
    r.setCluster(createDistroXClusterV1Request());
    r.setName("SomeDistroX");
    return r;
}
Also used : DistroXV1Request(com.sequenceiq.distrox.api.v1.distrox.model.DistroXV1Request)

Aggregations

DistroXV1Request (com.sequenceiq.distrox.api.v1.distrox.model.DistroXV1Request)21 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)13 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)12 Test (org.junit.jupiter.api.Test)12 StackV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request)8 DescribeFreeIpaResponse (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse)7 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)4 DistroXDatabaseRequest (com.sequenceiq.distrox.api.v1.distrox.model.database.DistroXDatabaseRequest)4 InstanceGroupV1Request (com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.InstanceGroupV1Request)3 DisplayName (org.junit.jupiter.api.DisplayName)3 DatabaseRequest (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.database.DatabaseRequest)2 TagsV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.TagsV4Request)2 EnvironmentClientService (com.sequenceiq.cloudbreak.service.environment.EnvironmentClientService)2 NullUtil.getIfNotNull (com.sequenceiq.cloudbreak.util.NullUtil.getIfNotNull)2 DistroXClusterV1Request (com.sequenceiq.distrox.api.v1.distrox.model.cluster.DistroXClusterV1Request)2 Optional (java.util.Optional)2 Set (java.util.Set)2 Inject (javax.inject.Inject)2 DefaultClusterTemplateV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.clustertemplate.requests.DefaultClusterTemplateV4Request)1 ClusterTemplateViewV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.clustertemplate.responses.ClusterTemplateViewV4Response)1