Search in sources :

Example 1 with NetworkConnector

use of com.sequenceiq.cloudbreak.cloud.NetworkConnector in project cloudbreak by hortonworks.

the class SubnetChooserService method chooseSubnetForPrivateEndpoint.

public List<CloudSubnet> chooseSubnetForPrivateEndpoint(Collection<CloudSubnet> subnetMetas, DBStack dbStack, boolean existingNetwork) {
    NetworkConnector networkConnector = cloudPlatformConnectors.get(new CloudPlatformVariant(dbStack.getCloudPlatform(), dbStack.getPlatformVariant())).networkConnector();
    List<CloudSubnet> suitableCloudSubnets = networkConnector.chooseSubnetsForPrivateEndpoint(subnetMetas, existingNetwork).getResult();
    LOGGER.debug("Subnets suitable for private endpoint: {}", suitableCloudSubnets);
    return suitableCloudSubnets;
}
Also used : NetworkConnector(com.sequenceiq.cloudbreak.cloud.NetworkConnector) CloudPlatformVariant(com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant) CloudSubnet(com.sequenceiq.cloudbreak.cloud.model.CloudSubnet)

Example 2 with NetworkConnector

use of com.sequenceiq.cloudbreak.cloud.NetworkConnector in project cloudbreak by hortonworks.

the class SubnetChooserService method chooseSubnets.

public List<CloudSubnet> chooseSubnets(List<CloudSubnet> subnetMetas, CloudPlatform cloudPlatform, DBStack dbStack) {
    NetworkConnector networkConnector = cloudPlatformConnectors.get(new CloudPlatformVariant(dbStack.getCloudPlatform(), dbStack.getPlatformVariant())).networkConnector();
    SubnetSelectionParameters build = SubnetSelectionParameters.builder().withHa(dbStack.isHa()).withPreferPrivateIfExist().build();
    SubnetSelectionResult subnetSelectionResult = networkConnector.chooseSubnets(subnetMetas, build);
    if (subnetSelectionResult.hasError()) {
        throw new BadRequestException(subnetSelectionResult.getErrorMessage());
    }
    return subnetSelectionResult.getResult();
}
Also used : SubnetSelectionParameters(com.sequenceiq.cloudbreak.cloud.model.SubnetSelectionParameters) NetworkConnector(com.sequenceiq.cloudbreak.cloud.NetworkConnector) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) CloudPlatformVariant(com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant) SubnetSelectionResult(com.sequenceiq.cloudbreak.cloud.model.SubnetSelectionResult)

Example 3 with NetworkConnector

use of com.sequenceiq.cloudbreak.cloud.NetworkConnector in project cloudbreak by hortonworks.

the class EnvironmentNetworkService method createCloudNetwork.

public BaseNetwork createCloudNetwork(EnvironmentDto environment, BaseNetwork baseNetwork) {
    NetworkConnector networkConnector = getNetworkConnector(environment.getCloudPlatform());
    NetworkCreationRequest networkCreationRequest = networkCreationRequestFactory.create(environment);
    EnvironmentNetworkConverter converter = environmentNetworkConverterMap.get(getCloudPlatform(environment));
    CreatedCloudNetwork createdCloudNetwork = networkConnector.createNetworkWithSubnets(networkCreationRequest);
    return converter.setCreatedCloudNetwork(baseNetwork, createdCloudNetwork);
}
Also used : NetworkCreationRequest(com.sequenceiq.cloudbreak.cloud.model.network.NetworkCreationRequest) NetworkConnector(com.sequenceiq.cloudbreak.cloud.NetworkConnector) CreatedCloudNetwork(com.sequenceiq.cloudbreak.cloud.model.network.CreatedCloudNetwork) EnvironmentNetworkConverter(com.sequenceiq.environment.network.v1.converter.EnvironmentNetworkConverter)

Example 4 with NetworkConnector

use of com.sequenceiq.cloudbreak.cloud.NetworkConnector in project cloudbreak by hortonworks.

the class EnvironmentNetworkService method getNetworkCidr.

public NetworkCidr getNetworkCidr(Network network, String cloudPlatform, Credential credential) {
    if (network == null) {
        LOGGER.info("Could not fetch network cidr from {}, because the network is null", cloudPlatform);
        return null;
    }
    NetworkConnector networkConnector = getNetworkConnector(cloudPlatform);
    CloudCredential cloudCredential = credentialToCloudCredentialConverter.convert(credential);
    return networkConnector.getNetworkCidr(network, cloudCredential);
}
Also used : CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) NetworkConnector(com.sequenceiq.cloudbreak.cloud.NetworkConnector)

Example 5 with NetworkConnector

use of com.sequenceiq.cloudbreak.cloud.NetworkConnector in project cloudbreak by hortonworks.

the class EnvironmentNetworkService method createProviderSpecificNetworkResources.

public void createProviderSpecificNetworkResources(EnvironmentDto environment, BaseNetwork baseNetwork) {
    NetworkConnector networkConnector = getNetworkConnector(environment.getCloudPlatform());
    NetworkResourcesCreationRequest networkResourcesCreationRequest = networkCreationRequestFactory.createProviderSpecificNetworkResources(environment, baseNetwork);
    networkConnector.createProviderSpecificNetworkResources(networkResourcesCreationRequest);
}
Also used : NetworkConnector(com.sequenceiq.cloudbreak.cloud.NetworkConnector) NetworkResourcesCreationRequest(com.sequenceiq.cloudbreak.cloud.model.network.NetworkResourcesCreationRequest)

Aggregations

NetworkConnector (com.sequenceiq.cloudbreak.cloud.NetworkConnector)13 CloudSubnet (com.sequenceiq.cloudbreak.cloud.model.CloudSubnet)6 SubnetSelectionParameters (com.sequenceiq.cloudbreak.cloud.model.SubnetSelectionParameters)6 SubnetSelectionResult (com.sequenceiq.cloudbreak.cloud.model.SubnetSelectionResult)4 CloudPlatformVariant (com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant)3 DBStack (com.sequenceiq.redbeams.domain.stack.DBStack)3 Test (org.junit.Test)3 CloudConnector (com.sequenceiq.cloudbreak.cloud.CloudConnector)2 ProvidedSubnetIds (com.sequenceiq.environment.network.service.domain.ProvidedSubnetIds)2 CloudCredential (com.sequenceiq.cloudbreak.cloud.model.CloudCredential)1 CreatedCloudNetwork (com.sequenceiq.cloudbreak.cloud.model.network.CreatedCloudNetwork)1 NetworkCreationRequest (com.sequenceiq.cloudbreak.cloud.model.network.NetworkCreationRequest)1 NetworkResourcesCreationRequest (com.sequenceiq.cloudbreak.cloud.model.network.NetworkResourcesCreationRequest)1 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)1 Tunnel (com.sequenceiq.common.api.type.Tunnel)1 NetworkDto (com.sequenceiq.environment.network.dto.NetworkDto)1 EnvironmentNetworkConverter (com.sequenceiq.environment.network.v1.converter.EnvironmentNetworkConverter)1 Test (org.junit.jupiter.api.Test)1