Search in sources :

Example 1 with CloudGateWays

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;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) CloudGateWays(com.sequenceiq.cloudbreak.cloud.model.CloudGateWays) CloudRegions(com.sequenceiq.cloudbreak.cloud.model.CloudRegions) Router(org.openstack4j.model.network.Router) AvailabilityZone(com.sequenceiq.cloudbreak.cloud.model.AvailabilityZone) CloudGateWay(com.sequenceiq.cloudbreak.cloud.model.CloudGateWay) Region(com.sequenceiq.cloudbreak.cloud.model.Region) List(java.util.List) HashSet(java.util.HashSet)

Example 2 with 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));
    }
}
Also used : CloudGateWays(com.sequenceiq.cloudbreak.cloud.model.CloudGateWays) CloudPlatformVariant(com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant) GetPlatformCloudGatewaysRequest(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformCloudGatewaysRequest) GetPlatformCloudGatewaysResult(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformCloudGatewaysResult)

Example 3 with CloudGateWays

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);
}
Also used : CloudGateWays(com.sequenceiq.cloudbreak.cloud.model.CloudGateWays) PlatformResourceRequest(com.sequenceiq.cloudbreak.domain.PlatformResourceRequest)

Example 4 with CloudGateWays

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);
}
Also used : AmazonEC2Client(com.amazonaws.services.ec2.AmazonEC2Client) DescribeInternetGatewaysResult(com.amazonaws.services.ec2.model.DescribeInternetGatewaysResult) Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) CloudGateWays(com.sequenceiq.cloudbreak.cloud.model.CloudGateWays) CloudRegions(com.sequenceiq.cloudbreak.cloud.model.CloudRegions) InternetGatewayAttachment(com.amazonaws.services.ec2.model.InternetGatewayAttachment) AvailabilityZone(com.sequenceiq.cloudbreak.cloud.model.AvailabilityZone) DescribeInternetGatewaysRequest(com.amazonaws.services.ec2.model.DescribeInternetGatewaysRequest) CloudGateWay(com.sequenceiq.cloudbreak.cloud.model.CloudGateWay) InternetGateway(com.amazonaws.services.ec2.model.InternetGateway) Region(com.sequenceiq.cloudbreak.cloud.model.Region) Collections.singletonList(java.util.Collections.singletonList) List(java.util.List) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet)

Aggregations

CloudGateWays (com.sequenceiq.cloudbreak.cloud.model.CloudGateWays)4 AvailabilityZone (com.sequenceiq.cloudbreak.cloud.model.AvailabilityZone)2 CloudGateWay (com.sequenceiq.cloudbreak.cloud.model.CloudGateWay)2 CloudRegions (com.sequenceiq.cloudbreak.cloud.model.CloudRegions)2 Region (com.sequenceiq.cloudbreak.cloud.model.Region)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Set (java.util.Set)2 AmazonEC2Client (com.amazonaws.services.ec2.AmazonEC2Client)1 DescribeInternetGatewaysRequest (com.amazonaws.services.ec2.model.DescribeInternetGatewaysRequest)1 DescribeInternetGatewaysResult (com.amazonaws.services.ec2.model.DescribeInternetGatewaysResult)1 InternetGateway (com.amazonaws.services.ec2.model.InternetGateway)1 InternetGatewayAttachment (com.amazonaws.services.ec2.model.InternetGatewayAttachment)1 GetPlatformCloudGatewaysRequest (com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformCloudGatewaysRequest)1 GetPlatformCloudGatewaysResult (com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformCloudGatewaysResult)1 CloudPlatformVariant (com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant)1 PlatformResourceRequest (com.sequenceiq.cloudbreak.domain.PlatformResourceRequest)1 ArrayList (java.util.ArrayList)1 Collections.singletonList (java.util.Collections.singletonList)1