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);
}
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);
}
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;
}
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;
}
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++;
}
}
Aggregations