Search in sources :

Example 31 with AwsCredentialView

use of com.sequenceiq.cloudbreak.cloud.aws.common.view.AwsCredentialView in project cloudbreak by hortonworks.

the class AwsObjectStorageConnector method getObjectStorageMetadata.

@Override
public ObjectStorageMetadataResponse getObjectStorageMetadata(ObjectStorageMetadataRequest request) {
    AwsCredentialView awsCredentialView = new AwsCredentialView(request.getCredential());
    try {
        AmazonS3Client s3Client = awsClient.createS3Client(awsCredentialView);
        String bucketLocation = fixBucketLocation(s3Client.getBucketLocation(request.getObjectStoragePath()));
        return ObjectStorageMetadataResponse.builder().withRegion(bucketLocation).withStatus(ResponseStatus.OK).build();
    } catch (AmazonS3Exception e) {
        // the same error code will be returned. However, this hack is mainly for QAAS.
        if (e.getStatusCode() != ACCESS_DENIED_ERROR_CODE) {
            throw new CloudConnectorException(String.format("We were not able to query S3 object storage location for %s. " + "Refer to Cloudera documentation at %s for the required setup. " + "The message from Amazon S3 was: %s.", request.getObjectStoragePath(), DocumentationLinkProvider.awsCloudStorageSetupLink(), e.getErrorMessage()), e);
        }
        return ObjectStorageMetadataResponse.builder().withStatus(ResponseStatus.ACCESS_DENIED).build();
    }
}
Also used : AwsCredentialView(com.sequenceiq.cloudbreak.cloud.aws.common.view.AwsCredentialView) AmazonS3Client(com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonS3Client) CloudConnectorException(com.sequenceiq.cloudbreak.cloud.exception.CloudConnectorException) AmazonS3Exception(com.amazonaws.services.s3.model.AmazonS3Exception)

Example 32 with AwsCredentialView

use of com.sequenceiq.cloudbreak.cloud.aws.common.view.AwsCredentialView in project cloudbreak by hortonworks.

the class AwsPlatformResources method securityGroups.

@Override
public CloudSecurityGroups securityGroups(ExtendedCloudCredential cloudCredential, Region region, Map<String, String> filters) {
    Map<String, Set<CloudSecurityGroup>> result = new HashMap<>();
    Set<CloudSecurityGroup> cloudSecurityGroups = new HashSet<>();
    AmazonEc2Client ec2Client = awsClient.createEc2Client(new AwsCredentialView(cloudCredential), region.value());
    // create securitygroup filter view
    PlatformResourceSecurityGroupFilterView filter = new PlatformResourceSecurityGroupFilterView(filters);
    DescribeSecurityGroupsRequest describeSecurityGroupsRequest = new DescribeSecurityGroupsRequest();
    // If the filtervalue is provided then we should filter only for those securitygroups
    if (!Strings.isNullOrEmpty(filter.getVpcId())) {
        describeSecurityGroupsRequest.withFilters(new Filter("vpc-id", singletonList(filter.getVpcId())));
    }
    if (!Strings.isNullOrEmpty(filter.getGroupId())) {
        describeSecurityGroupsRequest.withGroupIds(filter.getGroupId());
    }
    if (!Strings.isNullOrEmpty(filter.getGroupName())) {
        describeSecurityGroupsRequest.withGroupNames(filter.getGroupName());
    }
    for (SecurityGroup securityGroup : fetchSecurityGroups(ec2Client, describeSecurityGroupsRequest)) {
        Map<String, Object> properties = new HashMap<>();
        properties.put("vpcId", securityGroup.getVpcId());
        properties.put("description", securityGroup.getDescription());
        properties.put("ipPermissions", securityGroup.getIpPermissions());
        properties.put("ipPermissionsEgress", securityGroup.getIpPermissionsEgress());
        cloudSecurityGroups.add(new CloudSecurityGroup(securityGroup.getGroupName(), securityGroup.getGroupId(), properties));
    }
    result.put(region.value(), cloudSecurityGroups);
    return new CloudSecurityGroups(result);
}
Also used : PlatformResourceSecurityGroupFilterView(com.sequenceiq.cloudbreak.cloud.model.view.PlatformResourceSecurityGroupFilterView) DescribeSecurityGroupsRequest(com.amazonaws.services.ec2.model.DescribeSecurityGroupsRequest) Set(java.util.Set) LinkedHashSet(java.util.LinkedHashSet) HashSet(java.util.HashSet) HashMap(java.util.HashMap) SecurityGroup(com.amazonaws.services.ec2.model.SecurityGroup) CloudSecurityGroup(com.sequenceiq.cloudbreak.cloud.model.CloudSecurityGroup) AwsCredentialView(com.sequenceiq.cloudbreak.cloud.aws.common.view.AwsCredentialView) MinimalHardwareFilter(com.sequenceiq.cloudbreak.filter.MinimalHardwareFilter) Filter(com.amazonaws.services.ec2.model.Filter) CloudSecurityGroups(com.sequenceiq.cloudbreak.cloud.model.CloudSecurityGroups) AmazonEc2Client(com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonEc2Client) CloudSecurityGroup(com.sequenceiq.cloudbreak.cloud.model.CloudSecurityGroup) LinkedHashSet(java.util.LinkedHashSet) HashSet(java.util.HashSet)

