Search in sources :

Example 56 with Gateway

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

the class StackV4RequestToGatewayConverter method convert.

public Gateway convert(StackV4Request source) {
    Gateway gateway = new Gateway();
    GatewayV4Request gatewayJson = source.getCluster().getGateway();
    ValidationResult validationResult = gatewayJsonValidator.validate(gatewayJson);
    if (validationResult.hasError()) {
        throw new BadRequestException(validationResult.getFormattedErrors());
    }
    convertUtil.setBasicProperties(gatewayJson, gateway);
    convertUtil.setTopologies(gatewayJson, gateway);
    convertUtil.setGatewayPathAndSsoProvider(gatewayJson, gateway);
    return gateway;
}
Also used : GatewayV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.GatewayV4Request) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult)

Example 57 with Gateway

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

the class ClusterService method saveWithRef.

public Cluster saveWithRef(Cluster cluster) {
    Cluster savedCluster;
    try {
        long start = System.currentTimeMillis();
        if (cluster.getFileSystem() != null) {
            cluster.getFileSystem().setWorkspace(cluster.getWorkspace());
            fileSystemConfigService.pureSave(cluster.getFileSystem());
        }
        if (cluster.getAdditionalFileSystem() != null) {
            cluster.getAdditionalFileSystem().setWorkspace(cluster.getWorkspace());
            fileSystemConfigService.pureSave(cluster.getAdditionalFileSystem());
        }
        savedCluster = save(cluster);
        Gateway gateway = cluster.getGateway();
        if (gateway != null) {
            gateway.setCluster(savedCluster);
            gatewayService.save(gateway);
        }
        List<ClusterComponent> store = clusterComponentConfigProvider.store(cluster.getComponents(), savedCluster);
        savedCluster.setComponents(new HashSet<>(store));
        LOGGER.info("Cluster object saved in {} ms with cluster id {}", System.currentTimeMillis() - start, cluster.getId());
    } catch (DataIntegrityViolationException ex) {
        String msg = String.format("Error with resource [%s], %s", APIResourceType.CLUSTER, getProperSqlErrorMessage(ex));
        throw new BadRequestException(msg, ex);
    }
    return savedCluster;
}
Also used : ClusterComponent(com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) DataIntegrityViolationException(org.springframework.dao.DataIntegrityViolationException)

Example 58 with Gateway

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

the class ClusterServiceRunner method generateGatewaySignKeys.

private void generateGatewaySignKeys(Cluster cluster) {
    Gateway gateway = cluster.getGateway();
    if (Objects.nonNull(gateway)) {
        convertUtil.generateSignKeys(gateway);
        gatewayService.save(gateway);
    }
}
Also used : Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway)

Example 59 with Gateway

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

the class ClusterHostServiceRunner method createKnoxRelatedGatewayCofniguration.

private Map<String, Object> createKnoxRelatedGatewayCofniguration(Cluster cluster, VirtualGroupRequest virtualGroupRequest, ClusterPreCreationApi connector) throws IOException {
    Gateway clusterGateway = cluster.getGateway();
    Map<String, Object> gateway = new HashMap<>();
    if (clusterGateway != null) {
        gateway.put("path", clusterGateway.getPath());
        gateway.put("ssotype", clusterGateway.getSsoType());
        gateway.put("ssoprovider", clusterGateway.getSsoProvider());
        gateway.put("signpub", clusterGateway.getSignPub());
        gateway.put("signcert", clusterGateway.getSignCert());
        gateway.put("signkey", clusterGateway.getSignKey());
        gateway.put("tokencert", clusterGateway.getTokenCert());
        gateway.put("mastersecret", clusterGateway.getKnoxMasterSecret());
        gateway.put("envAccessGroup", virtualGroupService.createOrGetVirtualGroup(virtualGroupRequest, UmsVirtualGroupRight.ENVIRONMENT_ACCESS));
        List<Map<String, Object>> topologies = getTopologies(clusterGateway, cluster.getBlueprint().getStackVersion());
        gateway.put("topologies", topologies);
        if (cluster.getBlueprint() != null) {
            Boolean autoTlsEnabled = cluster.getAutoTlsEnabled();
            Map<String, Integer> servicePorts = connector.getServicePorts(cluster.getBlueprint(), autoTlsEnabled);
            gateway.put("ports", servicePorts);
            gateway.put("protocol", autoTlsEnabled ? "https" : "http");
        }
        if (SSOType.SSO_PROVIDER_FROM_UMS.equals(clusterGateway.getSsoType())) {
            String accountId = ThreadBasedUserCrnProvider.getAccountId();
            try {
                String metadataXml = umsClient.getIdentityProviderMetadataXml(accountId, regionAwareInternalCrnGeneratorFactory);
                gateway.put("saml", metadataXml);
            } catch (Exception e) {
                LOGGER.debug("Could not get SAML metadata file to set up IdP in KNOXSSO.", e);
                throw new NotFoundException("Could not get SAML metadata file to set up IdP in KNOXSSO: " + e.getMessage());
            }
        }
    } else {
        gateway.put("ssotype", SSOType.NONE);
        LOGGER.debug("Cluster gateway (Knox) is not set. Configure ssotype to 'NONE' for backward compatibility.");
    }
    return gateway;
}
Also used : HashMap(java.util.HashMap) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) Map(java.util.Map) ServiceLocationMap(com.sequenceiq.cloudbreak.cluster.model.ServiceLocationMap) HashMap(java.util.HashMap) Collections.singletonMap(java.util.Collections.singletonMap) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) CloudbreakOrchestratorException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException) CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) CancellationException(com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException) IOException(java.io.IOException) NodesUnreachableException(com.sequenceiq.cloudbreak.util.NodesUnreachableException) CloudbreakOrchestratorCancelledException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorCancelledException) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)

