Search in sources :

Example 1 with SiteConfigurations

use of com.sequenceiq.cloudbreak.blueprint.configuration.SiteConfigurations in project cloudbreak by hortonworks.

the class BlueprintTextProcessor method convertTextToConfiguration.

private SiteConfigurations convertTextToConfiguration(String config) {
    try {
        SiteConfigurations result = SiteConfigurations.getEmptyConfiguration();
        ObjectNode root = (ObjectNode) JsonUtil.readTree(config);
        for (Iterator<Map.Entry<String, JsonNode>> sites = root.fields(); sites.hasNext(); ) {
            Map.Entry<String, JsonNode> site = sites.next();
            ObjectNode siteNode = (ObjectNode) site.getValue();
            JsonNode properties = siteNode.findValue(PROPERTIES_NODE);
            if (properties != null) {
                siteNode = (ObjectNode) properties;
            }
            Map<String, String> siteprops = new HashMap<>();
            for (Iterator<Map.Entry<String, JsonNode>> props = siteNode.fields(); props.hasNext(); ) {
                Map.Entry<String, JsonNode> prop = props.next();
                siteprops.put(prop.getKey(), prop.getValue().textValue());
            }
            if (!siteprops.isEmpty()) {
                result.addSiteConfiguration(site.getKey(), siteprops);
            }
        }
        return result;
    } catch (IOException e) {
        throw new BlueprintProcessingException("Failed to parse configuration ('" + config + "').", e);
    }
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) HashMap(java.util.HashMap) SiteConfigurations(com.sequenceiq.cloudbreak.blueprint.configuration.SiteConfigurations) JsonNode(com.fasterxml.jackson.databind.JsonNode) IOException(java.io.IOException) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with SiteConfigurations

use of com.sequenceiq.cloudbreak.blueprint.configuration.SiteConfigurations in project cloudbreak by hortonworks.

the class HadoopConfigurationService method customTextManipulation.

@Override
public BlueprintTextProcessor customTextManipulation(BlueprintPreparationObject source, BlueprintTextProcessor blueprintProcessor) {
    Map<String, Map<String, Map<String, String>>> hostGroupConfig = configService.getHostGroupConfiguration(blueprintProcessor, source.getHostgroupViews());
    HostgroupConfigurations hostgroupConfigurations = HostgroupConfigurations.fromMap(hostGroupConfig);
    blueprintProcessor.extendBlueprintHostGroupConfiguration(hostgroupConfigurations, false);
    Map<String, Map<String, String>> globalConfig = getGlobalConfiguration(blueprintProcessor, source.getHostgroupViews());
    SiteConfigurations siteConfigurations = SiteConfigurations.fromMap(globalConfig);
    blueprintProcessor.extendBlueprintGlobalConfiguration(siteConfigurations, false);
    return blueprintProcessor;
}
Also used : HostgroupConfigurations(com.sequenceiq.cloudbreak.blueprint.configuration.HostgroupConfigurations) SiteConfigurations(com.sequenceiq.cloudbreak.blueprint.configuration.SiteConfigurations) Map(java.util.Map)

Example 3 with SiteConfigurations

use of com.sequenceiq.cloudbreak.blueprint.configuration.SiteConfigurations in project cloudbreak by hortonworks.

the class KerberosBlueprintService method extendBlueprintWithKerberos.

public BlueprintTextProcessor extendBlueprintWithKerberos(BlueprintTextProcessor blueprint, Map<String, String> kerberosEnv, String domains, Boolean useUdp, Integer kpropPort, boolean forced) {
    try {
        String krb5Config = FileReaderUtils.readFileFromClasspath("kerberos/krb5-conf-template.conf");
        krb5Config = krb5Config.replaceAll("udp_preference_limit_content", useUdp ? "0" : "1");
        if (kpropPort != null) {
            krb5Config = krb5Config.replaceAll("iprop_enable_content", "true");
            krb5Config = krb5Config.replaceAll("iprop_port_content", kpropPort.toString());
        } else {
            krb5Config = krb5Config.replaceAll("iprop_enable_content", "false");
            krb5Config = krb5Config.replaceAll("iprop_port_content", "8888");
        }
        SiteConfigurations configs = SiteConfigurations.getEmptyConfiguration();
        Map<String, String> krb5Conf = new HashMap<>();
        krb5Conf.put("domains", domains);
        krb5Conf.put("manage_krb5_conf", "true");
        if (!useUdp || kpropPort != null) {
            krb5Conf.put("content", krb5Config.toString());
        }
        configs.addSiteConfiguration("kerberos-env", kerberosEnv);
        configs.addSiteConfiguration("krb5-conf", krb5Conf);
        return blueprint.addComponentToHostgroups("KERBEROS_CLIENT", hg -> true).setSecurityType("KERBEROS").extendBlueprintGlobalConfiguration(configs, forced);
    } catch (IOException e) {
        throw new BlueprintProcessingException("Failed to extend blueprint with kerberos configurations.", e);
    }
}
Also used : BlueprintProcessingException(com.sequenceiq.cloudbreak.blueprint.BlueprintProcessingException) HashMap(java.util.HashMap) SiteConfigurations(com.sequenceiq.cloudbreak.blueprint.configuration.SiteConfigurations) IOException(java.io.IOException)

Aggregations

SiteConfigurations (com.sequenceiq.cloudbreak.blueprint.configuration.SiteConfigurations)3 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 BlueprintProcessingException (com.sequenceiq.cloudbreak.blueprint.BlueprintProcessingException)1 HostgroupConfigurations (com.sequenceiq.cloudbreak.blueprint.configuration.HostgroupConfigurations)1