Example 33 with AwsCredentialView

use of com.sequenceiq.cloudbreak.cloud.aws.common.view.AwsCredentialView in project cloudbreak by hortonworks.

the class AwsPlatformResources method getCloudVmTypes.

private CloudVmTypes getCloudVmTypes(ExtendedCloudCredential cloudCredential, Region region, Map<String, String> filters, Predicate<VmType> enabledInstanceTypeFilter, boolean enableMinimalHardwareFilter) {
    Map<String, Set<VmType>> cloudVmResponses = new HashMap<>();
    Map<String, VmType> defaultCloudVmResponses = new HashMap<>();
    if (region != null && !Strings.isNullOrEmpty(region.value())) {
        CloudRegions regions = regions(cloudCredential, region, filters, true);
        AwsCredentialView awsCredentialView = new AwsCredentialView(cloudCredential);
        AmazonEc2Client ec2Client = awsClient.createEc2Client(awsCredentialView, region.getRegionName());
        List<String> instanceTypes = ec2Client.describeInstanceTypeOfferings(getOfferingsRequest(region)).getInstanceTypeOfferings().stream().map(e -> e.getInstanceType()).collect(Collectors.toList());
        Set<VmType> awsInstances = new HashSet<>();
        for (int actualSegment = 0; actualSegment < instanceTypes.size(); actualSegment += SEGMENT) {
            DescribeInstanceTypesRequest request = new DescribeInstanceTypesRequest();
            request.setInstanceTypes(getInstanceTypes(instanceTypes, actualSegment));
            getVmTypesWithAwsCall(awsInstances, ec2Client.describeInstanceTypes(request));
        }
        if (enableMinimalHardwareFilter) {
            awsInstances = awsInstances.stream().filter(e -> minimalHardwareFilter.suitableAsMinimumHardware(e.getMetaData().getCPU(), e.getMetaData().getMemoryInGb())).collect(Collectors.toSet());
        }
        fillUpAvailabilityZones(region, enabledInstanceTypeFilter, regions, cloudVmResponses, defaultCloudVmResponses, awsInstances);
        filterInstancesByFilters(enabledInstanceTypeFilter, cloudVmResponses);
    }
    return new CloudVmTypes(cloudVmResponses, defaultCloudVmResponses);
}
Also used : CloudVmTypes(com.sequenceiq.cloudbreak.cloud.model.CloudVmTypes) DescribeSubnetsRequest(com.amazonaws.services.ec2.model.DescribeSubnetsRequest) AvailabilityZone.availabilityZone(com.sequenceiq.cloudbreak.cloud.model.AvailabilityZone.availabilityZone) ExtendedCloudCredential(com.sequenceiq.cloudbreak.cloud.model.ExtendedCloudCredential) MinimalHardwareFilter(com.sequenceiq.cloudbreak.filter.MinimalHardwareFilter) Cacheable(org.springframework.cache.annotation.Cacheable) ListKeysRequest(com.amazonaws.services.kms.model.ListKeysRequest) InstanceProfile(com.amazonaws.services.identitymanagement.model.InstanceProfile) Collections.singletonList(java.util.Collections.singletonList) DescribeSubnetsResult(com.amazonaws.services.ec2.model.DescribeSubnetsResult) VmType.vmTypeWithMeta(com.sequenceiq.cloudbreak.cloud.model.VmType.vmTypeWithMeta) AwsCredentialView(com.sequenceiq.cloudbreak.cloud.aws.common.view.AwsCredentialView) CloudAccessConfig(com.sequenceiq.cloudbreak.cloud.model.CloudAccessConfig) ListTablesRequest(com.amazonaws.services.dynamodbv2.model.ListTablesRequest) Map(java.util.Map) Location(com.sequenceiq.cloudbreak.cloud.model.Location) AmazonIdentityManagementClient(com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonIdentityManagementClient) CloudEncryptionKey(com.sequenceiq.cloudbreak.cloud.model.CloudEncryptionKey) CloudUnauthorizedException(com.sequenceiq.cloudbreak.cloud.exception.CloudUnauthorizedException) AmazonServiceException(com.amazonaws.AmazonServiceException) DescribeInternetGatewaysResult(com.amazonaws.services.ec2.model.DescribeInternetGatewaysResult) CloudEncryptionKeys(com.sequenceiq.cloudbreak.cloud.model.CloudEncryptionKeys) Set(java.util.Set) RegionSpecification(com.sequenceiq.cloudbreak.cloud.model.RegionSpecification) SecurityGroup(com.amazonaws.services.ec2.model.SecurityGroup) RegionCoordinateSpecifications(com.sequenceiq.cloudbreak.cloud.model.RegionCoordinateSpecifications) PlatformResourceVpcFilterView(com.sequenceiq.cloudbreak.cloud.model.view.PlatformResourceVpcFilterView) CloudSshKey(com.sequenceiq.cloudbreak.cloud.model.CloudSshKey) DescribeRouteTablesRequest(com.amazonaws.services.ec2.model.DescribeRouteTablesRequest) CloudPrivateDnsZones(com.sequenceiq.cloudbreak.cloud.model.dns.CloudPrivateDnsZones) Coordinate.coordinate(com.sequenceiq.cloudbreak.cloud.model.Coordinate.coordinate) Tag(com.amazonaws.services.ec2.model.Tag) MAGNETIC(com.sequenceiq.cloudbreak.cloud.model.VolumeParameterType.MAGNETIC) ListInstanceProfilesRequest(com.amazonaws.services.identitymanagement.model.ListInstanceProfilesRequest) RegionsSpecification(com.sequenceiq.cloudbreak.cloud.model.RegionsSpecification) DescribeRegionsResult(com.amazonaws.services.ec2.model.DescribeRegionsResult) CloudbreakResourceReaderService(com.sequenceiq.cloudbreak.service.CloudbreakResourceReaderService) Region(com.sequenceiq.cloudbreak.cloud.model.Region) ListTablesResult(com.amazonaws.services.dynamodbv2.model.ListTablesResult) DescribeKeyPairsRequest(com.amazonaws.services.ec2.model.DescribeKeyPairsRequest) CloudGateWays(com.sequenceiq.cloudbreak.cloud.model.CloudGateWays) CloudNetworks(com.sequenceiq.cloudbreak.cloud.model.CloudNetworks) CloudRegions(com.sequenceiq.cloudbreak.cloud.model.CloudRegions) StringUtils.isNotEmpty(org.apache.commons.lang3.StringUtils.isNotEmpty) ArrayList(java.util.ArrayList) Value(org.springframework.beans.factory.annotation.Value) CloudParameterConst(com.sequenceiq.cloudbreak.cloud.CloudParameterConst) CloudConnectorException(com.sequenceiq.cloudbreak.cloud.exception.CloudConnectorException) Strings(com.google.common.base.Strings) AmazonEc2Client(com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonEc2Client) AliasListEntry(com.amazonaws.services.kms.model.AliasListEntry) AmazonRdsClient(com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonRdsClient) DescribeInstanceTypesRequest(com.amazonaws.services.ec2.model.DescribeInstanceTypesRequest) AmazonDynamoDBClient(com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonDynamoDBClient) Service(org.springframework.stereotype.Service) ConfigSpecification(com.sequenceiq.cloudbreak.cloud.model.ConfigSpecification) PlatformResourceSecurityGroupFilterView(com.sequenceiq.cloudbreak.cloud.model.view.PlatformResourceSecurityGroupFilterView) DescribeSecurityGroupsRequest(com.amazonaws.services.ec2.model.DescribeSecurityGroupsRequest) Filter(com.amazonaws.services.ec2.model.Filter) RouteTable(com.amazonaws.services.ec2.model.RouteTable) PRIVATE(com.sequenceiq.cloudbreak.cloud.model.network.SubnetType.PRIVATE) CloudConstants(com.sequenceiq.cloudbreak.common.type.CloudConstants) LinkedHashSet(java.util.LinkedHashSet) ST1(com.sequenceiq.cloudbreak.cloud.model.VolumeParameterType.ST1) RegionCoordinateSpecification(com.sequenceiq.cloudbreak.cloud.model.RegionCoordinateSpecification) CloudSubnet(com.sequenceiq.cloudbreak.cloud.model.CloudSubnet) ListInstanceProfilesResult(com.amazonaws.services.identitymanagement.model.ListInstanceProfilesResult) Certificate(com.amazonaws.services.rds.model.Certificate) CloudNoSqlTable(com.sequenceiq.cloudbreak.cloud.model.nosql.CloudNoSqlTable) AwsPageCollector(com.sequenceiq.cloudbreak.cloud.aws.common.util.AwsPageCollector) IOException(java.io.IOException) CloudAccessConfigs(com.sequenceiq.cloudbreak.cloud.model.CloudAccessConfigs) SSD(com.sequenceiq.cloudbreak.cloud.model.VolumeParameterType.SSD) InternetGateway(com.amazonaws.services.ec2.model.InternetGateway) AmazonKmsClient(com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonKmsClient) HttpStatus(org.springframework.http.HttpStatus) SdkClientException(com.amazonaws.SdkClientException) AmazonEC2Exception(com.amazonaws.services.ec2.model.AmazonEC2Exception) StringUtils.isNullOrEmpty(com.amazonaws.util.StringUtils.isNullOrEmpty) DescribeInternetGatewaysRequest(com.amazonaws.services.ec2.model.DescribeInternetGatewaysRequest) PermanentlyFailedException(com.sequenceiq.cloudbreak.util.PermanentlyFailedException) DisplayName.displayName(com.sequenceiq.cloudbreak.cloud.model.DisplayName.displayName) CloudDatabaseServerSslCertificate(com.sequenceiq.cloudbreak.cloud.model.database.CloudDatabaseServerSslCertificate) DescribeVpcsRequest(com.amazonaws.services.ec2.model.DescribeVpcsRequest) ListRolesResult(com.amazonaws.services.identitymanagement.model.ListRolesResult) Role(com.amazonaws.services.identitymanagement.model.Role) LoggerFactory(org.slf4j.LoggerFactory) JsonUtil(com.sequenceiq.cloudbreak.common.json.JsonUtil) ListAliasesRequest(com.amazonaws.services.kms.model.ListAliasesRequest) AuthenticatedContext(com.sequenceiq.cloudbreak.cloud.context.AuthenticatedContext) CloudSshKeys(com.sequenceiq.cloudbreak.cloud.model.CloudSshKeys) InternetGatewayAttachment(com.amazonaws.services.ec2.model.InternetGatewayAttachment) DescribeKeyResult(com.amazonaws.services.kms.model.DescribeKeyResult) EPHEMERAL(com.sequenceiq.cloudbreak.cloud.model.VolumeParameterType.EPHEMERAL) DescribeAvailabilityZonesRequest(com.amazonaws.services.ec2.model.DescribeAvailabilityZonesRequest) InstanceStoreMetadata(com.sequenceiq.cloudbreak.cloud.model.InstanceStoreMetadata) DescribeRegionsRequest(com.amazonaws.services.ec2.model.DescribeRegionsRequest) Predicate(java.util.function.Predicate) Collection(java.util.Collection) CloudResourceGroups(com.sequenceiq.cloudbreak.cloud.model.resourcegroup.CloudResourceGroups) InstanceStorageInfo(com.amazonaws.services.ec2.model.InstanceStorageInfo) Collectors(java.util.stream.Collectors) VmType(com.sequenceiq.cloudbreak.cloud.model.VmType) CloudGateWay(com.sequenceiq.cloudbreak.cloud.model.CloudGateWay) CloudNoSqlTables(com.sequenceiq.cloudbreak.cloud.model.nosql.CloudNoSqlTables) Objects(java.util.Objects) List(java.util.List) VolumeParameterType(com.sequenceiq.cloudbreak.cloud.model.VolumeParameterType) Entry(java.util.Map.Entry) PostConstruct(javax.annotation.PostConstruct) Optional(java.util.Optional) DescribeCertificatesRequest(com.amazonaws.services.rds.model.DescribeCertificatesRequest) Coordinate(com.sequenceiq.cloudbreak.cloud.model.Coordinate) CloudDatabaseServerSslCertificates(com.sequenceiq.cloudbreak.cloud.model.database.CloudDatabaseServerSslCertificates) DescribeKeyRequest(com.amazonaws.services.kms.model.DescribeKeyRequest) KeyPairInfo(com.amazonaws.services.ec2.model.KeyPairInfo) CloudSecurityGroup(com.sequenceiq.cloudbreak.cloud.model.CloudSecurityGroup) CloudIpPools(com.sequenceiq.cloudbreak.cloud.model.CloudIpPools) HashMap(java.util.HashMap) ListKeysResult(com.amazonaws.services.kms.model.ListKeysResult) PlatformResourceSshKeyFilterView(com.sequenceiq.cloudbreak.cloud.model.view.PlatformResourceSshKeyFilterView) HashSet(java.util.HashSet) Inject(javax.inject.Inject) AvailabilityZone(com.sequenceiq.cloudbreak.cloud.model.AvailabilityZone) PUBLIC(com.sequenceiq.cloudbreak.cloud.model.network.SubnetType.PUBLIC) DescribeInstanceTypesResult(com.amazonaws.services.ec2.model.DescribeInstanceTypesResult) DescribeVpcsResult(com.amazonaws.services.ec2.model.DescribeVpcsResult) Objects.requireNonNull(java.util.Objects.requireNonNull) ListRolesRequest(com.amazonaws.services.identitymanagement.model.ListRolesRequest) Subnet(com.amazonaws.services.ec2.model.Subnet) CloudDatabaseServerSslCertificateType(com.sequenceiq.cloudbreak.cloud.model.database.CloudDatabaseServerSslCertificateType) LinkedList(java.util.LinkedList) DisplayName(com.sequenceiq.cloudbreak.cloud.model.DisplayName) Logger(org.slf4j.Logger) Vpc(com.amazonaws.services.ec2.model.Vpc) PlatformResources(com.sequenceiq.cloudbreak.cloud.PlatformResources) DiskInfo(com.amazonaws.services.ec2.model.DiskInfo) VmTypeMetaBuilder(com.sequenceiq.cloudbreak.cloud.model.VmTypeMeta.VmTypeMetaBuilder) Region.region(com.sequenceiq.cloudbreak.cloud.model.Region.region) CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) InstanceTypeInfo(com.amazonaws.services.ec2.model.InstanceTypeInfo) CloudSecurityGroups(com.sequenceiq.cloudbreak.cloud.model.CloudSecurityGroups) ListAliasesResult(com.amazonaws.services.kms.model.ListAliasesResult) DescribeInstanceTypeOfferingsRequest(com.amazonaws.services.ec2.model.DescribeInstanceTypeOfferingsRequest) VisibleForTesting(com.google.common.annotations.VisibleForTesting) VolumeParameterConfig(com.sequenceiq.cloudbreak.cloud.model.VolumeParameterConfig) CloudNetwork(com.sequenceiq.cloudbreak.cloud.model.CloudNetwork) DescribeInstanceTypesRequest(com.amazonaws.services.ec2.model.DescribeInstanceTypesRequest) Set(java.util.Set) LinkedHashSet(java.util.LinkedHashSet) HashSet(java.util.HashSet) HashMap(java.util.HashMap) CloudRegions(com.sequenceiq.cloudbreak.cloud.model.CloudRegions) AwsCredentialView(com.sequenceiq.cloudbreak.cloud.aws.common.view.AwsCredentialView) CloudVmTypes(com.sequenceiq.cloudbreak.cloud.model.CloudVmTypes) VmType(com.sequenceiq.cloudbreak.cloud.model.VmType) AmazonEc2Client(com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonEc2Client) LinkedHashSet(java.util.LinkedHashSet) HashSet(java.util.HashSet)

