Search in sources :

Example 11 with ExposedServices

use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.ExposedServices in project cloudbreak by hortonworks.

the class GatewayTopologyToGatewayTopologyV4ResponseConverter method convert.

public GatewayTopologyV4Response convert(GatewayTopology source) {
    GatewayTopologyV4Response response = new GatewayTopologyV4Response();
    ExposedServices exposedServices = getExposedServices(source);
    if (exposedServices != null) {
        response.setExposedServices(exposedServices.getServices());
    }
    response.setTopologyName(source.getTopologyName());
    return response;
}
Also used : ExposedServices(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.ExposedServices) GatewayTopologyV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.gateway.topology.GatewayTopologyV4Response)

Example 12 with ExposedServices

use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.ExposedServices in project cloudbreak by hortonworks.

the class GatewayTopologyV4RequestToExposedServicesConverter method convert.

public ExposedServices convert(GatewayTopologyV4Request source) {
    List<String> exposedServiceList = source.getExposedServices();
    ExposedServices exposedServices = new ExposedServices();
    if (!CollectionUtils.isEmpty(exposedServiceList)) {
        ValidationResult validationResult = exposedServiceListValidator.validate(exposedServiceList);
        if (validationResult.hasError()) {
            throw new BadRequestException(validationResult.getFormattedErrors());
        }
        exposedServices.setServices(new ArrayList<>(exposedServiceList));
    }
    return exposedServices;
}
Also used : BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) ExposedServices(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.ExposedServices) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult)

Example 13 with ExposedServices

use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.ExposedServices in project cloudbreak by hortonworks.

the class ClusterHostServiceRunner method mapTopologyToMap.

private Map<String, Object> mapTopologyToMap(GatewayTopology gt, Optional<String> version) throws IOException {
    Map<String, Object> topology = new HashMap<>();
    topology.put("name", gt.getTopologyName());
    Json exposedJson = gt.getExposedServices();
    if (exposedJson != null && isNotEmpty(exposedJson.getValue())) {
        ExposedServices exposedServicesDomain = exposedJson.get(ExposedServices.class);
        Set<String> exposedServices = exposedServiceCollector.getFullServiceListBasedOnList(exposedServicesDomain.getServices(), version);
        topology.put("exposed", exposedServices);
    } else {
        topology.put("exposed", new HashSet<>());
    }
    return topology;
}
Also used : HashMap(java.util.HashMap) ExposedServices(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.ExposedServices) Json(com.sequenceiq.cloudbreak.common.json.Json)

Example 14 with ExposedServices

use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.ExposedServices in project cloudbreak by hortonworks.

the class KnoxGatewayConfigProviderTest method roleConfigsWithGatewayWhenOdbcEntitlementFalse.

@Test
public void roleConfigsWithGatewayWhenOdbcEntitlementFalse() {
    GatewayTopology topology = new GatewayTopology();
    topology.setTopologyName("my-topology");
    topology.setExposedServices(Json.silent(new ExposedServices()));
    Gateway gateway = new Gateway();
    gateway.setKnoxMasterSecret("admin");
    gateway.setPath("/a/b/c");
    gateway.setTopologies(Set.of(topology));
    IdBroker idBroker = new IdBroker();
    idBroker.setMasterSecret("supersecret");
    BlueprintTextProcessor blueprintTextProcessor = mock(BlueprintTextProcessor.class);
    BlueprintView blueprintView = new BlueprintView("text", "7.2.11", "CDH", blueprintTextProcessor);
    GeneralClusterConfigs generalClusterConfigs = new GeneralClusterConfigs();
    generalClusterConfigs.setAccountId(Optional.of("1234"));
    TemplatePreparationObject source = Builder.builder().withGateway(gateway, "key", new HashSet<>()).withGeneralClusterConfigs(generalClusterConfigs).withBlueprintView(blueprintView).withVirtualGroupView(new VirtualGroupRequest(TestConstants.CRN, "")).withProductDetails(new ClouderaManagerRepo().withVersion("7.4.2"), List.of(new ClouderaManagerProduct().withVersion("7.2.10").withName("CDH"))).withIdBroker(idBroker).build();
    when(virtualGroupService.createOrGetVirtualGroup(source.getVirtualGroupRequest(), UmsVirtualGroupRight.KNOX_ADMIN)).thenReturn("");
    when(entitlementService.isOjdbcTokenDhOneHour(anyString())).thenReturn(false);
    assertEquals(List.of(config("idbroker_master_secret", "supersecret"), config("idbroker_gateway_knox_admin_groups", ""), config("idbroker_gateway_signing_keystore_name", "signing.jks"), config("idbroker_gateway_signing_keystore_type", "JKS"), config("idbroker_gateway_signing_key_alias", "signing-identity")), underTest.getRoleConfigs(KnoxRoles.IDBROKER, source));
    assertEquals(List.of(config("gateway_master_secret", gateway.getKnoxMasterSecret()), config("gateway_default_topology_name", gateway.getTopologies().iterator().next().getTopologyName()), config("gateway_knox_admin_groups", ""), config("gateway_auto_discovery_enabled", "false"), config("gateway_path", gateway.getPath()), config("gateway_signing_keystore_name", "signing.jks"), config("gateway_signing_keystore_type", "JKS"), config("gateway_signing_key_alias", "signing-identity"), config("gateway_dispatch_whitelist", "^*.*$"), config("gateway_token_generation_enable_lifespan_input", "true"), config("gateway_token_generation_knox_token_ttl", "86400000"), config("gateway_service_tokenstate_impl", "org.apache.knox.gateway.services.token.impl.JDBCTokenStateService")), ThreadBasedUserCrnProvider.doAs(TEST_USER_CRN, () -> underTest.getRoleConfigs(KnoxRoles.KNOX_GATEWAY, source)));
    assertEquals(List.of(), underTest.getRoleConfigs("NAMENODE", source));
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) GeneralClusterConfigs(com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs) VirtualGroupRequest(com.sequenceiq.cloudbreak.auth.altus.VirtualGroupRequest) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) BlueprintTextProcessor(com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor) BlueprintView(com.sequenceiq.cloudbreak.template.views.BlueprintView) ExposedServices(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.ExposedServices) ClouderaManagerProduct(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct) GatewayTopology(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology) IdBroker(com.sequenceiq.cloudbreak.domain.stack.cluster.IdBroker) Test(org.junit.Test)

Aggregations

ExposedServices (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.ExposedServices)14 GatewayTopology (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology)9 Json (com.sequenceiq.cloudbreak.common.json.Json)7 Test (org.junit.Test)7 GatewayTopologyV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.topology.GatewayTopologyV4Request)5 GatewayTopologyV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.gateway.topology.GatewayTopologyV4Response)3 VirtualGroupRequest (com.sequenceiq.cloudbreak.auth.altus.VirtualGroupRequest)2 ClouderaManagerProduct (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct)2 ClouderaManagerRepo (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)2 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)2 IdBroker (com.sequenceiq.cloudbreak.domain.stack.cluster.IdBroker)2 Gateway (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway)2 TemplatePreparationObject (com.sequenceiq.cloudbreak.template.TemplatePreparationObject)2 GeneralClusterConfigs (com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs)2 BlueprintTextProcessor (com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor)2 BlueprintView (com.sequenceiq.cloudbreak.template.views.BlueprintView)2 ValidationResultBuilder (com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder)2 ExposedService (com.sequenceiq.cloudbreak.api.service.ExposedService)1 ValidationResult (com.sequenceiq.cloudbreak.validation.ValidationResult)1 HashMap (java.util.HashMap)1