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)));
}
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;
}
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);
}
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);
}
}
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;
}
Aggregations