Example 34 with AwsCredentialView

use of com.sequenceiq.cloudbreak.cloud.aws.common.view.AwsCredentialView in project cloudbreak by hortonworks.

the class AwsPlatformResources method networks.

@Override
public CloudNetworks networks(ExtendedCloudCredential cloudCredential, Region region, Map<String, String> filters) {
    AmazonEc2Client ec2Client = awsClient.createEc2Client(new AwsCredentialView(cloudCredential), region.value());
    try {
        LOGGER.debug("Describing route tables in region {}", region.getRegionName());
        List<RouteTable> allRouteTables = AwsPageCollector.getAllRouteTables(ec2Client, new DescribeRouteTablesRequest());
        DescribeVpcsRequest describeVpcsRequest = getDescribeVpcsRequestWithFilters(filters);
        Set<CloudNetwork> cloudNetworks = new HashSet<>();
        DescribeVpcsResult describeVpcsResult = null;
        boolean first = true;
        while (first || !isNullOrEmpty(describeVpcsResult.getNextToken())) {
            LOGGER.debug("Getting VPC list in region {}{}", region.getRegionName(), first ? "" : " (continuation)");
            first = false;
            describeVpcsRequest.setNextToken(describeVpcsResult == null ? null : describeVpcsResult.getNextToken());
            describeVpcsResult = ec2Client.describeVpcs(describeVpcsRequest);
            Set<CloudNetwork> partialNetworks = getCloudNetworks(ec2Client, allRouteTables, describeVpcsResult);
            cloudNetworks.addAll(partialNetworks);
        }
        Map<String, Set<CloudNetwork>> result = new HashMap<>();
        result.put(region.value(), cloudNetworks);
        return new CloudNetworks(result);
    } catch (SdkClientException e) {
        LOGGER.error(String.format("Unable to enumerate networks in region '%s'. Check exception for details.", region.getRegionName()), e);
        throw e;
    }
}
Also used : DescribeVpcsResult(com.amazonaws.services.ec2.model.DescribeVpcsResult) Set(java.util.Set) LinkedHashSet(java.util.LinkedHashSet) HashSet(java.util.HashSet) HashMap(java.util.HashMap) CloudNetworks(com.sequenceiq.cloudbreak.cloud.model.CloudNetworks) AwsCredentialView(com.sequenceiq.cloudbreak.cloud.aws.common.view.AwsCredentialView) RouteTable(com.amazonaws.services.ec2.model.RouteTable) DescribeRouteTablesRequest(com.amazonaws.services.ec2.model.DescribeRouteTablesRequest) DescribeVpcsRequest(com.amazonaws.services.ec2.model.DescribeVpcsRequest) SdkClientException(com.amazonaws.SdkClientException) AmazonEc2Client(com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonEc2Client) CloudNetwork(com.sequenceiq.cloudbreak.cloud.model.CloudNetwork) LinkedHashSet(java.util.LinkedHashSet) HashSet(java.util.HashSet)

