use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceMetadataType.GATEWAY in project cloudbreak by hortonworks.
the class LoadBalancerConfigService method getKnoxGatewayGroups.
public Set<String> getKnoxGatewayGroups(Stack stack) {
LOGGER.debug("Fetching list of instance groups with Knox gateway installed");
Set<String> groupNames = new HashSet<>();
Cluster cluster = stack.getCluster();
if (cluster != null) {
LOGGER.debug("Checking if Knox gateway is explicitly defined");
CmTemplateProcessor cmTemplateProcessor = new CmTemplateProcessor(cluster.getBlueprint().getBlueprintText());
groupNames = cmTemplateProcessor.getHostGroupsWithComponent(KnoxRoles.KNOX_GATEWAY);
}
if (groupNames.isEmpty()) {
LOGGER.debug("Knox gateway is not explicitly defined; searching for CM gateway hosts");
groupNames = stack.getInstanceGroups().stream().filter(i -> InstanceGroupType.isGateway(i.getInstanceGroupType())).map(InstanceGroup::getGroupName).collect(Collectors.toSet());
}
if (groupNames.isEmpty()) {
LOGGER.info("No Knox gateway instance groups found");
}
return groupNames;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceMetadataType.GATEWAY 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.endpoint.v4.stacks.base.InstanceMetadataType.GATEWAY in project cloudbreak by hortonworks.
the class ServiceEndpointCollector method createExposedServiceResponse.
private ClusterExposedServiceV4Response createExposedServiceResponse(ExposedService exposedService, Gateway gateway, Set<String> exposedServicesInTopology, boolean api, String url) {
ClusterExposedServiceV4Response service = new ClusterExposedServiceV4Response();
service.setMode(api ? SSOType.PAM : getSSOType(exposedService, gateway));
service.setDisplayName(exposedService.getDisplayName());
service.setKnoxService(exposedService.getKnoxService());
service.setServiceName(exposedService.getServiceName());
service.setOpen(isExposed(exposedService, exposedServicesInTopology));
if (isNotEmpty(url)) {
service.setServiceUrl(url);
}
return service;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceMetadataType.GATEWAY in project cloudbreak by hortonworks.
the class GatewayConvertUtilTest method testGatewayPathConversionWhenNoPathInGatewayJson.
@Test
public void testGatewayPathConversionWhenNoPathInGatewayJson() {
Gateway gateway = new Gateway();
GatewayV4Request gatewayJson = new GatewayV4Request();
underTest.setGatewayPathAndSsoProvider(gatewayJson, gateway);
assertEquals('/' + gateway.getPath() + "/sso/api/v1/websso", gateway.getSsoProvider());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceMetadataType.GATEWAY in project cloudbreak by hortonworks.
the class GatewayTopologyV4RequestValidatorTest method testWithKnoxServiceButNoTopologyName.
@Test
public void testWithKnoxServiceButNoTopologyName() {
GatewayTopologyV4Request gatewayTopologyJson = new GatewayTopologyV4Request();
gatewayTopologyJson.setExposedServices(Collections.singletonList(exposedService("CLOUDERA_MANAGER_UI").getKnoxService()));
ValidationResult result = underTest.validate(gatewayTopologyJson);
assertEquals(1L, result.getErrors().size());
assertTrue(result.getErrors().get(0).contains("topologyName must be set in gateway topology."));
}
Aggregations