Search in sources :

Example 6 with CloudSecurityGroups

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

the class AzurePlatformResources method securityGroups.

@Override
public CloudSecurityGroups securityGroups(CloudCredential cloudCredential, Region region, Map<String, String> filters) {
    AzureClient client = azureClientService.getClient(cloudCredential);
    Map<String, Set<CloudSecurityGroup>> result = new HashMap<>();
    for (NetworkSecurityGroup securityGroup : client.getSecurityGroups().list()) {
        String actualRegion = securityGroup.region().label();
        if (regionMatch(actualRegion, region)) {
            Map<String, Object> properties = new HashMap<>();
            properties.put("resourceGroupName", securityGroup.resourceGroupName());
            properties.put("networkInterfaceIds", securityGroup.networkInterfaceIds());
            CloudSecurityGroup cloudSecurityGroup = new CloudSecurityGroup(securityGroup.name(), securityGroup.id(), properties);
            result.computeIfAbsent(actualRegion, s -> new HashSet<>()).add(cloudSecurityGroup);
        }
    }
    if (result.isEmpty() && Objects.nonNull(region)) {
        result.put(region.value(), new HashSet<>());
    }
    return new CloudSecurityGroups(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) NetworkSecurityGroup(com.microsoft.azure.management.network.NetworkSecurityGroup) HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) AzureClient(com.sequenceiq.cloudbreak.cloud.azure.client.AzureClient) CloudSecurityGroups(com.sequenceiq.cloudbreak.cloud.model.CloudSecurityGroups) CloudSecurityGroup(com.sequenceiq.cloudbreak.cloud.model.CloudSecurityGroup) HashSet(java.util.HashSet)

Aggregations

CloudSecurityGroups (com.sequenceiq.cloudbreak.cloud.model.CloudSecurityGroups)6 CloudSecurityGroup (com.sequenceiq.cloudbreak.cloud.model.CloudSecurityGroup)4 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)4 Set (java.util.Set)4 Strings (com.google.common.base.Strings)2 PlatformResources (com.sequenceiq.cloudbreak.cloud.PlatformResources)2 AvailabilityZone (com.sequenceiq.cloudbreak.cloud.model.AvailabilityZone)2 CloudAccessConfigs (com.sequenceiq.cloudbreak.cloud.model.CloudAccessConfigs)2 CloudCredential (com.sequenceiq.cloudbreak.cloud.model.CloudCredential)2 CloudGateWays (com.sequenceiq.cloudbreak.cloud.model.CloudGateWays)2 CloudIpPools (com.sequenceiq.cloudbreak.cloud.model.CloudIpPools)2 CloudNetwork (com.sequenceiq.cloudbreak.cloud.model.CloudNetwork)2 CloudNetworks (com.sequenceiq.cloudbreak.cloud.model.CloudNetworks)2 CloudRegions (com.sequenceiq.cloudbreak.cloud.model.CloudRegions)2 CloudSshKeys (com.sequenceiq.cloudbreak.cloud.model.CloudSshKeys)2 CloudVmTypes (com.sequenceiq.cloudbreak.cloud.model.CloudVmTypes)2 Region (com.sequenceiq.cloudbreak.cloud.model.Region)2 Region.region (com.sequenceiq.cloudbreak.cloud.model.Region.region)2 VmType (com.sequenceiq.cloudbreak.cloud.model.VmType)2