use of com.sequenceiq.cloudbreak.api.endpoint.v4.blueprint.requests.BlueprintV4Request 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.blueprint.requests.BlueprintV4Request in project cloudbreak by hortonworks.
the class BlueprintV4RequestToBlueprintConverterTest method acceptsBuiltinClouderaManagerTemplate.
@Test
public void acceptsBuiltinClouderaManagerTemplate() {
BlueprintV4Request request = new BlueprintV4Request();
request.setBlueprint(FileReaderUtils.readFileFromClasspathQuietly("defaults/blueprints/7.2.12/cdp-sdx.bp"));
Blueprint result = underTest.convert(request);
assertNotNull(result);
assertEquals("CDH", result.getStackType());
assertEquals("7.2.12", result.getStackVersion());
assertEquals(2, result.getHostGroupCount());
assertNotNull(result.getBlueprintText());
assertNotEquals("", result.getBlueprintText());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.blueprint.requests.BlueprintV4Request in project cloudbreak by hortonworks.
the class BlueprintV4RequestToBlueprintConverterTest method rejectsBuiltinWithInvalidContent.
@Test
public void rejectsBuiltinWithInvalidContent() {
BlueprintV4Request request = new BlueprintV4Request();
request.setBlueprint("{ \"blueprint\": { \"cdhVersion\": \"7.0.0\", { } }");
thrown.expect(BadRequestException.class);
thrown.expectMessage("Invalid cluster template: Failed to parse JSON.");
underTest.convert(request);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.blueprint.requests.BlueprintV4Request in project cloudbreak by hortonworks.
the class BlueprintV4RequestToBlueprintConverterTest method testConvertWhenUrlIsNotEmptyButInvalidThenExceptionWouldCome.
@Test
public void testConvertWhenUrlIsNotEmptyButInvalidThenExceptionWouldCome() {
String wrongUrl = "some wrong content for url";
BlueprintV4Request request = getRequest("blueprint.json");
request.setUrl(wrongUrl);
thrown.expect(BadRequestException.class);
thrown.expectMessage(String.format("Cannot download cluster template from: %s", wrongUrl));
underTest.convert(request);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.blueprint.requests.BlueprintV4Request in project cloudbreak by hortonworks.
the class BlueprintRequestTest method setUp.
@Before
public void setUp() {
underTest = new BlueprintV4Request();
localValidatorFactory = new LocalValidatorFactoryBean();
localValidatorFactory.setProviderClass(HibernateValidator.class);
localValidatorFactory.afterPropertiesSet();
}
Aggregations