Search in sources :

Example 1 with Tunnel

use of com.sequenceiq.common.api.type.Tunnel in project cloudbreak by hortonworks.

the class SubnetIdProviderTest method testProvideThenNetworkSelectorCalled.

@Test
void testProvideThenNetworkSelectorCalled() {
    NetworkDto networkDto = NetworkDto.builder().withCbSubnets(Map.of("AZ-a", new CloudSubnet())).withSubnetMetas(Map.of("AZ-a", new CloudSubnet())).build();
    NetworkConnector networkConnector = setupConnectorWithSelectionResult(List.of(new CloudSubnet("id", "name")));
    Tunnel tunnel = Tunnel.DIRECT;
    ProvidedSubnetIds providedSubnetIds = underTest.subnets(networkDto, tunnel, CloudPlatform.AWS, false);
    assertEquals("id", providedSubnetIds.getSubnetId());
    ArgumentCaptor<SubnetSelectionParameters> subnetSelectionParametersCaptor = ArgumentCaptor.forClass(SubnetSelectionParameters.class);
    verify(networkConnector).chooseSubnets(any(), subnetSelectionParametersCaptor.capture());
    assertFalse(subnetSelectionParametersCaptor.getValue().isPreferPrivateIfExist());
    assertFalse(subnetSelectionParametersCaptor.getValue().isHa());
    assertEquals(tunnel, subnetSelectionParametersCaptor.getValue().getTunnel());
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) Tunnel(com.sequenceiq.common.api.type.Tunnel) ProvidedSubnetIds(com.sequenceiq.environment.network.service.domain.ProvidedSubnetIds) SubnetSelectionParameters(com.sequenceiq.cloudbreak.cloud.model.SubnetSelectionParameters) NetworkConnector(com.sequenceiq.cloudbreak.cloud.NetworkConnector) CloudSubnet(com.sequenceiq.cloudbreak.cloud.model.CloudSubnet) Test(org.junit.jupiter.api.Test)

Example 2 with Tunnel

use of com.sequenceiq.common.api.type.Tunnel in project cloudbreak by hortonworks.

the class EnvironmentCreationService method initializeEnvironmentTunnel.

private void initializeEnvironmentTunnel(Environment environment) {
    ExperimentalFeatures experimentalFeatures = environment.getExperimentalFeaturesJson();
    Tunnel tunnel = experimentalFeatures.getTunnel();
    boolean overrideTunnel = experimentalFeatures.isOverrideTunnel();
    boolean ccmV2Enabled = entitlementService.ccmV2Enabled(environment.getAccountId());
    boolean ccmV2JumpgateEnabled = entitlementService.ccmV2JumpgateEnabled(environment.getAccountId());
    checkCcmEntitlements(tunnel, ccmV2Enabled, ccmV2JumpgateEnabled);
    if (!overrideTunnel) {
        if (Tunnel.CCM == tunnel) {
            if (ccmV2JumpgateEnabled) {
                tunnel = Tunnel.CCMV2_JUMPGATE;
            } else if (ccmV2Enabled) {
                tunnel = Tunnel.CCMV2;
            }
            experimentalFeatures.setTunnel(tunnel);
            environment.setExperimentalFeaturesJson(experimentalFeatures);
        }
    // TODO: if we want the Jumpgate to be default then this logic needs to be added for CCMV2 as well
    }
    LOGGER.info("Environment is initialized with [{}] tunnel.", tunnel);
}
Also used : ExperimentalFeatures(com.sequenceiq.environment.environment.domain.ExperimentalFeatures) Tunnel(com.sequenceiq.common.api.type.Tunnel)

Example 3 with Tunnel

use of com.sequenceiq.common.api.type.Tunnel in project cloudbreak by hortonworks.

the class EnvironmentDetailsToCDPNetworkDetailsConverter method convert.

