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());
}
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.");
}
}
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;
}
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;
}
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;
}
Aggregations