use of com.sequenceiq.cloudbreak.cloud.model.CloudCredential 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);
}
use of com.sequenceiq.cloudbreak.cloud.model.CloudCredential 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);
}
Aggregations