Search in sources :

Example 56 with InstanceGroup

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));
}
Also used : StackAuthenticationRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.security.StackAuthenticationRequest) StackAuthentication(com.sequenceiq.freeipa.entity.StackAuthentication) InstanceGroupRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupRequest) CreateFreeIpaRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest) Backup(com.sequenceiq.freeipa.api.model.Backup) NetworkRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.NetworkRequest) Telemetry(com.sequenceiq.common.api.telemetry.model.Telemetry) InstanceGroup(com.sequenceiq.freeipa.entity.InstanceGroup) Stack(com.sequenceiq.freeipa.entity.Stack) TelemetryRequest(com.sequenceiq.common.api.telemetry.request.TelemetryRequest) Network(com.sequenceiq.freeipa.entity.Network) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) FreeIpaServerRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.FreeIpaServerRequest) Test(org.junit.jupiter.api.Test)

Example 57 with InstanceGroup

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);
}
Also used : InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) Test(org.junit.jupiter.api.Test) InstanceGroup(com.sequenceiq.freeipa.entity.InstanceGroup) Set(java.util.Set) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Mockito.when(org.mockito.Mockito.when) Collectors(java.util.stream.Collectors) Mockito.mock(org.mockito.Mockito.mock) InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) InstanceGroup(com.sequenceiq.freeipa.entity.InstanceGroup)

Example 58 with InstanceGroup

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;
}
Also used : InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) Stack(com.sequenceiq.freeipa.entity.Stack) InstanceGroup(com.sequenceiq.freeipa.entity.InstanceGroup)

Example 59 with InstanceGroup

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);
    }
}
Also used : InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) InstanceGroup(com.sequenceiq.freeipa.entity.InstanceGroup)

Example 60 with 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;
}
Also used : InstanceGroupNetwork(com.sequenceiq.freeipa.entity.InstanceGroupNetwork) HashSet(java.util.HashSet) InstanceGroup(com.sequenceiq.freeipa.entity.InstanceGroup)

Aggregations

InstanceGroup (com.sequenceiq.freeipa.entity.InstanceGroup)60 Stack (com.sequenceiq.freeipa.entity.Stack)32 InstanceMetaData (com.sequenceiq.freeipa.entity.InstanceMetaData)31 Test (org.junit.jupiter.api.Test)30 Template (com.sequenceiq.freeipa.entity.Template)18 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)16 FreeIpaServerRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.FreeIpaServerRequest)11 Json (com.sequenceiq.cloudbreak.common.json.Json)10 InstanceGroupRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupRequest)10 NetworkRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.NetworkRequest)10 CloudInstance (com.sequenceiq.cloudbreak.cloud.model.CloudInstance)9 AwsInstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.instance.AwsInstanceTemplate)9 InstanceGroupNetwork (com.sequenceiq.freeipa.entity.InstanceGroupNetwork)9 HashSet (java.util.HashSet)9 AzureInstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.instance.AzureInstanceTemplate)8 FreeIpa (com.sequenceiq.freeipa.entity.FreeIpa)7 InstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate)6 InstanceTemplateRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceTemplateRequest)6 HashMap (java.util.HashMap)6 CreateFreeIpaRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest)5