Search in sources :

Example 6 with GATEWAY

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;
}
Also used : Arrays(java.util.Arrays) EntitlementService(com.sequenceiq.cloudbreak.auth.altus.EntitlementService) LoggerFactory(org.slf4j.LoggerFactory) StringUtils(org.apache.commons.lang3.StringUtils) OozieRoles(com.sequenceiq.cloudbreak.cmtemplate.configproviders.oozie.OozieRoles) ThreadBasedUserCrnProvider(com.sequenceiq.cloudbreak.auth.ThreadBasedUserCrnProvider) LoadBalancer(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer) ProviderParameterCalculator(com.sequenceiq.cloudbreak.common.mappable.ProviderParameterCalculator) PublicEndpointAccessGateway(com.sequenceiq.common.api.type.PublicEndpointAccessGateway) Map(java.util.Map) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) SubnetSelector(com.sequenceiq.cloudbreak.converter.v4.environment.network.SubnetSelector) AzureStackV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.stack.AzureStackV4Parameters) LoadBalancerPersistenceService(com.sequenceiq.cloudbreak.service.stack.LoadBalancerPersistenceService) Set(java.util.Set) LoadBalancerSku(com.sequenceiq.common.api.type.LoadBalancerSku) Collectors(java.util.stream.Collectors) KnoxRoles(com.sequenceiq.cloudbreak.cmtemplate.configproviders.knox.KnoxRoles) Json(com.sequenceiq.cloudbreak.common.json.Json) List(java.util.List) Optional(java.util.Optional) GCP(com.sequenceiq.cloudbreak.common.mappable.CloudPlatform.GCP) CmTemplateProcessor(com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor) CLOUDERA_STACK_VERSION_7_2_11(com.sequenceiq.cloudbreak.cmtemplate.CMRepositoryVersionUtil.CLOUDERA_STACK_VERSION_7_2_11) OOZIE_HTTPS_PORT(com.sequenceiq.cloudbreak.cmtemplate.configproviders.oozie.OozieHAConfigProvider.OOZIE_HTTPS_PORT) NetworkConstants(com.sequenceiq.cloudbreak.common.network.NetworkConstants) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) TargetGroupPortPair(com.sequenceiq.cloudbreak.cloud.model.TargetGroupPortPair) TargetGroup(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.TargetGroup) Network(com.sequenceiq.cloudbreak.domain.Network) EnvironmentNetworkResponse(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse) CloudPlatform(com.sequenceiq.cloudbreak.common.mappable.CloudPlatform) LoadBalancerType(com.sequenceiq.common.api.type.LoadBalancerType) HashSet(java.util.HashSet) Inject(javax.inject.Inject) Value(org.springframework.beans.factory.annotation.Value) AWS(com.sequenceiq.cloudbreak.common.mappable.CloudPlatform.AWS) Service(org.springframework.stereotype.Service) CMRepositoryVersionUtil.isVersionNewerOrEqualThanLimited(com.sequenceiq.cloudbreak.cmtemplate.CMRepositoryVersionUtil.isVersionNewerOrEqualThanLimited) NetworkV4Base(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.NetworkV4Base) Map.entry(java.util.Map.entry) AzureInstanceGroupParameters(com.sequenceiq.cloudbreak.cloud.model.instance.AzureInstanceGroupParameters) LoadBalancerCreation(com.sequenceiq.common.api.type.LoadBalancerCreation) CloudSubnet(com.sequenceiq.cloudbreak.cloud.model.CloudSubnet) Logger(org.slf4j.Logger) AvailabilitySetNameService(com.sequenceiq.cloudbreak.cloud.model.instance.AvailabilitySetNameService) TargetGroupType(com.sequenceiq.common.api.type.TargetGroupType) InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) StackType(com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType) Preconditions(com.google.common.base.Preconditions) AZURE(com.sequenceiq.cloudbreak.common.mappable.CloudPlatform.AZURE) Collections(java.util.Collections) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) CmTemplateProcessor(com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor) HashSet(java.util.HashSet) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)

Example 7 with GATEWAY

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);
}
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 8 with GATEWAY

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;
}
Also used : ClusterExposedServiceV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.gateway.topology.ClusterExposedServiceV4Response)

Example 9 with GATEWAY

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());
}
Also used : GatewayV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.GatewayV4Request) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) Test(org.junit.Test)

Example 10 with GATEWAY

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."));
}
Also used : GatewayTopologyV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.topology.GatewayTopologyV4Request) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) Test(org.junit.Test)

Aggregations

Gateway (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway)20 Test (org.junit.Test)18 GatewayV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.GatewayV4Request)16 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)16 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)15 Set (java.util.Set)15 Map (java.util.Map)14 List (java.util.List)13 Test (org.junit.jupiter.api.Test)12 InstanceGroup (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)10 Json (com.sequenceiq.cloudbreak.common.json.Json)9 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)9 Optional (java.util.Optional)9 Collectors (java.util.stream.Collectors)9 GatewayTopologyV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.topology.GatewayTopologyV4Request)8 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)8 InstanceGroupType (com.sequenceiq.common.api.type.InstanceGroupType)8 HashSet (java.util.HashSet)8 EntitlementService (com.sequenceiq.cloudbreak.auth.altus.EntitlementService)7 InstanceMetaDataService (com.sequenceiq.cloudbreak.service.stack.InstanceMetaDataService)7