Search in sources :

Example 1 with BlueprintRequest

use of com.sequenceiq.cloudbreak.api.model.BlueprintRequest in project cloudbreak by hortonworks.

the class BlueprintCreationTest method testBlueprintCreation.

@Test
@Parameters({ "blueprintName", "blueprintFile" })
public void testBlueprintCreation(@Optional("it-hdp-multi-blueprint") String blueprintName, @Optional("classpath:/blueprint/hdp-multinode-default.bp") String blueprintFile) throws Exception {
    // GIVEN
    String blueprintContent = ResourceUtil.readStringFromResource(applicationContext, blueprintFile);
    // WHEN
    BlueprintRequest blueprintRequest = new BlueprintRequest();
    blueprintRequest.setName(blueprintName);
    blueprintRequest.setDescription("Blueprint for integration testing");
    blueprintRequest.setAmbariBlueprint(blueprintContent);
    String id = getCloudbreakClient().blueprintEndpoint().postPrivate(blueprintRequest).getId().toString();
    // THEN
    Assert.assertNotNull(id);
    getItContext().putContextParam(CloudbreakITContextConstants.BLUEPRINT_ID, id, true);
}
Also used : BlueprintRequest(com.sequenceiq.cloudbreak.api.model.BlueprintRequest) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test)

Example 2 with BlueprintRequest

use of com.sequenceiq.cloudbreak.api.model.BlueprintRequest in project cloudbreak by hortonworks.

the class BlueprintToBlueprintRequestConverter method convert.

@Override
public BlueprintRequest convert(Blueprint source) {
    BlueprintRequest blueprintRequest = new BlueprintRequest();
    blueprintRequest.setName("");
    blueprintRequest.setDescription(source.getDescription());
    blueprintRequest.setAmbariBlueprint(source.getBlueprintText());
    return blueprintRequest;
}
Also used : BlueprintRequest(com.sequenceiq.cloudbreak.api.model.BlueprintRequest)

Example 3 with BlueprintRequest

use of com.sequenceiq.cloudbreak.api.model.BlueprintRequest in project cloudbreak by hortonworks.

the class DefaultBlueprintCache method loadBlueprintsFromFile.

@PostConstruct
public void loadBlueprintsFromFile() {
    for (String blueprintStrings : blueprintArray) {
        try {
            String[] split = blueprintStrings.split("=");
            if (blueprintUtils.isBlueprintNamePreConfigured(blueprintStrings, split)) {
                LOGGER.info("Load default validation '{}'.", blueprintStrings);
                BlueprintRequest blueprintJson = new BlueprintRequest();
                blueprintJson.setName(split[0].trim());
                JsonNode jsonNode = blueprintUtils.convertStringToJsonNode(blueprintUtils.readDefaultBlueprintFromFile(split));
                blueprintJson.setAmbariBlueprint(jsonNode.get("blueprint").toString());
                Blueprint bp = converter.convert(blueprintJson);
                JsonNode inputs = jsonNode.get("inputs");
                JsonNode description = jsonNode.get("description");
                bp.setDescription(description == null ? split[0] : description.asText(split[0]));
                BlueprintInputParameters inputParameters = new BlueprintInputParameters(blueprintUtils.prepareInputs(inputs));
                bp.setInputParameters(new Json(inputParameters));
                defaultBlueprints.put(bp.getName(), bp);
            }
        } catch (IOException e) {
            LOGGER.info("Can not read default validation from file: ", e);
        }
    }
}
Also used : Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) JsonNode(com.fasterxml.jackson.databind.JsonNode) Json(com.sequenceiq.cloudbreak.domain.json.Json) IOException(java.io.IOException) BlueprintRequest(com.sequenceiq.cloudbreak.api.model.BlueprintRequest) BlueprintInputParameters(com.sequenceiq.cloudbreak.domain.BlueprintInputParameters) PostConstruct(javax.annotation.PostConstruct)

Aggregations

BlueprintRequest (com.sequenceiq.cloudbreak.api.model.BlueprintRequest)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)1 BlueprintInputParameters (com.sequenceiq.cloudbreak.domain.BlueprintInputParameters)1 Json (com.sequenceiq.cloudbreak.domain.json.Json)1 IOException (java.io.IOException)1 PostConstruct (javax.annotation.PostConstruct)1 Parameters (org.testng.annotations.Parameters)1 Test (org.testng.annotations.Test)1