Search in sources :

Example 1 with FileSystemBase

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

the class ClusterRequestToClusterConverter method convert.

@Override
public Cluster convert(ClusterRequest source) {
    Cluster cluster = new Cluster();
    cluster.setName(source.getName());
    cluster.setStatus(REQUESTED);
    cluster.setDescription(source.getDescription());
    cluster.setEmailNeeded(source.getEmailNeeded());
    cluster.setUserName(source.getUserName());
    cluster.setPassword(source.getPassword());
    cluster.setExecutorType(source.getExecutorType());
    Boolean enableSecurity = source.getEnableSecurity();
    cluster.setSecure(enableSecurity == null ? Boolean.FALSE : enableSecurity);
    convertKnox(source, cluster);
    if (source.getKerberos() != null) {
        KerberosConfig kerberosConfig = getConversionService().convert(source.getKerberos(), KerberosConfig.class);
        cluster.setKerberosConfig(kerberosConfig);
    }
    cluster.setConfigStrategy(source.getConfigStrategy());
    cluster.setEmailTo(source.getEmailTo());
    FileSystemBase fileSystem = source.getFileSystem();
    cluster.setCloudbreakAmbariPassword(PasswordUtil.generatePassword());
    cluster.setCloudbreakAmbariUser("cloudbreak");
    convertAttributes(source, cluster);
    if (fileSystem != null) {
        cluster.setFileSystem(getConversionService().convert(fileSystem, FileSystem.class));
    }
    Map<String, String> inputs = source.getBlueprintInputs() == null ? Collections.emptyMap() : convertBlueprintInputJsons(source.getBlueprintInputs());
    try {
        cluster.setBlueprintInputs(new Json(inputs));
        if (source.getBlueprintCustomProperties() != null) {
            cluster.setBlueprintCustomProperties(source.getBlueprintCustomProperties());
        } else {
            cluster.setBlueprintCustomProperties(null);
        }
    } catch (JsonProcessingException ignored) {
        cluster.setBlueprintInputs(null);
    }
    try {
        Json json = new Json(convertContainerConfigs(source.getCustomContainer()));
        cluster.setCustomContainerDefinition(json);
    } catch (JsonProcessingException ignored) {
        cluster.setCustomContainerDefinition(null);
    }
    cluster.setAmbariSecurityMasterKey(source.getAmbariSecurityMasterKey());
    return cluster;
}
Also used : FileSystemBase(com.sequenceiq.cloudbreak.api.model.FileSystemBase) KerberosConfig(com.sequenceiq.cloudbreak.domain.KerberosConfig) FileSystem(com.sequenceiq.cloudbreak.domain.FileSystem) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) GatewayJson(com.sequenceiq.cloudbreak.api.model.GatewayJson) Json(com.sequenceiq.cloudbreak.domain.json.Json) BlueprintInputJson(com.sequenceiq.cloudbreak.api.model.BlueprintInputJson) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException)

Aggregations

JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 BlueprintInputJson (com.sequenceiq.cloudbreak.api.model.BlueprintInputJson)1 FileSystemBase (com.sequenceiq.cloudbreak.api.model.FileSystemBase)1 GatewayJson (com.sequenceiq.cloudbreak.api.model.GatewayJson)1 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)1 FileSystem (com.sequenceiq.cloudbreak.domain.FileSystem)1 KerberosConfig (com.sequenceiq.cloudbreak.domain.KerberosConfig)1 Json (com.sequenceiq.cloudbreak.domain.json.Json)1