use of com.sequenceiq.cloudbreak.domain.json.Json in project cloudbreak by hortonworks.
the class AmbariViewProvider method provideViewInformation.
public Cluster provideViewInformation(AmbariClient ambariClient, Cluster cluster) {
try {
LOGGER.info("Provide view definitions.");
List<String> viewDefinitions = (List<String>) ambariClient.getViewDefinitions();
Map<String, Object> obj = cluster.getAttributes().getMap();
if (obj == null || obj.isEmpty()) {
obj = new HashMap<>();
}
obj.put(VIEW_DEFINITIONS.name(), viewDefinitions);
cluster.setAttributes(new Json(obj));
return clusterRepository.save(cluster);
} catch (Exception e) {
LOGGER.warn("Failed to provide view definitions.", e);
}
return cluster;
}
use of com.sequenceiq.cloudbreak.domain.json.Json in project cloudbreak by hortonworks.
the class TestUtil method cluster.
public static Cluster cluster(Blueprint blueprint, Stack stack, Long id, KerberosConfig kerberosConfig) {
Cluster cluster = new Cluster();
cluster.setAmbariIp("50.51.52.100");
cluster.setStack(stack);
cluster.setId(id);
cluster.setName("dummyCluster");
cluster.setAmbariIp("10.0.0.1");
cluster.setBlueprint(blueprint);
cluster.setUpSince(new Date().getTime());
cluster.setStatus(AVAILABLE);
cluster.setStatusReason("statusReason");
cluster.setUserName("admin");
cluster.setPassword("admin");
Gateway gateway = new Gateway();
gateway.setEnableGateway(true);
gateway.setTopologyName("cb");
cluster.setGateway(gateway);
cluster.setExecutorType(ExecutorType.DEFAULT);
RDSConfig rdsConfig = new RDSConfig();
Set<RDSConfig> rdsConfigs = new HashSet<>();
rdsConfigs.add(rdsConfig);
cluster.setRdsConfigs(rdsConfigs);
cluster.setLdapConfig(ldapConfig());
cluster.setHostGroups(hostGroups(cluster));
Map<String, String> inputs = new HashMap<>();
inputs.put("S3_BUCKET", "testbucket");
try {
cluster.setBlueprintInputs(new Json(inputs));
} catch (JsonProcessingException ignored) {
cluster.setBlueprintInputs(null);
}
Map<String, String> map = new HashMap<>();
try {
cluster.setAttributes(new Json(map));
} catch (JsonProcessingException ignored) {
cluster.setAttributes(null);
}
if (kerberosConfig != null) {
cluster.setSecure(true);
cluster.setKerberosConfig(kerberosConfig);
}
return cluster;
}
use of com.sequenceiq.cloudbreak.domain.json.Json in project cloudbreak by hortonworks.
the class TestUtil method gateway.
public static Gateway gateway() throws JsonProcessingException {
Gateway gateway = new Gateway();
gateway.setEnableGateway(true);
gateway.setTopologyName("topology");
gateway.setPath("/path");
gateway.setSsoProvider("simple");
gateway.setGatewayType(GatewayType.CENTRAL);
gateway.setSignCert("signcert");
gateway.setSignKey("signkey");
gateway.setTokenCert("tokencert");
gateway.setSignPub("signpub");
gateway.setExposedServices(new Json("{}"));
return gateway;
}
use of com.sequenceiq.cloudbreak.domain.json.Json 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);
}
}
}
use of com.sequenceiq.cloudbreak.domain.json.Json in project cloudbreak by hortonworks.
the class UserProfileService method put.
public void put(UserProfileRequest request, IdentityUser user) {
UserProfile userProfile = get(user.getAccount(), user.getUserId(), user.getUsername());
if (request.getCredentialId() != null) {
Credential credential = credentialService.get(request.getCredentialId(), userProfile.getAccount());
userProfile.setCredential(credential);
} else if (request.getCredentialName() != null) {
Credential credential = credentialService.get(request.getCredentialName(), userProfile.getAccount());
userProfile.setCredential(credential);
}
for (Entry<String, Object> uiStringObjectEntry : request.getUiProperties().entrySet()) {
Map<String, Object> map = userProfile.getUiProperties().getMap();
if (map == null || map.isEmpty()) {
map = new HashMap<>();
}
map.put(uiStringObjectEntry.getKey(), uiStringObjectEntry.getValue());
try {
userProfile.setUiProperties(new Json(map));
} catch (JsonProcessingException ignored) {
throw new BadRequestException("The modification of the ui properties was unsuccesfull.");
}
}
userProfileRepository.save(userProfile);
}
Aggregations