use of com.sequenceiq.cloudbreak.cloud.model.CloudGateWays 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.CloudGateWays in project cloudbreak by hortonworks.
the class GetPlatformGatewaysHandler method accept.
@Override
public void accept(Event<GetPlatformCloudGatewaysRequest> getPlatformCloudGatewaysRequest) {
LOGGER.info("Received event: {}", getPlatformCloudGatewaysRequest);
GetPlatformCloudGatewaysRequest request = getPlatformCloudGatewaysRequest.getData();
try {
CloudPlatformVariant cloudPlatformVariant = new CloudPlatformVariant(Platform.platform(request.getExtendedCloudCredential().getCloudPlatform()), Variant.variant(request.getVariant()));
CloudGateWays cloudGateWays = cloudPlatformConnectors.get(cloudPlatformVariant).platformResources().gateways(request.getCloudCredential(), Region.region(request.getRegion()), request.getFilters());
GetPlatformCloudGatewaysResult getPlatformCloudGatewaysResult = new GetPlatformCloudGatewaysResult(request, cloudGateWays);
request.getResult().onNext(getPlatformCloudGatewaysResult);
LOGGER.info("Query platform gateway types finished.");
} catch (Exception e) {
request.getResult().onNext(new GetPlatformCloudGatewaysResult(e.getMessage(), e, request));
}
}
use of com.sequenceiq.cloudbreak.cloud.model.CloudGateWays in project cloudbreak by hortonworks.
the class PlatformParameterV1Controller method getGatewaysCredentialId.
@Override
public PlatformGatewaysResponse getGatewaysCredentialId(PlatformResourceRequestJson resourceRequestJson) {
resourceRequestJson = prepareAccountAndOwner(resourceRequestJson, authenticatedUserService.getCbUser());
PlatformResourceRequest convert = conversionService.convert(resourceRequestJson, PlatformResourceRequest.class);
CloudGateWays cloudGateWays = cloudParameterService.getGateways(convert.getCredential(), convert.getRegion(), convert.getPlatformVariant(), convert.getFilters());
return conversionService.convert(cloudGateWays, PlatformGatewaysResponse.class);
}
use of com.sequenceiq.cloudbreak.cloud.model.CloudGateWays 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);
}
Aggregations