Example 35 with AwsCredentialView

use of com.sequenceiq.cloudbreak.cloud.aws.common.view.AwsCredentialView in project cloudbreak by hortonworks.

the class AwsPublicKeyConnector method register.

@Override
public void register(PublicKeyRegisterRequest request) {
    LOGGER.debug("Importing public key {} to {} region on AWS", request.getPublicKeyId(), request.getRegion());
    AwsCredentialView awsCredential = new AwsCredentialView(request.getCredential());
    try {
        AmazonEc2Client client = awsClient.createEc2Client(awsCredential, request.getRegion());
        if (!exists(client, request.getPublicKeyId())) {
            ImportKeyPairRequest importKeyPairRequest = new ImportKeyPairRequest(request.getPublicKeyId(), request.getPublicKey());
            client.importKeyPair(importKeyPairRequest);
        }
    } catch (Exception e) {
        String errorMessage = String.format("Failed to import public key [%s:'%s', region: '%s'], detailed message: %s", getType(awsCredential), getAwsId(awsCredential), request.getRegion(), e.getMessage());
        LOGGER.error(errorMessage, e);
        throw new CloudConnectorException(e.getMessage(), e);
    }
}
Also used : AwsCredentialView(com.sequenceiq.cloudbreak.cloud.aws.common.view.AwsCredentialView) ImportKeyPairRequest(com.amazonaws.services.ec2.model.ImportKeyPairRequest) CloudConnectorException(com.sequenceiq.cloudbreak.cloud.exception.CloudConnectorException) AmazonEc2Client(com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonEc2Client) AmazonServiceException(com.amazonaws.AmazonServiceException) CloudConnectorException(com.sequenceiq.cloudbreak.cloud.exception.CloudConnectorException)

