use of com.sequenceiq.freeipa.entity.InstanceGroup in project cloudbreak by hortonworks.
the class CreateFreeIpaRequestToStackConverterTest method testConvertForInstanceGroupsWhenAwsNativeIsPresent.
@Test
void testConvertForInstanceGroupsWhenAwsNativeIsPresent() {
CreateFreeIpaRequest source = new CreateFreeIpaRequest();
source.setEnvironmentCrn("envCrn");
source.setName("dummyName");
source.setVariant("AWS_NATIVE");
source.setAuthentication(new StackAuthenticationRequest());
source.setTelemetry(new TelemetryRequest());
source.setInstanceGroups(List.of(new InstanceGroupRequest()));
FreeIpaServerRequest freeIpaServerRequest = new FreeIpaServerRequest();
freeIpaServerRequest.setDomain("dummyDomain");
freeIpaServerRequest.setHostname("dummyHostName");
source.setNetwork(new NetworkRequest());
source.setFreeIpa(freeIpaServerRequest);
DetailedEnvironmentResponse environmentResponse = new DetailedEnvironmentResponse();
environmentResponse.setAws(AwsEnvironmentParameters.builder().withAwsDiskEncryptionParameters(AwsDiskEncryptionParameters.builder().withEncryptionKeyArn("dummyEncryptionKeyArn").build()).build());
Future<String> owner = CompletableFuture.completedFuture("dummyUser");
when(crnService.createCrn(ACCOUNT_ID, CrnResourceDescriptor.FREEIPA)).thenReturn("resourceCrn");
when(stackAuthenticationConverter.convert(source.getAuthentication())).thenReturn(new StackAuthentication());
when(instanceGroupConverter.convert(any(), any(), any(), any(), any(), any(), mapCaptorForEncryption.capture())).thenReturn(new InstanceGroup());
when(networkConverter.convert(any(NetworkRequest.class))).thenReturn(new Network());
when(telemetryConverter.convert(source.getTelemetry())).thenReturn(new Telemetry());
when(backupConverter.convert(source.getTelemetry())).thenReturn(new Backup());
when(entitlementService.internalTenant(ACCOUNT_ID)).thenReturn(Boolean.FALSE);
when(costTagging.prepareDefaultTags(any())).thenReturn(new HashMap<>());
Stack stack = underTest.convert(source, environmentResponse, ACCOUNT_ID, owner, "crn1", CloudPlatform.AWS.name());
assertEquals(stack.getPlatformvariant(), "AWS_NATIVE");
assertNull(mapCaptorForEncryption.getValue().get(GCP_KMS_ENCRYPTION_KEY));
assertNull(mapCaptorForEncryption.getValue().get(DISK_ENCRYPTION_SET_ID));
}
use of com.sequenceiq.freeipa.entity.InstanceGroup in project cloudbreak by hortonworks.
the class PrivateIdProviderTest method createInstanceGroup.
private Set<InstanceGroup> createInstanceGroup(Set<Long> ids) {
Set<InstanceMetaData> instanceMetaDataSet = ids.stream().map(id -> {
InstanceMetaData im = mock(InstanceMetaData.class);
when(im.getPrivateId()).thenReturn(id);
return im;
}).collect(Collectors.toSet());
InstanceGroup ig = mock(InstanceGroup.class);
when(ig.getAllInstanceMetaData()).thenReturn(instanceMetaDataSet);
return Set.of(ig);
}
use of com.sequenceiq.freeipa.entity.InstanceGroup in project cloudbreak by hortonworks.
the class FreeIpaStackHealthDetailsServiceTest method getStack.
private Stack getStack() {
Stack stack = new Stack();
stack.setResourceCrn(ENVIRONMENT_ID);
InstanceGroup instanceGroup = new InstanceGroup();
stack.getInstanceGroups().add(instanceGroup);
instanceGroup.setInstanceGroupType(InstanceGroupType.MASTER);
InstanceMetaData instanceMetaData = new InstanceMetaData();
instanceMetaData.setInstanceId(INSTANCE_ID1);
instanceMetaData.setDiscoveryFQDN(HOST1);
instanceMetaData.setInstanceStatus(InstanceStatus.CREATED);
instanceGroup.setInstanceMetaData(Sets.newHashSet(instanceMetaData));
return stack;
}
use of com.sequenceiq.freeipa.entity.InstanceGroup in project cloudbreak by hortonworks.
the class FreeIpaCreationService method fillInstanceMetadata.
private void fillInstanceMetadata(Stack stack, DetailedEnvironmentResponse environment) {
long privateIdNumber = 0;
for (InstanceGroup instanceGroup : stack.getInstanceGroups()) {
for (InstanceMetaData instanceMetaData : instanceGroup.getAllInstanceMetaData()) {
instanceMetaData.setPrivateId(privateIdNumber++);
instanceMetaData.setInstanceStatus(InstanceStatus.REQUESTED);
}
multiAzCalculatorService.calculateByRoundRobin(multiAzCalculatorService.prepareSubnetAzMap(environment), instanceGroup);
}
}
use of com.sequenceiq.freeipa.entity.InstanceGroup in project cloudbreak by hortonworks.
the class NetworkService method collectSubnetIdsFromStack.
private Set<String> collectSubnetIdsFromStack(Stack stack) {
Set<String> subnetIds = new HashSet<>();
for (InstanceGroup instanceGroup : stack.getInstanceGroups()) {
InstanceGroupNetwork instanceGroupNetwork = instanceGroup.getInstanceGroupNetwork();
if (instanceGroupNetwork != null && instanceGroupNetwork.getAttributes() != null) {
Map<String, Object> map = instanceGroupNetwork.getAttributes().getMap();
subnetIds.addAll((List<String>) map.getOrDefault(NetworkConstants.SUBNET_IDS, new ArrayList<>()));
}
}
return subnetIds;
}
Aggregations