Search in sources :

Example 6 with FreeIpaServerRequest

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.FreeIpaServerRequest in project cloudbreak by hortonworks.

the class InstanceGroupRequestToInstanceGroupConverterTest method convertTestTemplateConversionWithDiskEncryptionSetId.

@Test
void convertTestTemplateConversionWithDiskEncryptionSetId() {
    InstanceGroupRequest request = new InstanceGroupRequest();
    Stack stack = new Stack();
    stack.setAccountId(ACCOUNT_ID);
    stack.setCloudPlatform(AZURE.name());
    stack.setName(NAME);
    FreeIpaServerRequest freeIpaServerRequest = new FreeIpaServerRequest();
    freeIpaServerRequest.setHostname(HOSTNAME);
    freeIpaServerRequest.setDomain(DOMAINNAME);
    NetworkRequest networkRequest = new NetworkRequest();
    DetailedEnvironmentResponse detailedEnvironmentResponse = new DetailedEnvironmentResponse();
    InstanceTemplateRequest instanceTemplateRequest = mock(InstanceTemplateRequest.class);
    request.setInstanceTemplateRequest(instanceTemplateRequest);
    Template template = new Template();
    Map<String, Object> json = new HashMap<>();
    json.put(AzureInstanceTemplate.DISK_ENCRYPTION_SET_ID, "dummyDiskEncryptionSetId");
    json.put(AzureInstanceTemplate.MANAGED_DISK_ENCRYPTION_WITH_CUSTOM_KEY_ENABLED, Boolean.TRUE);
    template.setAttributes(new Json(json));
    when(templateConverter.convert(instanceTemplateRequest, AZURE, ACCOUNT_ID, "dummyDiskEncryptionSetId", null, null)).thenReturn(template);
    InstanceGroup result = underTest.convert(request, networkRequest, ACCOUNT_ID, stack, freeIpaServerRequest, detailedEnvironmentResponse, createAndGetCloudArgsForIgCoverterMap("dummyDiskEncryptionSetId", null, null));
    assertThat(result).isNotNull();
    assertThat(result.getTemplate()).isSameAs(template);
}
Also used : InstanceGroupRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupRequest) HashMap(java.util.HashMap) NetworkRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.NetworkRequest) Json(com.sequenceiq.cloudbreak.common.json.Json) Stack(com.sequenceiq.freeipa.entity.Stack) Template(com.sequenceiq.freeipa.entity.Template) AzureInstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.instance.AzureInstanceTemplate) AwsInstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.instance.AwsInstanceTemplate) InstanceGroup(com.sequenceiq.freeipa.entity.InstanceGroup) InstanceTemplateRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceTemplateRequest) 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 7 with FreeIpaServerRequest

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.FreeIpaServerRequest in project cloudbreak by hortonworks.

the class InstanceGroupRequestToInstanceGroupConverterTest method convertTestDefaultTemplateConversionWithGcpEncryptionKey.

@Test
void convertTestDefaultTemplateConversionWithGcpEncryptionKey() {
    InstanceGroupRequest request = new InstanceGroupRequest();
    InstanceTemplateRequest instanceTemplateRequest = mock(InstanceTemplateRequest.class);
    request.setInstanceTemplateRequest(instanceTemplateRequest);
    Template template = mock(Template.class);
    Stack stack = new Stack();
    stack.setAccountId(ACCOUNT_ID);
    stack.setCloudPlatform(MOCK.name());
    stack.setName(NAME);
    FreeIpaServerRequest freeIpaServerRequest = new FreeIpaServerRequest();
    freeIpaServerRequest.setHostname(HOSTNAME);
    freeIpaServerRequest.setDomain(DOMAINNAME);
    NetworkRequest networkRequest = new NetworkRequest();
    DetailedEnvironmentResponse detailedEnvironmentResponse = new DetailedEnvironmentResponse();
    when(templateConverter.convert(instanceTemplateRequest, MOCK, ACCOUNT_ID, null, "dummyEncryptionKey", null)).thenReturn(template);
    InstanceGroup result = underTest.convert(request, networkRequest, ACCOUNT_ID, stack, freeIpaServerRequest, detailedEnvironmentResponse, createAndGetCloudArgsForIgCoverterMap(null, "dummyEncryptionKey", null));
    assertThat(result).isNotNull();
    assertThat(result.getTemplate()).isSameAs(template);
}
Also used : InstanceGroupRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupRequest) InstanceTemplateRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceTemplateRequest) NetworkRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.NetworkRequest) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) FreeIpaServerRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.FreeIpaServerRequest) Template(com.sequenceiq.freeipa.entity.Template) AzureInstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.instance.AzureInstanceTemplate) AwsInstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.instance.AwsInstanceTemplate) Stack(com.sequenceiq.freeipa.entity.Stack) InstanceGroup(com.sequenceiq.freeipa.entity.InstanceGroup) Test(org.junit.jupiter.api.Test)

