use of com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse in project cloudbreak by hortonworks.
the class GcpEnvironmentNetworkConverter method getAttributesForLegacyNetwork.
@Override
Map<String, Object> getAttributesForLegacyNetwork(EnvironmentNetworkResponse source) {
EnvironmentNetworkGcpParams gcp = source.getGcp();
Map<String, Object> result = new HashMap<>();
if (!Strings.isNullOrEmpty(gcp.getNetworkId())) {
result.put("networkId", gcp.getNetworkId());
}
if (gcp.getNoFirewallRules() != null) {
result.put("noFirewallRules", gcp.getNoFirewallRules());
}
if (gcp.getNoPublicIp() != null) {
result.put("noPublicIp", gcp.getNoPublicIp());
}
if (!Strings.isNullOrEmpty(gcp.getSharedProjectId())) {
result.put("sharedProjectId", gcp.getSharedProjectId());
}
return result;
}
use of com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse in project cloudbreak by hortonworks.
the class EndpointGatewayNetworkValidator method validate.
@Override
public ValidationResult validate(Pair<String, EnvironmentNetworkResponse> subject) {
String baseSubnetId = subject.getLeft();
EnvironmentNetworkResponse network = subject.getRight();
ValidationResultBuilder resultBuilder = ValidationResult.builder();
if (network == null) {
LOGGER.debug("No network provided; public endpoint access gateway is disabled.");
} else {
if (PublicEndpointAccessGateway.ENABLED.equals(network.getPublicEndpointAccessGateway())) {
if (Strings.isNullOrEmpty(baseSubnetId)) {
resultBuilder.error(NO_BASE_SUBNET);
} else {
Optional<CloudSubnet> baseSubnet = subnetSelector.findSubnetById(network.getSubnetMetas(), baseSubnetId);
if (baseSubnet.isEmpty()) {
resultBuilder.error(String.format(NO_BASE_SUBNET_META, baseSubnetId));
} else {
String error;
if (!MapUtils.isEmpty(network.getGatewayEndpointSubnetMetas())) {
LOGGER.debug("Attempting to validate endpoint gateway subnet using provided endpoint subnets.");
error = NO_USABLE_SUBNET_IN_ENDPOINT_GATEWAY;
} else {
LOGGER.debug("Attempting to validate endpoint gateway subnet using cluster subnets.");
error = NO_USABLE_SUBNET_IN_CLUSTER;
}
Optional<CloudSubnet> endpointGatewaySubnet = subnetSelector.chooseSubnetForEndpointGateway(network, baseSubnetId);
resultBuilder.ifError(endpointGatewaySubnet::isEmpty, String.format(error, baseSubnet.get().getAvailabilityZone()));
}
}
}
}
return resultBuilder.build();
}
use of com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse in project cloudbreak by hortonworks.
the class AwsEnvironmentNetworkConverterTest method getAttributesForLegacyNetwork.
@Test
void getAttributesForLegacyNetwork() {
EnvironmentNetworkResponse source = mock(EnvironmentNetworkResponse.class);
EnvironmentNetworkAwsParams aws = mock(EnvironmentNetworkAwsParams.class);
when(source.getAws()).thenReturn(aws);
when(aws.getVpcId()).thenReturn("my_vpc_id");
Map<String, Object> result = converter.getAttributesForLegacyNetwork(source);
assertEquals("my_vpc_id", result.get("vpcId"));
}
use of com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse in project cloudbreak by hortonworks.
the class AzureEnvironmentNetworkConverterTest method testGetAttributesForLegacyNetwork.
@Test
void testGetAttributesForLegacyNetwork() {
EnvironmentNetworkResponse environmentNetworkResponse = mock(EnvironmentNetworkResponse.class);
EnvironmentNetworkAzureParams azure = mock(EnvironmentNetworkAzureParams.class);
when(environmentNetworkResponse.getAzure()).thenReturn(azure);
when(azure.getNetworkId()).thenReturn("my_network_id");
when(azure.getResourceGroupName()).thenReturn("my_resource_group");
when(azure.getNoPublicIp()).thenReturn(true);
Map<String, Object> result = converter.getAttributesForLegacyNetwork(environmentNetworkResponse);
assertEquals("my_network_id", result.get("networkId"));
assertEquals("my_resource_group", result.get("resourceGroupName"));
assertEquals(true, result.get("noPublicIp"));
}
use of com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse in project cloudbreak by hortonworks.
the class EnvironmentBaseNetworkConverterTest method setupResponse.
private EnvironmentNetworkResponse setupResponse() {
EnvironmentNetworkResponse source = new EnvironmentNetworkResponse();
source.setNetworkCidrs(NETWORK_CIDRS);
source.setOutboundInternetTraffic(OutboundInternetTraffic.DISABLED);
return source;
}
Aggregations