use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType in project cloudbreak by hortonworks.
the class DefaultBlueprintCache method loadBlueprintsFromFile.
@PostConstruct
public void loadBlueprintsFromFile() {
Map<String, Set<String>> blueprints = blueprints();
for (Map.Entry<String, Set<String>> blueprintEntry : blueprints.entrySet()) {
try {
for (String blueprintText : blueprintEntry.getValue()) {
String[] split = blueprintText.trim().split("=");
if (blueprintUtils.isBlueprintNamePreConfigured(blueprintText, split)) {
LOGGER.debug("Load default validation '{}'.", AnonymizerUtil.anonymize(blueprintText));
BlueprintV4Request blueprintJson = new BlueprintV4Request();
blueprintJson.setName(split[0].trim());
JsonNode jsonNode = blueprintUtils.convertStringToJsonNode(blueprintUtils.readDefaultBlueprintFromFile(blueprintEntry.getKey(), split));
JsonNode blueprintNode = jsonNode.get("blueprint");
blueprintJson.setBlueprint(blueprintNode.toString());
Blueprint bp = converter.convert(blueprintJson);
JsonNode tags = jsonNode.get("tags");
Map<String, Object> tagParameters = blueprintUtils.prepareTags(tags);
bp.setTags(new Json(tagParameters));
JsonNode description = jsonNode.get("description");
bp.setDescription(description == null ? split[0] : description.asText(split[0]));
JsonNode blueprintUpgradeOption = blueprintNode.isMissingNode() ? null : blueprintNode.get("blueprintUpgradeOption");
bp.setBlueprintUpgradeOption(getBlueprintUpgradeOption(blueprintUpgradeOption));
BlueprintFile bpf = new BlueprintFile.Builder().name(bp.getName()).blueprintText(bp.getBlueprintText()).stackName(bp.getStackName()).stackVersion(bp.getStackVersion()).stackType(bp.getStackType()).blueprintUpgradeOption(bp.getBlueprintUpgradeOption()).hostGroupCount(bp.getHostGroupCount()).description(bp.getDescription()).build();
defaultBlueprints.put(bp.getName(), bpf);
}
}
} catch (IOException e) {
LOGGER.error("Can not read default validation from file: ", e);
}
}
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType in project cloudbreak by hortonworks.
the class StackCreatorServiceTest method testDetermineStackTypeBasedOnTheUsedApiShouldReturnWhenStackTypeIsNullAndNotDistroXRequest.
@Test
public void testDetermineStackTypeBasedOnTheUsedApiShouldReturnWhenStackTypeIsNullAndNotDistroXRequest() {
Stack stack = new Stack();
stack.setType(null);
StackType actual = underTest.determineStackTypeBasedOnTheUsedApi(stack, false);
assertEquals(StackType.LEGACY, actual);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType in project cloudbreak by hortonworks.
the class StackService method getByCrnInWorkspaceWithEntries.
public StackV4Response getByCrnInWorkspaceWithEntries(String crn, Long workspaceId, Set<String> entries, User user, StackType stackType) {
try {
return transactionService.required(() -> {
Workspace workspace = workspaceService.get(workspaceId, user);
ShowTerminatedClustersAfterConfig showTerminatedClustersAfterConfig = showTerminatedClusterConfigService.get();
Optional<Stack> stack = findByCrnAndWorkspaceIdWithLists(crn, workspace.getId(), stackType, showTerminatedClustersAfterConfig);
if (stack.isEmpty()) {
throw new NotFoundException(format("Stack not found by crn '%s'", crn));
}
StackV4Response stackResponse = stackToStackV4ResponseConverter.convert(stack.get());
stackResponse = stackResponseDecorator.decorate(stackResponse, stack.get(), entries);
return stackResponse;
});
} catch (TransactionExecutionException e) {
throw new TransactionRuntimeExecutionException(e);
}
}
Aggregations