Search in sources :

Example 26 with PlatformResourceRequest

use of com.sequenceiq.environment.platformresource.PlatformResourceRequest in project cloudbreak by hortonworks.

the class EnvironmentPlatformResourceController method getIpPoolsCredentialId.

@Override
@CheckPermissionByResourceCrn(action = AuthorizationResourceAction.DESCRIBE_ENVIRONMENT)
public PlatformIpPoolsResponse getIpPoolsCredentialId(@ResourceCrn String environmentCrn, String region, String platformVariant, String availabilityZone) {
    String accountId = getAccountId();
    validateEnvironmentCrnPattern(environmentCrn);
    PlatformResourceRequest request = platformParameterService.getPlatformResourceRequestByEnvironment(accountId, environmentCrn, region, platformVariant, availabilityZone, null);
    LOGGER.info("Get /platform_resources/ip_pools, request: {}", request);
    CloudIpPools ipPools = platformParameterService.getIpPoolsCredentialId(request);
    PlatformIpPoolsResponse response = cloudIpPoolsToPlatformIpPoolsV1ResponseConverter.convert(ipPools);
    LOGGER.info("Resp /platform_resources/ip_pools, request: {}, ipPools: {}, response: {}", request, ipPools, response);
    return response;
}
Also used : PlatformIpPoolsResponse(com.sequenceiq.environment.api.v1.platformresource.model.PlatformIpPoolsResponse) CloudIpPools(com.sequenceiq.cloudbreak.cloud.model.CloudIpPools) PlatformResourceRequest(com.sequenceiq.environment.platformresource.PlatformResourceRequest) CheckPermissionByResourceCrn(com.sequenceiq.authorization.annotation.CheckPermissionByResourceCrn)

Example 27 with PlatformResourceRequest

use of com.sequenceiq.environment.platformresource.PlatformResourceRequest in project cloudbreak by hortonworks.

the class EnvironmentPlatformResourceController method getEncryptionKeys.

@Override
@CheckPermissionByResourceCrn(action = AuthorizationResourceAction.DESCRIBE_ENVIRONMENT)
public PlatformEncryptionKeysResponse getEncryptionKeys(@ResourceCrn String environmentCrn, String region, String platformVariant, String availabilityZone) {
    String accountId = getAccountId();
    validateEnvironmentCrnPattern(environmentCrn);
    PlatformResourceRequest request = platformParameterService.getPlatformResourceRequestByEnvironment(accountId, environmentCrn, region, platformVariant, availabilityZone, null);
    LOGGER.info("Get /platform_resources/encryption_keys, request: {}", request);
    CloudEncryptionKeys encryptionKeys = platformParameterService.getEncryptionKeys(request);
    PlatformEncryptionKeysResponse response = cloudEncryptionKeysToPlatformEncryptionKeysV1ResponseConverter.convert(encryptionKeys);
    LOGGER.info("Resp /platform_resources/encryption_keys, request: {}, ipPools: {}, response: {}", request, encryptionKeys, response);
    return response;
}
Also used : PlatformEncryptionKeysResponse(com.sequenceiq.environment.api.v1.platformresource.model.PlatformEncryptionKeysResponse) PlatformResourceRequest(com.sequenceiq.environment.platformresource.PlatformResourceRequest) CloudEncryptionKeys(com.sequenceiq.cloudbreak.cloud.model.CloudEncryptionKeys) CheckPermissionByResourceCrn(com.sequenceiq.authorization.annotation.CheckPermissionByResourceCrn)

Example 28 with PlatformResourceRequest

use of com.sequenceiq.environment.platformresource.PlatformResourceRequest in project cloudbreak by hortonworks.

the class EnvironmentPlatformResourceController method getAccessConfigs.

@Override
@CheckPermissionByResourceCrn(action = AuthorizationResourceAction.DESCRIBE_ENVIRONMENT)
public PlatformAccessConfigsResponse getAccessConfigs(@ResourceCrn String environmentCrn, String region, String platformVariant, String availabilityZone, AccessConfigTypeQueryParam accessConfigType) {
    String accountId = getAccountId();
    validateEnvironmentCrnPattern(environmentCrn);
    PlatformResourceRequest request = platformParameterService.getPlatformResourceRequestByEnvironment(accountId, environmentCrn, region, platformVariant, availabilityZone, null, accessConfigType);
    LOGGER.info("Get /platform_resources/access_configs, request: {}", request);
    CloudAccessConfigs accessConfigs = platformParameterService.getAccessConfigs(request);
    PlatformAccessConfigsResponse response = cloudAccessConfigsToPlatformAccessConfigsV1ResponseConverter.convert(accessConfigs);
    LOGGER.info("Resp /platform_resources/access_configs, request: {}, accessConfigs: {}, response: {}", request, accessConfigs, response);
    return response;
}
Also used : PlatformAccessConfigsResponse(com.sequenceiq.environment.api.v1.platformresource.model.PlatformAccessConfigsResponse) CloudAccessConfigs(com.sequenceiq.cloudbreak.cloud.model.CloudAccessConfigs) PlatformResourceRequest(com.sequenceiq.environment.platformresource.PlatformResourceRequest) CheckPermissionByResourceCrn(com.sequenceiq.authorization.annotation.CheckPermissionByResourceCrn)

Example 29 with PlatformResourceRequest

