Search in sources :

Example 11 with NetworkRequest

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.NetworkRequest 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 12 with NetworkRequest

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.NetworkRequest in project cloudbreak by hortonworks.

the class FreeIpaMockNetworkProvider method network.

@Override
public NetworkRequest network(EnvironmentDto environment, boolean multiAzRequired) {
    NetworkDto network = environment.getNetwork();
    NetworkRequest networkRequest = new NetworkRequest();
    MockParams mockParam = network.getMock();
    MockNetworkParameters mockNetworkParameters = new MockNetworkParameters();
    networkRequest.setNetworkCidrs(collectNetworkCidrs(network));
    networkRequest.setOutboundInternetTraffic(network.getOutboundInternetTraffic());
    mockNetworkParameters.setVpcId(mockParam.getVpcId());
    if (!multiAzRequired) {
        ProvidedSubnetIds providedSubnetIds = subnetIdProvider.subnets(environment.getNetwork(), environment.getExperimentalFeatures().getTunnel(), CloudPlatform.MOCK, multiAzRequired);
        mockNetworkParameters.setSubnetId(providedSubnetIds.getSubnetId());
    }
    networkRequest.setMock(mockNetworkParameters);
    return networkRequest;
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) MockParams(com.sequenceiq.environment.network.dto.MockParams) ProvidedSubnetIds(com.sequenceiq.environment.network.service.domain.ProvidedSubnetIds) MockNetworkParameters(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.MockNetworkParameters) NetworkRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.NetworkRequest)

Example 13 with NetworkRequest

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.NetworkRequest 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)

Example 14 with NetworkRequest

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.NetworkRequest in project cloudbreak by hortonworks.

the class InstanceGroupRequestToInstanceGroupConverterTest method convertTestTemplateConversion.

@Test
void convertTestTemplateConversion() {
    InstanceGroupRequest request = new InstanceGroupRequest();
    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();
    InstanceTemplateRequest instanceTemplateRequest = mock(InstanceTemplateRequest.class);
    request.setInstanceTemplateRequest(instanceTemplateRequest);
    Template template = mock(Template.class);
    when(templateConverter.convert(instanceTemplateRequest, MOCK, ACCOUNT_ID, "dummyDiskEncryptionSetId", "encryptionKey", "awsEncryptionKeyArn")).thenReturn(template);
    InstanceGroup result = underTest.convert(request, networkRequest, ACCOUNT_ID, stack, freeIpaServerRequest, detailedEnvironmentResponse, createAndGetCloudArgsForIgCoverterMap("dummyDiskEncryptionSetId", "encryptionKey", "awsEncryptionKeyArn"));
    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) 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) Test(org.junit.jupiter.api.Test)

Example 15 with NetworkRequest

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.NetworkRequest in project cloudbreak by hortonworks.

the class InstanceGroupRequestToInstanceGroupConverterTest method convertTestTemplateConversionWithAwsEncryptionKey.

@Test
void convertTestTemplateConversionWithAwsEncryptionKey() {
    InstanceGroupRequest request = new InstanceGroupRequest();
    Stack stack = new Stack();
    stack.setAccountId(ACCOUNT_ID);
    stack.setCloudPlatform(AWS.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(AwsInstanceTemplate.VOLUME_ENCRYPTION_KEY_ID, "dummyAwsDiskEncryptionKeyArn");
    json.put(AwsInstanceTemplate.VOLUME_ENCRYPTION_KEY_TYPE, EncryptionType.CUSTOM);
    template.setAttributes(new Json(json));
    when(templateConverter.convert(instanceTemplateRequest, AWS, ACCOUNT_ID, null, null, "dummyAwsDiskEncryptionKeyArn")).thenReturn(template);
    InstanceGroup result = underTest.convert(request, networkRequest, ACCOUNT_ID, stack, freeIpaServerRequest, detailedEnvironmentResponse, createAndGetCloudArgsForIgCoverterMap(null, null, "dummyAwsDiskEncryptionKeyArn"));
    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)

Aggregations

NetworkRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.NetworkRequest)21 Test (org.junit.jupiter.api.Test)11 FreeIpaServerRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.FreeIpaServerRequest)10 InstanceGroupRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupRequest)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 Json (com.sequenceiq.cloudbreak.common.json.Json)6 InstanceTemplateRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceTemplateRequest)6 NetworkDto (com.sequenceiq.environment.network.dto.NetworkDto)4 AwsNetworkParameters (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.AwsNetworkParameters)4 HashMap (java.util.HashMap)4 ProvidedSubnetIds (com.sequenceiq.environment.network.service.domain.ProvidedSubnetIds)3 InstanceGroupNetworkRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupNetworkRequest)3 AzureNetworkParameters (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.AzureNetworkParameters)3 MockNetworkParameters (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.MockNetworkParameters)3 Telemetry (com.sequenceiq.common.api.telemetry.model.Telemetry)2