public UsageProto.CDPNetworkDetails convert(EnvironmentDetails environmentDetails) {
    UsageProto.CDPNetworkDetails.Builder cdpNetworkDetails = UsageProto.CDPNetworkDetails.newBuilder();
    cdpNetworkDetails.setNumberPublicSubnets(DEFAULT_INTEGER_VALUE);
    cdpNetworkDetails.setNumberPrivateSubnets(DEFAULT_INTEGER_VALUE);
    Tunnel tunnel = environmentDetails.getTunnel();
    if (tunnel != null) {
        cdpNetworkDetails.setConnectivity(tunnel.name());
    }
    CcmV2TlsType tlsType = environmentDetails.getTlsType();
    if (tlsType != null) {
        cdpNetworkDetails.setControlPlaneAndCCMAgentConnectionSecurity(tlsType.name());
    }
    NetworkDto network = environmentDetails.getNetwork();
    if (network != null) {
        cdpNetworkDetails.setNetworkType(network.getRegistrationType().name());
        cdpNetworkDetails.setServiceEndpointCreation(network.getServiceEndpointCreation().name());
        if (network.getSubnetMetas() != null) {
            if (network.getSubnetMetas().isEmpty()) {
                cdpNetworkDetails.setNumberPrivateSubnets(0);
                cdpNetworkDetails.setNumberPublicSubnets(0);
            } else {
                List<SubnetType> types = network.getSubnetMetas().values().stream().map(CloudSubnet::getType).filter(Objects::nonNull).sorted().collect(Collectors.toUnmodifiableList());
                if (!types.isEmpty()) {
                    cdpNetworkDetails.setNumberPrivateSubnets(types.stream().filter(e -> e.equals(SubnetType.PRIVATE) || e.equals(SubnetType.MLX) || e.equals(SubnetType.DWX)).collect(Collectors.toList()).size());
                    cdpNetworkDetails.setNumberPublicSubnets(types.stream().filter(e -> e.equals(SubnetType.PUBLIC)).collect(Collectors.toList()).size());
                }
            }
        }
        cdpNetworkDetails.setPublicEndpointAccessGateway(network.getPublicEndpointAccessGateway() != null ? network.getPublicEndpointAccessGateway().name() : PublicEndpointAccessGateway.DISABLED.name());
    }
    cdpNetworkDetails.setSecurityAccessType(defaultIfEmpty(environmentDetails.getSecurityAccessType(), ""));
    cdpNetworkDetails.setProxyDetails(convertProxy(environmentDetails.getProxyDetails()));
    cdpNetworkDetails.setDomain(defaultIfEmpty(environmentDetails.getDomain(), ""));
    cdpNetworkDetails.setOwnDnsZones(convertOwnDnsZones(network, environmentDetails.getCloudPlatform()));
    UsageProto.CDPNetworkDetails ret = cdpNetworkDetails.build();
    LOGGER.debug("Converted CDPNetworkDetails: {}", ret);
    return ret;
}
Also used : StringUtils.defaultIfEmpty(org.apache.commons.lang3.StringUtils.defaultIfEmpty) CloudSubnet(com.sequenceiq.cloudbreak.cloud.model.CloudSubnet) Logger(org.slf4j.Logger) AzureParams(com.sequenceiq.environment.network.dto.AzureParams) LoggerFactory(org.slf4j.LoggerFactory) Collectors(java.util.stream.Collectors) StringUtils(org.apache.commons.lang3.StringUtils) CloudPlatform(com.sequenceiq.cloudbreak.common.mappable.CloudPlatform) ProxyDetails(com.sequenceiq.cloudbreak.structuredevent.event.cdp.environment.proxy.ProxyDetails) Objects(java.util.Objects) List(java.util.List) Component(org.springframework.stereotype.Component) NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) SubnetType(com.sequenceiq.cloudbreak.cloud.model.network.SubnetType) PublicEndpointAccessGateway(com.sequenceiq.common.api.type.PublicEndpointAccessGateway) Optional(java.util.Optional) UsageProto(com.cloudera.thunderhead.service.common.usage.UsageProto) CcmV2TlsType(com.sequenceiq.common.api.type.CcmV2TlsType) EnvironmentDetails(com.sequenceiq.cloudbreak.structuredevent.event.cdp.environment.EnvironmentDetails) Tunnel(com.sequenceiq.common.api.type.Tunnel) NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) Tunnel(com.sequenceiq.common.api.type.Tunnel) Objects(java.util.Objects) CcmV2TlsType(com.sequenceiq.common.api.type.CcmV2TlsType) SubnetType(com.sequenceiq.cloudbreak.cloud.model.network.SubnetType) UsageProto(com.cloudera.thunderhead.service.common.usage.UsageProto)

Aggregations

Tunnel (com.sequenceiq.common.api.type.Tunnel)3 CloudSubnet (com.sequenceiq.cloudbreak.cloud.model.CloudSubnet)2 NetworkDto (com.sequenceiq.environment.network.dto.NetworkDto)2 UsageProto (com.cloudera.thunderhead.service.common.usage.UsageProto)1 NetworkConnector (com.sequenceiq.cloudbreak.cloud.NetworkConnector)1 SubnetSelectionParameters (com.sequenceiq.cloudbreak.cloud.model.SubnetSelectionParameters)1 SubnetType (com.sequenceiq.cloudbreak.cloud.model.network.SubnetType)1 CloudPlatform (com.sequenceiq.cloudbreak.common.mappable.CloudPlatform)1 EnvironmentDetails (com.sequenceiq.cloudbreak.structuredevent.event.cdp.environment.EnvironmentDetails)1 ProxyDetails (com.sequenceiq.cloudbreak.structuredevent.event.cdp.environment.proxy.ProxyDetails)1 CcmV2TlsType (com.sequenceiq.common.api.type.CcmV2TlsType)1 PublicEndpointAccessGateway (com.sequenceiq.common.api.type.PublicEndpointAccessGateway)1 ExperimentalFeatures (com.sequenceiq.environment.environment.domain.ExperimentalFeatures)1 AzureParams (com.sequenceiq.environment.network.dto.AzureParams)1 ProvidedSubnetIds (com.sequenceiq.environment.network.service.domain.ProvidedSubnetIds)1 List (java.util.List)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 StringUtils (org.apache.commons.lang3.StringUtils)1