Search in sources :

Example 6 with CloudNetworks

use of com.sequenceiq.cloudbreak.cloud.model.CloudNetworks in project cloudbreak by hortonworks.

the class AzurePlatformResources method networks.

@Override
public CloudNetworks networks(CloudCredential cloudCredential, Region region, Map<String, String> filters) {
    AzureClient client = azureClientService.getClient(cloudCredential);
    Map<String, Set<CloudNetwork>> result = new HashMap<>();
    for (Network network : client.getNetworks()) {
        String actualRegion = network.region().label();
        if (regionMatch(actualRegion, region)) {
            Map<String, String> subnets = new HashMap<>();
            for (Entry<String, Subnet> subnet : network.subnets().entrySet()) {
                subnets.put(subnet.getKey(), subnet.getKey());
            }
            Map<String, Object> properties = new HashMap<>();
            properties.put("addressSpaces", network.addressSpaces());
            properties.put("dnsServerIPs", network.dnsServerIPs());
            properties.put("resourceGroupName", network.resourceGroupName());
            CloudNetwork cloudNetwork = new CloudNetwork(network.name(), network.id(), subnets, properties);
            result.computeIfAbsent(actualRegion, s -> new HashSet<>()).add(cloudNetwork);
        }
    }
    if (result.isEmpty() && Objects.nonNull(region)) {
        result.put(region.value(), new HashSet<>());
    }
    return new CloudNetworks(result);
}
Also used : VolumeParameterType.values(com.sequenceiq.cloudbreak.cloud.model.VolumeParameterType.values) AzureClient(com.sequenceiq.cloudbreak.cloud.azure.client.AzureClient) CloudVmTypes(com.sequenceiq.cloudbreak.cloud.model.CloudVmTypes) CloudIpPools(com.sequenceiq.cloudbreak.cloud.model.CloudIpPools) Region(com.sequenceiq.cloudbreak.cloud.model.Region) Cacheable(org.springframework.cache.annotation.Cacheable) Subnet(com.microsoft.azure.management.network.Subnet) HashMap(java.util.HashMap) CloudGateWays(com.sequenceiq.cloudbreak.cloud.model.CloudGateWays) CloudNetworks(com.sequenceiq.cloudbreak.cloud.model.CloudNetworks) CloudRegions(com.sequenceiq.cloudbreak.cloud.model.CloudRegions) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Inject(javax.inject.Inject) Value(org.springframework.beans.factory.annotation.Value) AvailabilityZone(com.sequenceiq.cloudbreak.cloud.model.AvailabilityZone) Strings(com.google.common.base.Strings) Network(com.microsoft.azure.management.network.Network) CloudSshKeys(com.sequenceiq.cloudbreak.cloud.model.CloudSshKeys) Service(org.springframework.stereotype.Service) Map(java.util.Map) PlatformResources(com.sequenceiq.cloudbreak.cloud.PlatformResources) VmTypeMetaBuilder(com.sequenceiq.cloudbreak.cloud.model.VmTypeMeta.VmTypeMetaBuilder) Region.region(com.sequenceiq.cloudbreak.cloud.model.Region.region) Set(java.util.Set) NetworkSecurityGroup(com.microsoft.azure.management.network.NetworkSecurityGroup) CloudAccessConfigs(com.sequenceiq.cloudbreak.cloud.model.CloudAccessConfigs) CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) VmType(com.sequenceiq.cloudbreak.cloud.model.VmType) Objects(java.util.Objects) List(java.util.List) VirtualMachineSize(com.microsoft.azure.management.compute.VirtualMachineSize) VolumeParameterType(com.sequenceiq.cloudbreak.cloud.model.VolumeParameterType) CloudSecurityGroups(com.sequenceiq.cloudbreak.cloud.model.CloudSecurityGroups) Entry(java.util.Map.Entry) AzureClientService(com.sequenceiq.cloudbreak.cloud.azure.client.AzureClientService) VolumeParameterConfig(com.sequenceiq.cloudbreak.cloud.model.VolumeParameterConfig) CloudNetwork(com.sequenceiq.cloudbreak.cloud.model.CloudNetwork) MAGNETIC(com.sequenceiq.cloudbreak.cloud.model.VolumeParameterType.MAGNETIC) CloudSecurityGroup(com.sequenceiq.cloudbreak.cloud.model.CloudSecurityGroup) HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) CloudNetworks(com.sequenceiq.cloudbreak.cloud.model.CloudNetworks) AzureClient(com.sequenceiq.cloudbreak.cloud.azure.client.AzureClient) Network(com.microsoft.azure.management.network.Network) CloudNetwork(com.sequenceiq.cloudbreak.cloud.model.CloudNetwork) Subnet(com.microsoft.azure.management.network.Subnet) CloudNetwork(com.sequenceiq.cloudbreak.cloud.model.CloudNetwork) HashSet(java.util.HashSet)

Aggregations

CloudNetworks (com.sequenceiq.cloudbreak.cloud.model.CloudNetworks)6 CloudNetwork (com.sequenceiq.cloudbreak.cloud.model.CloudNetwork)4 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)4 Set (java.util.Set)4 AmazonEC2Client (com.amazonaws.services.ec2.AmazonEC2Client)1 DescribeVpcsRequest (com.amazonaws.services.ec2.model.DescribeVpcsRequest)1 Subnet (com.amazonaws.services.ec2.model.Subnet)1 Vpc (com.amazonaws.services.ec2.model.Vpc)1 Compute (com.google.api.services.compute.Compute)1 Network (com.google.api.services.compute.model.Network)1 NetworkList (com.google.api.services.compute.model.NetworkList)1 Subnetwork (com.google.api.services.compute.model.Subnetwork)1 Strings (com.google.common.base.Strings)1 VirtualMachineSize (com.microsoft.azure.management.compute.VirtualMachineSize)1 Network (com.microsoft.azure.management.network.Network)1 NetworkSecurityGroup (com.microsoft.azure.management.network.NetworkSecurityGroup)1 Subnet (com.microsoft.azure.management.network.Subnet)1 PlatformResources (com.sequenceiq.cloudbreak.cloud.PlatformResources)1 AwsCredentialView (com.sequenceiq.cloudbreak.cloud.aws.view.AwsCredentialView)1