Search in sources :

Example 6 with Template

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

the class DefaultInstanceGroupProviderTest method createDefaultTemplateTestVolumeEncryptionAddedWhenAzureAndEncryptionAtHostEnabled.

@Test
void createDefaultTemplateTestVolumeEncryptionAddedWhenAzureAndEncryptionAtHostEnabled() {
    when(entitlementService.isAzureEncryptionAtHostEnabled(ACCOUNT_ID)).thenReturn(Boolean.TRUE);
    Template result = underTest.createDefaultTemplate(CloudPlatform.AZURE, ACCOUNT_ID, "dummyDiskEncryptionSet", null, null);
    assertThat(result).isNotNull();
    Json attributes = result.getAttributes();
    assertThat(attributes).isNotNull();
    assertThat(attributes.<Object>getValue(AzureInstanceTemplate.DISK_ENCRYPTION_SET_ID)).isEqualTo("dummyDiskEncryptionSet");
    assertThat(attributes.<Object>getValue(AzureInstanceTemplate.MANAGED_DISK_ENCRYPTION_WITH_CUSTOM_KEY_ENABLED)).isEqualTo(Boolean.TRUE);
    assertThat(attributes.<Object>getValue(AzureInstanceTemplate.ENCRYPTION_AT_HOST_ENABLED)).isEqualTo(Boolean.TRUE);
}
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)

Example 7 with Template

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

the class FreeIpaNodeUtilServiceTest method before.

@BeforeEach
void before() {
    Template template = new Template();
    template.setInstanceType(INSTANCE_TYPE);
    InstanceGroup ig = new InstanceGroup();
    ig.setTemplate(template);
    ig.setGroupName(GROUP_NAME);
    im = new InstanceMetaData();
    im.setPrivateIp(PRIVATE_IP);
    im.setInstanceId(INSTANCE_ID);
    im.setInstanceGroup(ig);
    im.setDiscoveryFQDN(FQDN);
}
Also used : InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) Template(com.sequenceiq.freeipa.entity.Template) InstanceGroup(com.sequenceiq.freeipa.entity.InstanceGroup) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 8 with Template

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

the class TelemetryAgentServiceTest method createInstanceMetadataSet.

private Set<InstanceMetaData> createInstanceMetadataSet() {
    Set<InstanceMetaData> instanceMetaDataSet = new HashSet<>();
    InstanceMetaData instanceMetaData = new InstanceMetaData();
    instanceMetaData.setId(1L);
    InstanceGroup instanceGroup = new InstanceGroup();
    Template template = new Template();
    instanceGroup.setTemplate(template);
    instanceMetaData.setInstanceGroup(instanceGroup);
    instanceMetaDataSet.add(instanceMetaData);
    return instanceMetaDataSet;
}
Also used : InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) HashSet(java.util.HashSet) InstanceGroup(com.sequenceiq.freeipa.entity.InstanceGroup) Template(com.sequenceiq.freeipa.entity.Template)

Example 9 with Template

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

the class RemoveHostsHandlerTest method testSendsSuccessMessageWhenRemovingHostAndIPAddressIsReusedAfterRepair.

@Test
void testSendsSuccessMessageWhenRemovingHostAndIPAddressIsReusedAfterRepair() throws Exception {
    CleanupEvent cleanupEvent = new CleanupEvent(STACK_ID, USERS, Set.of("example1.com"), ROLES, IPS, STATES_TO_SKIP, ACCOUNT_ID, OPERATION_ID, CLUSTER_NAME, ENVIRONMENT_CRN);
    RemoveHostsFromOrchestrationRequest request = new RemoveHostsFromOrchestrationRequest(cleanupEvent);
    Stack stack = new Stack();
    when(stackService.getByIdWithListsInTransaction(any())).thenReturn(stack);
    InstanceGroup ig = new InstanceGroup();
    ig.setGroupName("group");
    Template t = new Template();
    t.setInstanceType("GATEWAY");
    ig.setTemplate(t);
    InstanceMetaData im1 = new InstanceMetaData();
    im1.setDiscoveryFQDN("example1.com");
    im1.setPrivateIp("192.168.0.1");
    im1.setInstanceId("i-1");
    im1.setInstanceGroup(ig);
    InstanceMetaData im2 = new InstanceMetaData();
    im2.setDiscoveryFQDN("example2.com");
    im2.setPrivateIp("192.168.0.2");
    im2.setInstanceId("i-2");
    im2.setInstanceGroup(ig);
    InstanceMetaData im3 = new InstanceMetaData();
    im3.setDiscoveryFQDN("example3.com");
    im3.setPrivateIp("192.168.0.1");
    im3.setInstanceId("i-3");
    im3.setInstanceGroup(ig);
    ig.setInstanceMetaData(Set.of(im1, im2, im3));
    stack.setInstanceGroups(Set.of(ig));
    underTest.accept(new Event<>(request));
    verify(eventBus, times(1)).notify(eq("REMOVEHOSTSFROMORCHESTRATIONSUCCESS"), ArgumentMatchers.<Event>any());
    verify(bootstrapService).bootstrap(any(), any());
    verify(hostOrchestrator).tearDown(any(), any(), eq(Map.of("example1.com", "192.168.0.1")), any(), any());
}
Also used : InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) CleanupEvent(com.sequenceiq.freeipa.flow.freeipa.cleanup.CleanupEvent) RemoveHostsFromOrchestrationRequest(com.sequenceiq.freeipa.flow.freeipa.downscale.event.removehosts.RemoveHostsFromOrchestrationRequest) Stack(com.sequenceiq.freeipa.entity.Stack) InstanceGroup(com.sequenceiq.freeipa.entity.InstanceGroup) Template(com.sequenceiq.freeipa.entity.Template) Test(org.junit.jupiter.api.Test)

Example 10 with Template

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

the class InstanceTemplateRequestToTemplateConverterTest method shouldSetEncryptionKeyAndEncryptionMethodPropertyWhenGcpEncryptionKeyPresent.

@Test
void shouldSetEncryptionKeyAndEncryptionMethodPropertyWhenGcpEncryptionKeyPresent() {
    InstanceTemplateRequest source = new InstanceTemplateRequest();
    source.setInstanceType(INSTANCE_TYPE);
    Template result = underTest.convert(source, CloudPlatform.GCP, ACCOUNT_ID, null, "dummyEncryptionKey", null);
    Json attributes = result.getAttributes();
    assertThat(attributes).isNotNull();
    assertThat(attributes.<Object>getValue(GcpInstanceTemplate.VOLUME_ENCRYPTION_KEY_ID)).isEqualTo("dummyEncryptionKey");
    assertThat(attributes.<Object>getValue("keyEncryptionMethod")).isEqualTo("KMS");
}
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)

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