Search in sources :

Example 1 with LocationAwareCredential

use of com.sequenceiq.environment.environment.domain.LocationAwareCredential in project cloudbreak by hortonworks.

the class NoSqlTableCreationModeDeterminerService method getNoSqlTableMetaData.

private NoSqlTableMetadataResponse getNoSqlTableMetaData(LocationAwareCredential locationAwareCredential, String dynamoDbTablename) {
    Credential credential = locationAwareCredential.getCredential();
    String cloudPlatform = credential.getCloudPlatform();
    String location = locationAwareCredential.getLocation();
    NoSqlConnector noSqlConnector = getNoSqlConnector(cloudPlatform);
    CloudCredential cloudCredential = credentialToCloudCredentialConverter.convert(credential);
    NoSqlTableMetadataRequest request = NoSqlTableMetadataRequest.builder().withCloudPlatform(cloudPlatform).withCredential(cloudCredential).withRegion(location).withTableName(dynamoDbTablename).build();
    return noSqlConnector.getNoSqlTableMetaData(request);
}
Also used : Credential(com.sequenceiq.environment.credential.domain.Credential) CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) LocationAwareCredential(com.sequenceiq.environment.environment.domain.LocationAwareCredential) CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) NoSqlConnector(com.sequenceiq.cloudbreak.cloud.NoSqlConnector) NoSqlTableMetadataRequest(com.sequenceiq.cloudbreak.cloud.model.nosql.NoSqlTableMetadataRequest)

Example 2 with LocationAwareCredential

use of com.sequenceiq.environment.environment.domain.LocationAwareCredential in project cloudbreak by hortonworks.

the class S3GuardTableDeleteHandler method deleteS3GuardTable.

private void deleteS3GuardTable(Environment environment, AwsParameters awsParameters) {
    if (S3GuardTableCreation.CREATE_NEW == awsParameters.getS3guardTableCreation()) {
        LocationAwareCredential locationAwareCredential = getLocationAwareCredential(environment);
        ResponseStatus responseStatus = deleteNoSqlTable(locationAwareCredential, awsParameters.getS3guardTableName());
        if (responseStatus == ResponseStatus.OK) {
            LOGGER.info("'{}' DynamoDB table deletion initiated at cloud provider.", awsParameters.getS3guardTableName());
        } else if (responseStatus == ResponseStatus.RESOURCE_NOT_FOUND) {
            LOGGER.warn("'{}' DynamoDB table deletion initiated but table was not found.", awsParameters.getS3guardTableName());
        }
    } else {
        LOGGER.info("'{}' DynamoDB table had already been existing before environment creation. Will not delete it.", awsParameters.getS3guardTableName());
    }
}
Also used : ResponseStatus(com.sequenceiq.cloudbreak.cloud.model.base.ResponseStatus) LocationAwareCredential(com.sequenceiq.environment.environment.domain.LocationAwareCredential)

Example 3 with LocationAwareCredential

use of com.sequenceiq.environment.environment.domain.LocationAwareCredential in project cloudbreak by hortonworks.

the class S3GuardTableDeleteHandler method deleteNoSqlTable.

private ResponseStatus deleteNoSqlTable(LocationAwareCredential locationAwareCredential, String dynamoDbTablename) {
    Credential credential = locationAwareCredential.getCredential();
    String cloudPlatform = credential.getCloudPlatform();
    String location = locationAwareCredential.getLocation();
    NoSqlConnector noSqlConnector = getNoSqlConnector(cloudPlatform);
    CloudCredential cloudCredential = credentialToCloudCredentialConverter.convert(credential);
    NoSqlTableMetadataRequest noSqlTableMetadataRequest = NoSqlTableMetadataRequest.builder().withCloudPlatform(cloudPlatform).withCredential(cloudCredential).withRegion(location).withTableName(dynamoDbTablename).build();
    NoSqlTableMetadataResponse noSqlTableMetaData = noSqlConnector.getNoSqlTableMetaData(noSqlTableMetadataRequest);
    if (ResponseStatus.OK.equals(noSqlTableMetaData.getStatus())) {
        NoSqlTableDeleteRequest request = NoSqlTableDeleteRequest.builder().withCloudPlatform(cloudPlatform).withCredential(cloudCredential).withRegion(location).withTableName(dynamoDbTablename).build();
        NoSqlTableDeleteResponse response = noSqlConnector.deleteNoSqlTable(request);
        return response.getStatus();
    } else {
        return ResponseStatus.OK;
    }
}
Also used : Credential(com.sequenceiq.environment.credential.domain.Credential) CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) LocationAwareCredential(com.sequenceiq.environment.environment.domain.LocationAwareCredential) CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) NoSqlConnector(com.sequenceiq.cloudbreak.cloud.NoSqlConnector) NoSqlTableMetadataRequest(com.sequenceiq.cloudbreak.cloud.model.nosql.NoSqlTableMetadataRequest) NoSqlTableDeleteResponse(com.sequenceiq.cloudbreak.cloud.model.nosql.NoSqlTableDeleteResponse) NoSqlTableDeleteRequest(com.sequenceiq.cloudbreak.cloud.model.nosql.NoSqlTableDeleteRequest) NoSqlTableMetadataResponse(com.sequenceiq.cloudbreak.cloud.model.nosql.NoSqlTableMetadataResponse)

Example 4 with LocationAwareCredential

use of com.sequenceiq.environment.environment.domain.LocationAwareCredential in project cloudbreak by hortonworks.

the class AwsParameterValidator method determineAwsParameters.

private void determineAwsParameters(EnvironmentDto environment, ParametersDto parametersDto) {
    LocationAwareCredential locationAwareCredential = getLocationAwareCredential(environment);
    S3GuardTableCreation dynamoDbTableCreation = noSqlTableCreationModeDeterminerService.determineCreationMode(locationAwareCredential, parametersDto.getAwsParametersDto().getS3GuardTableName());
    LOGGER.debug("S3Guard table name: {}, creation: {}", parametersDto.getAwsParametersDto().getS3GuardTableName(), dynamoDbTableCreation);
    parametersDto.getAwsParametersDto().setDynamoDbTableCreation(dynamoDbTableCreation);
    parametersService.saveParameters(environment.getId(), parametersDto);
}
Also used : S3GuardTableCreation(com.sequenceiq.environment.parameter.dto.s3guard.S3GuardTableCreation) LocationAwareCredential(com.sequenceiq.environment.environment.domain.LocationAwareCredential)

Aggregations

LocationAwareCredential (com.sequenceiq.environment.environment.domain.LocationAwareCredential)4 NoSqlConnector (com.sequenceiq.cloudbreak.cloud.NoSqlConnector)2 CloudCredential (com.sequenceiq.cloudbreak.cloud.model.CloudCredential)2 NoSqlTableMetadataRequest (com.sequenceiq.cloudbreak.cloud.model.nosql.NoSqlTableMetadataRequest)2 Credential (com.sequenceiq.environment.credential.domain.Credential)2 ResponseStatus (com.sequenceiq.cloudbreak.cloud.model.base.ResponseStatus)1 NoSqlTableDeleteRequest (com.sequenceiq.cloudbreak.cloud.model.nosql.NoSqlTableDeleteRequest)1 NoSqlTableDeleteResponse (com.sequenceiq.cloudbreak.cloud.model.nosql.NoSqlTableDeleteResponse)1 NoSqlTableMetadataResponse (com.sequenceiq.cloudbreak.cloud.model.nosql.NoSqlTableMetadataResponse)1 S3GuardTableCreation (com.sequenceiq.environment.parameter.dto.s3guard.S3GuardTableCreation)1