use of com.sequenceiq.cloudbreak.domain.Blueprint in project cloudbreak by hortonworks.
the class BlueprintService method create.
@Transactional(TxType.NEVER)
public Blueprint create(IdentityUser user, Blueprint blueprint, Collection<Map<String, Map<String, String>>> properties) {
LOGGER.debug("Creating blueprint: [User: '{}', Account: '{}']", user.getUsername(), user.getAccount());
Blueprint savedBlueprint;
blueprint.setOwner(user.getUserId());
blueprint.setAccount(user.getAccount());
if (properties != null && !properties.isEmpty()) {
LOGGER.info("Extend validation with the following properties: {}", properties);
Map<String, Map<String, String>> configs = new HashMap<>(properties.size());
for (Map<String, Map<String, String>> property : properties) {
for (Entry<String, Map<String, String>> entry : property.entrySet()) {
Map<String, String> configValues = configs.get(entry.getKey());
if (configValues != null) {
configValues.putAll(entry.getValue());
} else {
configs.put(entry.getKey(), entry.getValue());
}
}
}
String extendedBlueprint = blueprintProcessorFactory.get(blueprint.getBlueprintText()).extendBlueprintGlobalConfiguration(SiteConfigurations.fromMap(configs), false).asText();
LOGGER.info("Extended validation result: {}", extendedBlueprint);
blueprint.setBlueprintText(extendedBlueprint);
}
try {
savedBlueprint = blueprintRepository.save(blueprint);
} catch (DataIntegrityViolationException ex) {
String msg = String.format("Error with resource [%s], error: [%s]", APIResourceType.BLUEPRINT, getProperSqlErrorMessage(ex));
throw new BadRequestException(msg);
}
return savedBlueprint;
}
use of com.sequenceiq.cloudbreak.domain.Blueprint in project cloudbreak by hortonworks.
the class BlueprintService method delete.
public void delete(Long id, IdentityUser user) {
Blueprint blueprint = blueprintRepository.findByIdInAccount(id, user.getAccount());
if (blueprint == null) {
throw new NotFoundException(String.format("Blueprint '%s' not found.", id));
}
delete(blueprint);
}
use of com.sequenceiq.cloudbreak.domain.Blueprint in project cloudbreak by hortonworks.
the class BlueprintService method get.
public Blueprint get(String name, String account) {
Blueprint blueprint = blueprintRepository.findOneByName(name, account);
if (blueprint == null) {
throw new NotFoundException(String.format("Blueprint '%s' not found in %s account.", name, account));
}
authorizationService.hasReadPermission(blueprint);
return blueprint;
}
use of com.sequenceiq.cloudbreak.domain.Blueprint in project cloudbreak by hortonworks.
the class AmbariClusterService method recreate.
@Override
public Cluster recreate(Long stackId, Long blueprintId, Set<HostGroup> hostGroups, boolean validateBlueprint, StackRepoDetails stackRepoDetails, String kerberosPassword, String kerberosPrincipal) {
if (blueprintId == null || hostGroups == null) {
throw new BadRequestException("Blueprint id and hostGroup assignments can not be null.");
}
Stack stack = stackService.getByIdWithLists(stackId);
Cluster cluster = getCluster(stack);
if (cluster != null && stack.getCluster().isSecure()) {
List<String> missing = Stream.of(Pair.of("password", kerberosPassword), Pair.of("principal", kerberosPrincipal)).filter(p -> !StringUtils.hasLength(p.getRight())).map(Pair::getLeft).collect(Collectors.toList());
if (!missing.isEmpty()) {
throw new BadRequestException(String.format("Missing Kerberos credential detail(s): %s", String.join(", ", missing)));
}
KerberosConfig kerberosConfig = cluster.getKerberosConfig();
kerberosConfig.setPassword(kerberosPassword);
kerberosConfig.setPrincipal(kerberosPrincipal);
kerberosConfigRepository.save(kerberosConfig);
}
Blueprint blueprint = blueprintService.get(blueprintId);
if (!withEmbeddedAmbariDB(cluster)) {
throw new BadRequestException("Ambari doesn't support resetting external DB automatically. To reset Ambari Server schema you must first drop " + "and then create it using DDL scripts from /var/lib/ambari-server/resources");
}
if (validateBlueprint) {
blueprintValidator.validateBlueprintForStack(cluster, blueprint, hostGroups, stack.getInstanceGroups());
}
Boolean containerOrchestrator;
try {
containerOrchestrator = orchestratorTypeResolver.resolveType(stack.getOrchestrator()).containerOrchestrator();
} catch (CloudbreakException ignored) {
containerOrchestrator = false;
}
if (containerOrchestrator) {
clusterTerminationService.deleteClusterComponents(cluster.getId());
cluster = clusterRepository.findById(stack.getCluster().getId());
}
hostGroups = hostGroupService.saveOrUpdateWithMetadata(hostGroups, cluster);
cluster = prepareCluster(hostGroups, stackRepoDetails, blueprint, stack, cluster);
try {
triggerClusterInstall(stack, cluster);
} catch (CloudbreakException e) {
throw new CloudbreakServiceException(e);
}
return stack.getCluster();
}
use of com.sequenceiq.cloudbreak.domain.Blueprint in project cloudbreak by hortonworks.
the class TestUtil method blueprint.
public static Blueprint blueprint(String name, String blueprintText) {
Blueprint blueprint = new Blueprint();
blueprint.setId(1L);
blueprint.setBlueprintText(blueprintText);
blueprint.setName(name);
blueprint.setAmbariName("multi-node-yarn");
blueprint.setStatus(ResourceStatus.DEFAULT);
return blueprint;
}
Aggregations