Search in sources :

Example 36 with Template

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

the class InstanceTemplateRequestToTemplateConverterTest method shouldSetEncryptionKeyAndEncryptionMethodPropertyWhenCustomAwsEncryptionKeyPresent.

@Test
void shouldSetEncryptionKeyAndEncryptionMethodPropertyWhenCustomAwsEncryptionKeyPresent() {
    InstanceTemplateRequest source = new InstanceTemplateRequest();
    source.setInstanceType(INSTANCE_TYPE);
    Template result = underTest.convert(source, CloudPlatform.AWS, ACCOUNT_ID, null, null, "dummyAwsEncryptionKeyArn");
    Json attributes = result.getAttributes();
    assertThat(attributes).isNotNull();
    assertThat(attributes.<Object>getValue(GcpInstanceTemplate.VOLUME_ENCRYPTION_KEY_ID)).isEqualTo("dummyAwsEncryptionKeyArn");
    assertThat(attributes.<Object>getValue(InstanceTemplate.VOLUME_ENCRYPTION_KEY_TYPE)).isEqualTo(EncryptionType.CUSTOM.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 37 with Template

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

the class InstanceTemplateRequestToTemplateConverterTest method shouldSetSpotPercentagePropertyWhenProvided.

@Test
void shouldSetSpotPercentagePropertyWhenProvided() {
    InstanceTemplateRequest source = new InstanceTemplateRequest();
    source.setInstanceType(INSTANCE_TYPE);
    source.setAws(createAwsInstanceTemplateParameters(SPOT_PERCENTAGE, SPOT_MAX_PRICE));
    Template result = underTest.convert(source, CLOUD_PLATFORM, ACCOUNT_ID, null, null, null);
    Json attributes = result.getAttributes();
    assertThat(attributes).isNotNull();
    assertThat(attributes.<Object>getValue(AwsInstanceTemplate.EC2_SPOT_PERCENTAGE)).isEqualTo(SPOT_PERCENTAGE);
    assertThat(attributes.<Object>getValue(AwsInstanceTemplate.EC2_SPOT_MAX_PRICE)).isEqualTo(SPOT_MAX_PRICE);
}
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 38 with Template

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

the class InstanceTemplateRequestToTemplateConverterTest method shouldNotSetVolumeEncryptionWhenAzure.

@Test
void shouldNotSetVolumeEncryptionWhenAzure() {
    InstanceTemplateRequest source = new InstanceTemplateRequest();
    source.setInstanceType(INSTANCE_TYPE);
    Template result = underTest.convert(source, CloudPlatform.AZURE, ACCOUNT_ID, null, null, null);
    Json attributes = result.getAttributes();
    assertThat(attributes).isNotNull();
    assertThat(attributes.<Object>getValue(AwsInstanceTemplate.EBS_ENCRYPTION_ENABLED)).isNull();
    assertThat(attributes.<Object>getValue(InstanceTemplate.VOLUME_ENCRYPTION_KEY_TYPE)).isNull();
}
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 39 with Template

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

the class InstanceTemplateRequestToTemplateConverterTest method shouldSetAccoundIdWhenProvided.

@Test
void shouldSetAccoundIdWhenProvided() {
    InstanceTemplateRequest source = new InstanceTemplateRequest();
    source.setInstanceType(INSTANCE_TYPE);
    Template result = underTest.convert(source, CLOUD_PLATFORM, ACCOUNT_ID, null, null, null);
    assertThat(result.getAccountId()).isEqualTo(ACCOUNT_ID);
}
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)

Example 40 with Template

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

the class DefaultInstanceGroupProviderTest method createDefaultTemplateTestVolumeEncryptionAddedWhenGcp.

@Test
void createDefaultTemplateTestVolumeEncryptionAddedWhenGcp() {
    Template result = underTest.createDefaultTemplate(CloudPlatform.GCP, ACCOUNT_ID, null, "dummyEncryptionKey", null);
    assertThat(result).isNotNull();
    Json attributes = result.getAttributes();
    assertThat(attributes).isNotNull();
    assertThat(attributes.<Object>getValue(AzureInstanceTemplate.VOLUME_ENCRYPTION_KEY_ID)).isEqualTo("dummyEncryptionKey");
    assertThat(attributes.<Object>getValue("keyEncryptionMethod")).isEqualTo("KMS");
}
Also used : JSONObject(net.sf.json.JSONObject) Json(com.sequenceiq.cloudbreak.common.json.Json) Template(com.sequenceiq.freeipa.entity.Template) InstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate) AzureInstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.instance.AzureInstanceTemplate) AwsInstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.instance.AwsInstanceTemplate) 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