Example 8 with FreeIpaServerRequest

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.FreeIpaServerRequest in project cloudbreak by hortonworks.

the class FreeIpaCreationHandler method createFreeIpaRequest.

private CreateFreeIpaRequest createFreeIpaRequest(EnvironmentDto environment) {
    boolean multiAzRequired = environment.getFreeIpaCreation().isEnableMultiAz();
    CreateFreeIpaRequest createFreeIpaRequest = new CreateFreeIpaRequest();
    createFreeIpaRequest.setEnvironmentCrn(environment.getResourceCrn());
    createFreeIpaRequest.setName(environment.getName() + "-freeipa");
    FreeIpaServerRequest freeIpaServerRequest = freeIpaServerRequestProvider.create(environment);
    createFreeIpaRequest.setFreeIpa(freeIpaServerRequest);
    setPlacementAndNetwork(environment, createFreeIpaRequest, multiAzRequired);
    setAuthentication(environment.getAuthentication(), createFreeIpaRequest);
    setTelemetry(environment, createFreeIpaRequest);
    setBackup(environment, createFreeIpaRequest);
    setTags(environment, createFreeIpaRequest);
    setImage(environment, createFreeIpaRequest);
    SecurityGroupRequest securityGroupRequest = null;
    if (environment.getSecurityAccess() != null) {
        securityGroupRequest = createSecurityGroupRequest(environment.getSecurityAccess());
    }
    createFreeIpaRequest.setInstanceGroups(createInstanceGroupRequests(createFreeIpaRequest, securityGroupRequest, environment, multiAzRequired));
    setVariant(environment, createFreeIpaRequest, multiAzRequired);
    setUseCcm(environment.getExperimentalFeatures().getTunnel(), createFreeIpaRequest);
    return createFreeIpaRequest;
}
Also used : CreateFreeIpaRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest) SecurityGroupRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.security.SecurityGroupRequest) FreeIpaServerRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.FreeIpaServerRequest)

Example 9 with FreeIpaServerRequest

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.FreeIpaServerRequest in project cloudbreak by hortonworks.

the class FreeIpaServerRequestProvider method create.

FreeIpaServerRequest create(EnvironmentDto environment) {
    String domain = environment.getDomain();
    LOGGER.info("Creating FreeIPA request for environment: '{}' with domain: '{}'", environment.getName(), domain);
    String adminGroupName = environment.getAdminGroupName();
    FreeIpaServerRequest freeIpaServerRequest = new FreeIpaServerRequest();
    freeIpaServerRequest.setAdminPassword(FreeIpaPasswordUtil.generatePassword());
    freeIpaServerRequest.setDomain(domain);
    freeIpaServerRequest.setHostname(FREEIPA_HOSTNAME);
    freeIpaServerRequest.setAdminGroupName(adminGroupName);
    LOGGER.info("FreeIpaServerRequest created for environment: {}, request {}", environment.getName(), freeIpaServerRequest);
    return freeIpaServerRequest;
}
Also used : FreeIpaServerRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.FreeIpaServerRequest)

Example 10 with FreeIpaServerRequest

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.FreeIpaServerRequest in project cloudbreak by hortonworks.

the class InstanceGroupRequestToInstanceGroupConverterTest method testConvertWithNullTemplate.

