use of com.sequenceiq.cloudbreak.common.exception.BadRequestException in project cloudbreak by hortonworks.
the class DiagnosticsCollectionValidatorTest method testValidateWithSupportDestination.
@Test
void testValidateWithSupportDestination() {
BaseDiagnosticsCollectionRequest request = new BaseDiagnosticsCollectionRequest();
request.setDestination(DiagnosticsDestination.SUPPORT);
Telemetry telemetry = new Telemetry();
BadRequestException thrown = assertThrows(BadRequestException.class, () -> underTest.validate(request, createStack(), telemetry));
assertTrue(thrown.getMessage().contains("Destination SUPPORT is not supported yet."));
}
use of com.sequenceiq.cloudbreak.common.exception.BadRequestException in project cloudbreak by hortonworks.
the class DiagnosticsCollectionValidatorTest method testValidateWithInvalidEngDestination.
@Test
void testValidateWithInvalidEngDestination() {
BaseDiagnosticsCollectionRequest request = new BaseDiagnosticsCollectionRequest();
request.setDestination(DiagnosticsDestination.ENG);
Telemetry telemetry = new Telemetry();
BadRequestException thrown = assertThrows(BadRequestException.class, () -> underTest.validate(request, createStack(), telemetry));
assertTrue(thrown.getMessage().contains("Cluster log collection is not enabled for Data Hub"));
}
use of com.sequenceiq.cloudbreak.common.exception.BadRequestException in project cloudbreak by hortonworks.
the class NetworkService method validate.
public BaseNetwork validate(BaseNetwork originalNetwork, EnvironmentEditDto editDto, Environment environment) {
CloudPlatform cloudPlatform = CloudPlatform.valueOf(environment.getCloudPlatform());
if (originalNetwork.getRegistrationType() == RegistrationType.CREATE_NEW) {
throw new BadRequestException("Subnets of this environment could not be modified, because its network has been created by Cloudera. " + "You need to re-install the environment into an existing VPC/VNet." + getDocLink(cloudPlatform));
}
EnvironmentNetworkConverter environmentNetworkConverter = environmentNetworkConverterMap.get(cloudPlatform);
NetworkDto originalNetworkDto = environmentNetworkConverter.convertToDto(originalNetwork);
NetworkDto cloneNetworkDto = NetworkDto.builder(originalNetworkDto).withSubnetMetas(editDto.getNetworkDto().getSubnetMetas()).build();
ValidationResultBuilder validationResultBuilder = networkCreationValidator.validateNetworkEdit(environment, cloneNetworkDto);
ValidationResult validationResult = validationResultBuilder.build();
if (validationResult.hasError()) {
throw new BadRequestException(validationResult.getFormattedErrors());
}
return originalNetwork;
}
use of com.sequenceiq.cloudbreak.common.exception.BadRequestException in project cloudbreak by hortonworks.
the class NetworkService method refreshMetadataFromCloudProvider.
public BaseNetwork refreshMetadataFromCloudProvider(BaseNetwork originalNetwork, EnvironmentEditDto editDto, Environment environment) {
EnvironmentNetworkConverter environmentNetworkConverter = environmentNetworkConverterMap.get(CloudPlatform.valueOf(environment.getCloudPlatform()));
NetworkDto originalNetworkDto = environmentNetworkConverter.convertToDto(originalNetwork);
NetworkDto cloneNetworkDto = NetworkDto.builder(originalNetworkDto).withSubnetMetas(editDto.getNetworkDto().getSubnetMetas()).build();
try {
Map<String, CloudSubnet> subnetMetadatas = cloudNetworkService.retrieveSubnetMetadata(environment, cloneNetworkDto);
originalNetwork.setSubnetMetas(subnetMetadatas.values().stream().collect(toMap(c -> getId(environment.getCloudPlatform(), c), c -> c)));
Map<String, CloudSubnet> endpointGatewaySubnetMetadatas = cloudNetworkService.retrieveEndpointGatewaySubnetMetadata(environment, cloneNetworkDto);
originalNetwork.setEndpointGatewaySubnetMetas(endpointGatewaySubnetMetadatas.values().stream().collect(toMap(c -> getId(environment.getCloudPlatform(), c), c -> c)));
Network network = environmentNetworkConverter.convertToNetwork(originalNetwork);
NetworkCidr networkCidr = environmentNetworkService.getNetworkCidr(network, environment.getCloudPlatform(), environment.getCredential());
originalNetwork.setNetworkCidr(networkCidr.getCidr());
originalNetwork.setNetworkCidrs(StringUtils.join(networkCidr.getCidrs(), ","));
} catch (NetworkConnectorNotFoundException connectorNotFoundException) {
throw new BadRequestException(connectorNotFoundException.getMessage());
}
return originalNetwork;
}
use of com.sequenceiq.cloudbreak.common.exception.BadRequestException in project cloudbreak by hortonworks.
the class CmTemplateValidator method validateRole.
private void validateRole(String accountId, EntitledForServiceScale role, Optional<ClouderaManagerProduct> cdhProduct, CmTemplateProcessor templateProcessor) {
Versioned blueprintVersion = () -> cdhProduct.isEmpty() ? "7.0.0" : cdhProduct.get().getVersion();
boolean versionEnablesScaling = isVersionEnablesScaling(blueprintVersion, role);
boolean entitledFor = entitlementService.isEntitledFor(accountId, role.getEntitledFor());
if (role.getBlockedUntilCDPVersion().isPresent() && !versionEnablesScaling && !entitledFor) {
throw new BadRequestException(String.format("'%s' service is not enabled to scale until CDP %s", role.name(), role.getBlockedUntilCDPVersion().get()));
} else if (role.getBlockedUntilCDPVersion().isEmpty() && !entitledFor) {
throw new BadRequestException(String.format("'%s' service is not enabled to scale", role.name()));
} else if (role.getRequiredService().isPresent() && !isRequiredServicePresent(role.getRequiredService(), templateProcessor) && versionEnablesScaling) {
throw new BadRequestException(String.format("'%s' service is not presented on the cluster, and that is required", role.getRequiredService().get()));
} else {
LOGGER.info("Account is entitled for {} so scaling is enabled.", role.getEntitledFor());
}
}
Aggregations