Search in sources :

Example 1 with ExposedService

use of com.sequenceiq.cloudbreak.api.service.ExposedService in project cloudbreak by hortonworks.

the class ClusterHostServiceRunner method createGatewayPillar.

@SuppressWarnings("ParameterNumber")
private Map<String, SaltPillarProperties> createGatewayPillar(GatewayConfig gatewayConfig, Cluster cluster, Stack stack, VirtualGroupRequest virtualGroupRequest, ClusterPreCreationApi connector, KerberosConfig kerberosConfig, Map<String, List<String>> serviceLocations, ClouderaManagerRepo clouderaManagerRepo) throws IOException {
    Map<String, Object> gateway = new HashMap<>();
    gateway.put("address", gatewayConfig.getPublicAddress());
    if (gatewayConfig.getPublicAddress() != null) {
        boolean addressIsIp = InetAddresses.isInetAddress(gatewayConfig.getPublicAddress());
        LOGGER.debug("Checking if {} is an ip address. Result: {}", gatewayConfig.getPublicAddress(), addressIsIp);
        gateway.put("address_is_ip", addressIsIp);
    }
    gateway.put("username", cluster.getUserName());
    gateway.put("password", cluster.getPassword());
    gateway.put("enable_knox_ranger_authorizer", isRangerAuthorizerEnabled(clouderaManagerRepo));
    gateway.put("enable_ccmv2", stack.getTunnel().useCcmV2OrJumpgate());
    gateway.put("enable_ccmv2_jumpgate", stack.getTunnel().useCcmV2Jumpgate());
    gateway.putAll(createKnoxRelatedGatewayCofniguration(cluster, virtualGroupRequest, connector));
    gateway.putAll(createGatewayUserFacingCertAndFqdn(gatewayConfig, cluster));
    gateway.put("kerberos", kerberosConfig != null);
    ExposedService rangerService = exposedServiceCollector.getRangerService();
    List<String> rangerLocations = serviceLocations.get(rangerService.getServiceName());
    if (!CollectionUtils.isEmpty(rangerLocations)) {
        List<String> rangerGatewayHosts = getRangerFqdn(cluster, gatewayConfig.getHostname(), rangerLocations);
        serviceLocations.put(rangerService.getServiceName(), rangerGatewayHosts);
    }
    serviceLocations.put(exposedServiceCollector.getClouderaManagerService().getServiceName(), asList(gatewayConfig.getHostname()));
    gateway.put("location", serviceLocations);
    if (stack.getNetwork() != null) {
        gateway.put("cidrBlocks", stack.getNetwork().getNetworkCidrs());
    }
    return Map.of("gateway", new SaltPillarProperties("/gateway/init.sls", singletonMap("gateway", gateway)));
}
Also used : HashMap(java.util.HashMap) ExposedService(com.sequenceiq.cloudbreak.api.service.ExposedService) SaltPillarProperties(com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties)

Example 2 with ExposedService

use of com.sequenceiq.cloudbreak.api.service.ExposedService in project cloudbreak by hortonworks.

the class ClusterHostServiceRunner method getServiceLocations.

private Map<String, List<String>> getServiceLocations(Cluster cluster) {
    Set<String> serviceNames = exposedServiceCollector.getAllServiceNames();
    Map<String, List<String>> componentLocation = componentLocator.getComponentLocation(cluster, serviceNames);
    ExposedService impalaService = exposedServiceCollector.getImpalaService();
    if (componentLocation.containsKey(impalaService.getServiceName())) {
        // IMPALA_DEBUG_UI role is not a valid role, but we need to distinguish the 2 roles in order to generate the Knox topology file
        componentLocation.put(exposedServiceCollector.getImpalaDebugUIService().getServiceName(), List.copyOf(componentLocation.get(impalaService.getServiceName())));
        Map<String, List<String>> impalaLocations = componentLocator.getImpalaCoordinatorLocations(cluster);
        List<String> locations = impalaLocations.values().stream().flatMap(List::stream).collect(Collectors.toList());
        componentLocation.replace(impalaService.getServiceName(), locations);
    }
    return componentLocation;
}
Also used : ExposedService(com.sequenceiq.cloudbreak.api.service.ExposedService) ArrayList(java.util.ArrayList) List(java.util.List)

Example 3 with ExposedService

use of com.sequenceiq.cloudbreak.api.service.ExposedService in project cloudbreak by hortonworks.

the class ServiceEndpointCollector method generateGatewayTopology.

