use of com.sequenceiq.cloudbreak.cloud.model.CloudGateWay in project cloudbreak by hortonworks.
the class OpenStackPlatformResources method gateways.
@Override
public CloudGateWays gateways(CloudCredential cloudCredential, Region region, Map<String, String> filters) {
OSClient<?> osClient = openStackClient.createOSClient(cloudCredential);
Map<String, Set<CloudGateWay>> resultCloudGateWayMap = new HashMap<>();
CloudRegions regions = regions(cloudCredential, region, filters);
for (Entry<Region, List<AvailabilityZone>> regionListEntry : regions.getCloudRegions().entrySet()) {
Set<CloudGateWay> cloudGateWays = new HashSet<>();
List<? extends Router> routerList = osClient.networking().router().list();
LOGGER.info("routers from openstack: {}", routerList);
for (Router router : routerList) {
CloudGateWay cloudGateWay = new CloudGateWay();
cloudGateWay.setId(router.getId());
cloudGateWay.setName(router.getName());
Map<String, Object> properties = new HashMap<>();
properties.put("tenantId", router.getTenantId());
cloudGateWay.setProperties(properties);
cloudGateWays.add(cloudGateWay);
}
for (AvailabilityZone availabilityZone : regionListEntry.getValue()) {
resultCloudGateWayMap.put(availabilityZone.value(), cloudGateWays);
}
}
CloudGateWays cloudGateWays = new CloudGateWays(resultCloudGateWayMap);
LOGGER.info("openstack cloudgateway result: {}", cloudGateWays);
return cloudGateWays;
}
use of com.sequenceiq.cloudbreak.cloud.model.CloudGateWay in project cloudbreak by hortonworks.
the class AwsPlatformResources method gateways.
@Override
public CloudGateWays gateways(CloudCredential cloudCredential, Region region, Map<String, String> filters) {
AmazonEC2Client ec2Client = awsClient.createAccess(cloudCredential);
Map<String, Set<CloudGateWay>> resultCloudGateWayMap = new HashMap<>();
CloudRegions regions = regions(cloudCredential, region, filters);
for (Entry<Region, List<AvailabilityZone>> regionListEntry : regions.getCloudRegions().entrySet()) {
if (region == null || Strings.isNullOrEmpty(region.value()) || regionListEntry.getKey().value().equals(region.value())) {
ec2Client.setRegion(RegionUtils.getRegion(regionListEntry.getKey().value()));
DescribeInternetGatewaysRequest describeInternetGatewaysRequest = new DescribeInternetGatewaysRequest();
DescribeInternetGatewaysResult describeInternetGatewaysResult = ec2Client.describeInternetGateways(describeInternetGatewaysRequest);
Set<CloudGateWay> gateWays = new HashSet<>();
for (InternetGateway internetGateway : describeInternetGatewaysResult.getInternetGateways()) {
CloudGateWay cloudGateWay = new CloudGateWay();
cloudGateWay.setId(internetGateway.getInternetGatewayId());
cloudGateWay.setName(internetGateway.getInternetGatewayId());
Collection<String> vpcs = new ArrayList<>();
for (InternetGatewayAttachment internetGatewayAttachment : internetGateway.getAttachments()) {
vpcs.add(internetGatewayAttachment.getVpcId());
}
Map<String, Object> properties = new HashMap<>();
properties.put("attachment", vpcs);
cloudGateWay.setProperties(properties);
gateWays.add(cloudGateWay);
}
for (AvailabilityZone availabilityZone : regionListEntry.getValue()) {
resultCloudGateWayMap.put(availabilityZone.value(), gateWays);
}
}
}
return new CloudGateWays(resultCloudGateWayMap);
}
use of com.sequenceiq.cloudbreak.cloud.model.CloudGateWay in project cloudbreak by hortonworks.
the class CloudGatewayssToPlatformGatewaysResponseConverter method convert.
@Override
public PlatformGatewaysResponse convert(CloudGateWays source) {
Map<String, Set<CloudGatewayJson>> result = new HashMap<>();
for (Entry<String, Set<CloudGateWay>> entry : source.getCloudGateWayResponses().entrySet()) {
Set<CloudGatewayJson> cloudGatewayJsons = new HashSet<>();
for (CloudGateWay gateway : entry.getValue()) {
CloudGatewayJson actual = new CloudGatewayJson(gateway.getName(), gateway.getId(), gateway.getProperties());
cloudGatewayJsons.add(actual);
}
result.put(entry.getKey(), cloudGatewayJsons);
}
return new PlatformGatewaysResponse(result);
}
Aggregations