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