use of com.sequenceiq.cloudbreak.domain.StackValidation in project cloudbreak by hortonworks.
the class StackCommonService method validate.
@Override
public Response validate(StackValidationRequest request) {
StackValidation stackValidation = conversionService.convert(request, StackValidation.class);
stackService.validateStack(stackValidation, true);
CloudCredential cloudCredential = credentialToCloudCredentialConverter.convert(stackValidation.getCredential());
fileSystemValidator.validateFileSystem(request.getPlatform(), cloudCredential, request.getFileSystem());
return Response.status(Status.NO_CONTENT).build();
}
use of com.sequenceiq.cloudbreak.domain.StackValidation in project cloudbreak by hortonworks.
the class StackCreatorService method createStack.
public StackResponse createStack(IdentityUser user, StackRequest stackRequest, boolean publicInAccount) throws Exception {
stackRequest.setAccount(user.getAccount());
stackRequest.setOwner(user.getUserId());
stackRequest.setOwnerEmail(user.getUsername());
long start = System.currentTimeMillis();
Stack stack = conversionService.convert(stackRequest, Stack.class);
String stackName = stack.getName();
LOGGER.info("Stack request converted to stack in {} ms for stack {}", System.currentTimeMillis() - start, stackName);
MDCBuilder.buildMdcContext(stack);
start = System.currentTimeMillis();
stack = stackSensitiveDataPropagator.propagate(stackRequest.getCredentialSource(), stack, user);
LOGGER.info("Stack propagated with sensitive data in {} ms for stack {}", System.currentTimeMillis() - start, stackName);
start = System.currentTimeMillis();
stack = stackDecorator.decorate(stack, stackRequest, user);
LOGGER.info("Stack object has been decorated in {} ms for stack {}", System.currentTimeMillis() - start, stackName);
stack.setPublicInAccount(publicInAccount);
start = System.currentTimeMillis();
validateAccountPreferences(stack, user);
LOGGER.info("Account preferences has been validated in {} ms for stack {}", System.currentTimeMillis() - start, stackName);
if (stack.getOrchestrator() != null && stack.getOrchestrator().getApiEndpoint() != null) {
stackService.validateOrchestrator(stack.getOrchestrator());
}
for (InstanceGroup instanceGroup : stack.getInstanceGroups()) {
templateValidator.validateTemplateRequest(stack.getCredential(), instanceGroup.getTemplate(), stack.getRegion(), stack.getAvailabilityZone(), stack.getPlatformVariant());
}
Blueprint blueprint = null;
if (stackRequest.getClusterRequest() != null) {
start = System.currentTimeMillis();
StackValidationRequest stackValidationRequest = conversionService.convert(stackRequest, StackValidationRequest.class);
LOGGER.info("Stack validation request has been created in {} ms for stack {}", System.currentTimeMillis() - start, stackName);
start = System.currentTimeMillis();
StackValidation stackValidation = conversionService.convert(stackValidationRequest, StackValidation.class);
LOGGER.info("Stack validation object has been created in {} ms for stack {}", System.currentTimeMillis() - start, stackName);
blueprint = stackValidation.getBlueprint();
start = System.currentTimeMillis();
stackService.validateStack(stackValidation, stackRequest.getClusterRequest().getValidateBlueprint());
LOGGER.info("Stack has been validated in {} ms for stack {}", System.currentTimeMillis() - start, stackName);
CloudCredential cloudCredential = credentialToCloudCredentialConverter.convert(stack.getCredential());
start = System.currentTimeMillis();
fileSystemValidator.validateFileSystem(stackValidationRequest.getPlatform(), cloudCredential, stackValidationRequest.getFileSystem());
LOGGER.info("Filesystem has been validated in {} ms for stack {}", System.currentTimeMillis() - start, stackName);
start = System.currentTimeMillis();
clusterCreationService.validate(stackRequest.getClusterRequest(), cloudCredential, stack, user);
LOGGER.info("Cluster has been validated in {} ms for stack {}", System.currentTimeMillis() - start, stackName);
}
start = System.currentTimeMillis();
stack = stackService.create(user, stack, stackRequest.getImageCatalog(), Optional.ofNullable(stackRequest.getImageId()), Optional.ofNullable(blueprint));
LOGGER.info("Stack object and its dependencies has been created in {} ms for stack {}", System.currentTimeMillis() - start, stackName);
createClusterIfNeed(user, stackRequest, stack, stackName, blueprint);
start = System.currentTimeMillis();
StackResponse response = conversionService.convert(stack, StackResponse.class);
LOGGER.info("Stack response has been created in {} ms for stack {}", System.currentTimeMillis() - start, stackName);
start = System.currentTimeMillis();
flowManager.triggerProvisioning(stack.getId());
LOGGER.info("Stack provision triggered in {} ms for stack {}", System.currentTimeMillis() - start, stackName);
return response;
}
use of com.sequenceiq.cloudbreak.domain.StackValidation in project cloudbreak by hortonworks.
the class StackValidationRequestToStackValidationConverter method convert.
@Override
public StackValidation convert(StackValidationRequest stackValidationRequest) {
StackValidation stackValidation = new StackValidation();
Set<InstanceGroup> instanceGroups = convertInstanceGroups(stackValidationRequest.getInstanceGroups());
stackValidation.setInstanceGroups(instanceGroups);
stackValidation.setHostGroups(convertHostGroupsFromJson(instanceGroups, stackValidationRequest.getHostGroups()));
try {
validateBlueprint(stackValidationRequest, stackValidation);
} catch (AccessDeniedException e) {
throw new AccessDeniedException(String.format("Access to validation '%s' is denied or validation doesn't exist.", stackValidationRequest.getBlueprintId()), e);
}
try {
validateCredential(stackValidationRequest, stackValidation);
} catch (AccessDeniedException e) {
throw new AccessDeniedException(String.format("Access to credential '%s' is denied or credential doesn't exist.", stackValidationRequest.getCredentialId()), e);
}
try {
validateNetwork(stackValidationRequest.getNetworkId(), stackValidationRequest.getNetwork(), stackValidation);
} catch (AccessDeniedException e) {
throw new AccessDeniedException(String.format("Access to network '%s' is denied or network doesn't exist.", stackValidationRequest.getNetworkId()), e);
}
return stackValidation;
}
Aggregations