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;
}
Aggregations