use of com.sequenceiq.cloudbreak.domain.BlueprintInputParameters in project cloudbreak by hortonworks.
the class BlueprintRequestToBlueprintConverter method prepareBlueprintInputs.
private void prepareBlueprintInputs(BlueprintRequest json, Blueprint blueprint) {
List<BlueprintParameter> blueprintParameterList = new ArrayList<>();
for (BlueprintParameterJson blueprintParameterJson : json.getInputs()) {
BlueprintParameter blueprintParameter = new BlueprintParameter();
blueprintParameter.setReferenceConfiguration(blueprintParameterJson.getReferenceConfiguration());
blueprintParameter.setDescription(blueprintParameterJson.getDescription());
blueprintParameter.setName(blueprintParameterJson.getName());
blueprintParameterList.add(blueprintParameter);
}
BlueprintInputParameters inputParameters = new BlueprintInputParameters(blueprintParameterList);
try {
blueprint.setInputParameters(new Json(inputParameters));
} catch (JsonProcessingException e) {
throw new BadRequestException("Invalid Blueprint: Failed to parse inputs.", e);
}
}
use of com.sequenceiq.cloudbreak.domain.BlueprintInputParameters in project cloudbreak by hortonworks.
the class BlueprintToBlueprintResponseConverter method convertInputParameters.
private Set<BlueprintParameterJson> convertInputParameters(Json inputParameters) throws IOException {
Set<BlueprintParameterJson> result = new HashSet<>();
if (inputParameters != null && StringUtils.isNoneEmpty(inputParameters.getValue())) {
BlueprintInputParameters inputParametersObj = inputParameters.get(BlueprintInputParameters.class);
List<BlueprintParameter> parameters = inputParametersObj.getParameters();
for (BlueprintParameter record : parameters) {
BlueprintParameterJson json = new BlueprintParameterJson();
json.setDescription(record.getDescription());
json.setName(record.getName());
json.setReferenceConfiguration(record.getReferenceConfiguration());
result.add(json);
}
}
return result;
}
use of com.sequenceiq.cloudbreak.domain.BlueprintInputParameters in project cloudbreak by hortonworks.
the class ClusterDecorator method prepareConnectedClusterParameters.
private void prepareConnectedClusterParameters(Cluster requestedCluster, IdentityUser user, ConnectedClusterRequest connectedClusterRequest) {
if (connectedClusterRequest != null) {
Long stackId;
Stack publicStack;
if (!Strings.isNullOrEmpty(connectedClusterRequest.getSourceClusterName())) {
publicStack = stackService.getPublicStack(connectedClusterRequest.getSourceClusterName(), user);
stackId = publicStack.getId();
} else {
stackId = connectedClusterRequest.getSourceClusterId();
publicStack = stackService.get(connectedClusterRequest.getSourceClusterId());
}
// We should set the ldap to the source cluster ldap
requestedCluster.setLdapConfig(publicStack.getCluster().getLdapConfig());
// We should set the ranger metastore to the source cluster ranger metastore if exist!
RDSConfig rangerRds = rdsConfigService.findByClusterIdAndType(publicStack.getOwner(), publicStack.getAccount(), publicStack.getCluster().getId(), RdsType.RANGER);
if (rangerRds != null) {
requestedCluster.getRdsConfigs().add(rangerRds);
}
try {
Set<BlueprintParameterJson> requests = new HashSet<>();
Json blueprintAttributes = requestedCluster.getBlueprint().getInputParameters();
if (blueprintAttributes != null && StringUtils.isNoneEmpty(blueprintAttributes.getValue())) {
BlueprintInputParameters inputParametersObj = blueprintAttributes.get(BlueprintInputParameters.class);
for (BlueprintParameter blueprintParameter : inputParametersObj.getParameters()) {
BlueprintParameterJson blueprintParameterJson = new BlueprintParameterJson();
blueprintParameterJson.setName(blueprintParameter.getName());
blueprintParameterJson.setReferenceConfiguration(blueprintParameter.getReferenceConfiguration());
blueprintParameterJson.setDescription(blueprintParameter.getDescription());
requests.add(blueprintParameterJson);
}
}
ConfigsResponse configsResponse = clusterService.retrieveOutputs(stackId, requests);
Map<String, String> newInputs = requestedCluster.getBlueprintInputs().get(Map.class);
for (BlueprintInputJson blueprintInputJson : configsResponse.getInputs()) {
newInputs.put(blueprintInputJson.getName(), blueprintInputJson.getPropertyValue());
}
requestedCluster.setBlueprintInputs(new Json(newInputs));
} catch (IOException e) {
LOGGER.error("Could not propagate cluster input parameters", e);
throw new BadRequestException("Could not propagate cluster input parameters: " + e.getMessage());
}
}
}
use of com.sequenceiq.cloudbreak.domain.BlueprintInputParameters 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);
}
}
}
Aggregations