use of com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentBaseResponse in project cloudbreak by hortonworks.
the class CleanupWaitUtil method checkEnvironmentDeleteFailedStatus.
/**
* Checking the environment is in DELETE_FAILED state.
*
* Returns with:
* TRUE: DELETE_FAILED state is available.
* FALSE: DELETE_FAILED state is not available.
*
* @param environmentClient com.sequenceiq.environment.client.EnvironmentClient
* @param environmentName Provided environment name
* @return TRUE or FALSE based on existing DELETE_FAILED status
*/
private boolean checkEnvironmentDeleteFailedStatus(EnvironmentClient environmentClient, String environmentName) {
try {
EnvironmentStatus environmentStatus = environmentClient.environmentV1Endpoint().list().getResponses().stream().filter(response -> response.getName().equalsIgnoreCase(environmentName)).findFirst().map(EnvironmentBaseResponse::getEnvironmentStatus).orElse(EnvironmentStatus.ARCHIVED);
LOG.info("{} environment actual state is: {}", environmentName, environmentStatus);
return environmentStatus.equals(EnvironmentStatus.DELETE_FAILED);
} catch (Exception e) {
LOG.warn("Exception has been occurred while checking {} environment's DELETE_FAILED state: {}", environmentName, e.getMessage(), e);
return false;
}
}
use of com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentBaseResponse in project cloudbreak by hortonworks.
the class StackV4RequestToStackConverter method convert.
public Stack convert(StackV4Request source) {
Workspace workspace = workspaceService.getForCurrentUser();
Stack stack = new Stack();
stack.setEnvironmentCrn(source.getEnvironmentCrn());
DetailedEnvironmentResponse environment = null;
if (!StringUtils.isEmpty(source.getEnvironmentCrn())) {
environment = measure(() -> environmentClientService.getByCrn(source.getEnvironmentCrn()), LOGGER, "Environment responded in {} ms for stack {}", source.getName());
}
if (isTemplate(source)) {
updateCustomDomainOrKerberos(source, stack);
updateCloudPlatformAndRelatedFields(source, stack, environment);
convertAsStackTemplate(source, stack, environment);
setNetworkAsTemplate(source, stack);
} else {
convertAsStack(source, stack);
updateCloudPlatformAndRelatedFields(source, stack, environment);
setNetworkIfApplicable(source, stack, environment);
setInstanceGroupNetworkIfApplicable(source, stack, environment);
stack.getComponents().add(getTelemetryComponent(stack, source));
}
Map<String, Object> asMap = providerParameterCalculator.get(source).asMap();
if (asMap != null) {
Map<String, String> parameter = new HashMap<>();
asMap.forEach((key, value) -> parameter.put(key, value.toString()));
stack.setParameters(parameter);
}
setTimeToLive(source, stack);
stack.setWorkspace(workspace);
stack.setDisplayName(source.getName());
stack.setDatalakeCrn(datalakeService.getDatalakeCrn(source, workspace));
stack.setStackAuthentication(stackAuthenticationV4RequestToStackAuthenticationConverter.convert(source.getAuthentication()));
stack.setStackStatus(new StackStatus(stack, DetailedStackStatus.PROVISION_REQUESTED));
stack.setCreated(clock.getCurrentTimeMillis());
stack.setInstanceGroups(convertInstanceGroups(source, stack));
Optional<String> parentEnvCloudPlatform = Optional.ofNullable(environment).map(EnvironmentBaseResponse::getParentEnvironmentCloudPlatform);
measure(() -> updateCluster(source, stack, parentEnvCloudPlatform), LOGGER, "Converted cluster and updated the stack in {} ms for stack {}", source.getName());
stack.setGatewayPort(source.getGatewayPort());
stack.setUuid(UUID.randomUUID().toString());
stack.setType(source.getType());
stack.setInputs(Json.silent(new StackInputs(source.getInputs(), new HashMap<>(), new HashMap<>())));
if (source.getImage() != null) {
stack.getComponents().add(getImageComponent(source, stack));
}
if (!isTemplate(source) && environment != null) {
gatewaySecurityGroupDecorator.extendGatewaySecurityGroupWithDefaultGatewayCidrs(stack, environment.getTunnel());
}
stack.setExternalDatabaseCreationType(getIfNotNull(source.getExternalDatabase(), DatabaseRequest::getAvailabilityType));
stack.setExternalDatabaseEngineVersion(getIfNotNull(source.getExternalDatabase(), DatabaseRequest::getDatabaseEngineVersion));
stack.setDomainDnsResolver(targetedUpscaleSupportService.isUnboundEliminationSupported(Crn.safeFromString(source.getEnvironmentCrn()).getAccountId()) ? DnsResolverType.FREEIPA_FOR_ENV : DnsResolverType.LOCAL_UNBOUND);
determineServiceTypeTag(stack, source.getTags());
determineServiceFeatureTag(stack, source.getTags());
Set<LoadBalancer> loadBalancers = loadBalancerConfigService.createLoadBalancers(stack, environment, source);
stack.setLoadBalancers(loadBalancers);
return stack;
}
Aggregations