@Test
public void testConvertWithNullTemplate() {
    int nodeCount = 2;
    InstanceGroupRequest request = new InstanceGroupRequest();
    request.setName(NAME);
    request.setType(InstanceGroupType.MASTER);
    request.setNodeCount(nodeCount);
    Template template = mock(Template.class);
    SecurityGroupRequest securityGroupRequest = mock(SecurityGroupRequest.class);
    SecurityGroup securityGroup = mock(SecurityGroup.class);
    request.setSecurityGroup(securityGroupRequest);
    Stack stack = new Stack();
    stack.setAccountId(ACCOUNT_ID);
    stack.setCloudPlatform(MOCK.name());
    stack.setName(NAME);
    FreeIpaServerRequest freeIpaServerRequest = new FreeIpaServerRequest();
    freeIpaServerRequest.setHostname(HOSTNAME);
    freeIpaServerRequest.setDomain(DOMAINNAME);
    NetworkRequest networkRequest = new NetworkRequest();
    DetailedEnvironmentResponse detailedEnvironmentResponse = new DetailedEnvironmentResponse();
    // GIVEN
    given(defaultInstanceGroupProvider.createDefaultTemplate(eq(MOCK), eq(ACCOUNT_ID), eq(null), eq(null), eq(null))).willReturn(template);
    given(securityGroupConverter.convert(eq(securityGroupRequest))).willReturn(securityGroup);
    // WHEN
    InstanceGroup result = underTest.convert(request, networkRequest, ACCOUNT_ID, stack, freeIpaServerRequest, detailedEnvironmentResponse, createAndGetCloudArgsForIgCoverterMap(null, null, null));
    // THEN
    assertThat(result).isNotNull();
    assertThat(result.getGroupName()).isEqualTo(NAME);
    assertThat(result.getInstanceGroupType()).isEqualTo(InstanceGroupType.MASTER);
    assertThat(result.getSecurityGroup()).isEqualTo(securityGroup);
    assertThat(result.getNodeCount()).isEqualTo(nodeCount);
    assertThat(result.getInstanceMetaData().size()).isEqualTo(nodeCount);
    int i = 0;
    for (InstanceMetaData instanceMetaData : result.getInstanceMetaData()) {
        assertThat(instanceMetaData.getInstanceGroup()).isEqualTo(result);
        assertThat(instanceMetaData.getDiscoveryFQDN()).startsWith(HOSTNAME + i);
        i++;
    }
}
Also used : InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) InstanceGroupRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupRequest) SecurityGroupRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.security.SecurityGroupRequest) NetworkRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.NetworkRequest) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) SecurityGroup(com.sequenceiq.freeipa.entity.SecurityGroup) FreeIpaServerRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.FreeIpaServerRequest) Template(com.sequenceiq.freeipa.entity.Template) AzureInstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.instance.AzureInstanceTemplate) AwsInstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.instance.AwsInstanceTemplate) Stack(com.sequenceiq.freeipa.entity.Stack) InstanceGroup(com.sequenceiq.freeipa.entity.InstanceGroup) Test(org.junit.jupiter.api.Test)

Aggregations

FreeIpaServerRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.FreeIpaServerRequest)16 InstanceGroupRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupRequest)11 Test (org.junit.jupiter.api.Test)11 NetworkRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.NetworkRequest)10 InstanceGroup (com.sequenceiq.freeipa.entity.InstanceGroup)10 Stack (com.sequenceiq.freeipa.entity.Stack)10 AwsInstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.instance.AwsInstanceTemplate)9 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)9 Template (com.sequenceiq.freeipa.entity.Template)9 AzureInstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.instance.AzureInstanceTemplate)8 InstanceTemplateRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceTemplateRequest)6 Json (com.sequenceiq.cloudbreak.common.json.Json)5 CreateFreeIpaRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest)4 HashMap (java.util.HashMap)4 TelemetryRequest (com.sequenceiq.common.api.telemetry.request.TelemetryRequest)3 StackAuthenticationRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.security.StackAuthenticationRequest)3 Telemetry (com.sequenceiq.common.api.telemetry.model.Telemetry)2 Backup (com.sequenceiq.freeipa.api.model.Backup)2 SecurityGroupRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.security.SecurityGroupRequest)2 FreeIpa (com.sequenceiq.freeipa.entity.FreeIpa)2