Search in sources :

Example 1 with PlacementBase

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.region.PlacementBase in project cloudbreak by hortonworks.

the class CreateFreeIpaRequestToStackConverter method convert.

public Stack convert(CreateFreeIpaRequest source, DetailedEnvironmentResponse environment, String accountId, Future<String> ownerFuture, String userCrn, String cloudPlatform) {
    Stack stack = new Stack();
    stack.setEnvironmentCrn(source.getEnvironmentCrn());
    stack.setAccountId(accountId);
    stack.setName(source.getName());
    stack.setCreated(System.currentTimeMillis());
    stack.setResourceCrn(crnService.createCrn(accountId, CrnResourceDescriptor.FREEIPA));
    MDCBuilder.addResourceCrn(stack.getResourceCrn());
    stack.setGatewayport(source.getGatewayPort() == null ? nginxPort : source.getGatewayPort());
    stack.setStackStatus(new StackStatus(stack, "Stack provision requested.", DetailedStackStatus.PROVISION_REQUESTED));
    stack.setAvailabilityZone(Optional.ofNullable(source.getPlacement()).map(PlacementBase::getAvailabilityZone).orElse(null));
    updateCloudPlatformAndRelatedFields(source, stack, cloudPlatform);
    stack.setStackAuthentication(stackAuthenticationConverter.convert(source.getAuthentication()));
    if (source.getNetwork() != null) {
        source.getNetwork().setCloudPlatform(CloudPlatform.valueOf(cloudPlatform));
        stack.setNetwork(networkConverter.convert(source.getNetwork()));
    }
    stack.setInstanceGroups(convertInstanceGroups(source, stack, environment, accountId));
    stack.setTelemetry(telemetryConverter.convert(source.getTelemetry()));
    if (source.getBackup() != null && isNotEmpty(source.getBackup().getStorageLocation())) {
        stack.setBackup(backupConverter.convert(source.getBackup()));
    } else {
        stack.setBackup(backupConverter.convert(source.getTelemetry()));
    }
    stack.setCdpNodeStatusMonitorUser(UUID.randomUUID().toString());
    stack.setCdpNodeStatusMonitorPassword(PasswordUtil.generatePassword());
    decorateStackWithTunnelAndCcm(stack, source);
    updateOwnerRelatedFields(source, accountId, ownerFuture, userCrn, stack);
    extendGatewaySecurityGroupWithDefaultGatewayCidrs(stack);
    return stack;
}
Also used : DetailedStackStatus(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.DetailedStackStatus) StackStatus(com.sequenceiq.freeipa.entity.StackStatus) PlacementBase(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.region.PlacementBase) Stack(com.sequenceiq.freeipa.entity.Stack)

Aggregations

DetailedStackStatus (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.DetailedStackStatus)1 PlacementBase (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.region.PlacementBase)1 Stack (com.sequenceiq.freeipa.entity.Stack)1 StackStatus (com.sequenceiq.freeipa.entity.StackStatus)1