use of com.sequenceiq.cloudbreak.api.model.BlueprintInputJson 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.api.model.BlueprintInputJson in project cloudbreak by hortonworks.
the class ClusterToClusterResponseConverter method convertBlueprintInputs.
private Set<BlueprintInputJson> convertBlueprintInputs(Json inputs) {
Set<BlueprintInputJson> blueprintInputJsons = new HashSet<>();
try {
if (inputs != null && inputs.getValue() != null) {
Map<String, String> is = inputs.get(Map.class);
for (Entry<String, String> stringStringEntry : is.entrySet()) {
BlueprintInputJson blueprintInputJson = new BlueprintInputJson();
blueprintInputJson.setName(stringStringEntry.getKey());
blueprintInputJson.setPropertyValue(stringStringEntry.getValue());
blueprintInputJsons.add(blueprintInputJson);
}
}
} catch (IOException ignored) {
LOGGER.error("Could not convert blueprintinputs json to Set.");
}
return blueprintInputJsons;
}
use of com.sequenceiq.cloudbreak.api.model.BlueprintInputJson in project cloudbreak by hortonworks.
the class AmbariClusterService method retrieveOutputs.
@Override
public ConfigsResponse retrieveOutputs(Long stackId, Set<BlueprintParameterJson> requests) throws IOException {
Stack stack = stackService.get(stackId);
AmbariClient ambariClient = getAmbariClient(stack);
Cluster cluster = stack.getCluster();
List<String> targets = new ArrayList<>();
Map<String, String> bpI = new HashMap<>();
if (cluster.getBlueprintInputs().getValue() != null) {
bpI = cluster.getBlueprintInputs().get(Map.class);
}
prepareTargets(requests, targets, bpI);
Map<String, String> results = new HashMap<>();
if (cluster.getAmbariIp() != null) {
results = ambariClient.getConfigValuesByConfigIds(targets);
}
prepareResults(requests, cluster, bpI, results);
prepareAdditionalInputParameters(results, cluster);
Set<BlueprintInputJson> blueprintInputJsons = new HashSet<>();
for (Entry<String, String> stringStringEntry : results.entrySet()) {
for (BlueprintParameterJson blueprintParameter : requests) {
if (stringStringEntry.getKey().equals(blueprintParameter.getName())) {
BlueprintInputJson blueprintInputJson = new BlueprintInputJson();
blueprintInputJson.setName(blueprintParameter.getName());
blueprintInputJson.setPropertyValue(stringStringEntry.getValue());
blueprintInputJsons.add(blueprintInputJson);
break;
}
}
}
ConfigsResponse configsResponse = new ConfigsResponse();
configsResponse.setInputs(blueprintInputJsons);
return configsResponse;
}
Aggregations