private void generateGatewayTopology(Cluster cluster, String managerIp, Map<String, Collection<ClusterExposedServiceV4Response>> clusterExposedServiceMap, Collection<ExposedService> knownExposedServices, Gateway gateway, Map<String, List<String>> privateIps, GatewayTopology gatewayTopology, Optional<String> version) {
    LOGGER.debug("Generating the topology for '{}' topologies", gatewayTopology.getTopologyName());
    Set<String> exposedServicesInTopology = gateway.getTopologies().stream().flatMap(e -> getExposedServiceStream(e, version)).filter(Objects::nonNull).collect(Collectors.toSet());
    List<ClusterExposedServiceV4Response> uiServices = new ArrayList<>();
    List<ClusterExposedServiceV4Response> apiServices = new ArrayList<>();
    boolean autoTlsEnabled = cluster.getAutoTlsEnabled();
    LOGGER.debug("AutoTls enabled '{}' for the cluster", autoTlsEnabled);
    SecurityConfig securityConfig = cluster.getStack().getSecurityConfig();
    String managerServerUrl = getManagerServerUrl(cluster, managerIp);
    for (ExposedService exposedService : knownExposedServices) {
        if (exposedService.isCmProxied()) {
            List<ClusterExposedServiceV4Response> uiServiceOnPrivateIps = createCmProxiedServiceEntries(exposedService, gateway, gatewayTopology, managerServerUrl, cluster.getName());
            uiServices.addAll(uiServiceOnPrivateIps);
        } else {
            if (!exposedService.isApiOnly()) {
                List<ClusterExposedServiceV4Response> uiServiceOnPrivateIps = createServiceEntries(exposedService, gateway, gatewayTopology, managerIp, privateIps, exposedServicesInTopology, false, autoTlsEnabled, securityConfig, version);
                uiServices.addAll(uiServiceOnPrivateIps);
            }
            if (exposedService.isApiIncluded()) {
                List<ClusterExposedServiceV4Response> apiServiceOnPrivateIps = createServiceEntries(exposedService, gateway, gatewayTopology, managerIp, privateIps, exposedServicesInTopology, true, autoTlsEnabled, securityConfig, version);
                apiServices.addAll(apiServiceOnPrivateIps);
            }
        }
    }
    clusterExposedServiceMap.put(gatewayTopology.getTopologyName(), uiServices);
    clusterExposedServiceMap.put(gatewayTopology.getTopologyName() + API_TOPOLOGY_POSTFIX, apiServices);
}
Also used : SecurityConfig(com.sequenceiq.cloudbreak.domain.SecurityConfig) ExposedService(com.sequenceiq.cloudbreak.api.service.ExposedService) ArrayList(java.util.ArrayList) ClusterExposedServiceV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.gateway.topology.ClusterExposedServiceV4Response)

Example 4 with ExposedService

use of com.sequenceiq.cloudbreak.api.service.ExposedService in project cloudbreak by hortonworks.

the class ServiceEndpointCollector method getImpalaCoordinatorUrlWithHostFromGatewayTopology.

private String getImpalaCoordinatorUrlWithHostFromGatewayTopology(String managerIp, GatewayTopology gt, String impalaPrivateIp, boolean autoTlsEnabled) {
    Gateway gateway = gt.getGateway();
    ExposedService impalaDebugUi = exposedServiceCollector.getImpalaDebugUIService();
    Integer port = autoTlsEnabled ? impalaDebugUi.getTlsPort() : impalaDebugUi.getPort();
    if (gatewayListeningOnHttpsPort(gateway)) {
        return String.format("https://%s/%s/%s%s?scheme=%s&host=%s&port=%s", managerIp, gateway.getPath(), gt.getTopologyName(), impalaDebugUi.getKnoxUrl(), getHttpProtocol(autoTlsEnabled), impalaPrivateIp, port);
    } else {
        return String.format("https://%s:%s/%s/%s%s?scheme=%s&host=%s&port=%s", managerIp, gateway.getGatewayPort(), gateway.getPath(), gt.getTopologyName(), impalaDebugUi.getKnoxUrl(), getHttpProtocol(autoTlsEnabled), impalaPrivateIp, port);
    }
}
Also used : Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) ExposedService(com.sequenceiq.cloudbreak.api.service.ExposedService)

Example 5 with ExposedService

use of com.sequenceiq.cloudbreak.api.service.ExposedService in project cloudbreak by hortonworks.

the class ExposedServiceUtil method exposedService.

public static ExposedService exposedService(String name) {
    ExposedService exposedService = new ExposedService();
    exposedService.setApiIncluded(true);
    exposedService.setApiOnly(true);
    exposedService.setDisplayName(name);
    exposedService.setKnoxService(name);
    exposedService.setKnoxUrl(name);
    exposedService.setName(name);
    exposedService.setPort(1);
    exposedService.setServiceName(name);
    exposedService.setSsoSupported(true);
    exposedService.setTlsPort(1);
    exposedService.setVisibleForDatalake(true);
    exposedService.setVisibleForDatahub(true);
    return exposedService;
}
Also used : ExposedService(com.sequenceiq.cloudbreak.api.service.ExposedService)

Aggregations

ExposedService (com.sequenceiq.cloudbreak.api.service.ExposedService)24 Gateway (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway)10 ArrayList (java.util.ArrayList)8 GatewayTopology (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology)6 List (java.util.List)6 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)5 ClusterExposedServiceV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.gateway.topology.ClusterExposedServiceV4Response)4 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)4 ExposedServices (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.ExposedServices)4 IOException (java.io.IOException)4 GatewayType (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.GatewayType)3 GatewayTopologyV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.topology.GatewayTopologyV4Request)3 ExposedServiceV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.ExposedServiceV4Response)3 ExposedServiceCollector (com.sequenceiq.cloudbreak.api.service.ExposedServiceCollector)3 EntitlementService (com.sequenceiq.cloudbreak.auth.altus.EntitlementService)3 CmTemplateProcessor (com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor)3 CmTemplateProcessorFactory (com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessorFactory)3 Json (com.sequenceiq.cloudbreak.common.json.Json)3 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)3 BlueprintService (com.sequenceiq.cloudbreak.service.blueprint.BlueprintService)3