Example 60 with Gateway

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

the class HdfsConfigProviderTest method getTemplatePreparationObject.

private TemplatePreparationObject getTemplatePreparationObject(boolean useS3FileSystem, boolean fillDynamoTableName, boolean includeLocations) {
    HostgroupView master = new HostgroupView("master", 1, InstanceGroupType.GATEWAY, 1);
    HostgroupView worker = new HostgroupView("worker", 2, InstanceGroupType.CORE, 2);
    List<StorageLocationView> locations = new ArrayList<>();
    if (includeLocations) {
        locations.add(new StorageLocationView(getStorageLocation("hive.metastore.warehouse.dir", "s3a://bucket/warehouse/managed")));
        locations.add(new StorageLocationView(getStorageLocation("hive.metastore.warehouse.external.dir", "s3a://bucket/warehouse/external")));
    }
    BaseFileSystemConfigurationsView fileSystemConfigurationsView;
    if (useS3FileSystem) {
        S3FileSystem s3FileSystem = new S3FileSystem();
        if (fillDynamoTableName) {
            s3FileSystem.setS3GuardDynamoTableName("dynamoTable");
        }
        fileSystemConfigurationsView = new S3FileSystemConfigurationsView(s3FileSystem, locations, false);
    } else {
        fileSystemConfigurationsView = new AdlsFileSystemConfigurationsView(new AdlsFileSystem(), locations, false);
    }
    Gateway gateway = TestUtil.gatewayEnabledWithExposedKnoxServices(ExposedServiceUtil.exposedService("NAMENODE").getKnoxService());
    PlacementView placementView = new PlacementView("region", "az");
    return Builder.builder().withFileSystemConfigurationView(fileSystemConfigurationsView).withHostgroupViews(Set.of(master, worker)).withGateway(gateway, "/cb/secret/signkey", new HashSet<>()).withPlacementView(placementView).withDefaultTags(Map.of("apple", "apple1")).withProductDetails(new ClouderaManagerRepo().withVersion("7.1.0"), List.of()).withStackType(StackType.DATALAKE).build();
}
Also used : StorageLocationView(com.sequenceiq.cloudbreak.template.filesystem.StorageLocationView) BaseFileSystemConfigurationsView(com.sequenceiq.cloudbreak.template.filesystem.BaseFileSystemConfigurationsView) ArrayList(java.util.ArrayList) PlacementView(com.sequenceiq.cloudbreak.template.views.PlacementView) S3FileSystemConfigurationsView(com.sequenceiq.cloudbreak.template.filesystem.s3.S3FileSystemConfigurationsView) S3FileSystem(com.sequenceiq.common.api.filesystem.S3FileSystem) ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) HostgroupView(com.sequenceiq.cloudbreak.template.views.HostgroupView) AdlsFileSystem(com.sequenceiq.common.api.filesystem.AdlsFileSystem) AdlsFileSystemConfigurationsView(com.sequenceiq.cloudbreak.template.filesystem.adls.AdlsFileSystemConfigurationsView) HashSet(java.util.HashSet)

Aggregations

Gateway (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway)69 Test (org.junit.Test)30 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)20 HashSet (java.util.HashSet)17 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)15 TemplatePreparationObject (com.sequenceiq.cloudbreak.template.TemplatePreparationObject)15 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)15 GatewayV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.GatewayV4Request)13 ExposedService (com.sequenceiq.cloudbreak.api.service.ExposedService)12 GatewayTopology (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology)12 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)11 BlueprintView (com.sequenceiq.cloudbreak.template.views.BlueprintView)11 GeneralClusterConfigs (com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs)10 IOException (java.io.IOException)10 VirtualGroupRequest (com.sequenceiq.cloudbreak.auth.altus.VirtualGroupRequest)8 ClouderaManagerRepo (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)8 ArrayList (java.util.ArrayList)8 Json (com.sequenceiq.cloudbreak.common.json.Json)7 IdBroker (com.sequenceiq.cloudbreak.domain.stack.cluster.IdBroker)7 ExposedServices (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.ExposedServices)7