Search in sources :

Example 31 with Template

use of com.sequenceiq.freeipa.entity.Template 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)

Example 32 with Template

use of com.sequenceiq.freeipa.entity.Template in project cloudbreak by hortonworks.

the class InstanceGroupToInstanceGroupDetailsConverterTest method createInstanceGroup.

private InstanceGroup createInstanceGroup() {
    InstanceGroup instanceGroup = new InstanceGroup();
    Template template = new Template();
    Map<String, Object> attributes = Map.of("encrypted", Boolean.TRUE, "everything-else", Boolean.TRUE);
    template.setAttributes(new Json(attributes));
    instanceGroup.setTemplate(template);
    return instanceGroup;
}
Also used : Json(com.sequenceiq.cloudbreak.common.json.Json) InstanceGroup(com.sequenceiq.freeipa.entity.InstanceGroup) Template(com.sequenceiq.freeipa.entity.Template)

Example 33 with Template

use of com.sequenceiq.freeipa.entity.Template in project cloudbreak by hortonworks.

the class InstanceTemplateRequestToTemplateConverterTest method shouldSetAwsDefaultVolumeEncryptionWhenCustomEncryptionKeyArnIsAbsent.

@Test
void shouldSetAwsDefaultVolumeEncryptionWhenCustomEncryptionKeyArnIsAbsent() {
    InstanceTemplateRequest source = new InstanceTemplateRequest();
    source.setInstanceType(INSTANCE_TYPE);
    Template result = underTest.convert(source, CLOUD_PLATFORM, ACCOUNT_ID, null, null, null);
    Json attributes = result.getAttributes();
    assertThat(attributes).isNotNull();
    assertThat(attributes.<Object>getValue(AwsInstanceTemplate.EBS_ENCRYPTION_ENABLED)).isEqualTo(Boolean.TRUE);
    assertThat(attributes.<Object>getValue(InstanceTemplate.VOLUME_ENCRYPTION_KEY_TYPE)).isEqualTo(EncryptionType.DEFAULT.name());
}
Also used : InstanceTemplateRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceTemplateRequest) Json(com.sequenceiq.cloudbreak.common.json.Json) AzureInstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.instance.AzureInstanceTemplate) Template(com.sequenceiq.freeipa.entity.Template) AwsInstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.instance.AwsInstanceTemplate) GcpInstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.instance.GcpInstanceTemplate) InstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate) Test(org.junit.jupiter.api.Test)

Example 34 with Template

use of com.sequenceiq.freeipa.entity.Template in project cloudbreak by hortonworks.

the class InstanceTemplateRequestToTemplateConverterTest method shouldSetEncryptionAtHostPropertyWhenAzureAndEncryptionAtHostEnabled.

@Test
void shouldSetEncryptionAtHostPropertyWhenAzureAndEncryptionAtHostEnabled() {
    InstanceTemplateRequest source = new InstanceTemplateRequest();
    source.setInstanceType(INSTANCE_TYPE);
    when(entitlementService.isAzureEncryptionAtHostEnabled(ACCOUNT_ID)).thenReturn(Boolean.TRUE);
    Template result = underTest.convert(source, CloudPlatform.AZURE, ACCOUNT_ID, "dummyDiskEncryptionSet", "", "");
    Json attributes = result.getAttributes();
    assertThat(attributes).isNotNull();
    assertThat(attributes.<Object>getValue(AzureInstanceTemplate.ENCRYPTION_AT_HOST_ENABLED)).isEqualTo(Boolean.TRUE);
}
Also used : InstanceTemplateRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceTemplateRequest) Json(com.sequenceiq.cloudbreak.common.json.Json) AzureInstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.instance.AzureInstanceTemplate) Template(com.sequenceiq.freeipa.entity.Template) AwsInstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.instance.AwsInstanceTemplate) GcpInstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.instance.GcpInstanceTemplate) InstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate) Test(org.junit.jupiter.api.Test)

Example 35 with Template

use of com.sequenceiq.freeipa.entity.Template in project cloudbreak by hortonworks.

the class InstanceTemplateRequestToTemplateConverterTest method shouldSetDefaultInstanceTypeWhenNotProvided.

@Test
void shouldSetDefaultInstanceTypeWhenNotProvided() {
    String defaultInstanceType = "default";
    InstanceTemplateRequest source = new InstanceTemplateRequest();
    when(defaultInstanceTypeProvider.getForPlatform(CLOUD_PLATFORM.name())).thenReturn(defaultInstanceType);
    Template result = underTest.convert(source, CLOUD_PLATFORM, ACCOUNT_ID, null, null, null);
    assertThat(result.getInstanceType()).isEqualTo(defaultInstanceType);
}
Also used : InstanceTemplateRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceTemplateRequest) AzureInstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.instance.AzureInstanceTemplate) Template(com.sequenceiq.freeipa.entity.Template) AwsInstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.instance.AwsInstanceTemplate) GcpInstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.instance.GcpInstanceTemplate) InstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate) Test(org.junit.jupiter.api.Test)

Aggregations

Template (com.sequenceiq.freeipa.entity.Template)44 AwsInstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.instance.AwsInstanceTemplate)33 AzureInstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.instance.AzureInstanceTemplate)31 Test (org.junit.jupiter.api.Test)31 Json (com.sequenceiq.cloudbreak.common.json.Json)27 InstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate)26 InstanceTemplateRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceTemplateRequest)21 InstanceGroup (com.sequenceiq.freeipa.entity.InstanceGroup)19 GcpInstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.instance.GcpInstanceTemplate)16 Stack (com.sequenceiq.freeipa.entity.Stack)13 FreeIpaServerRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.FreeIpaServerRequest)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 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)8 InstanceMetaData (com.sequenceiq.freeipa.entity.InstanceMetaData)7 HashMap (java.util.HashMap)6 JSONObject (net.sf.json.JSONObject)6 CloudInstance (com.sequenceiq.cloudbreak.cloud.model.CloudInstance)4 ImageEntity (com.sequenceiq.freeipa.entity.ImageEntity)3 InstanceGroupNetwork (com.sequenceiq.freeipa.entity.InstanceGroupNetwork)3