use of com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor in project cloudbreak by hortonworks.
the class ClusterStartHandler method accept.
@Override
public void accept(Event<ClusterStartRequest> event) {
ClusterStartRequest request = event.getData();
ClusterStartResult result;
int requestId;
try {
Stack stack = stackService.getByIdWithListsInTransaction(request.getResourceId());
Optional<Stack> datalakeStack = datalakeService.getDatalakeStackByDatahubStack(stack);
CmTemplateProcessor blueprintProcessor = getCmTemplateProcessor(stack.getCluster());
if (datalakeStack.isPresent() && clusterServicesRestartService.isRDCRefreshNeeded(stack, datalakeStack.get())) {
requestId = clusterServicesRestartService.refreshClusterOnStart(stack, datalakeStack.get(), blueprintProcessor);
} else {
requestId = apiConnectors.getConnector(stack).startCluster();
}
handleStopStartScalingFeature(stack, blueprintProcessor);
result = new ClusterStartResult(request, requestId);
} catch (Exception e) {
result = new ClusterStartResult(e.getMessage(), e, request);
}
eventBus.notify(result.selector(), new Event<>(event.getHeaders(), result));
}
use of com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor in project cloudbreak by hortonworks.
the class LoadBalancerSANProvider method getLoadBalancerSAN.
public Optional<String> getLoadBalancerSAN(Stack stack) {
checkNotNull(stack);
checkNotNull(stack.getCluster());
Cluster cluster = stack.getCluster();
CmTemplateProcessor cmTemplateProcessor = new CmTemplateProcessor(cluster.getBlueprint().getBlueprintText());
String cdhVersion = cmTemplateProcessor.getStackVersion();
if (isVersionNewerOrEqualThanLimited(cdhVersion, CLOUDERA_STACK_VERSION_7_2_11)) {
Set<LoadBalancer> loadBalancers = loadBalancerPersistenceService.findByStackId(stack.getId());
if (!loadBalancers.isEmpty()) {
Optional<LoadBalancer> loadBalancer = loadBalancerConfigService.selectLoadBalancerForFrontend(loadBalancers, LoadBalancerType.PUBLIC);
return loadBalancer.flatMap(this::getBestSANForLB);
}
}
return Optional.empty();
}
use of com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor in project cloudbreak by hortonworks.
the class LoadBalancerConfigService method getKnoxGatewayGroups.
public Set<String> getKnoxGatewayGroups(Stack stack) {
LOGGER.debug("Fetching list of instance groups with Knox gateway installed");
Set<String> groupNames = new HashSet<>();
Cluster cluster = stack.getCluster();
if (cluster != null) {
LOGGER.debug("Checking if Knox gateway is explicitly defined");
CmTemplateProcessor cmTemplateProcessor = new CmTemplateProcessor(cluster.getBlueprint().getBlueprintText());
groupNames = cmTemplateProcessor.getHostGroupsWithComponent(KnoxRoles.KNOX_GATEWAY);
}
if (groupNames.isEmpty()) {
LOGGER.debug("Knox gateway is not explicitly defined; searching for CM gateway hosts");
groupNames = stack.getInstanceGroups().stream().filter(i -> InstanceGroupType.isGateway(i.getInstanceGroupType())).map(InstanceGroup::getGroupName).collect(Collectors.toSet());
}
if (groupNames.isEmpty()) {
LOGGER.info("No Knox gateway instance groups found");
}
return groupNames;
}
use of com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor in project cloudbreak by hortonworks.
the class BlueprintConfigValidator method validate.
public void validate(Blueprint blueprint) {
CmTemplateProcessor cmTemplateProcessor = new CmTemplateProcessor(blueprint.getBlueprintText());
if (cmTemplateProcessor.isInstantiatorPresent()) {
throw new BadRequestException("Instantiator is present in your Cloudera Manager template which is probably incorrect.");
}
if (cmTemplateProcessor.isRepositoriesPresent()) {
throw new BadRequestException("Repositories are present in your Cloudera Manager template, this must be removed.");
}
Pattern passwordPattern = Pattern.compile("\\*\\*\\*");
Matcher passwordMatch = passwordPattern.matcher(blueprint.getBlueprintText());
if (passwordMatch.find()) {
throw new BadRequestException("Password placeholder with **** is present in your Cloudera Manager template which is probably incorrect.");
}
Pattern volumePattern = Pattern.compile("/hadoopfs/fs(.*?)");
Matcher volumeMatch = volumePattern.matcher(blueprint.getBlueprintText());
if (volumeMatch.find()) {
throw new BadRequestException("Volume configuration should not be part of your Cloudera Manager template.");
}
if (!cmTemplateProcessor.everyHostTemplateHasRoleConfigGroupsRefNames()) {
throw new BadRequestException("RoleConfigGroupsRefNames is probably missing or misspelled in your Cloudera Manager template.");
}
if (!cmTemplateProcessor.everyServiceHasRoleConfigGroups()) {
throw new BadRequestException("RoleConfigGroups is probably missing or misspelled in your Cloudera Manager template.");
}
}
use of com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor in project cloudbreak by hortonworks.
the class BlueprintValidator method validate.
@Override
public void validate(Object target, Errors errors) {
Blueprint blueprint = (Blueprint) target;
if (blueprint.getBlueprintText().isEmpty()) {
errors.rejectValue("blueprintText", "empty", "The blueprint text is empty");
}
CmTemplateProcessor cm = cmTemplateProcessorFactory.get(blueprint.getBlueprintText());
validateHostNames(cm, errors);
validateRoleType(cm, errors);
}
Aggregations