use of com.sequenceiq.environment.platformresource.PlatformResourceRequest in project cloudbreak by hortonworks.

the class EnvironmentValidatorService method fetchSecurityGroup.

private void fetchSecurityGroup(EnvironmentEditDto editDto, Environment environment, String securityGroupId) {
    PlatformResourceRequest request = platformParameterService.getPlatformResourceRequest(editDto.getAccountId(), environment.getCredential().getName(), null, environment.getRegionSet().stream().findFirst().get().getName(), environment.getCloudPlatform(), null);
    request.setFilters(Map.of("groupId", securityGroupId));
    platformParameterService.getSecurityGroups(request);
}
Also used : PlatformResourceRequest(com.sequenceiq.environment.platformresource.PlatformResourceRequest)

Example 30 with PlatformResourceRequest

use of com.sequenceiq.environment.platformresource.PlatformResourceRequest in project cloudbreak by hortonworks.

the class AwsEnvironmentSecurityGroupValidator method checkSecurityGroupVpc.

private void checkSecurityGroupVpc(EnvironmentDto environmentDto, ValidationResult.ValidationResultBuilder resultBuilder, String securityGroupIds) {
    Region region = environmentDto.getRegions().iterator().next();
    PlatformResourceRequest request = platformParameterService.getPlatformResourceRequest(environmentDto.getAccountId(), environmentDto.getCredential().getName(), null, region.getName(), getCloudPlatform().name(), null);
    CloudSecurityGroups securityGroups = platformParameterService.getSecurityGroups(request);
    boolean securityGroupInVpc = false;
    String awsVpcId = environmentDto.getNetwork().getAws().getVpcId();
    Map<String, Set<CloudSecurityGroup>> cloudSecurityGroupsResponses = securityGroups.getCloudSecurityGroupsResponses();
    if (Objects.nonNull(cloudSecurityGroupsResponses)) {
        Set<CloudSecurityGroup> cloudSecurityGroups = cloudSecurityGroupsResponses.get(region.getName());
        if (Objects.nonNull(cloudSecurityGroups)) {
            for (String securityGroupId : getSecurityGroupIds(securityGroupIds)) {
                securityGroupInVpc = isSecurityGroupInVpc(awsVpcId, cloudSecurityGroups, securityGroupId);
                if (!securityGroupInVpc) {
                    break;
                }
            }
        }
    }
    if (!securityGroupInVpc) {
        LOGGER.error("Security group {} does not belongs to the {} network.", securityGroupIds, environmentDto.getNetwork());
        resultBuilder.error(securityGroupNotInTheSameVpc(securityGroupIds));
        return;
    }
}
Also used : Set(java.util.Set) CloudSecurityGroups(com.sequenceiq.cloudbreak.cloud.model.CloudSecurityGroups) Region(com.sequenceiq.environment.environment.domain.Region) PlatformResourceRequest(com.sequenceiq.environment.platformresource.PlatformResourceRequest) CloudSecurityGroup(com.sequenceiq.cloudbreak.cloud.model.CloudSecurityGroup)

Aggregations

PlatformResourceRequest (com.sequenceiq.environment.platformresource.PlatformResourceRequest)31 CheckPermissionByResourceCrn (com.sequenceiq.authorization.annotation.CheckPermissionByResourceCrn)12 CustomPermissionCheck (com.sequenceiq.authorization.annotation.CustomPermissionCheck)12 CloudSecurityGroups (com.sequenceiq.cloudbreak.cloud.model.CloudSecurityGroups)9 CloudNetworks (com.sequenceiq.cloudbreak.cloud.model.CloudNetworks)7 CloudNoSqlTables (com.sequenceiq.cloudbreak.cloud.model.nosql.CloudNoSqlTables)7 PlatformNoSqlTablesResponse (com.sequenceiq.environment.api.v1.platformresource.model.PlatformNoSqlTablesResponse)7 CloudAccessConfigs (com.sequenceiq.cloudbreak.cloud.model.CloudAccessConfigs)6 CloudEncryptionKeys (com.sequenceiq.cloudbreak.cloud.model.CloudEncryptionKeys)6 CloudGateWays (com.sequenceiq.cloudbreak.cloud.model.CloudGateWays)6 CloudIpPools (com.sequenceiq.cloudbreak.cloud.model.CloudIpPools)6 CloudRegions (com.sequenceiq.cloudbreak.cloud.model.CloudRegions)6 CloudSshKeys (com.sequenceiq.cloudbreak.cloud.model.CloudSshKeys)6 CloudVmTypes (com.sequenceiq.cloudbreak.cloud.model.CloudVmTypes)6 PlatformAccessConfigsResponse (com.sequenceiq.environment.api.v1.platformresource.model.PlatformAccessConfigsResponse)6 PlatformEncryptionKeysResponse (com.sequenceiq.environment.api.v1.platformresource.model.PlatformEncryptionKeysResponse)6 PlatformGatewaysResponse (com.sequenceiq.environment.api.v1.platformresource.model.PlatformGatewaysResponse)6 PlatformIpPoolsResponse (com.sequenceiq.environment.api.v1.platformresource.model.PlatformIpPoolsResponse)6 PlatformNetworksResponse (com.sequenceiq.environment.api.v1.platformresource.model.PlatformNetworksResponse)6 PlatformSecurityGroupsResponse (com.sequenceiq.environment.api.v1.platformresource.model.PlatformSecurityGroupsResponse)6