use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest in project cloudbreak by hortonworks.
the class FreeIpaCreationHandler method createInstanceGroupRequests.
private List<InstanceGroupRequest> createInstanceGroupRequests(CreateFreeIpaRequest createFreeIpaRequest, SecurityGroupRequest securityGroupRequest, EnvironmentDto environment, boolean multiAzRequired) {
List<InstanceGroupRequest> instanceGroupRequests = new LinkedList<>();
FreeIpaCreationDto freeIpaCreation = environment.getFreeIpaCreation();
InstanceGroupRequest instanceGroupRequest = new InstanceGroupRequest();
instanceGroupRequest.setName(MASTER_GROUP_NAME);
instanceGroupRequest.setNodeCount(freeIpaCreation.getInstanceCountByGroup());
instanceGroupRequest.setType(InstanceGroupType.MASTER);
instanceGroupRequest.setSecurityGroup(securityGroupRequest);
instanceGroupRequest.setInstanceTemplateRequest(createInstanceTemplate(freeIpaCreation));
if (multiAzRequired && multiAzValidator.suportedMultiAzForEnvironment(environment.getCloudPlatform())) {
FreeIpaNetworkProvider freeIpaNetworkProvider = freeIpaNetworkProviderMapByCloudPlatform.get(CloudPlatform.valueOf(environment.getCloudPlatform()));
if (freeIpaNetworkProvider != null) {
InstanceGroupNetworkRequest instanceGroupNetworkRequest = freeIpaNetworkProvider.networkByGroup(environment);
instanceGroupRequest.setNetwork(instanceGroupNetworkRequest);
createFreeIpaRequest.getPlacement().setAvailabilityZone(freeIpaNetworkProvider.availabilityZone(instanceGroupNetworkRequest, environment));
}
}
instanceGroupRequests.add(instanceGroupRequest);
return instanceGroupRequests;
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest 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;
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest in project cloudbreak by hortonworks.
the class CreateFreeIpaRequestValidatorTest method validateShouldContainErrorsWhenThereAreZeroNodes.
@Test
void validateShouldContainErrorsWhenThereAreZeroNodes() {
CreateFreeIpaRequest request = new CreateFreeIpaRequest();
InstanceGroupRequest instanceGroupRequest = new InstanceGroupRequest();
instanceGroupRequest.setNodeCount(0);
request.setInstanceGroups(List.of(instanceGroupRequest));
ValidationResult result = underTest.validate(request);
assertThat(result.hasError()).isTrue();
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest in project cloudbreak by hortonworks.
the class CreateFreeIpaRequestValidatorTest method validateShouldNotContainErrors.
@Test
void validateShouldNotContainErrors() {
CreateFreeIpaRequest request = new CreateFreeIpaRequest();
InstanceGroupRequest instanceGroupRequest = new InstanceGroupRequest();
instanceGroupRequest.setNodeCount(1);
request.setInstanceGroups(List.of(instanceGroupRequest));
ValidationResult result = underTest.validate(request);
assertThat(result.hasError()).isFalse();
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest in project cloudbreak by hortonworks.
the class CreateFreeIpaRequestValidatorTest method validateShouldNotContainErrorsForHA.
@Test
void validateShouldNotContainErrorsForHA() {
CreateFreeIpaRequest request = new CreateFreeIpaRequest();
InstanceGroupRequest instanceGroupRequest = new InstanceGroupRequest();
instanceGroupRequest.setNodeCount(2);
request.setInstanceGroups(List.of(instanceGroupRequest));
ValidationResult result = underTest.validate(request);
assertThat(result.hasError()).isFalse();
}
Aggregations