Aggregations

AwsCredentialView (com.sequenceiq.cloudbreak.cloud.aws.common.view.AwsCredentialView)94 AmazonEc2Client (com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonEc2Client)32 CloudConnectorException (com.sequenceiq.cloudbreak.cloud.exception.CloudConnectorException)32 List (java.util.List)25 AmazonServiceException (com.amazonaws.AmazonServiceException)22 AmazonCloudFormationClient (com.sequenceiq.cloudbreak.cloud.aws.client.AmazonCloudFormationClient)21 Logger (org.slf4j.Logger)21 Inject (javax.inject.Inject)20 ArrayList (java.util.ArrayList)19 Collectors (java.util.stream.Collectors)19 CloudInstance (com.sequenceiq.cloudbreak.cloud.model.CloudInstance)18 Group (com.sequenceiq.cloudbreak.cloud.model.Group)18 Set (java.util.Set)18 CloudResource (com.sequenceiq.cloudbreak.cloud.model.CloudResource)17 CloudStack (com.sequenceiq.cloudbreak.cloud.model.CloudStack)17 Map (java.util.Map)16 LoggerFactory (org.slf4j.LoggerFactory)16 AuthenticatedContext (com.sequenceiq.cloudbreak.cloud.context.AuthenticatedContext)15 Service (org.springframework.stereotype.Service)15 AmazonAutoScalingClient (com.sequenceiq.cloudbreak.cloud.aws.client.AmazonAutoScalingClient)14